his_api_controller.go 1.2MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. //"github.com/tjfoc/gmsm/sm3"
  8. "math"
  9. //"crypto/x509/pkix"
  10. "encoding/json"
  11. "fmt"
  12. "gdyb/controllers"
  13. "gdyb/enums"
  14. "gdyb/models"
  15. "gdyb/service"
  16. "gdyb/utils"
  17. "github.com/astaxie/beego"
  18. "github.com/axgle/mahonia"
  19. "github.com/gorilla/websocket"
  20. "github.com/jinzhu/gorm"
  21. "github.com/shopspring/decimal"
  22. "io"
  23. "io/ioutil"
  24. //"math"
  25. "math/rand"
  26. "net/http"
  27. "net/url"
  28. "os"
  29. "path/filepath"
  30. "regexp"
  31. "strconv"
  32. "strings"
  33. "syscall"
  34. "time"
  35. "unsafe"
  36. "github.com/go-ole/go-ole/oleutil"
  37. )
  38. type HisApiController struct {
  39. controllers.BaseAuthAPIController
  40. }
  41. func HisManagerApiRegistRouters() {
  42. //挂号
  43. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  44. //上传就诊信息-上传明细-结算
  45. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  46. //查询
  47. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  48. //对总账
  49. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  50. //对明细
  51. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  52. //退费,退明细
  53. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  54. //退号
  55. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  56. //退明细
  57. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  58. //上传就诊信息-上传明细-预结算
  59. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  60. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  61. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  62. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  63. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  64. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  65. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  66. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  67. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  68. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  69. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  70. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  71. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  72. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  73. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  74. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  75. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  76. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  77. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  78. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  79. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  80. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  81. beego.Router("/api/check", &HisApiController{}, "get:Check")
  82. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  83. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  84. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  85. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  86. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  87. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  88. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  89. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  90. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  91. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  92. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  93. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  94. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  95. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  96. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  97. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  98. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  99. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  100. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  101. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  102. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  103. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  104. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  108. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  109. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  110. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  111. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  112. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  113. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  114. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  115. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  116. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  117. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  118. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  119. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  120. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  121. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  122. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  123. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  124. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  125. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  126. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  127. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  128. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  129. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  130. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  131. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  132. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  133. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  134. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  135. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  136. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  137. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  138. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  139. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  140. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  141. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  142. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  143. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  144. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  145. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  146. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  147. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  148. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  149. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  150. //库盘和变更
  151. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  152. //删除库盘和变更
  153. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  154. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeleteXSandBG")
  155. //药品变更
  156. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  157. }
  158. func (c *HisApiController) FJ3501AND3502() {
  159. ids := c.getString("ids")
  160. id_arr := strings.Split(ids, ",")
  161. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  162. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  163. //库盘
  164. for _, drug := range drugs {
  165. if drug.IsPc == 0 && drug.IsBg == 0 {
  166. var struct3501 models.Struct3501
  167. struct3501.OrgName = miConfig.OrgName
  168. struct3501.AccessKey = miConfig.AccessKey
  169. struct3501.RequestUrl = miConfig.Url
  170. struct3501.SecretKey = miConfig.SecretKey
  171. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  172. struct3501.FixmedinsHilistId = miConfig.Code
  173. struct3501.FixmedinsHilistName = miConfig.OrgName
  174. struct3501.RxFlag = "0"
  175. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
  176. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  177. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  178. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  179. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02 15:04:05")
  180. //todo 批次号规则需要在咨询下保健
  181. struct3501.FixmedinsBchno = ""
  182. struct3501.Memo = ""
  183. result1, result2, result3 := service.FJyb3501(struct3501)
  184. fmt.Println(result1)
  185. fmt.Println(result2)
  186. fmt.Println(result3)
  187. var struct3502 models.Struct3502
  188. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  189. struct3502.FixmedinsHilistId = miConfig.Code
  190. struct3502.FixmedinsHilistName = miConfig.OrgName
  191. struct3502.FixmedinsCode = miConfig.Code
  192. struct3502.RxFlag = "0"
  193. struct3502.InvChgTime = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
  194. struct3502.OrgName = miConfig.OrgName
  195. struct3502.AccessKey = miConfig.AccessKey
  196. struct3502.RequestUrl = miConfig.Url
  197. struct3502.SecretKey = miConfig.SecretKey
  198. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  199. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  200. struct3502.InvChgType = "102"
  201. struct3502.FixmedinsBchno = ""
  202. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  203. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  204. result11, result22, result33 := service.FJyb3502(struct3502)
  205. fmt.Println(result11)
  206. fmt.Println(result22)
  207. fmt.Println(result33)
  208. }
  209. //变更
  210. if drug.IsPc == 1 && drug.IsBg == 0 {
  211. var struct3502 models.Struct3502
  212. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  213. struct3502.FixmedinsHilistId = miConfig.Code
  214. struct3502.FixmedinsHilistName = miConfig.OrgName
  215. struct3502.FixmedinsCode = miConfig.Code
  216. struct3502.RxFlag = "0"
  217. struct3502.InvChgTime = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
  218. struct3502.OrgName = miConfig.OrgName
  219. struct3502.AccessKey = miConfig.AccessKey
  220. struct3502.RequestUrl = miConfig.Url
  221. struct3502.SecretKey = miConfig.SecretKey
  222. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  223. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  224. struct3502.InvChgType = "102"
  225. struct3502.FixmedinsBchno = ""
  226. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  227. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  228. result1, result2, result3 := service.FJyb3502(struct3502)
  229. fmt.Println(result1)
  230. fmt.Println(result2)
  231. fmt.Println(result3)
  232. }
  233. }
  234. }
  235. func (c *HisApiController) DeletePCandBG() {
  236. ids := c.getString("ids")
  237. id_arr := strings.Split(ids, ",")
  238. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  239. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  240. for _, item := range drugs {
  241. if item.IsPc == 1 && item.IsBg == 1 {
  242. var struct3507 models.Struct3507
  243. struct3507.FixmedinsBchno = ""
  244. struct3507.InvDataType = "1"
  245. struct3507.OrgName = miConfig.OrgName
  246. struct3507.AccessKey = miConfig.AccessKey
  247. struct3507.RequestUrl = miConfig.Url
  248. struct3507.SecretKey = miConfig.SecretKey
  249. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  250. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  251. service.FJyb3507(struct3507)
  252. var struct3507_2 models.Struct3507
  253. struct3507_2.OrgName = miConfig.OrgName
  254. struct3507_2.AccessKey = miConfig.AccessKey
  255. struct3507_2.RequestUrl = miConfig.Url
  256. struct3507_2.SecretKey = miConfig.SecretKey
  257. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  258. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  259. struct3507_2.FixmedinsBchno = ""
  260. struct3507_2.InvDataType = "2"
  261. service.FJyb3507(struct3507_2)
  262. }
  263. if item.IsPc == 1 && item.IsBg == 0 {
  264. var struct3507 models.Struct3507
  265. struct3507.OrgName = miConfig.OrgName
  266. struct3507.AccessKey = miConfig.AccessKey
  267. struct3507.RequestUrl = miConfig.Url
  268. struct3507.SecretKey = miConfig.SecretKey
  269. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  270. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  271. struct3507.FixmedinsBchno = ""
  272. struct3507.InvDataType = "1"
  273. service.FJyb3507(struct3507)
  274. }
  275. }
  276. }
  277. func (c *HisApiController) DeleteXSandBG() {
  278. ids := c.getString("ids")
  279. id_arr := strings.Split(ids, ",")
  280. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  281. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  282. for _, item := range drugs {
  283. if item.is == 1 && item.IsBg == 1 {
  284. var struct3507 models.Struct3507
  285. struct3507.FixmedinsBchno = ""
  286. struct3507.InvDataType = "1"
  287. struct3507.OrgName = miConfig.OrgName
  288. struct3507.AccessKey = miConfig.AccessKey
  289. struct3507.RequestUrl = miConfig.Url
  290. struct3507.SecretKey = miConfig.SecretKey
  291. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  292. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  293. service.FJyb3507(struct3507)
  294. var struct3507_2 models.Struct3507
  295. struct3507_2.OrgName = miConfig.OrgName
  296. struct3507_2.AccessKey = miConfig.AccessKey
  297. struct3507_2.RequestUrl = miConfig.Url
  298. struct3507_2.SecretKey = miConfig.SecretKey
  299. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  300. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  301. struct3507_2.FixmedinsBchno = ""
  302. struct3507_2.InvDataType = "2"
  303. service.FJyb3507(struct3507_2)
  304. }
  305. if item.IsPc == 1 && item.IsBg == 0 {
  306. var struct3507 models.Struct3507
  307. struct3507.OrgName = miConfig.OrgName
  308. struct3507.AccessKey = miConfig.AccessKey
  309. struct3507.RequestUrl = miConfig.Url
  310. struct3507.SecretKey = miConfig.SecretKey
  311. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  312. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  313. struct3507.FixmedinsBchno = ""
  314. struct3507.InvDataType = "1"
  315. service.FJyb3507(struct3507)
  316. }
  317. }
  318. }
  319. func (c *HisApiController) ChangeDrug() {
  320. ids := c.getString("ids")
  321. id_arr := strings.Split(ids, ",")
  322. flows, _ := service.GetNewDrugFlowInfo(id_arr)
  323. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  324. for _, item := range flows {
  325. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  326. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  327. if prescription.OrderStatus == 2 { //已经结算
  328. //判断是否已经销售
  329. if item.IsSale == 1 { //是否已经销售,1是 0否
  330. //是否已经变更 1是 0否
  331. if item.IsChange == 0 { //没变更,进行变更操作
  332. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  333. }
  334. } else { //没销售,
  335. //进行商品销售接口
  336. SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "")
  337. if item.IsChange == 0 { //没变更,进行变更操作
  338. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  339. }
  340. }
  341. } else { //还没结算
  342. if item.IsChange == 0 { //没变更,进行变更操作
  343. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  344. }
  345. }
  346. } else if item.ConsumableType == 7 {
  347. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  348. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  349. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  350. //判断是否已经销售
  351. if item.IsSale == 1 { //是否已经销售,1是 0否
  352. //是否已经变更 1是 0否
  353. if item.IsChange == 0 { //没变更,进行变更操作
  354. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  355. }
  356. } else { //没销售,
  357. //进行商品销售退货接口
  358. CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "")
  359. if item.IsChange == 0 { //没变更,进行变更操作
  360. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  361. }
  362. }
  363. } else { //还没结算
  364. if item.IsChange == 0 { //没变更,进行变更操作
  365. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  366. }
  367. }
  368. } else { //其他方式
  369. if item.IsChange == 0 { //没变更,进行变更操作
  370. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  371. }
  372. }
  373. }
  374. }
  375. func ChangeStock(count int64, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string) {
  376. var struct3502 models.Struct3502
  377. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  378. struct3502.FixmedinsHilistId = miConfig.Code
  379. struct3502.FixmedinsHilistName = miConfig.OrgName
  380. struct3502.FixmedinsCode = miConfig.Code
  381. struct3502.RxFlag = "0"
  382. struct3502.InvChgTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  383. struct3502.OrgName = miConfig.OrgName
  384. struct3502.AccessKey = miConfig.AccessKey
  385. struct3502.RequestUrl = miConfig.Url
  386. struct3502.SecretKey = miConfig.SecretKey
  387. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  388. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  389. struct3502.InvChgType = chgType
  390. struct3502.FixmedinsBchno = ""
  391. struct3502.Cnt = strconv.FormatInt(count, 10)
  392. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  393. result1, result2, result3 := service.FJyb3502(struct3502)
  394. fmt.Println(result1)
  395. fmt.Println(result2)
  396. fmt.Println(result3)
  397. }
  398. func SaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string) {
  399. var struct3505 models.Struct3505
  400. struct3505.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  401. struct3505.FixmedinsHilistId = miConfig.Code
  402. struct3505.FixmedinsHilistName = miConfig.OrgName
  403. struct3505.FixmedinsCode = miConfig.Code
  404. struct3505.FixmedinsBchno = ""
  405. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  406. struct3505.PrscDrName = roles.UserName
  407. struct3505.PharName = ""
  408. struct3505.PharPracCertNo = ""
  409. order := service.GetHisOrderByNumber(pre.BatchNumber)
  410. struct3505.SetlId = order.SetlId
  411. struct3505.MdtrtSn = order.MdtrtId
  412. struct3505.ManuLotnum = ""
  413. struct3505.ManuDate = ""
  414. struct3505.ExpyEnd = ""
  415. struct3505.RxFlag = "0"
  416. struct3505.TrdnFlag = "1"
  417. struct3505.RtalDocno = order.Number
  418. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  419. struct3505.SelRetnCnt = strValue
  420. struct3505.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  421. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  422. struct3505.SelRetnOpterName = roles_two.UserName
  423. if order.IsMedicineInsurance == 1 {
  424. struct3505.MdtrtSetlType = "1"
  425. } else {
  426. struct3505.MdtrtSetlType = "2"
  427. }
  428. struct3505.OrgName = miConfig.OrgName
  429. struct3505.AccessKey = miConfig.AccessKey
  430. struct3505.RequestUrl = miConfig.Url
  431. struct3505.SecretKey = miConfig.SecretKey
  432. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  433. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  434. result1, result2, result3 := service.FJyb3505(struct3505)
  435. fmt.Println(result1)
  436. fmt.Println(result2)
  437. fmt.Println(result3)
  438. }
  439. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string) {
  440. var struct3506 models.Struct3506
  441. struct3506.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  442. struct3506.FixmedinsHilistId = miConfig.Code
  443. struct3506.FixmedinsHilistName = miConfig.OrgName
  444. struct3506.FixmedinsCode = miConfig.Code
  445. struct3506.FixmedinsBchno = ""
  446. order := service.GetHisOrderByNumber(pre.BatchNumber)
  447. //roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  448. struct3506.ManuLotnum = ""
  449. struct3506.ManuDate = ""
  450. struct3506.MdtrtSn = order.MdtrtId
  451. struct3506.ExpyEnd = ""
  452. struct3506.RxFlag = "0"
  453. struct3506.TrdnFlag = "1"
  454. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  455. struct3506.SelRetnCnt = strValue
  456. struct3506.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  457. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  458. struct3506.SelRetnOpterName = roles_two.UserName
  459. struct3506.OrgName = miConfig.OrgName
  460. struct3506.AccessKey = miConfig.AccessKey
  461. struct3506.RequestUrl = miConfig.Url
  462. struct3506.SecretKey = miConfig.SecretKey
  463. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  464. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  465. result1, result2, result3 := service.FJyb3506(struct3506)
  466. fmt.Println(result1)
  467. fmt.Println(result2)
  468. fmt.Println(result3)
  469. }
  470. func (c *HisApiController) Get1318() {
  471. adminUser := c.GetAdminUserInfo()
  472. admin_user_id, _ := c.GetInt64("admin_user_id")
  473. code := c.GetString("code")
  474. code = ""
  475. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  476. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  477. api := ""
  478. if miConfig.MdtrtareaAdmvs == "320921" {
  479. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  480. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  481. } else {
  482. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  483. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  484. }
  485. resp, requestErr := http.Get(api)
  486. if requestErr != nil {
  487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  488. return
  489. }
  490. body, ioErr := ioutil.ReadAll(resp.Body)
  491. if ioErr != nil {
  492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  494. return
  495. }
  496. var respJSON map[string]interface{}
  497. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  500. return
  501. }
  502. //var res Result2406
  503. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  504. result, _ := json.Marshal(respJSON)
  505. if err := json.Unmarshal([]byte(result), &res); err != nil {
  506. utils.ErrorLog("解析失败:%v", err)
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  508. return
  509. }
  510. if res.Infcode == "0" {
  511. c.ServeSuccessJSON(map[string]interface{}{
  512. "result": "",
  513. })
  514. } else {
  515. c.ServeSuccessJSON(map[string]interface{}{
  516. "failed_code": -10,
  517. "msg": res.ErrMsg,
  518. })
  519. */return
  520. //}
  521. }
  522. func (c *HisApiController) Get2503() {
  523. adminUser := c.GetAdminUserInfo()
  524. admin_user_id, _ := c.GetInt64("admin_user_id")
  525. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  526. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  527. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  528. }
  529. func (c *HisApiController) Get2406() {
  530. id, _ := c.GetInt64("id")
  531. record_time := c.GetString("record_time")
  532. his_patient_id, _ := c.GetInt64("his_patient_id")
  533. admin_user_id, _ := c.GetInt64("admin_user_id")
  534. diagnosis_id := c.GetString("diagnosis")
  535. timeLayout := "2006-01-02"
  536. loc, _ := time.LoadLocation("Local")
  537. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  538. if err != nil {
  539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  540. return
  541. }
  542. recordDateTime := theTime.Unix()
  543. adminUser := c.GetAdminUserInfo()
  544. diagnosis_ids := strings.Split(diagnosis_id, ",")
  545. var config []*models.HisXtDiagnoseConfig
  546. for _, item := range diagnosis_ids {
  547. id, _ := strconv.ParseInt(item, 10, 64)
  548. diagnosisConfig, _ := service.FindDiagnoseById(id)
  549. config = append(config, &diagnosisConfig)
  550. }
  551. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  552. fmt.Println(his_patient_id)
  553. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  554. //timestamp := time.Now().Unix()
  555. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  556. var patientPrescription models.HisPrescriptionInfo
  557. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  558. if patientPrescription.ID == 0 {
  559. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  560. }
  561. var res2 Result2406
  562. if miConfig.MdtrtareaAdmvs == "341203" {
  563. data := make(map[string]interface{})
  564. client := &http.Client{}
  565. data["psn_no"] = his.PsnNo
  566. data["mdtrt_id"] = his.Number
  567. data["operator"] = roles.UserName
  568. data["cert_no"] = his.IdCardNo
  569. data["org_name"] = miConfig.OrgName
  570. data["psn_name"] = his.Name
  571. data["ipt_otp_no"] = his.IptOtpNo
  572. data["ipt_psn_sp_flag_type"] = "0901"
  573. data["ipt_psn_sp_flag"] = "1"
  574. data["fixmedins_code"] = miConfig.Code
  575. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  576. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  577. data["url"] = miConfig.Url
  578. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  579. bytesData, _ := json.Marshal(data)
  580. var req *http.Request
  581. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  582. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  583. resp, _ := client.Do(req)
  584. defer resp.Body.Close()
  585. body, ioErr := ioutil.ReadAll(resp.Body)
  586. if ioErr != nil {
  587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  589. return
  590. }
  591. var respJSON map[string]interface{}
  592. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  595. return
  596. }
  597. status := respJSON["data"].(map[string]interface{})["status"].(string)
  598. if status == "0" {
  599. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  600. c.ServeSuccessJSON(map[string]interface{}{
  601. "failed_code": -10,
  602. "msg": err_msg,
  603. })
  604. return
  605. }
  606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  607. userJSONBytes, _ := json.Marshal(respJSON)
  608. fmt.Println("log")
  609. fmt.Println(string(userJSONBytes))
  610. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  611. utils.ErrorLog("解析失败:%v", err)
  612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  613. return
  614. }
  615. }
  616. if res2.Infcode != 0 {
  617. adminUser := c.GetAdminUserInfo()
  618. errlog := &models.HisOrderError{
  619. UserOrgId: adminUser.CurrentOrgId,
  620. Ctime: time.Now().Unix(),
  621. Mtime: time.Now().Unix(),
  622. ErrMsg: res2.ErrMsg,
  623. Status: 1,
  624. PatientId: id,
  625. RecordTime: recordDateTime,
  626. Stage: 3,
  627. }
  628. service.CreateErrMsgLog(errlog)
  629. c.ServeSuccessJSON(map[string]interface{}{
  630. "failed_code": -10,
  631. "msg": res2.ErrMsg,
  632. })
  633. return
  634. } else {
  635. c.ServeSuccessJSON(map[string]interface{}{
  636. "msg": "上传成功",
  637. })
  638. return
  639. }
  640. }
  641. func (c *HisApiController) Get4105() {
  642. }
  643. func (c *HisApiController) Post5302() {
  644. patient_id, _ := c.GetInt64("id")
  645. admin_user_id, _ := c.GetInt64("admin_user_id")
  646. p, _ := service.GetHisPatientById(patient_id)
  647. adminUser := c.GetAdminUserInfo()
  648. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  649. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  650. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  651. }
  652. func (c *HisApiController) Get4104() {
  653. }
  654. type Output struct {
  655. CertNo string `json:"certno"`
  656. PsnName string `json:"psn_name"`
  657. CardNo string `json:"card_no"`
  658. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  659. CardSN string `json:"card_sn"`
  660. PsnCertType string `json:"psn_cert_type"`
  661. MdtrtCertNo string `json:"mdtrt_cert_no"`
  662. MdtrtCertType string `json:"mdtrt_cert_type"`
  663. QRCode string `json:"qrCode"`
  664. EcToken string `json:"ecToken"`
  665. }
  666. type AHResponse struct {
  667. Body AHBody `json:"body"`
  668. Code int `json:"code"`
  669. CSBCode int `json:"csbCode"`
  670. Message string `json:"message"`
  671. RequestID string `json:"requestId"`
  672. State struct{} `json:"state"`
  673. }
  674. type AHBody struct {
  675. ErrMsg string `json:"err_msg"`
  676. InfRefMsgID string `json:"inf_refmsgid"`
  677. InfCode int `json:"infcode"`
  678. Output struct {
  679. Result []struct {
  680. BasMednFlag string `json:"bas_medn_flag"`
  681. ChldMedcFlag string `json:"chld_medc_flag"`
  682. ChrgitmLv string `json:"chrgitm_lv"`
  683. Cnt float64 `json:"cnt"`
  684. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  685. DrtReimFlag string `json:"drt_reim_flag"`
  686. FeedetlSn string `json:"feedetl_sn"`
  687. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  688. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  689. InscpScpAmt float64 `json:"inscp_scp_amt"`
  690. ListSpItemFlag string `json:"list_sp_item_flag"`
  691. LmtUsedFlag string `json:"lmt_used_flag"`
  692. MedChrgitmType string `json:"med_chrgitm_type"`
  693. Memo string `json:"memo"`
  694. OverlmtAmt float64 `json:"overlmt_amt"`
  695. PreselfpayAmt float64 `json:"preselfpay_amt"`
  696. Pric float64 `json:"pric"`
  697. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  698. SelfpayProp float64 `json:"selfpay_prop"`
  699. } `json:"result"`
  700. } `json:"output"`
  701. }
  702. type Response struct {
  703. Output Output `json:"output"`
  704. Infcode int `json:"infcode"`
  705. InfRefMsgID string `json:"inf_refmsgid"`
  706. RefMsgTime string `json:"refmsg_time"`
  707. RespondTime string `json:"respond_time"`
  708. ErrMsg string `json:"err_msg"`
  709. WarnMsg string `json:"warn_msg"`
  710. SignType string `json:"signtype"`
  711. CAInfo string `json:"cainfo"`
  712. }
  713. func (c *HisApiController) Getquerydata() {
  714. query_type, _ := c.GetInt64("type")
  715. refd_setl_flag := c.GetString("refd_setl_flag")
  716. med_type := c.GetString("med_type")
  717. //admin_user_id,_ := c.GetInt64("admin_user_id")
  718. cert_no := c.GetString("cert_no")
  719. psn_no := c.GetString("psn_no")
  720. start_time := c.GetString("start_time")
  721. end_time := c.GetString("end_time")
  722. page, _ := c.GetInt64("page")
  723. limit, _ := c.GetInt64("limit")
  724. var bp models.BusinessParams5262
  725. bp.RefdSetlFlag = refd_setl_flag
  726. bp.MedType = med_type
  727. bp.Certno = cert_no
  728. bp.Psnno = psn_no
  729. bp.QBegntime = start_time
  730. bp.QEndtime = end_time
  731. if query_type == 1 { //本地
  732. Post5262(c, bp, page, limit)
  733. } else { //异地
  734. Post5267(c, bp, page, limit)
  735. }
  736. }
  737. func (c *HisApiController) Drugscheck() {
  738. admin_user_id, _ := c.GetInt64("admin_user_id")
  739. adminUser := c.GetAdminUserInfo()
  740. var queryResult []QueryResult
  741. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  742. for _, item := range drugs {
  743. result := QueryResult{
  744. ID: item.ID,
  745. Name: item.DrugName,
  746. Code: item.MedicalInsuranceNumber,
  747. List_type_code: "101",
  748. }
  749. queryResult = append(queryResult, result)
  750. }
  751. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  752. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  753. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  754. for _, item := range queryResult {
  755. 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)
  756. }
  757. }
  758. func (c *HisApiController) Goodcheck() {
  759. admin_user_id, _ := c.GetInt64("admin_user_id")
  760. adminUser := c.GetAdminUserInfo()
  761. var queryResult []QueryResult
  762. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  763. for _, item := range goods {
  764. result := QueryResult{
  765. ID: item.ID,
  766. Name: item.GoodName,
  767. Code: item.SocialSecurityDirectoryCode,
  768. List_type_code: "301",
  769. }
  770. queryResult = append(queryResult, result)
  771. }
  772. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  773. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  774. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  775. for _, item := range queryResult {
  776. 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)
  777. //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)
  778. }
  779. }
  780. func (c *HisApiController) Projectcheck() {
  781. admin_user_id, _ := c.GetInt64("admin_user_id")
  782. adminUser := c.GetAdminUserInfo()
  783. var queryResult []QueryResult
  784. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  785. for _, item := range projects {
  786. result := QueryResult{
  787. ID: item.ID,
  788. Name: item.ProjectName,
  789. Code: item.MedicalCode,
  790. List_type_code: "201",
  791. }
  792. queryResult = append(queryResult, result)
  793. }
  794. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  795. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  796. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  797. for _, item := range queryResult {
  798. 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)
  799. }
  800. }
  801. //func (c *HisApiController)CancleDia(){
  802. //
  803. // id, _ := c.GetInt64("id")
  804. // record_time := c.GetString("record_time")
  805. // his_patient_id, _ := c.GetInt64("his_patient_id")
  806. //
  807. // admin_user_id, _ := c.GetInt64("admin_user_id")
  808. //
  809. // diagnosis_id := c.GetString("diagnosis")
  810. // sick_type, _ := c.GetInt64("sick_type")
  811. // reg_type, _ := c.GetInt64("p_type")
  812. // begin_time := c.GetString("begin_time")
  813. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  814. //
  815. //
  816. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  817. //
  818. // fmt.Println(acct_used_flag)
  819. //
  820. //
  821. // timeLayout := "2006-01-02"
  822. // loc, _ := time.LoadLocation("Local")
  823. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  824. // if err != nil {
  825. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  826. // return
  827. // }
  828. // recordDateTime := theTime.Unix()
  829. // adminUser := c.GetAdminUserInfo()
  830. //
  831. //
  832. //
  833. //
  834. //
  835. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  836. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  837. // var patientPrescription models.HisPrescriptionInfo
  838. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  839. // if patientPrescription.ID == 0 {
  840. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  841. // }
  842. // //if patientPrescription.Do
  843. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  844. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  845. //
  846. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  847. //
  848. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  849. //
  850. // var config []*models.HisXtDiagnoseConfig
  851. // for _, item := range diagnosis_ids {
  852. // id, _ := strconv.ParseInt(item, 10, 64)
  853. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  854. // config = append(config, &diagnosisConfig)
  855. // }
  856. //
  857. // sickConfig, _ := service.FindSickById(sick_type)
  858. //
  859. //
  860. // data := make(map[string]interface{})
  861. // client := &http.Client{}
  862. // data["psn_no"] = his.PsnNo
  863. // data["mdtrt_id"] = his.Number
  864. // data["doctor"] = roles.UserName
  865. // data["department"] = department.Name
  866. // data["org_name"] = miConfig.OrgName
  867. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  868. // data["doctor_id"] = doctor_info.DoctorNumber
  869. // data["new_doctor_name"] = doctor_info.UserName
  870. // data["fixmedins_code"] = miConfig.Code
  871. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  872. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  873. // data["secret_key"] = miConfig.SecretKey
  874. // data["sick_code"] = sickConfig.CountryCode
  875. // data["sick_name"] = sickConfig.ClassName
  876. // data["url"] = miConfig.Url
  877. // data["ak"] = miConfig.AccessKey
  878. // data["begin_time"] = begin_time
  879. // data["cainfo"] = miConfig.Cainfo
  880. // data["is_vaild"] = "0"
  881. //
  882. // data["dept"] = strconv.FormatInt(department.ID, 10)
  883. // data["config"] = config
  884. // bytesData, _ := json.Marshal(data)
  885. //
  886. // var req *http.Request
  887. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  888. // resp, _ := client.Do(req)
  889. // defer resp.Body.Close()
  890. // body, ioErr := ioutil.ReadAll(resp.Body)
  891. // if ioErr != nil {
  892. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  893. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  894. // return
  895. // }
  896. // var respJSON map[string]interface{}
  897. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  898. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  900. // return
  901. // }
  902. //
  903. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  904. // userJSONBytes, _ := json.Marshal(respJSON)
  905. // fmt.Println("log")
  906. // fmt.Println(string(userJSONBytes))
  907. //
  908. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  909. // utils.ErrorLog("解析失败:%v", err)
  910. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  911. // return
  912. // }
  913. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  914. // res2.Output = ressix10265.Output
  915. // res2.ErrMsg = ressix10265.ErrMsg
  916. // res2.Cainfo = ressix10265.Cainfo
  917. // res2.WarnMsg = ressix10265.WarnMsg
  918. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  919. // res2.Infcode = infocode
  920. //
  921. //}
  922. func (c *HisApiController) Get4102() {
  923. order_id, _ := c.GetInt64("order_id")
  924. admin_user_id, _ := c.GetInt64("admin_user_id")
  925. stas_type := c.GetString("stas_type")
  926. order, _ := service.GetHisOrderByIDTwo(order_id)
  927. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  928. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  929. var pp models.PublicParams
  930. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  931. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  932. pp.FixmedinsName = miConfig.OrgName
  933. pp.FixmedinsCode = miConfig.Code
  934. pp.RequestUrl = miConfig.Url
  935. pp.Cainfo = miConfig.Cainfo
  936. pp.SecretKey = miConfig.SecretKey
  937. pp.AccessKey = miConfig.AccessKey
  938. pp.OpterName = curRoles.UserName
  939. if miConfig.MdtrtareaAdmvs == "350500" {
  940. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  941. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  942. saveLog(result, request, "4102", "清单确认")
  943. var dat map[string]interface{}
  944. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  945. fmt.Println(dat)
  946. } else {
  947. fmt.Println(err)
  948. }
  949. var empty ResultFourteen
  950. userJSONBytes, _ := json.Marshal(dat)
  951. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  952. utils.ErrorLog("解析失败:%v", err)
  953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  954. return
  955. }
  956. if empty.Infcode == 0 {
  957. c.ServeSuccessJSON(map[string]interface{}{
  958. "msg": "确认成功",
  959. })
  960. return
  961. }
  962. } else {
  963. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  964. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  965. result3, request3 := service.Jxyb4105(pp)
  966. saveLog(result, request, "4102", "清单确认")
  967. saveLog(result2, request2, "4103", "清单确认")
  968. saveLog(result3, request3, "4105", "清单统计")
  969. var dat map[string]interface{}
  970. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  971. fmt.Println(dat)
  972. } else {
  973. fmt.Println(err)
  974. }
  975. var empty ResultFourteen
  976. userJSONBytes, _ := json.Marshal(dat)
  977. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  978. utils.ErrorLog("解析失败:%v", err)
  979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  980. return
  981. }
  982. if empty.Infcode == 0 {
  983. c.ServeSuccessJSON(map[string]interface{}{
  984. "msg": "确认成功",
  985. })
  986. return
  987. }
  988. }
  989. }
  990. // 对账权限查询
  991. func (c *HisApiController) Get3260() {
  992. admin_user_id, _ := c.GetInt64("admin_user_id")
  993. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  994. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  995. var api string
  996. var res models.JSResult3260
  997. if miConfig.MdtrtareaAdmvs == "320921" {
  998. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  999. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1000. } else {
  1001. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1002. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1003. }
  1004. resp, requestErr := http.Get(api)
  1005. if requestErr != nil {
  1006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1007. return
  1008. }
  1009. body, ioErr := ioutil.ReadAll(resp.Body)
  1010. if ioErr != nil {
  1011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1013. return
  1014. }
  1015. var respJSON map[string]interface{}
  1016. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1019. return
  1020. }
  1021. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1022. result, _ := json.Marshal(respJSON)
  1023. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1024. utils.ErrorLog("解析失败:%v", err)
  1025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1026. return
  1027. }
  1028. if res.Infcode == "0" {
  1029. c.ServeSuccessJSON(map[string]interface{}{
  1030. "result": res.Output.Data,
  1031. })
  1032. } else {
  1033. c.ServeSuccessJSON(map[string]interface{}{
  1034. "failed_code": -10,
  1035. "msg": res.ErrMsg,
  1036. })
  1037. return
  1038. }
  1039. }
  1040. func (c *HisApiController) Get3261() {
  1041. admin_user_id, _ := c.GetInt64("admin_user_id")
  1042. //month := c.GetString("month")
  1043. startTime := c.GetString("start_time")
  1044. //endTime, _ := c.GetString("end_time")
  1045. times := strings.Split(startTime, "-")
  1046. stmt_mon := times[0] + times[1]
  1047. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1048. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1049. var api string
  1050. var res models.JSResult3261
  1051. //var res10265 Result5301For10265
  1052. if miConfig.MdtrtareaAdmvs == "320921" {
  1053. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1054. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1055. } else {
  1056. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1057. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1058. }
  1059. resp, requestErr := http.Get(api)
  1060. if requestErr != nil {
  1061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1062. return
  1063. }
  1064. body, ioErr := ioutil.ReadAll(resp.Body)
  1065. if ioErr != nil {
  1066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1068. return
  1069. }
  1070. var respJSON map[string]interface{}
  1071. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1074. return
  1075. }
  1076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1077. result, _ := json.Marshal(respJSON)
  1078. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1079. utils.ErrorLog("解析失败:%v", err)
  1080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1081. return
  1082. }
  1083. if res.Infcode == "0" {
  1084. c.ServeSuccessJSON(map[string]interface{}{
  1085. "result": res.Output,
  1086. })
  1087. } else {
  1088. c.ServeSuccessJSON(map[string]interface{}{
  1089. "failed_code": -10,
  1090. "msg": res.ErrMsg,
  1091. })
  1092. return
  1093. }
  1094. }
  1095. type TempFun struct {
  1096. FundKey string
  1097. FundCode string
  1098. }
  1099. func (c *HisApiController) Get3262() {
  1100. admin_user_id, _ := c.GetInt64("admin_user_id")
  1101. startTime := c.GetString("start_time")
  1102. endTime := c.GetString("end_time")
  1103. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1104. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1105. //timeLayout := "2006-01-02"
  1106. //loc, _ := time.LoadLocation("Local")
  1107. //var theStartTIme int64
  1108. //if len(startTime) > 0 {
  1109. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  1110. // if err != nil {
  1111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1112. // return
  1113. // }
  1114. // theStartTIme = theTime.Unix()
  1115. //}
  1116. //var theEndtTIme int64
  1117. //if len(endTime) > 0 {
  1118. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  1119. // if err != nil {
  1120. // utils.ErrorLog(err.Error())
  1121. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1122. // return
  1123. // }
  1124. // theEndtTIme = theTime.Unix()
  1125. //}
  1126. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1127. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1128. for _, team := range datas {
  1129. fmt.Println(team.PsnTime)
  1130. for _, team_two := range datas_two {
  1131. fmt.Println(team_two.PsnTime)
  1132. if team.FundKey == team_two.FundKey {
  1133. fmt.Println(team_two.PsnTime)
  1134. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  1135. fmt.Println(team.PsnTime)
  1136. }
  1137. }
  1138. }
  1139. fmt.Println("1111")
  1140. fmt.Println(datas)
  1141. fmt.Println("1111")
  1142. var twos []models.FixMonRecDetailFileInTwo
  1143. for _, team := range datas {
  1144. var two models.FixMonRecDetailFileInTwo
  1145. two.MedType = team.MedType
  1146. two.Insutype = team.Insutype
  1147. two.PsnType = team.PsnType
  1148. two.MedType = team.MedType
  1149. two.FixBlngAdmdvs = "999999"
  1150. two.InsuAdmdvs = "555555"
  1151. two.PsnTime = team.PsnTime
  1152. two.PsnCnt = team.PsnCnt
  1153. two.FundKey = team.FundKey
  1154. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1155. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1156. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1157. two.MedfeeSumAmt = ms
  1158. two.InscpAmt = ia
  1159. two.FundPaySumAmt = fps
  1160. twos = append(twos, two)
  1161. }
  1162. //startTime := c.GetString("start_time")
  1163. //endTime, _ := c.GetString("end_time")
  1164. times := strings.Split(startTime, "-")
  1165. stmt_mon := times[0] + times[1]
  1166. var funs []models.FundDetail
  1167. for _, item := range datas {
  1168. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1169. funs = append(funs, fun...)
  1170. }
  1171. var funInfos []models.Fund
  1172. //for _, item := range funs {
  1173. // var rf []models.FundInfo
  1174. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1175. // for _, subitem := range rf {
  1176. // var fund models.Fund
  1177. // fund.FundCode = subitem.FundPayType
  1178. // fund.FundName = subitem.FundPayTypeName
  1179. // fund.FundAmt = subitem.FundPayAmt
  1180. // fund.FundKey = item.FundKey
  1181. // fund.InsuAdmdvs = "555555"
  1182. // fund.FixBlngAdmdvs = "999999"
  1183. // funInfos = append(funInfos, fund)
  1184. // }
  1185. //}
  1186. var tempFuns []TempFun
  1187. for _, funInfo := range funInfos {
  1188. var tempFun TempFun
  1189. tempFun.FundKey = funInfo.FundKey
  1190. tempFun.FundCode = funInfo.FundCode
  1191. tempFuns = append(tempFuns, tempFun)
  1192. }
  1193. tempFuns = RemoveRepeatedFunElement(tempFuns)
  1194. fmt.Println(tempFuns)
  1195. var funInfosTwo []models.Fund
  1196. decimal.DivisionPrecision = 2
  1197. for _, item := range tempFuns {
  1198. var fund models.Fund
  1199. for _, subItem := range funInfos {
  1200. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  1201. fund.FundKey = subItem.FundKey
  1202. fund.InsuAdmdvs = subItem.InsuAdmdvs
  1203. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  1204. fund.FundName = subItem.FundName
  1205. fund.FundCode = subItem.FundCode
  1206. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  1207. }
  1208. }
  1209. funInfosTwo = append(funInfosTwo, fund)
  1210. }
  1211. fmt.Println("funInfosTwo")
  1212. fmt.Println(funInfosTwo)
  1213. var upld_btch string
  1214. var empty models.JSResultEmpty
  1215. data := make(map[string]interface{})
  1216. data["org_name"] = miConfig.OrgName
  1217. data["doctor"] = curRoles.UserName
  1218. data["doctor_name"] = curRoles.UserName
  1219. data["fixmedins_code"] = miConfig.Code
  1220. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1221. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1222. data["secret_key"] = miConfig.SecretKey
  1223. data["url"] = miConfig.Url
  1224. data["ak"] = miConfig.AccessKey
  1225. data["cainfo"] = miConfig.Cainfo
  1226. data["datas"] = twos
  1227. data["fund"] = funInfosTwo
  1228. fmt.Println(twos)
  1229. month := time.Unix(1557042972, 0).Format("1")
  1230. year := time.Now().Format("2006")
  1231. month = time.Now().Format("01")
  1232. day := time.Now().Format("02")
  1233. hour := time.Now().Format("15")
  1234. min := time.Now().Format("04")
  1235. sec := time.Now().Format("05")
  1236. fix_fill_date := year + month + day + hour + min + sec
  1237. data["fix_fill_dept"] = miConfig.OrgName
  1238. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1239. data["fix_fill_psn"] = curRoles.UserName
  1240. data["fix_fill_date"] = fix_fill_date
  1241. data["stmt_loc"] = "2"
  1242. data["setl_mon"] = stmt_mon
  1243. upld_btch = "0"
  1244. data["upld_btch"] = upld_btch
  1245. //fmt.Println(data)
  1246. client := &http.Client{}
  1247. bytesData, _ := json.Marshal(data)
  1248. var req *http.Request
  1249. if miConfig.MdtrtareaAdmvs == "320921" {
  1250. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1251. } else {
  1252. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1253. }
  1254. resp, _ := client.Do(req)
  1255. defer resp.Body.Close()
  1256. body, ioErr := ioutil.ReadAll(resp.Body)
  1257. if ioErr != nil {
  1258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1260. }
  1261. var respJSON map[string]interface{}
  1262. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1265. }
  1266. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1267. //fmt.Println(respJSON)
  1268. result, _ := json.Marshal(respJSON)
  1269. //fmt.Println(result)
  1270. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1271. utils.ErrorLog("解析失败:%v", err)
  1272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1273. }
  1274. if empty.Infcode != "0" {
  1275. c.ServeSuccessJSON(map[string]interface{}{
  1276. "failed_code": -10,
  1277. "msg": empty.ErrMsg,
  1278. })
  1279. return
  1280. } else {
  1281. c.ServeSuccessJSON(map[string]interface{}{
  1282. "msg": "上传成功",
  1283. })
  1284. return
  1285. }
  1286. }
  1287. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  1288. newArr = make([]TempFun, 0)
  1289. for i := 0; i < len(arr); i++ {
  1290. repeat := false
  1291. for j := i + 1; j < len(arr); j++ {
  1292. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  1293. repeat = true
  1294. break
  1295. }
  1296. }
  1297. if !repeat {
  1298. newArr = append(newArr, arr[i])
  1299. }
  1300. }
  1301. return
  1302. }
  1303. func (c *HisApiController) Get3263() {
  1304. admin_user_id, _ := c.GetInt64("admin_user_id")
  1305. startTime := c.GetString("start_time")
  1306. //endTime, _ := c.GetString("end_time")
  1307. times := strings.Split(startTime, "-")
  1308. setl_mon := times[0] + times[1]
  1309. upld_btch := "0"
  1310. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1311. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1312. var result3263 models.JSResult3263
  1313. data := make(map[string]interface{})
  1314. data["org_name"] = miConfig.OrgName
  1315. data["doctor"] = curRoles.UserName
  1316. data["doctor_name"] = curRoles.UserName
  1317. data["fixmedins_code"] = miConfig.Code
  1318. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1319. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1320. data["secret_key"] = miConfig.SecretKey
  1321. data["url"] = miConfig.Url
  1322. data["ak"] = miConfig.AccessKey
  1323. data["cainfo"] = miConfig.Cainfo
  1324. data["setl_mon"] = setl_mon
  1325. data["stmt_loc"] = "2"
  1326. data["upld_btch"] = upld_btch
  1327. client := &http.Client{}
  1328. bytesData, _ := json.Marshal(data)
  1329. var req *http.Request
  1330. if miConfig.MdtrtareaAdmvs == "320921" {
  1331. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1332. } else {
  1333. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1334. }
  1335. resp, _ := client.Do(req)
  1336. defer resp.Body.Close()
  1337. body, ioErr := ioutil.ReadAll(resp.Body)
  1338. if ioErr != nil {
  1339. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1341. }
  1342. var respJSON map[string]interface{}
  1343. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1344. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1346. }
  1347. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1348. fmt.Println(respJSON)
  1349. result, _ := json.Marshal(respJSON)
  1350. fmt.Println(result)
  1351. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1352. utils.ErrorLog("解析失败:%v", err)
  1353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1354. }
  1355. if result3263.Infcode != "0" {
  1356. c.ServeSuccessJSON(map[string]interface{}{
  1357. "failed_code": -10,
  1358. "msg": result3263.ErrMsg,
  1359. })
  1360. return
  1361. } else {
  1362. c.ServeSuccessJSON(map[string]interface{}{
  1363. "list": result3263.Output,
  1364. })
  1365. return
  1366. }
  1367. }
  1368. func (c *HisApiController) Get3264() {
  1369. admin_user_id, _ := c.GetInt64("admin_user_id")
  1370. startTime := c.GetString("start_time")
  1371. //endTime, _ := c.GetString("end_time")
  1372. times := strings.Split(startTime, "-")
  1373. setl_mon := times[0] + times[1]
  1374. upld_btch := "0"
  1375. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1376. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1377. //solidify_id := []
  1378. var result3263 models.JSResult3263
  1379. data := make(map[string]interface{})
  1380. data["org_name"] = miConfig.OrgName
  1381. data["doctor"] = curRoles.UserName
  1382. data["doctor_name"] = curRoles.UserName
  1383. data["fixmedins_code"] = miConfig.Code
  1384. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1385. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1386. data["secret_key"] = miConfig.SecretKey
  1387. data["url"] = miConfig.Url
  1388. data["ak"] = miConfig.AccessKey
  1389. data["cainfo"] = miConfig.Cainfo
  1390. data["setl_mon"] = setl_mon
  1391. data["stmt_loc"] = "2"
  1392. data["upld_btch"] = upld_btch
  1393. client := &http.Client{}
  1394. bytesData, _ := json.Marshal(data)
  1395. var req3263 *http.Request
  1396. if miConfig.MdtrtareaAdmvs == "320921" {
  1397. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1398. } else {
  1399. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1400. }
  1401. resp, _ := client.Do(req3263)
  1402. defer resp.Body.Close()
  1403. body, ioErr := ioutil.ReadAll(resp.Body)
  1404. if ioErr != nil {
  1405. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1407. }
  1408. var respJSON3263 map[string]interface{}
  1409. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  1410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1412. }
  1413. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1414. fmt.Println(respJSON3263)
  1415. result, _ := json.Marshal(respJSON3263)
  1416. fmt.Println(result)
  1417. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1418. utils.ErrorLog("解析失败:%v", err)
  1419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1420. }
  1421. var ids []string
  1422. for _, item := range result3263.Output {
  1423. ids = append(ids, item.SolidifyID)
  1424. }
  1425. var empty models.JSResultEmpty
  1426. data2 := make(map[string]interface{})
  1427. data2["org_name"] = miConfig.OrgName
  1428. data2["doctor"] = curRoles.UserName
  1429. data2["doctor_name"] = curRoles.UserName
  1430. data2["fixmedins_code"] = miConfig.Code
  1431. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1432. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1433. data2["secret_key"] = miConfig.SecretKey
  1434. data2["url"] = miConfig.Url
  1435. data2["ak"] = miConfig.AccessKey
  1436. data2["cainfo"] = miConfig.Cainfo
  1437. data2["setl_mon"] = setl_mon
  1438. data2["stmt_loc"] = "2"
  1439. data2["upld_btch"] = upld_btch
  1440. data2["solidify_id"] = ids
  1441. client2 := &http.Client{}
  1442. bytesData2, _ := json.Marshal(data2)
  1443. var req *http.Request
  1444. if miConfig.MdtrtareaAdmvs == "320921" {
  1445. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1446. } else {
  1447. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1448. }
  1449. resp2, _ := client2.Do(req)
  1450. defer resp.Body.Close()
  1451. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1452. if ioErr2 != nil {
  1453. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1455. }
  1456. var respJSON map[string]interface{}
  1457. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  1458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1460. }
  1461. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1462. fmt.Println(respJSON)
  1463. result2, _ := json.Marshal(respJSON)
  1464. fmt.Println(result2)
  1465. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  1466. utils.ErrorLog("解析失败:%v", err)
  1467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1468. }
  1469. if empty.Infcode != "0" {
  1470. c.ServeSuccessJSON(map[string]interface{}{
  1471. "failed_code": -10,
  1472. "msg": empty.ErrMsg,
  1473. })
  1474. return
  1475. } else {
  1476. c.ServeSuccessJSON(map[string]interface{}{
  1477. "msg": "",
  1478. })
  1479. return
  1480. }
  1481. }
  1482. func (c *HisApiController) Get3265() {
  1483. admin_user_id, _ := c.GetInt64("admin_user_id")
  1484. startTime := c.GetString("start_time")
  1485. //endTime, _ := c.GetString("end_time")
  1486. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1487. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1488. times := strings.Split(startTime, "-")
  1489. setl_mon := times[0] + times[1]
  1490. var upld_btch string
  1491. upld_btch = "0"
  1492. //var empty models.JSResultEmpty
  1493. var result3265 models.JSResult3264
  1494. var result3263 models.JSResult3263
  1495. data2 := make(map[string]interface{})
  1496. data2["org_name"] = miConfig.OrgName
  1497. data2["doctor"] = curRoles.UserName
  1498. data2["doctor_name"] = curRoles.UserName
  1499. data2["fixmedins_code"] = miConfig.Code
  1500. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1501. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1502. data2["secret_key"] = miConfig.SecretKey
  1503. data2["url"] = miConfig.Url
  1504. data2["ak"] = miConfig.AccessKey
  1505. data2["cainfo"] = miConfig.Cainfo
  1506. data2["setl_mon"] = setl_mon
  1507. data2["stmt_loc"] = "2"
  1508. data2["upld_btch"] = upld_btch
  1509. client2 := &http.Client{}
  1510. bytesData2, _ := json.Marshal(data2)
  1511. var req3263 *http.Request
  1512. if miConfig.MdtrtareaAdmvs == "320921" {
  1513. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1514. } else {
  1515. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1516. }
  1517. resp2, _ := client2.Do(req3263)
  1518. defer resp2.Body.Close()
  1519. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1520. if ioErr2 != nil {
  1521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1523. }
  1524. var respJSON3263 map[string]interface{}
  1525. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1528. }
  1529. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1530. fmt.Println(respJSON3263)
  1531. result2, _ := json.Marshal(respJSON3263)
  1532. fmt.Println(result2)
  1533. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1534. utils.ErrorLog("解析失败:%v", err)
  1535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1536. }
  1537. var ids []string
  1538. for _, item := range result3263.Output {
  1539. ids = append(ids, item.SolidifyID)
  1540. }
  1541. data := make(map[string]interface{})
  1542. data["org_name"] = miConfig.OrgName
  1543. data["doctor"] = curRoles.UserName
  1544. data["doctor_name"] = curRoles.UserName
  1545. data["fixmedins_code"] = miConfig.Code
  1546. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1547. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1548. data["secret_key"] = miConfig.SecretKey
  1549. data["url"] = miConfig.Url
  1550. data["ak"] = miConfig.AccessKey
  1551. data["cainfo"] = miConfig.Cainfo
  1552. data["setl_mon"] = setl_mon
  1553. data["solidify_id"] = ids
  1554. month := time.Unix(1557042972, 0).Format("1")
  1555. year := time.Now().Format("2006")
  1556. month = time.Now().Format("01")
  1557. day := time.Now().Format("02")
  1558. hour := time.Now().Format("15")
  1559. min := time.Now().Format("04")
  1560. sec := time.Now().Format("05")
  1561. fix_fill_date := year + month + day + hour + min + sec
  1562. data["fix_fill_dept"] = miConfig.OrgName
  1563. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1564. data["fix_fill_psn"] = curRoles.UserName
  1565. data["fix_fill_date"] = fix_fill_date
  1566. data["stmt_loc"] = "2"
  1567. data["upld_btch"] = upld_btch
  1568. client := &http.Client{}
  1569. bytesData, _ := json.Marshal(data)
  1570. var req *http.Request
  1571. if miConfig.MdtrtareaAdmvs == "320921" {
  1572. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1573. } else {
  1574. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1575. }
  1576. resp, _ := client.Do(req)
  1577. defer resp.Body.Close()
  1578. body, ioErr := ioutil.ReadAll(resp.Body)
  1579. if ioErr != nil {
  1580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1582. }
  1583. var respJSON map[string]interface{}
  1584. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1587. }
  1588. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1589. fmt.Println(respJSON)
  1590. result, _ := json.Marshal(respJSON)
  1591. fmt.Println(result)
  1592. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1593. utils.ErrorLog("解析失败:%v", err)
  1594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1595. }
  1596. if result3265.Infcode != "0" {
  1597. c.ServeSuccessJSON(map[string]interface{}{
  1598. "failed_code": -10,
  1599. "msg": result3265.ErrMsg,
  1600. })
  1601. return
  1602. } else {
  1603. c.ServeSuccessJSON(map[string]interface{}{
  1604. "info": result3265.Output,
  1605. })
  1606. return
  1607. }
  1608. }
  1609. func (c *HisApiController) Get3266() {
  1610. admin_user_id, _ := c.GetInt64("admin_user_id")
  1611. startTime := c.GetString("start_time")
  1612. //endTime, _ := c.GetString("end_time")
  1613. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1614. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1615. times := strings.Split(startTime, "-")
  1616. stmt_mon := times[0] + times[1]
  1617. var upld_btch string
  1618. //var empty models.JSResultEmpty
  1619. var result3265 models.JSResult3264
  1620. data := make(map[string]interface{})
  1621. data["org_name"] = miConfig.OrgName
  1622. data["doctor"] = curRoles.UserName
  1623. data["doctor_name"] = curRoles.UserName
  1624. data["fixmedins_code"] = miConfig.Code
  1625. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1626. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1627. data["secret_key"] = miConfig.SecretKey
  1628. data["url"] = miConfig.Url
  1629. data["ak"] = miConfig.AccessKey
  1630. data["cainfo"] = miConfig.Cainfo
  1631. data["setl_mon"] = stmt_mon
  1632. month := time.Unix(1557042972, 0).Format("1")
  1633. year := time.Now().Format("2006")
  1634. month = time.Now().Format("01")
  1635. day := time.Now().Format("02")
  1636. hour := time.Now().Format("15")
  1637. min := time.Now().Format("04")
  1638. sec := time.Now().Format("05")
  1639. fix_fill_date := year + month + day + hour + min + sec
  1640. data["fix_fill_dept"] = miConfig.OrgName
  1641. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1642. data["fix_fill_psn"] = curRoles.UserName
  1643. data["fix_fill_date"] = fix_fill_date
  1644. data["stmt_loc"] = "2"
  1645. upld_btch = "0"
  1646. data["upld_btch"] = upld_btch
  1647. client := &http.Client{}
  1648. bytesData, _ := json.Marshal(data)
  1649. var req *http.Request
  1650. if miConfig.MdtrtareaAdmvs == "320921" {
  1651. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1652. } else {
  1653. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1654. }
  1655. resp, _ := client.Do(req)
  1656. defer resp.Body.Close()
  1657. body, ioErr := ioutil.ReadAll(resp.Body)
  1658. if ioErr != nil {
  1659. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1661. }
  1662. var respJSON map[string]interface{}
  1663. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1664. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1666. }
  1667. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1668. fmt.Println(respJSON)
  1669. result, _ := json.Marshal(respJSON)
  1670. fmt.Println(result)
  1671. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1672. utils.ErrorLog("解析失败:%v", err)
  1673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1674. }
  1675. if result3265.Infcode != "0" {
  1676. c.ServeSuccessJSON(map[string]interface{}{
  1677. "failed_code": -10,
  1678. "msg": result3265.ErrMsg,
  1679. })
  1680. return
  1681. } else {
  1682. c.ServeSuccessJSON(map[string]interface{}{
  1683. "info": result3265.Output,
  1684. })
  1685. return
  1686. }
  1687. }
  1688. func (c *HisApiController) Get3267() {
  1689. admin_user_id, _ := c.GetInt64("admin_user_id")
  1690. startTime := c.GetString("start_time")
  1691. //endTime, _ := c.GetString("end_time")
  1692. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1693. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1694. times := strings.Split(startTime, "-")
  1695. setl_mon := times[0] + times[1]
  1696. var upld_btch string
  1697. //var empty models.JSResultEmpty
  1698. var result3265 models.JSResult3264
  1699. upld_btch = "0"
  1700. data := make(map[string]interface{})
  1701. data["org_name"] = miConfig.OrgName
  1702. data["doctor"] = curRoles.UserName
  1703. data["doctor_name"] = curRoles.UserName
  1704. data["fixmedins_code"] = miConfig.Code
  1705. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1706. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1707. data["secret_key"] = miConfig.SecretKey
  1708. data["url"] = miConfig.Url
  1709. data["ak"] = miConfig.AccessKey
  1710. data["cainfo"] = miConfig.Cainfo
  1711. data["setl_mon"] = setl_mon
  1712. data["stmt_loc"] = "2"
  1713. data["upld_btch"] = upld_btch
  1714. client := &http.Client{}
  1715. bytesData, _ := json.Marshal(data)
  1716. var req *http.Request
  1717. if miConfig.MdtrtareaAdmvs == "320921" {
  1718. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1719. } else {
  1720. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1721. }
  1722. resp, _ := client.Do(req)
  1723. defer resp.Body.Close()
  1724. body, ioErr := ioutil.ReadAll(resp.Body)
  1725. if ioErr != nil {
  1726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1728. }
  1729. var respJSON map[string]interface{}
  1730. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1733. }
  1734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1735. fmt.Println(respJSON)
  1736. result, _ := json.Marshal(respJSON)
  1737. fmt.Println(result)
  1738. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1739. utils.ErrorLog("解析失败:%v", err)
  1740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1741. }
  1742. if result3265.Infcode != "0" {
  1743. c.ServeSuccessJSON(map[string]interface{}{
  1744. "failed_code": -10,
  1745. "msg": result3265.ErrMsg,
  1746. })
  1747. return
  1748. } else {
  1749. c.ServeSuccessJSON(map[string]interface{}{
  1750. "info": result3265.Output.Data,
  1751. })
  1752. return
  1753. }
  1754. }
  1755. func (c *HisApiController) Get3268() {
  1756. admin_user_id, _ := c.GetInt64("admin_user_id")
  1757. startTime := c.GetString("start_time")
  1758. endTime := c.GetString("end_time")
  1759. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1760. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1761. times := strings.Split(startTime, "-")
  1762. setl_mon := times[0] + times[1]
  1763. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1764. var twos []models.FixMonRecDetailFileInTwo
  1765. var funs []models.FundDetail
  1766. for _, item := range datas {
  1767. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1768. funs = append(funs, fun...)
  1769. }
  1770. var funInfos []models.Fund
  1771. //for _, item := range funs {
  1772. // var rf []models.FundInfo
  1773. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1774. // for _, subitem := range rf {
  1775. // var fund models.Fund
  1776. // fund.FundCode = subitem.FundPayType
  1777. // fund.FundName = subitem.FundPayTypeName
  1778. // fund.FundAmt = subitem.FundPayAmt
  1779. // fund.FundKey = item.FundKey
  1780. // fund.InsuAdmdvs = "555555"
  1781. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  1782. // funInfos = append(funInfos, fund)
  1783. // }
  1784. //}
  1785. for _, team := range datas {
  1786. var two models.FixMonRecDetailFileInTwo
  1787. two.SetlDate = time.Now().Format("2006-01-02")
  1788. two.MedType = team.MedType
  1789. two.Insutype = team.Insutype
  1790. two.PsnType = team.PsnType
  1791. two.MedType = team.MedType
  1792. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  1793. two.InsuAdmdvs = team.InsuAdmdvs
  1794. two.PsnTime = team.PsnTime
  1795. two.PsnCnt = team.PsnCnt
  1796. two.FundKey = team.FundKey
  1797. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1798. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1799. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1800. two.MedfeeSumAmt = ms
  1801. two.InscpAmt = ia
  1802. two.FundPaySumAmt = fps
  1803. twos = append(twos, two)
  1804. }
  1805. var upld_btch string
  1806. upld_btch = "0"
  1807. var empty models.JSResultEmpty
  1808. data := make(map[string]interface{})
  1809. data["org_name"] = miConfig.OrgName
  1810. data["doctor"] = curRoles.UserName
  1811. data["doctor_name"] = curRoles.UserName
  1812. data["fixmedins_code"] = miConfig.Code
  1813. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1814. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1815. data["secret_key"] = miConfig.SecretKey
  1816. data["url"] = miConfig.Url
  1817. data["ak"] = miConfig.AccessKey
  1818. data["cainfo"] = miConfig.Cainfo
  1819. data["datas"] = twos
  1820. data["fund"] = funInfos
  1821. data["setl_mon"] = setl_mon
  1822. month := time.Unix(1557042972, 0).Format("1")
  1823. year := time.Now().Format("2006")
  1824. month = time.Now().Format("01")
  1825. day := time.Now().Format("02")
  1826. hour := time.Now().Format("15")
  1827. min := time.Now().Format("04")
  1828. sec := time.Now().Format("05")
  1829. fix_fill_date := year + month + day + hour + min + sec
  1830. data["fix_fill_dept"] = miConfig.OrgName
  1831. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1832. data["fix_fill_psn"] = curRoles.UserName
  1833. data["fix_fill_date"] = fix_fill_date
  1834. data["stmt_loc"] = "2"
  1835. data["upld_btch"] = upld_btch
  1836. client := &http.Client{}
  1837. bytesData, _ := json.Marshal(data)
  1838. var req *http.Request
  1839. if miConfig.MdtrtareaAdmvs == "320921" {
  1840. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1841. } else {
  1842. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1843. }
  1844. resp, _ := client.Do(req)
  1845. defer resp.Body.Close()
  1846. body, ioErr := ioutil.ReadAll(resp.Body)
  1847. if ioErr != nil {
  1848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1850. }
  1851. var respJSON map[string]interface{}
  1852. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1855. }
  1856. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1857. fmt.Println(respJSON)
  1858. result, _ := json.Marshal(respJSON)
  1859. fmt.Println(result)
  1860. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1861. utils.ErrorLog("解析失败:%v", err)
  1862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1863. }
  1864. if empty.Infcode != "0" {
  1865. c.ServeSuccessJSON(map[string]interface{}{
  1866. "failed_code": -10,
  1867. "msg": empty.ErrMsg,
  1868. })
  1869. return
  1870. } else {
  1871. c.ServeSuccessJSON(map[string]interface{}{
  1872. "msg": "上传成功",
  1873. })
  1874. return
  1875. }
  1876. }
  1877. func (c *HisApiController) Get3269() {
  1878. admin_user_id, _ := c.GetInt64("admin_user_id")
  1879. startTime := c.GetString("start_time")
  1880. //endTime, _ := c.GetString("end_time")
  1881. times := strings.Split(startTime, "-")
  1882. setl_mon := times[0] + times[1]
  1883. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1884. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1885. var result3263 models.JSResult3263
  1886. data := make(map[string]interface{})
  1887. data["org_name"] = miConfig.OrgName
  1888. data["doctor"] = curRoles.UserName
  1889. data["doctor_name"] = curRoles.UserName
  1890. data["fixmedins_code"] = miConfig.Code
  1891. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1892. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1893. data["secret_key"] = miConfig.SecretKey
  1894. data["url"] = miConfig.Url
  1895. data["ak"] = miConfig.AccessKey
  1896. data["cainfo"] = miConfig.Cainfo
  1897. data["setl_mon"] = setl_mon
  1898. data["stmt_loc"] = "2"
  1899. client := &http.Client{}
  1900. bytesData, _ := json.Marshal(data)
  1901. var req *http.Request
  1902. if miConfig.MdtrtareaAdmvs == "320921" {
  1903. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1904. } else {
  1905. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1906. }
  1907. resp, _ := client.Do(req)
  1908. defer resp.Body.Close()
  1909. body, ioErr := ioutil.ReadAll(resp.Body)
  1910. if ioErr != nil {
  1911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1913. }
  1914. var respJSON map[string]interface{}
  1915. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1918. }
  1919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1920. fmt.Println(respJSON)
  1921. result, _ := json.Marshal(respJSON)
  1922. fmt.Println(result)
  1923. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1924. utils.ErrorLog("解析失败:%v", err)
  1925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1926. }
  1927. if result3263.Infcode != "0" {
  1928. c.ServeSuccessJSON(map[string]interface{}{
  1929. "failed_code": -10,
  1930. "msg": result3263.ErrMsg,
  1931. })
  1932. return
  1933. } else {
  1934. c.ServeSuccessJSON(map[string]interface{}{
  1935. "msg": "上传成功",
  1936. })
  1937. return
  1938. }
  1939. }
  1940. func (c *HisApiController) Get3270() {
  1941. admin_user_id, _ := c.GetInt64("admin_user_id")
  1942. startTime := c.GetString("start_time")
  1943. //endTime, _ := c.GetString("end_time")
  1944. times := strings.Split(startTime, "-")
  1945. setl_mon := times[0] + times[1]
  1946. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1947. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1948. var result3263 models.JSResult3263
  1949. data2 := make(map[string]interface{})
  1950. data2["org_name"] = miConfig.OrgName
  1951. data2["doctor"] = curRoles.UserName
  1952. data2["doctor_name"] = curRoles.UserName
  1953. data2["fixmedins_code"] = miConfig.Code
  1954. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1955. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1956. data2["secret_key"] = miConfig.SecretKey
  1957. data2["url"] = miConfig.Url
  1958. data2["ak"] = miConfig.AccessKey
  1959. data2["cainfo"] = miConfig.Cainfo
  1960. data2["setl_mon"] = setl_mon
  1961. data2["stmt_loc"] = "2"
  1962. client2 := &http.Client{}
  1963. bytesData2, _ := json.Marshal(data2)
  1964. var req3263 *http.Request
  1965. if miConfig.MdtrtareaAdmvs == "320921" {
  1966. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1967. } else {
  1968. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1969. }
  1970. resp2, _ := client2.Do(req3263)
  1971. defer resp2.Body.Close()
  1972. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1973. if ioErr2 != nil {
  1974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1976. }
  1977. var respJSON3263 map[string]interface{}
  1978. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1981. }
  1982. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1983. fmt.Println(respJSON3263)
  1984. result2, _ := json.Marshal(respJSON3263)
  1985. fmt.Println(result2)
  1986. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1987. utils.ErrorLog("解析失败:%v", err)
  1988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1989. }
  1990. var ids []string
  1991. for _, item := range result3263.Output {
  1992. ids = append(ids, item.SolidifyID)
  1993. }
  1994. var result3264 models.JSResult3264
  1995. data := make(map[string]interface{})
  1996. data["org_name"] = miConfig.OrgName
  1997. data["doctor"] = curRoles.UserName
  1998. data["doctor_name"] = curRoles.UserName
  1999. data["fixmedins_code"] = miConfig.Code
  2000. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2001. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2002. data["secret_key"] = miConfig.SecretKey
  2003. data["url"] = miConfig.Url
  2004. data["ak"] = miConfig.AccessKey
  2005. data["cainfo"] = miConfig.Cainfo
  2006. data["setl_mon"] = setl_mon
  2007. data["stmt_loc"] = "2"
  2008. data["solidify_id"] = ids
  2009. client := &http.Client{}
  2010. bytesData, _ := json.Marshal(data)
  2011. var req *http.Request
  2012. if miConfig.MdtrtareaAdmvs == "320921" {
  2013. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2014. } else {
  2015. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2016. }
  2017. resp, _ := client.Do(req)
  2018. defer resp.Body.Close()
  2019. body, ioErr := ioutil.ReadAll(resp.Body)
  2020. if ioErr != nil {
  2021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2023. }
  2024. var respJSON map[string]interface{}
  2025. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2028. }
  2029. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2030. fmt.Println(respJSON)
  2031. result, _ := json.Marshal(respJSON)
  2032. fmt.Println(result)
  2033. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  2034. utils.ErrorLog("解析失败:%v", err)
  2035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2036. }
  2037. if result3264.Infcode != "0" {
  2038. c.ServeSuccessJSON(map[string]interface{}{
  2039. "failed_code": -10,
  2040. "msg": result3264.ErrMsg,
  2041. })
  2042. return
  2043. } else {
  2044. c.ServeSuccessJSON(map[string]interface{}{
  2045. "info": result3264.Output,
  2046. })
  2047. return
  2048. }
  2049. }
  2050. func (c *HisApiController) Get3271() {
  2051. admin_user_id, _ := c.GetInt64("admin_user_id")
  2052. startTime := c.GetString("start_time")
  2053. //endTime, _ := c.GetString("end_time")
  2054. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2055. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2056. times := strings.Split(startTime, "-")
  2057. setl_mon := times[0] + times[1]
  2058. //var empty models.JSResultEmpty
  2059. var result3265 models.JSResult3264
  2060. var result3263 models.JSResult3263
  2061. data2 := make(map[string]interface{})
  2062. data2["org_name"] = miConfig.OrgName
  2063. data2["doctor"] = curRoles.UserName
  2064. data2["doctor_name"] = curRoles.UserName
  2065. data2["fixmedins_code"] = miConfig.Code
  2066. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2067. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2068. data2["secret_key"] = miConfig.SecretKey
  2069. data2["url"] = miConfig.Url
  2070. data2["ak"] = miConfig.AccessKey
  2071. data2["cainfo"] = miConfig.Cainfo
  2072. data2["setl_mon"] = setl_mon
  2073. data2["stmt_loc"] = "2"
  2074. client2 := &http.Client{}
  2075. bytesData2, _ := json.Marshal(data2)
  2076. var req3263 *http.Request
  2077. if miConfig.MdtrtareaAdmvs == "320921" {
  2078. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2079. } else {
  2080. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2081. }
  2082. resp2, _ := client2.Do(req3263)
  2083. defer resp2.Body.Close()
  2084. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2085. if ioErr2 != nil {
  2086. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2088. }
  2089. var respJSON3263 map[string]interface{}
  2090. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2093. }
  2094. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2095. fmt.Println(respJSON3263)
  2096. result2, _ := json.Marshal(respJSON3263)
  2097. fmt.Println(result2)
  2098. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2099. utils.ErrorLog("解析失败:%v", err)
  2100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2101. }
  2102. var ids []string
  2103. for _, item := range result3263.Output {
  2104. ids = append(ids, item.SolidifyID)
  2105. }
  2106. data := make(map[string]interface{})
  2107. data["org_name"] = miConfig.OrgName
  2108. data["doctor"] = curRoles.UserName
  2109. data["doctor_name"] = curRoles.UserName
  2110. data["fixmedins_code"] = miConfig.Code
  2111. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2112. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2113. data["secret_key"] = miConfig.SecretKey
  2114. data["url"] = miConfig.Url
  2115. data["ak"] = miConfig.AccessKey
  2116. data["cainfo"] = miConfig.Cainfo
  2117. data["setl_mon"] = setl_mon
  2118. data["solidify_id"] = ids
  2119. month := time.Unix(1557042972, 0).Format("1")
  2120. year := time.Now().Format("2006")
  2121. month = time.Now().Format("01")
  2122. day := time.Now().Format("02")
  2123. hour := time.Now().Format("15")
  2124. min := time.Now().Format("04")
  2125. sec := time.Now().Format("05")
  2126. fix_fill_date := year + month + day + hour + min + sec
  2127. data["fix_fill_dept"] = miConfig.OrgName
  2128. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2129. data["fix_fill_psn"] = curRoles.UserName
  2130. data["fix_fill_date"] = fix_fill_date
  2131. data["stmt_loc"] = "2"
  2132. client := &http.Client{}
  2133. bytesData, _ := json.Marshal(data)
  2134. var req *http.Request
  2135. if miConfig.MdtrtareaAdmvs == "320921" {
  2136. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2137. } else {
  2138. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2139. }
  2140. resp, _ := client.Do(req)
  2141. defer resp.Body.Close()
  2142. body, ioErr := ioutil.ReadAll(resp.Body)
  2143. if ioErr != nil {
  2144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2146. }
  2147. var respJSON map[string]interface{}
  2148. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2151. }
  2152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2153. fmt.Println(respJSON)
  2154. result, _ := json.Marshal(respJSON)
  2155. fmt.Println(result)
  2156. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2157. utils.ErrorLog("解析失败:%v", err)
  2158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2159. }
  2160. if result3265.Infcode != "0" {
  2161. c.ServeSuccessJSON(map[string]interface{}{
  2162. "failed_code": -10,
  2163. "msg": result3265.ErrMsg,
  2164. })
  2165. return
  2166. } else {
  2167. c.ServeSuccessJSON(map[string]interface{}{
  2168. "info": result3265.Output.Data,
  2169. })
  2170. return
  2171. }
  2172. }
  2173. func (c *HisApiController) Get3272() {
  2174. admin_user_id, _ := c.GetInt64("admin_user_id")
  2175. startTime := c.GetString("start_time")
  2176. //endTime, _ := c.GetString("end_time")
  2177. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2178. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2179. times := strings.Split(startTime, "-")
  2180. setl_mon := times[0] + times[1]
  2181. var upld_btch string
  2182. //var empty models.JSResultEmpty
  2183. var result3265 models.JSResult3264
  2184. data := make(map[string]interface{})
  2185. data["org_name"] = miConfig.OrgName
  2186. data["doctor"] = curRoles.UserName
  2187. data["doctor_name"] = curRoles.UserName
  2188. data["fixmedins_code"] = miConfig.Code
  2189. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2190. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2191. data["secret_key"] = miConfig.SecretKey
  2192. data["url"] = miConfig.Url
  2193. data["ak"] = miConfig.AccessKey
  2194. data["cainfo"] = miConfig.Cainfo
  2195. data["setl_mon"] = setl_mon
  2196. month := time.Unix(1557042972, 0).Format("1")
  2197. year := time.Now().Format("2006")
  2198. month = time.Now().Format("01")
  2199. day := time.Now().Format("02")
  2200. hour := time.Now().Format("15")
  2201. min := time.Now().Format("04")
  2202. sec := time.Now().Format("05")
  2203. fix_fill_date := year + month + day + hour + min + sec
  2204. data["fix_fill_dept"] = miConfig.OrgName
  2205. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2206. data["fix_fill_psn"] = curRoles.UserName
  2207. data["fix_fill_date"] = fix_fill_date
  2208. data["stmt_loc"] = "2"
  2209. data["upld_btch"] = upld_btch
  2210. client := &http.Client{}
  2211. bytesData, _ := json.Marshal(data)
  2212. var req *http.Request
  2213. if miConfig.MdtrtareaAdmvs == "320921" {
  2214. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2215. } else {
  2216. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2217. }
  2218. resp, _ := client.Do(req)
  2219. defer resp.Body.Close()
  2220. body, ioErr := ioutil.ReadAll(resp.Body)
  2221. if ioErr != nil {
  2222. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2224. }
  2225. var respJSON map[string]interface{}
  2226. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2229. }
  2230. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2231. fmt.Println(respJSON)
  2232. result, _ := json.Marshal(respJSON)
  2233. fmt.Println(result)
  2234. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2235. utils.ErrorLog("解析失败:%v", err)
  2236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2237. }
  2238. if result3265.Infcode != "0" {
  2239. c.ServeSuccessJSON(map[string]interface{}{
  2240. "failed_code": -10,
  2241. "msg": result3265.ErrMsg,
  2242. })
  2243. return
  2244. } else {
  2245. c.ServeSuccessJSON(map[string]interface{}{
  2246. "info": result3265.Output,
  2247. })
  2248. return
  2249. }
  2250. }
  2251. func (c *HisApiController) Get3273() {
  2252. admin_user_id, _ := c.GetInt64("admin_user_id")
  2253. startTime := c.GetString("start_time")
  2254. //endTime, _ := c.GetString("end_time")
  2255. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2256. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2257. times := strings.Split(startTime, "-")
  2258. setl_mon := times[0] + times[1]
  2259. var result3265 models.JSResult3264
  2260. data := make(map[string]interface{})
  2261. data["org_name"] = miConfig.OrgName
  2262. data["doctor"] = curRoles.UserName
  2263. data["doctor_name"] = curRoles.UserName
  2264. data["fixmedins_code"] = miConfig.Code
  2265. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2266. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2267. data["secret_key"] = miConfig.SecretKey
  2268. data["url"] = miConfig.Url
  2269. data["ak"] = miConfig.AccessKey
  2270. data["cainfo"] = miConfig.Cainfo
  2271. data["setl_mon"] = setl_mon
  2272. data["stmt_loc"] = "2"
  2273. client := &http.Client{}
  2274. bytesData, _ := json.Marshal(data)
  2275. var req *http.Request
  2276. if miConfig.MdtrtareaAdmvs == "320921" {
  2277. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2278. } else {
  2279. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2280. }
  2281. resp, _ := client.Do(req)
  2282. defer resp.Body.Close()
  2283. body, ioErr := ioutil.ReadAll(resp.Body)
  2284. if ioErr != nil {
  2285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2287. }
  2288. var respJSON map[string]interface{}
  2289. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2292. }
  2293. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2294. fmt.Println(respJSON)
  2295. result, _ := json.Marshal(respJSON)
  2296. fmt.Println(result)
  2297. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2298. utils.ErrorLog("解析失败:%v", err)
  2299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2300. }
  2301. if result3265.Infcode != "0" {
  2302. c.ServeSuccessJSON(map[string]interface{}{
  2303. "failed_code": -10,
  2304. "msg": result3265.ErrMsg,
  2305. })
  2306. return
  2307. } else {
  2308. c.ServeSuccessJSON(map[string]interface{}{
  2309. "info": result3265.Output.Data,
  2310. })
  2311. return
  2312. }
  2313. }
  2314. func (c *HisApiController) Get3274() {
  2315. //if miConfig.MdtrtareaAdmvs == "320921" {
  2316. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2317. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2318. // "&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
  2319. //
  2320. //} else {
  2321. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2322. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2323. // "&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
  2324. //
  2325. //}
  2326. }
  2327. func (c *HisApiController) Get3275() {
  2328. //if miConfig.MdtrtareaAdmvs == "320921" {
  2329. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2330. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2331. // "&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
  2332. //
  2333. //} else {
  2334. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2335. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2336. // "&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
  2337. //
  2338. //}
  2339. }
  2340. func (c *HisApiController) Get3276() {
  2341. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2342. //month := c.GetString("month")
  2343. //
  2344. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2345. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2346. //var api string
  2347. //var res Result5301
  2348. //
  2349. //if miConfig.MdtrtareaAdmvs == "320921" {
  2350. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2351. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2352. //} else {
  2353. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2354. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2355. //}
  2356. //
  2357. //resp, requestErr := http.Get(api)
  2358. //if requestErr != nil {
  2359. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2360. // return
  2361. //}
  2362. //
  2363. //body, ioErr := ioutil.ReadAll(resp.Body)
  2364. //if ioErr != nil {
  2365. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2366. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2367. // return
  2368. //}
  2369. //var respJSON map[string]interface{}
  2370. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2371. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2372. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2373. // return
  2374. //}
  2375. //
  2376. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2377. //result, _ := json.Marshal(respJSON)
  2378. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2379. // utils.ErrorLog("解析失败:%v", err)
  2380. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2381. // return
  2382. //}
  2383. }
  2384. func (c *HisApiController) Get3277() {
  2385. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2386. //month := c.GetString("month")
  2387. //
  2388. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2389. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2390. //var api string
  2391. //var res Result5301
  2392. //
  2393. //if miConfig.MdtrtareaAdmvs == "320921" {
  2394. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2395. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2396. //} else {
  2397. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2398. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2399. //}
  2400. //
  2401. //resp, requestErr := http.Get(api)
  2402. //if requestErr != nil {
  2403. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2404. // return
  2405. //}
  2406. //
  2407. //body, ioErr := ioutil.ReadAll(resp.Body)
  2408. //if ioErr != nil {
  2409. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2410. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2411. // return
  2412. //}
  2413. //var respJSON map[string]interface{}
  2414. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2415. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2416. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2417. // return
  2418. //}
  2419. //
  2420. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2421. //result, _ := json.Marshal(respJSON)
  2422. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2423. // utils.ErrorLog("解析失败:%v", err)
  2424. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2425. // return
  2426. //}
  2427. }
  2428. func (c *HisApiController) GetCFYLJG001() {
  2429. admin_user_id, _ := c.GetInt64("admin_user_id")
  2430. patient_id, _ := c.GetInt64("patient_id")
  2431. his_patient_id, _ := c.GetInt64("his_patient_id")
  2432. record_time := c.GetString("record_time")
  2433. admin_user_id = 3626
  2434. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2435. psn, _ := service.GetPsnByPatientId(patient_id)
  2436. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2437. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2438. var cFYLJG001 models.CFYLJG001
  2439. timeLayout := "2006-01-02"
  2440. loc, _ := time.LoadLocation("Local")
  2441. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2442. if err != nil {
  2443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2444. return
  2445. }
  2446. recordDateTime := theTime.Unix()
  2447. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2448. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2449. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2450. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2451. //dept, _ := service.GetDepartMentDetail(info.Departments)
  2452. for _, item := range prescriptions {
  2453. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  2454. if his.IdCardType == 1 {
  2455. bas := strings.Split(psn.CardInfo, "|")
  2456. basNumber := bas[1]
  2457. fmt.Println(basNumber)
  2458. card_sn := bas[3]
  2459. card_no := bas[2]
  2460. cFYLJG001.MdtrtCertType = "03"
  2461. cFYLJG001.CardSn = card_sn
  2462. cFYLJG001.MdtrtCertNo = card_no
  2463. cFYLJG001.EcToken = ""
  2464. cFYLJG001.AuthNo = ""
  2465. } else if his.IdCardType == 2 {
  2466. cFYLJG001.MdtrtCertType = "02"
  2467. cFYLJG001.CardSn = ""
  2468. cFYLJG001.MdtrtCertNo = his.IdCardNo
  2469. cFYLJG001.EcToken = ""
  2470. cFYLJG001.AuthNo = ""
  2471. } else if his.IdCardType == 4 {
  2472. cFYLJG001.MdtrtCertType = "01"
  2473. cFYLJG001.CardSn = ""
  2474. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  2475. cFYLJG001.EcToken = psn.VerifyNumber
  2476. cFYLJG001.AuthNo = ""
  2477. }
  2478. cFYLJG001.BizTypeCode = "01"
  2479. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  2480. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  2481. cFYLJG001.RxTypeCode = "1"
  2482. tempTime := time.Unix(item.PreTime, 0)
  2483. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2484. cFYLJG001.PrscTime = timeFormatOne
  2485. var count float64
  2486. if item.Type == 1 {
  2487. for _, sumItem := range item.HisDoctorAdviceInfo {
  2488. count = count + sumItem.PrescribingNumber
  2489. }
  2490. }
  2491. cFYLJG001.RxDrugCnt = count
  2492. cFYLJG001.ValiDays = "5"
  2493. ts := time.Unix(item.PreTime, 0)
  2494. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  2495. tempTime3 := time.Unix(record_time2, 0)
  2496. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  2497. cFYLJG001.ValiEndTime = timeFormat3
  2498. cFYLJG001.RxCotnFlag = "0"
  2499. for _, subItem := range item.HisDoctorAdviceInfo {
  2500. var drug models.RxDrug
  2501. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2502. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2503. drug.RxItemTypeCode = "11"
  2504. drug.DrugDosform = "乳膏剂" //TODO
  2505. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  2506. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  2507. }
  2508. drug.MedcWayDscr = subItem.DeliveryWay
  2509. tempTime2 := time.Unix(subItem.StartTime, 0)
  2510. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2511. drug.MedcBegntime = timeFormatTwo
  2512. if subItem.Day > 0 {
  2513. ts := time.Unix(subItem.StartTime, 0)
  2514. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  2515. tempTime4 := time.Unix(record_time, 0)
  2516. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  2517. drug.MedcEndtime = timeFormat5
  2518. } else {
  2519. tempTime2 := time.Unix(subItem.StartTime, 0)
  2520. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2521. drug.MedcEndtime = timeFormatTwo
  2522. }
  2523. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  2524. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  2525. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  2526. drug.DrugCnt = subItem.PrescribingNumber
  2527. drug.DrugDosunt = subItem.PrescribingNumberUnit
  2528. drug.DrugGenname = subItem.AdviceName
  2529. drug.MedcWayCodg = subItem.DeliveryWay
  2530. //drug.DrugTotlcnt = subItem.PrescribingNumber
  2531. drug.SinDoscnt = subItem.SingleDose
  2532. drug.SinDosunt = subItem.SingleDoseUnit
  2533. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  2534. drug.UsedFrquName = subItem.ExecutionFrequency
  2535. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2536. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  2537. drug.HospApprFlag = "1"
  2538. cFYLJG001.List = append(cFYLJG001.List, drug)
  2539. }
  2540. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  2541. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  2542. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  2543. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  2544. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  2545. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  2546. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  2547. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  2548. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  2549. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  2550. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2551. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  2552. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  2553. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  2554. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2555. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  2556. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  2557. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  2558. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  2559. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  2560. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  2561. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  2562. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  2563. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  2564. tempTime2 := time.Now().Unix()
  2565. tempTime6 := time.Unix(tempTime2, 0)
  2566. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  2567. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  2568. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  2569. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  2570. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  2571. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  2572. //memo := make(map[string]interface{})
  2573. //inputData := make(map[string]interface{}, 0)
  2574. //type MyData struct {
  2575. // Insutype string `json:"insutype"`
  2576. //}
  2577. //
  2578. // data := MyData{
  2579. // Insutype: his.Insutype,
  2580. //}
  2581. //
  2582. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  2583. var config []*models.HisXtDiagnoseConfig
  2584. for _, item := range diagnosis_ids {
  2585. id, _ := strconv.ParseInt(item, 10, 64)
  2586. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2587. config = append(config, &diagnosisConfig)
  2588. }
  2589. for index, subitem := range config {
  2590. if index == 0 {
  2591. var dia models.DiseInfo
  2592. dia.DiagType = "1"
  2593. dia.MaindiagFlag = "1"
  2594. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2595. dia.DiagCode = subitem.CountryCode
  2596. dia.DiagName = subitem.ClassName
  2597. dia.DiagDept = "肾内科"
  2598. dia.DiagDrNo = doctor.DoctorNumber
  2599. dia.DiagDrName = doctor.UserName
  2600. tempTime3 := time.Unix(item.PreTime, 0)
  2601. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2602. dia.DiagTime = timeFormatTwo
  2603. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2604. } else {
  2605. var dia models.DiseInfo
  2606. dia.DiagType = "1"
  2607. dia.MaindiagFlag = "0"
  2608. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2609. dia.DiagCode = subitem.CountryCode
  2610. dia.DiagName = subitem.ClassName
  2611. dia.DiagDept = "肾内科"
  2612. dia.DiagDrNo = doctor.DoctorNumber
  2613. dia.DiagDrName = doctor.UserName
  2614. tempTime3 := time.Unix(item.PreTime, 0)
  2615. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2616. dia.DiagTime = timeFormatTwo
  2617. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2618. }
  2619. }
  2620. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  2621. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  2622. var res ResultCFYLJG001
  2623. var respJSON2 map[string]interface{}
  2624. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2627. return
  2628. }
  2629. userJSONBytes2, _ := json.Marshal(respJSON2)
  2630. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2631. utils.ErrorLog("解析失败:%v", err)
  2632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2633. return
  2634. }
  2635. if res.Infcode == -1 {
  2636. c.ServeSuccessJSON(map[string]interface{}{
  2637. "failed_code": -10,
  2638. "msg": res.ErrMsg,
  2639. })
  2640. return
  2641. } else {
  2642. var flow models.HisPrescriptionFlow
  2643. flow.Ctime = time.Now().Unix()
  2644. flow.SignDigest = ""
  2645. flow.RxTraceCode = res.Output.RxTraceCode
  2646. flow.HiRxno = res.Output.HiRxno
  2647. flow.MID = his.Number
  2648. flow.Status = 1
  2649. flow.DCode = doctor_info.DoctorNumber
  2650. flow.OriginalRxFile = ""
  2651. flow.OriginalValue = ""
  2652. flow.SignCertDn = ""
  2653. flow.UserOrgId = 10454
  2654. flow.SignCertSn = ""
  2655. flow.Mtime = time.Now().Unix()
  2656. service.Createflow(&flow)
  2657. c.ServeSuccessJSON(map[string]interface{}{
  2658. "msg": "上传成功",
  2659. })
  2660. }
  2661. }
  2662. }
  2663. func (c *HisApiController) GetCFYLJG002() {
  2664. admin_user_id, _ := c.GetInt64("admin_user_id")
  2665. his_patient_id, _ := c.GetInt64("his_patient_id")
  2666. record_time := c.GetString("record_time")
  2667. admin_user_id = 3626
  2668. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2669. //id, _ := c.GetInt64("id")
  2670. admin_user_id = 3626
  2671. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2672. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2673. flow, _ := service.Getflowtwo(his.Number)
  2674. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2675. //record_time := c.GetString("record_time")
  2676. patient_id, _ := c.GetInt64("patient_id")
  2677. //patient_id = 23834
  2678. //record_time = "2023-09-18"
  2679. timeLayout := "2006-01-02"
  2680. loc, _ := time.LoadLocation("Local")
  2681. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2682. if err != nil {
  2683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2684. return
  2685. }
  2686. recordDateTime := theTime.Unix()
  2687. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2688. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2689. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2690. dept, _ := service.GetDepartMentDetail(info.Departments)
  2691. inputData := make(map[string]interface{})
  2692. inputData["rxTraceCode"] = flow.RxTraceCode
  2693. inputData["hiRxno"] = flow.HiRxno
  2694. inputData["mdtrtId"] = flow.MID
  2695. inputData["patnName"] = his.PsnName
  2696. inputData["psnCertType"] = his.PsnCertType
  2697. inputData["certno"] = his.Certno
  2698. inputData["fixmedinsName"] = miConfig.OrgName
  2699. inputData["fixmedinsCode"] = miConfig.Code
  2700. inputData["drCode"] = doctor_info.DoctorNumber
  2701. inputData["prscDrName"] = doctor_info.UserName
  2702. inputData["pharDeptName"] = dept.Name
  2703. inputData["pharDeptCode"] = dept.Number
  2704. inputData["pharProfttlCodg"] = dept.Name
  2705. inputData["pharProfttlName"] = ""
  2706. inputData["pharCode"] = "HY440309002107"
  2707. inputData["pharCertType"] = "01"
  2708. inputData["pharCertno"] = "430482199408260023"
  2709. inputData["pharName"] = "彭斯遥"
  2710. inputData["pharPracCertNo"] = ""
  2711. tempTime2 := time.Unix(info.Ctime, 0)
  2712. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2713. inputData["pharChkTime"] = timeFormatTwo
  2714. bytesData, _ := json.Marshal(inputData)
  2715. fmt.Println(string(bytesData))
  2716. encoded := base64.StdEncoding.EncodeToString(bytesData)
  2717. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  2718. if err != nil {
  2719. fmt.Println("Error reading PDF file:", err)
  2720. return
  2721. }
  2722. // 将 PDF 文件内容进行 Base64 编码
  2723. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  2724. fmt.Println(err)
  2725. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  2726. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  2727. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  2728. var res2 Result002
  2729. var respJSON2 map[string]interface{}
  2730. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2733. return
  2734. }
  2735. userJSONBytes2, _ := json.Marshal(respJSON2)
  2736. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2737. utils.ErrorLog("解析失败:%v", err)
  2738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2739. return
  2740. }
  2741. if res2.Infcode == 0 {
  2742. flow.Ctime = time.Now().Unix()
  2743. flow.SignDigest = res2.Output.SignDigest
  2744. flow.RxFile = res2.Output.RxFile
  2745. flow.MID = his.Number
  2746. flow.Status = 1
  2747. flow.DCode = doctor_info.DoctorNumber
  2748. flow.OriginalRxFile = rx_encoded
  2749. flow.OriginalValue = encoded
  2750. flow.SignCertDn = res2.Output.SignCertDn
  2751. flow.SignCertSn = res2.Output.SignCertSn
  2752. flow.Mtime = time.Now().Unix()
  2753. service.Saveflow(flow)
  2754. c.ServeSuccessJSON(map[string]interface{}{
  2755. "msg": "预签名成功",
  2756. })
  2757. } else {
  2758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2759. return
  2760. }
  2761. }
  2762. func (c *HisApiController) GetCFYLJG003() {
  2763. admin_user_id, _ := c.GetInt64("admin_user_id")
  2764. his_patient_id, _ := c.GetInt64("his_patient_id")
  2765. record_time := c.GetString("record_time")
  2766. admin_user_id = 3626
  2767. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2768. //id, _ := c.GetInt64("id")
  2769. admin_user_id = 3626
  2770. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2771. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2772. flow, _ := service.Getflowtwo(his.Number)
  2773. //id = 3
  2774. patient_id, _ := c.GetInt64("patient_id")
  2775. //patient_id = 23834
  2776. //record_time = "2023-09-18"
  2777. timeLayout := "2006-01-02"
  2778. loc, _ := time.LoadLocation("Local")
  2779. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2780. if err != nil {
  2781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2782. return
  2783. }
  2784. recordDateTime := theTime.Unix()
  2785. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2786. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2787. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2788. dept, _ := service.GetDepartMentDetail(info.Departments)
  2789. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  2790. var cFYLJG003 models.CFYLJG003
  2791. cFYLJG003.RxTraceCode = flow.RxTraceCode
  2792. cFYLJG003.HiRxno = flow.HiRxno
  2793. cFYLJG003.MdtrtID = flow.MID
  2794. cFYLJG003.PatnName = his.Name
  2795. cFYLJG003.Certno = his.Certno
  2796. cFYLJG003.FixmedinsName = miConfig.OrgName
  2797. cFYLJG003.FixmedinsCode = miConfig.Code
  2798. cFYLJG003.DrCode = doctor_info.DoctorNumber
  2799. cFYLJG003.PrscDrName = doctor_info.UserName
  2800. cFYLJG003.PharDeptName = dept.Name
  2801. cFYLJG003.PharDeptCode = dept.Number
  2802. cFYLJG003.PharCode = "HY440309002107"
  2803. cFYLJG003.PharCertType = "01"
  2804. cFYLJG003.PharCertno = "430482199408260023"
  2805. cFYLJG003.PharName = "彭斯遥"
  2806. cFYLJG003.PsnCertType = "01"
  2807. cFYLJG003.RxFile = flow.RxFile
  2808. cFYLJG003.SignDigest = flow.SignDigest
  2809. cFYLJG003.FixmedinsCode = miConfig.Code
  2810. cFYLJG003.PsnCertType = "01"
  2811. cFYLJG003.PharProfttlCodg = dept.Name
  2812. //inputData["pharProfttlCodg"] =dept.Name
  2813. tempTime2 := time.Unix(info.Ctime, 0)
  2814. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2815. cFYLJG003.PharChkTime = timeFormatTwo
  2816. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  2817. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  2818. var res ResultCFYLJG003
  2819. var respJSON2 map[string]interface{}
  2820. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2823. return
  2824. }
  2825. userJSONBytes2, _ := json.Marshal(respJSON2)
  2826. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2827. utils.ErrorLog("解析失败:%v", err)
  2828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2829. return
  2830. }
  2831. if res.Infcode == -1 {
  2832. c.ServeSuccessJSON(map[string]interface{}{
  2833. "failed_code": -10,
  2834. "msg": res.ErrMsg,
  2835. })
  2836. return
  2837. } else {
  2838. c.ServeSuccessJSON(map[string]interface{}{
  2839. "info": res.Output,
  2840. })
  2841. }
  2842. }
  2843. func (c *HisApiController) GetCFYLJG004() {
  2844. admin_user_id, _ := c.GetInt64("admin_user_id")
  2845. his_patient_id, _ := c.GetInt64("his_patient_id")
  2846. record_time := c.GetString("record_time")
  2847. admin_user_id = 3626
  2848. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2849. //id, _ := c.GetInt64("id")
  2850. admin_user_id = 3626
  2851. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2852. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2853. flow, _ := service.Getflowtwo(his.Number)
  2854. //id = 3
  2855. patient_id, _ := c.GetInt64("patient_id")
  2856. //patient_id = 23834
  2857. //record_time = "2023-09-18"
  2858. timeLayout := "2006-01-02"
  2859. loc, _ := time.LoadLocation("Local")
  2860. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2861. if err != nil {
  2862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2863. return
  2864. }
  2865. recordDateTime := theTime.Unix()
  2866. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2867. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2868. var cFYLJG004 models.CFYLJG004
  2869. cFYLJG004.HiRxno = flow.HiRxno
  2870. cFYLJG004.FixmedinsCode = miConfig.Code
  2871. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  2872. cFYLJG004.UndoDrCertType = "01"
  2873. cFYLJG004.UndoRea = "撤销处方"
  2874. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  2875. cFYLJG004.UndoDrName = doctor_info.UserName
  2876. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  2877. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  2878. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  2879. var res ResultCFYLJG004
  2880. var respJSON2 map[string]interface{}
  2881. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2884. return
  2885. }
  2886. userJSONBytes2, _ := json.Marshal(respJSON2)
  2887. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2888. utils.ErrorLog("解析失败:%v", err)
  2889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2890. return
  2891. }
  2892. if res.Infcode == -1 {
  2893. c.ServeSuccessJSON(map[string]interface{}{
  2894. "failed_code": -10,
  2895. "msg": res.ErrMsg,
  2896. })
  2897. return
  2898. } else {
  2899. flow.Status = 0
  2900. service.Saveflow(flow)
  2901. c.ServeSuccessJSON(map[string]interface{}{
  2902. "msg": "撤销成功",
  2903. })
  2904. return
  2905. }
  2906. }
  2907. func (c *HisApiController) GetCFYLJG005() {
  2908. admin_user_id, _ := c.GetInt64("admin_user_id")
  2909. his_patient_id, _ := c.GetInt64("his_patient_id")
  2910. //record_time := c.GetString("record_time")
  2911. admin_user_id = 3626
  2912. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2913. //id, _ := c.GetInt64("id")
  2914. admin_user_id = 3626
  2915. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2916. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2917. flow, _ := service.Getflowtwo(his.Number)
  2918. //id = 3
  2919. var cFYLJG005 models.CFYLJG005
  2920. //patient_id, _ := c.GetInt64("patient_id")
  2921. cFYLJG005.HiRxno = flow.HiRxno
  2922. cFYLJG005.MdtrtID = flow.MID
  2923. cFYLJG005.EcToken = ""
  2924. cFYLJG005.PsnName = his.Name
  2925. cFYLJG005.PsnCertType = "01"
  2926. cFYLJG005.Certno = his.IdCardNo
  2927. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  2928. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  2929. var res ResultCFYLJG005
  2930. var respJSON2 map[string]interface{}
  2931. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2934. return
  2935. }
  2936. userJSONBytes2, _ := json.Marshal(respJSON2)
  2937. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2938. utils.ErrorLog("解析失败:%v", err)
  2939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2940. return
  2941. }
  2942. if res.Infcode == -1 {
  2943. c.ServeSuccessJSON(map[string]interface{}{
  2944. "failed_code": -10,
  2945. "msg": res.ErrMsg,
  2946. })
  2947. return
  2948. } else {
  2949. c.ServeSuccessJSON(map[string]interface{}{
  2950. "info": res.Output,
  2951. })
  2952. return
  2953. }
  2954. }
  2955. func (c *HisApiController) GetCFYLJG006() {
  2956. admin_user_id, _ := c.GetInt64("admin_user_id")
  2957. his_patient_id, _ := c.GetInt64("his_patient_id")
  2958. admin_user_id = 3626
  2959. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2960. //id, _ := c.GetInt64("id")
  2961. admin_user_id = 3626
  2962. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2963. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2964. flow, _ := service.Getflowtwo(his.Number)
  2965. //id = 3
  2966. patient_id, _ := c.GetInt64("patient_id")
  2967. var cFYLJG006 models.CFYLJG006
  2968. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  2969. cFYLJG006.HiRxno = flow.HiRxno
  2970. cFYLJG006.MdtrtID = flow.MID
  2971. cFYLJG006.PsnName = patient.Name
  2972. cFYLJG006.PsnCertType = "01"
  2973. cFYLJG006.Certno = patient.IdCardNo
  2974. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  2975. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  2976. var res ResultCFYLJG006
  2977. var respJSON2 map[string]interface{}
  2978. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2981. return
  2982. }
  2983. userJSONBytes2, _ := json.Marshal(respJSON2)
  2984. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2985. utils.ErrorLog("解析失败:%v", err)
  2986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2987. return
  2988. }
  2989. if res.Infcode == -1 {
  2990. c.ServeSuccessJSON(map[string]interface{}{
  2991. "failed_code": -10,
  2992. "msg": res.ErrMsg,
  2993. })
  2994. return
  2995. } else {
  2996. c.ServeSuccessJSON(map[string]interface{}{
  2997. "info": res.Output,
  2998. })
  2999. return
  3000. }
  3001. }
  3002. func (c *HisApiController) GetCFYLJG007() {
  3003. admin_user_id, _ := c.GetInt64("admin_user_id")
  3004. his_patient_id, _ := c.GetInt64("his_patient_id")
  3005. admin_user_id = 3626
  3006. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3007. //id, _ := c.GetInt64("id")
  3008. admin_user_id = 3626
  3009. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3010. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3011. flow, _ := service.Getflowtwo(his.Number)
  3012. //id = 3
  3013. patient_id, _ := c.GetInt64("patient_id")
  3014. var cFYLJG007 models.CFYLJG007
  3015. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3016. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3017. cFYLJG007.HiRxno = flow.HiRxno
  3018. cFYLJG007.MdtrtID = flow.MID
  3019. cFYLJG007.PsnNo = his.PsnNo
  3020. cFYLJG007.PsnCertType = "01"
  3021. cFYLJG007.Certno = patient.IdCardNo
  3022. cFYLJG007.PsnName = patient.Name
  3023. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  3024. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  3025. var res ResultCFYLJG007
  3026. var respJSON2 map[string]interface{}
  3027. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3030. return
  3031. }
  3032. userJSONBytes2, _ := json.Marshal(respJSON2)
  3033. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3034. utils.ErrorLog("解析失败:%v", err)
  3035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3036. return
  3037. }
  3038. if res.Infcode == -1 {
  3039. c.ServeSuccessJSON(map[string]interface{}{
  3040. "failed_code": -10,
  3041. "msg": res.ErrMsg,
  3042. })
  3043. return
  3044. } else {
  3045. c.ServeSuccessJSON(map[string]interface{}{
  3046. "info": res,
  3047. })
  3048. return
  3049. }
  3050. }
  3051. func (c *HisApiController) GetCFYLJG008() {
  3052. admin_user_id, _ := c.GetInt64("admin_user_id")
  3053. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3054. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3055. var cFYLJG008 models.CFYLJG008
  3056. //id, _ := c.GetInt64("id")
  3057. patient_id, _ := c.GetInt64("patient_id")
  3058. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3059. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3060. //id = 3
  3061. //flow, _ := service.Getflow(id)
  3062. //his, _ := service.GetHisPatientByNumber(flow.MID)
  3063. //
  3064. //admin_user_id, _ := c.GetInt64("admin_user_id")
  3065. //patient_id, _ := c.GetInt64("patient_id")
  3066. //his_patient_id, _ := c.GetInt64("his_patient_id")
  3067. record_time := c.GetString("record_time")
  3068. admin_user_id = 3626
  3069. patient_id = 19424
  3070. //his_patient_id = 263947
  3071. record_time = "2023-08-29"
  3072. timeLayout := "2006-01-02"
  3073. loc, _ := time.LoadLocation("Local")
  3074. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3075. if err != nil {
  3076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3077. return
  3078. }
  3079. recordDateTime := theTime.Unix()
  3080. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3081. cFYLJG008.FixmedinsName = ""
  3082. cFYLJG008.Lat = ""
  3083. cFYLJG008.Lng = ""
  3084. cFYLJG008.OrderType = "1"
  3085. cFYLJG008.PoolareaNo = ""
  3086. cFYLJG008.Lng = ""
  3087. cFYLJG008.PageNum = 1
  3088. cFYLJG008.PageSize = 10
  3089. var MPI models.MedinsProdInvChgDDTO
  3090. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  3091. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  3092. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  3093. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  3094. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  3095. var res ResultCFYLJG008
  3096. var respJSON2 map[string]interface{}
  3097. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3100. return
  3101. }
  3102. userJSONBytes2, _ := json.Marshal(respJSON2)
  3103. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3104. utils.ErrorLog("解析失败:%v", err)
  3105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3106. return
  3107. }
  3108. if res.Infcode == -1 {
  3109. c.ServeSuccessJSON(map[string]interface{}{
  3110. "failed_code": -10,
  3111. "msg": res.ErrMsg,
  3112. })
  3113. return
  3114. } else {
  3115. c.ServeSuccessJSON(map[string]interface{}{
  3116. "info": res.Output,
  3117. })
  3118. return
  3119. }
  3120. }
  3121. func (c *HisApiController) GetBL4201A() {
  3122. order_id, _ := c.GetInt64("order_id")
  3123. admin_user_id, _ := c.GetInt64("admin_user_id")
  3124. order, _ := service.GetHisOrderByIDTwo(order_id)
  3125. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3126. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3127. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3128. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3129. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3130. department, _ := service.GetDepartMentDetail(his.Departments)
  3131. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3132. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3133. if order.ID == 0 {
  3134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3135. return
  3136. }
  3137. var struct4201A models.Struct4201A
  3138. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3139. for _, items := range order_info {
  3140. memo := make(map[string]interface{})
  3141. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3142. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3143. fsiOPFLD.MedType = "14"
  3144. fsiOPFLD.BkkpSn = items.FeedetlSn
  3145. fsiOPFLD.FixmedinsCode = miConfig.Code
  3146. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3147. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3148. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3149. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3150. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3151. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3152. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3153. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3154. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3155. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3156. fsiOPFLD.BilgDeptName = department.Name
  3157. fsiOPFLD.BilgDeptCodg = department.Number
  3158. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3159. fsiOPFLD.BilgDrName = doctor.UserName
  3160. fsiOPFLD.MedChrgitmType = "09"
  3161. memo["hosp_appr_flag"] = "1"
  3162. memo["invoice_no"] = order.MdtrtId
  3163. memo["memo"] = "自费"
  3164. bytesData, _ := json.Marshal(memo)
  3165. fsiOPFLD.Memo = string(bytesData)
  3166. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3167. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3168. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3169. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3170. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3171. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3172. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3173. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3174. fsiOPFLD.BilgDeptName = department.Name
  3175. fsiOPFLD.BilgDeptCodg = department.Number
  3176. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3177. fsiOPFLD.BilgDrName = doctor.UserName
  3178. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3179. case 0:
  3180. break
  3181. case 1:
  3182. fsiOPFLD.MedChrgitmType = "14"
  3183. break
  3184. case 2:
  3185. fsiOPFLD.MedChrgitmType = "05"
  3186. break
  3187. case 3:
  3188. fsiOPFLD.MedChrgitmType = "03"
  3189. break
  3190. case 4:
  3191. fsiOPFLD.MedChrgitmType = "03"
  3192. break
  3193. case 5:
  3194. fsiOPFLD.MedChrgitmType = "08"
  3195. break
  3196. case 6:
  3197. fsiOPFLD.MedChrgitmType = "14"
  3198. break
  3199. case 7:
  3200. fsiOPFLD.MedChrgitmType = "14"
  3201. break
  3202. case 8:
  3203. fsiOPFLD.MedChrgitmType = "03"
  3204. break
  3205. case 9:
  3206. fsiOPFLD.MedChrgitmType = "14"
  3207. break
  3208. case 10:
  3209. fsiOPFLD.MedChrgitmType = "14"
  3210. break
  3211. case 11:
  3212. fsiOPFLD.MedChrgitmType = "06"
  3213. break
  3214. case 12:
  3215. fsiOPFLD.MedChrgitmType = "12"
  3216. break
  3217. case 13:
  3218. fsiOPFLD.MedChrgitmType = "01"
  3219. break
  3220. case 14:
  3221. fsiOPFLD.MedChrgitmType = "04"
  3222. break
  3223. case 15:
  3224. fsiOPFLD.MedChrgitmType = "14"
  3225. break
  3226. }
  3227. memo["hosp_appr_flag"] = "1"
  3228. memo["invoice_no"] = order.MdtrtId
  3229. memo["memo"] = "自费"
  3230. bytesData, _ := json.Marshal(memo)
  3231. fsiOPFLD.Memo = string(bytesData)
  3232. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3233. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3234. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3235. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3236. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3237. fsiOPFLD.BilgDeptName = department.Name
  3238. fsiOPFLD.BilgDeptCodg = department.Number
  3239. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3240. fsiOPFLD.BilgDrName = doctor.UserName
  3241. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3242. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3243. fsiOPFLD.MedChrgitmType = "08"
  3244. memo["hosp_appr_flag"] = "1"
  3245. memo["invoice_no"] = order.MdtrtId
  3246. memo["memo"] = "自费"
  3247. bytesData, _ := json.Marshal(memo)
  3248. fsiOPFLD.Memo = string(bytesData)
  3249. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3250. }
  3251. }
  3252. }
  3253. for _, items := range order_info_two {
  3254. memo := make(map[string]interface{})
  3255. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3256. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3257. fsiOPFLD.MedType = "14"
  3258. fsiOPFLD.BkkpSn = items.FeedetlSn
  3259. fsiOPFLD.FixmedinsCode = miConfig.Code
  3260. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3261. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3262. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3263. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3264. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3265. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3266. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3267. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3268. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3269. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3270. fsiOPFLD.BilgDeptName = department.Name
  3271. fsiOPFLD.BilgDeptCodg = department.Number
  3272. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3273. fsiOPFLD.BilgDrName = doctor.UserName
  3274. fsiOPFLD.MedChrgitmType = "09"
  3275. memo["hosp_appr_flag"] = "1"
  3276. memo["invoice_no"] = order.MdtrtId
  3277. memo["memo"] = "自费"
  3278. bytesData, _ := json.Marshal(memo)
  3279. fsiOPFLD.Memo = string(bytesData)
  3280. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3281. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3282. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3283. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3284. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3285. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3286. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3287. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3288. fsiOPFLD.BilgDeptName = department.Name
  3289. fsiOPFLD.BilgDeptCodg = department.Number
  3290. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3291. fsiOPFLD.BilgDrName = doctor.UserName
  3292. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3293. case 0:
  3294. break
  3295. case 1:
  3296. fsiOPFLD.MedChrgitmType = "14"
  3297. break
  3298. case 2:
  3299. fsiOPFLD.MedChrgitmType = "05"
  3300. break
  3301. case 3:
  3302. fsiOPFLD.MedChrgitmType = "03"
  3303. break
  3304. case 4:
  3305. fsiOPFLD.MedChrgitmType = "03"
  3306. break
  3307. case 5:
  3308. fsiOPFLD.MedChrgitmType = "08"
  3309. break
  3310. case 6:
  3311. fsiOPFLD.MedChrgitmType = "14"
  3312. break
  3313. case 7:
  3314. fsiOPFLD.MedChrgitmType = "14"
  3315. break
  3316. case 8:
  3317. fsiOPFLD.MedChrgitmType = "03"
  3318. break
  3319. case 9:
  3320. fsiOPFLD.MedChrgitmType = "14"
  3321. break
  3322. case 10:
  3323. fsiOPFLD.MedChrgitmType = "14"
  3324. break
  3325. case 11:
  3326. fsiOPFLD.MedChrgitmType = "06"
  3327. break
  3328. case 12:
  3329. fsiOPFLD.MedChrgitmType = "12"
  3330. break
  3331. case 13:
  3332. fsiOPFLD.MedChrgitmType = "01"
  3333. break
  3334. case 14:
  3335. fsiOPFLD.MedChrgitmType = "04"
  3336. break
  3337. case 15:
  3338. fsiOPFLD.MedChrgitmType = "14"
  3339. break
  3340. }
  3341. memo["hosp_appr_flag"] = "1"
  3342. memo["invoice_no"] = order.MdtrtId
  3343. memo["memo"] = "自费"
  3344. bytesData, _ := json.Marshal(memo)
  3345. fsiOPFLD.Memo = string(bytesData)
  3346. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3347. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3348. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3349. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3350. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3351. fsiOPFLD.BilgDeptName = department.Name
  3352. fsiOPFLD.BilgDeptCodg = department.Number
  3353. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3354. fsiOPFLD.BilgDrName = doctor.UserName
  3355. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3356. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3357. fsiOPFLD.MedChrgitmType = "08"
  3358. memo["hosp_appr_flag"] = "1"
  3359. memo["invoice_no"] = order.MdtrtId
  3360. memo["memo"] = "自费"
  3361. bytesData, _ := json.Marshal(memo)
  3362. fsiOPFLD.Memo = string(bytesData)
  3363. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3364. }
  3365. }
  3366. }
  3367. fmt.Println(fsiOPFLDs)
  3368. struct4201A.Fopfd = fsiOPFLDs
  3369. fmt.Println(struct4201A.Fopfd)
  3370. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3371. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3372. var res2 ResultSix
  3373. var respJSON2 map[string]interface{}
  3374. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3377. return
  3378. }
  3379. userJSONBytes2, _ := json.Marshal(respJSON2)
  3380. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3381. utils.ErrorLog("解析失败:%v", err)
  3382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3383. return
  3384. }
  3385. if res2.Infcode != 0 {
  3386. c.ServeSuccessJSON(map[string]interface{}{
  3387. "failed_code": -10,
  3388. "msg": res2.ErrMsg,
  3389. })
  3390. return
  3391. } else {
  3392. order.IsUploadOrderInfo = 1
  3393. service.UpdateOrder(order)
  3394. c.ServeSuccessJSON(map[string]interface{}{
  3395. "msg": "上传成功",
  3396. })
  3397. }
  3398. }
  3399. func (c *HisApiController) Get2505() {
  3400. admin_user_id, _ := c.GetInt64("admin_user_id")
  3401. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  3402. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3403. 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)
  3404. }
  3405. func (c *HisApiController) Get4201A() {
  3406. order_id, _ := c.GetInt64("order_id")
  3407. admin_user_id, _ := c.GetInt64("admin_user_id")
  3408. order, _ := service.GetHisOrderByIDTwo(order_id)
  3409. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3410. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3411. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3412. //order_info = append(order_info, order_info_two...)
  3413. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3414. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3415. department, _ := service.GetDepartMentDetail(his.Departments)
  3416. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3417. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3418. if order.ID == 0 {
  3419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3420. return
  3421. }
  3422. var struct4201A models.Struct4201A
  3423. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3424. for _, items := range order_info {
  3425. memo := make(map[string]interface{})
  3426. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3427. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3428. fsiOPFLD.MedType = "14"
  3429. fsiOPFLD.BkkpSn = items.FeedetlSn
  3430. fsiOPFLD.FixmedinsCode = miConfig.Code
  3431. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3432. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3433. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3434. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3435. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3436. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3437. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3438. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3439. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3440. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3441. fsiOPFLD.BilgDeptName = department.Name
  3442. fsiOPFLD.BilgDeptCodg = department.Number
  3443. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3444. fsiOPFLD.BilgDrName = doctor.UserName
  3445. fsiOPFLD.MedChrgitmType = "09"
  3446. memo["hosp_appr_flag"] = "1"
  3447. memo["invoice_no"] = order.MdtrtId
  3448. memo["memo"] = "自费"
  3449. bytesData, _ := json.Marshal(memo)
  3450. fsiOPFLD.Memo = string(bytesData)
  3451. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3452. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3453. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3454. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3455. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3456. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3457. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3458. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3459. fsiOPFLD.BilgDeptName = department.Name
  3460. fsiOPFLD.BilgDeptCodg = department.Number
  3461. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3462. fsiOPFLD.BilgDrName = doctor.UserName
  3463. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3464. case 0:
  3465. break
  3466. case 1:
  3467. fsiOPFLD.MedChrgitmType = "14"
  3468. break
  3469. case 2:
  3470. fsiOPFLD.MedChrgitmType = "05"
  3471. break
  3472. case 3:
  3473. fsiOPFLD.MedChrgitmType = "03"
  3474. break
  3475. case 4:
  3476. fsiOPFLD.MedChrgitmType = "03"
  3477. break
  3478. case 5:
  3479. fsiOPFLD.MedChrgitmType = "08"
  3480. break
  3481. case 6:
  3482. fsiOPFLD.MedChrgitmType = "14"
  3483. break
  3484. case 7:
  3485. fsiOPFLD.MedChrgitmType = "14"
  3486. break
  3487. case 8:
  3488. fsiOPFLD.MedChrgitmType = "03"
  3489. break
  3490. case 9:
  3491. fsiOPFLD.MedChrgitmType = "14"
  3492. break
  3493. case 10:
  3494. fsiOPFLD.MedChrgitmType = "14"
  3495. break
  3496. case 11:
  3497. fsiOPFLD.MedChrgitmType = "06"
  3498. break
  3499. case 12:
  3500. fsiOPFLD.MedChrgitmType = "12"
  3501. break
  3502. case 13:
  3503. fsiOPFLD.MedChrgitmType = "01"
  3504. break
  3505. case 14:
  3506. fsiOPFLD.MedChrgitmType = "04"
  3507. break
  3508. case 15:
  3509. fsiOPFLD.MedChrgitmType = "14"
  3510. break
  3511. }
  3512. memo["hosp_appr_flag"] = "1"
  3513. memo["invoice_no"] = order.MdtrtId
  3514. memo["memo"] = "自费"
  3515. bytesData, _ := json.Marshal(memo)
  3516. fsiOPFLD.Memo = string(bytesData)
  3517. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3518. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3519. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3520. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3521. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3522. fsiOPFLD.BilgDeptName = department.Name
  3523. fsiOPFLD.BilgDeptCodg = department.Number
  3524. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3525. fsiOPFLD.BilgDrName = doctor.UserName
  3526. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3527. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3528. fsiOPFLD.MedChrgitmType = "08"
  3529. memo["hosp_appr_flag"] = "1"
  3530. memo["invoice_no"] = order.MdtrtId
  3531. memo["memo"] = "自费"
  3532. bytesData, _ := json.Marshal(memo)
  3533. fsiOPFLD.Memo = string(bytesData)
  3534. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3535. }
  3536. }
  3537. }
  3538. for _, items := range order_info_two {
  3539. memo := make(map[string]interface{})
  3540. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3541. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3542. fsiOPFLD.MedType = "14"
  3543. fsiOPFLD.BkkpSn = items.FeedetlSn
  3544. fsiOPFLD.FixmedinsCode = miConfig.Code
  3545. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3546. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3547. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3548. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3549. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3550. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3551. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3552. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3553. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3554. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3555. fsiOPFLD.BilgDeptName = department.Name
  3556. fsiOPFLD.BilgDeptCodg = department.Number
  3557. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3558. fsiOPFLD.BilgDrName = doctor.UserName
  3559. fsiOPFLD.MedChrgitmType = "09"
  3560. memo["hosp_appr_flag"] = "1"
  3561. memo["invoice_no"] = order.MdtrtId
  3562. memo["memo"] = "自费"
  3563. bytesData, _ := json.Marshal(memo)
  3564. fsiOPFLD.Memo = string(bytesData)
  3565. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3566. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3567. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3568. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3569. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3570. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3571. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3572. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3573. fsiOPFLD.BilgDeptName = department.Name
  3574. fsiOPFLD.BilgDeptCodg = department.Number
  3575. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3576. fsiOPFLD.BilgDrName = doctor.UserName
  3577. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3578. case 0:
  3579. break
  3580. case 1:
  3581. fsiOPFLD.MedChrgitmType = "14"
  3582. break
  3583. case 2:
  3584. fsiOPFLD.MedChrgitmType = "05"
  3585. break
  3586. case 3:
  3587. fsiOPFLD.MedChrgitmType = "03"
  3588. break
  3589. case 4:
  3590. fsiOPFLD.MedChrgitmType = "03"
  3591. break
  3592. case 5:
  3593. fsiOPFLD.MedChrgitmType = "08"
  3594. break
  3595. case 6:
  3596. fsiOPFLD.MedChrgitmType = "14"
  3597. break
  3598. case 7:
  3599. fsiOPFLD.MedChrgitmType = "14"
  3600. break
  3601. case 8:
  3602. fsiOPFLD.MedChrgitmType = "03"
  3603. break
  3604. case 9:
  3605. fsiOPFLD.MedChrgitmType = "14"
  3606. break
  3607. case 10:
  3608. fsiOPFLD.MedChrgitmType = "14"
  3609. break
  3610. case 11:
  3611. fsiOPFLD.MedChrgitmType = "06"
  3612. break
  3613. case 12:
  3614. fsiOPFLD.MedChrgitmType = "12"
  3615. break
  3616. case 13:
  3617. fsiOPFLD.MedChrgitmType = "01"
  3618. break
  3619. case 14:
  3620. fsiOPFLD.MedChrgitmType = "04"
  3621. break
  3622. case 15:
  3623. fsiOPFLD.MedChrgitmType = "14"
  3624. break
  3625. }
  3626. memo["hosp_appr_flag"] = "1"
  3627. memo["invoice_no"] = order.MdtrtId
  3628. memo["memo"] = "自费"
  3629. bytesData, _ := json.Marshal(memo)
  3630. fsiOPFLD.Memo = string(bytesData)
  3631. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3632. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3633. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3634. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3635. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3636. fsiOPFLD.BilgDeptName = department.Name
  3637. fsiOPFLD.BilgDeptCodg = department.Number
  3638. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3639. fsiOPFLD.BilgDrName = doctor.UserName
  3640. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3641. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3642. fsiOPFLD.MedChrgitmType = "08"
  3643. memo["hosp_appr_flag"] = "1"
  3644. memo["invoice_no"] = order.MdtrtId
  3645. memo["memo"] = "自费"
  3646. bytesData, _ := json.Marshal(memo)
  3647. fsiOPFLD.Memo = string(bytesData)
  3648. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3649. }
  3650. }
  3651. }
  3652. fmt.Println(fsiOPFLDs)
  3653. struct4201A.Fopfd = fsiOPFLDs
  3654. fmt.Println(struct4201A.Fopfd)
  3655. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3656. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3657. var res2 ResultSix
  3658. var respJSON2 map[string]interface{}
  3659. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3662. return
  3663. }
  3664. userJSONBytes2, _ := json.Marshal(respJSON2)
  3665. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3666. utils.ErrorLog("解析失败:%v", err)
  3667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3668. return
  3669. }
  3670. if res2.Infcode != 0 {
  3671. c.ServeSuccessJSON(map[string]interface{}{
  3672. "failed_code": -10,
  3673. "msg": res2.ErrMsg,
  3674. })
  3675. return
  3676. } else {
  3677. order.IsUploadOrderInfo = 1
  3678. service.UpdateOrder(order)
  3679. c.ServeSuccessJSON(map[string]interface{}{
  3680. "msg": "上传成功",
  3681. })
  3682. }
  3683. }
  3684. func (c *HisApiController) Get4202() {
  3685. order_id, _ := c.GetInt64("order_id")
  3686. admin_user_id, _ := c.GetInt64("admin_user_id")
  3687. order, _ := service.GetHisOrderByIDTwo(order_id)
  3688. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3689. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3690. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3691. if order.ID == 0 {
  3692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3693. return
  3694. }
  3695. var struct4202 models.Struct4202
  3696. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  3697. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  3698. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  3699. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  3700. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  3701. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  3702. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  3703. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  3704. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  3705. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3706. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3707. var config []*models.HisXtDiagnoseConfig
  3708. for _, item := range diagnosis_ids {
  3709. id, _ := strconv.ParseInt(item, 10, 64)
  3710. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3711. config = append(config, &diagnosisConfig)
  3712. }
  3713. var tempDiaginfos []models.OwnPayPatnDiagListD
  3714. for index, item := range config {
  3715. if index == 0 {
  3716. var tempDiaginfo models.OwnPayPatnDiagListD
  3717. tempDiaginfo.InoutDiagType = "1"
  3718. tempDiaginfo.DiagCode = item.CountryCode
  3719. tempDiaginfo.DiagName = item.CountryContentName
  3720. tempDiaginfo.DiagType = "1"
  3721. tempDiaginfo.DiagSrtNo = "1"
  3722. tempDiaginfo.MaindiagFlag = "1"
  3723. tempDiaginfo.ValiFlag = "1"
  3724. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3725. } else {
  3726. var tempDiaginfo models.OwnPayPatnDiagListD
  3727. tempDiaginfo.DiagCode = item.CountryCode
  3728. tempDiaginfo.DiagName = item.CountryContentName
  3729. tempDiaginfo.DiagType = "2"
  3730. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3731. tempDiaginfo.MaindiagFlag = "0"
  3732. tempDiaginfo.ValiFlag = "1"
  3733. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3734. }
  3735. }
  3736. struct4202.ODiagListD = tempDiaginfos
  3737. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  3738. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  3739. var res2 ResultSix
  3740. var respJSON2 map[string]interface{}
  3741. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3744. return
  3745. }
  3746. userJSONBytes2, _ := json.Marshal(respJSON2)
  3747. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3748. utils.ErrorLog("解析失败:%v", err)
  3749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3750. return
  3751. }
  3752. if res2.Infcode != 0 {
  3753. c.ServeSuccessJSON(map[string]interface{}{
  3754. "failed_code": -10,
  3755. "msg": res2.ErrMsg,
  3756. })
  3757. return
  3758. } else {
  3759. order.IsUploadDiagnose = 1
  3760. service.UpdateOrder(order)
  3761. c.ServeSuccessJSON(map[string]interface{}{
  3762. "msg": "上传成功",
  3763. })
  3764. }
  3765. }
  3766. func (c *HisApiController) Get4203() {
  3767. admin_user_id, _ := c.GetInt64("admin_user_id")
  3768. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3769. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3770. order_id, _ := c.GetInt64("order_id")
  3771. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3772. number := ""
  3773. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3774. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3775. if his.ID == 0 {
  3776. number = hospital.Number
  3777. } else {
  3778. number = his.Number
  3779. }
  3780. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  3781. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  3782. var res2 ResultSix
  3783. var respJSON2 map[string]interface{}
  3784. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3787. return
  3788. }
  3789. userJSONBytes2, _ := json.Marshal(respJSON2)
  3790. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3791. utils.ErrorLog("解析失败:%v", err)
  3792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3793. return
  3794. }
  3795. if res2.Infcode != 0 {
  3796. c.ServeSuccessJSON(map[string]interface{}{
  3797. "failed_code": -10,
  3798. "msg": res2.ErrMsg,
  3799. })
  3800. return
  3801. } else {
  3802. order.IsUploadSuccess = 1
  3803. service.UpdateOrderTwo(order)
  3804. c.ServeSuccessJSON(map[string]interface{}{
  3805. "msg": "上传成功",
  3806. })
  3807. }
  3808. }
  3809. func (c *HisApiController) Get4205() {
  3810. order_id, _ := c.GetInt64("order_id")
  3811. admin_user_id, _ := c.GetInt64("admin_user_id")
  3812. fapiao_code := c.GetString("fapiao_code")
  3813. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3814. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3815. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3816. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3817. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  3818. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  3819. //order_info = append(order_info, order_info_two...)
  3820. department, _ := service.GetDepartMentDetail(his.Departments)
  3821. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3822. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3823. if order.ID == 0 {
  3824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3825. return
  3826. }
  3827. var struct4201A models.Struct4201A
  3828. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3829. for _, items := range order_info {
  3830. memo := make(map[string]interface{})
  3831. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3832. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3833. fsiOPFLD.MedType = pre.MedType
  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.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  3843. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3844. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3845. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3846. fsiOPFLD.BilgDeptName = department.Name
  3847. fsiOPFLD.BilgDeptCodg = department.Number
  3848. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3849. fsiOPFLD.BilgDrName = doctor.UserName
  3850. fsiOPFLD.MedChrgitmType = "09"
  3851. memo["hosp_appr_flag"] = "1"
  3852. memo["invoice_no"] = fapiao_code
  3853. memo["memo"] = "自费"
  3854. bytesData, _ := json.Marshal(memo)
  3855. fsiOPFLD.Memo = string(bytesData)
  3856. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3857. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3858. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  3859. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3860. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3861. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3862. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3863. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3864. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3865. fsiOPFLD.BilgDeptName = department.Name
  3866. fsiOPFLD.BilgDeptCodg = department.Number
  3867. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3868. fsiOPFLD.BilgDrName = doctor.UserName
  3869. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3870. case 0:
  3871. break
  3872. case 1:
  3873. fsiOPFLD.MedChrgitmType = "14"
  3874. break
  3875. case 2:
  3876. fsiOPFLD.MedChrgitmType = "05"
  3877. break
  3878. case 3:
  3879. fsiOPFLD.MedChrgitmType = "03"
  3880. break
  3881. case 4:
  3882. fsiOPFLD.MedChrgitmType = "03"
  3883. break
  3884. case 5:
  3885. fsiOPFLD.MedChrgitmType = "08"
  3886. break
  3887. case 6:
  3888. fsiOPFLD.MedChrgitmType = "14"
  3889. break
  3890. case 7:
  3891. fsiOPFLD.MedChrgitmType = "14"
  3892. break
  3893. case 8:
  3894. fsiOPFLD.MedChrgitmType = "03"
  3895. break
  3896. case 9:
  3897. fsiOPFLD.MedChrgitmType = "14"
  3898. break
  3899. case 10:
  3900. fsiOPFLD.MedChrgitmType = "14"
  3901. break
  3902. case 11:
  3903. fsiOPFLD.MedChrgitmType = "06"
  3904. break
  3905. case 12:
  3906. fsiOPFLD.MedChrgitmType = "12"
  3907. break
  3908. case 13:
  3909. fsiOPFLD.MedChrgitmType = "01"
  3910. break
  3911. case 14:
  3912. fsiOPFLD.MedChrgitmType = "04"
  3913. break
  3914. case 15:
  3915. fsiOPFLD.MedChrgitmType = "14"
  3916. break
  3917. }
  3918. memo["hosp_appr_flag"] = "1"
  3919. memo["invoice_no"] = fapiao_code
  3920. memo["memo"] = "自费"
  3921. bytesData, _ := json.Marshal(memo)
  3922. fsiOPFLD.Memo = string(bytesData)
  3923. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3924. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3925. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3926. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3927. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3928. fsiOPFLD.BilgDeptName = department.Name
  3929. fsiOPFLD.BilgDeptCodg = department.Number
  3930. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3931. fsiOPFLD.BilgDrName = doctor.UserName
  3932. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3933. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3934. fsiOPFLD.MedChrgitmType = "08"
  3935. memo["hosp_appr_flag"] = "1"
  3936. memo["invoice_no"] = fapiao_code
  3937. memo["memo"] = "自费"
  3938. bytesData, _ := json.Marshal(memo)
  3939. fsiOPFLD.Memo = string(bytesData)
  3940. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3941. }
  3942. }
  3943. }
  3944. for _, items := range order_info_two {
  3945. memo := make(map[string]interface{})
  3946. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3947. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3948. fsiOPFLD.MedType = pre.MedType
  3949. fsiOPFLD.BkkpSn = items.FeedetlSn
  3950. fsiOPFLD.FixmedinsCode = miConfig.Code
  3951. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3952. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3953. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3954. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3955. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3956. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3957. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3958. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3959. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3960. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3961. fsiOPFLD.BilgDeptName = department.Name
  3962. fsiOPFLD.BilgDeptCodg = department.Number
  3963. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3964. fsiOPFLD.BilgDrName = doctor.UserName
  3965. fsiOPFLD.MedChrgitmType = "09"
  3966. memo["hosp_appr_flag"] = "1"
  3967. memo["invoice_no"] = fapiao_code
  3968. memo["memo"] = "自费"
  3969. bytesData, _ := json.Marshal(memo)
  3970. fsiOPFLD.Memo = string(bytesData)
  3971. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3972. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3973. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  3974. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3975. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3976. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3977. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3978. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3979. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3980. fsiOPFLD.BilgDeptName = department.Name
  3981. fsiOPFLD.BilgDeptCodg = department.Number
  3982. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3983. fsiOPFLD.BilgDrName = doctor.UserName
  3984. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3985. case 0:
  3986. break
  3987. case 1:
  3988. fsiOPFLD.MedChrgitmType = "14"
  3989. break
  3990. case 2:
  3991. fsiOPFLD.MedChrgitmType = "05"
  3992. break
  3993. case 3:
  3994. fsiOPFLD.MedChrgitmType = "03"
  3995. break
  3996. case 4:
  3997. fsiOPFLD.MedChrgitmType = "03"
  3998. break
  3999. case 5:
  4000. fsiOPFLD.MedChrgitmType = "08"
  4001. break
  4002. case 6:
  4003. fsiOPFLD.MedChrgitmType = "14"
  4004. break
  4005. case 7:
  4006. fsiOPFLD.MedChrgitmType = "14"
  4007. break
  4008. case 8:
  4009. fsiOPFLD.MedChrgitmType = "03"
  4010. break
  4011. case 9:
  4012. fsiOPFLD.MedChrgitmType = "14"
  4013. break
  4014. case 10:
  4015. fsiOPFLD.MedChrgitmType = "14"
  4016. break
  4017. case 11:
  4018. fsiOPFLD.MedChrgitmType = "06"
  4019. break
  4020. case 12:
  4021. fsiOPFLD.MedChrgitmType = "12"
  4022. break
  4023. case 13:
  4024. fsiOPFLD.MedChrgitmType = "01"
  4025. break
  4026. case 14:
  4027. fsiOPFLD.MedChrgitmType = "04"
  4028. break
  4029. case 15:
  4030. fsiOPFLD.MedChrgitmType = "14"
  4031. break
  4032. }
  4033. memo["hosp_appr_flag"] = "1"
  4034. memo["invoice_no"] = fapiao_code
  4035. memo["memo"] = "自费"
  4036. bytesData, _ := json.Marshal(memo)
  4037. fsiOPFLD.Memo = string(bytesData)
  4038. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4039. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4040. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4041. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4042. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4043. fsiOPFLD.BilgDeptName = department.Name
  4044. fsiOPFLD.BilgDeptCodg = department.Number
  4045. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4046. fsiOPFLD.BilgDrName = doctor.UserName
  4047. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4048. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4049. fsiOPFLD.MedChrgitmType = "08"
  4050. memo["hosp_appr_flag"] = "1"
  4051. memo["invoice_no"] = fapiao_code
  4052. memo["memo"] = "自费"
  4053. bytesData, _ := json.Marshal(memo)
  4054. fsiOPFLD.Memo = string(bytesData)
  4055. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4056. }
  4057. }
  4058. }
  4059. fmt.Println(fsiOPFLDs)
  4060. struct4201A.Fopfd = fsiOPFLDs
  4061. fmt.Println(struct4201A.Fopfd)
  4062. var struct4202 models.Struct4202
  4063. timeLayout := "2006-01-02 15:04:05"
  4064. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  4065. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  4066. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  4067. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  4068. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  4069. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  4070. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  4071. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  4072. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  4073. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  4074. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4075. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4076. var config []*models.HisXtDiagnoseConfig
  4077. for _, item := range diagnosis_ids {
  4078. id, _ := strconv.ParseInt(item, 10, 64)
  4079. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4080. config = append(config, &diagnosisConfig)
  4081. }
  4082. var tempDiaginfos []models.OwnPayPatnDiagListD
  4083. for index, item := range config {
  4084. if index == 0 {
  4085. var tempDiaginfo models.OwnPayPatnDiagListD
  4086. tempDiaginfo.InoutDiagType = "1"
  4087. tempDiaginfo.DiagCode = item.CountryCode
  4088. tempDiaginfo.DiagName = item.CountryContentName
  4089. tempDiaginfo.DiagType = "1"
  4090. tempDiaginfo.DiagSrtNo = "1"
  4091. tempDiaginfo.MaindiagFlag = "1"
  4092. tempDiaginfo.ValiFlag = "1"
  4093. tempDiaginfo.DiagDrName = doctor.UserName
  4094. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4095. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4096. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4097. } else {
  4098. var tempDiaginfo models.OwnPayPatnDiagListD
  4099. tempDiaginfo.DiagCode = item.CountryCode
  4100. tempDiaginfo.DiagName = item.CountryContentName
  4101. tempDiaginfo.DiagType = "2"
  4102. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  4103. tempDiaginfo.MaindiagFlag = "0"
  4104. tempDiaginfo.ValiFlag = "1"
  4105. tempDiaginfo.DiagDrName = doctor.UserName
  4106. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4107. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4108. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4109. }
  4110. }
  4111. struct4202.ODiagListD = tempDiaginfos
  4112. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  4113. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  4114. var res2 ResultSix
  4115. var respJSON2 map[string]interface{}
  4116. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4117. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4119. return
  4120. }
  4121. userJSONBytes2, _ := json.Marshal(respJSON2)
  4122. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4123. utils.ErrorLog("解析失败:%v", err)
  4124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4125. return
  4126. }
  4127. if res2.Infcode != 0 {
  4128. c.ServeSuccessJSON(map[string]interface{}{
  4129. "failed_code": -10,
  4130. "msg": res2.ErrMsg,
  4131. })
  4132. return
  4133. } else {
  4134. order.IsUploadDiagnose = 1
  4135. order.IsUploadOrderInfo = 1
  4136. service.UpdateOrderTwo(order)
  4137. c.ServeSuccessJSON(map[string]interface{}{
  4138. "msg": "上传成功",
  4139. })
  4140. }
  4141. }
  4142. func (c *HisApiController) Get4207() {
  4143. admin_user_id, _ := c.GetInt64("admin_user_id")
  4144. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4145. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4146. order_id, _ := c.GetInt64("order_id")
  4147. order, _ := service.GetHisOrderByIDTwo(order_id)
  4148. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4149. var struct4207 models.Struct4207
  4150. struct4207.PageNum = "1"
  4151. struct4207.PageSize = "1000"
  4152. struct4207.FixmedinsCode = miConfig.Code
  4153. struct4207.FixmedinsMdtrtID = order.Number
  4154. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  4155. saveLog(result, requestLog, "4207", "查询")
  4156. var res2 ResultSix
  4157. var respJSON2 map[string]interface{}
  4158. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4161. return
  4162. }
  4163. userJSONBytes2, _ := json.Marshal(respJSON2)
  4164. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4165. utils.ErrorLog("解析失败:%v", err)
  4166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4167. return
  4168. }
  4169. if res2.Infcode != 0 {
  4170. c.ServeSuccessJSON(map[string]interface{}{
  4171. "failed_code": -10,
  4172. "msg": res2.ErrMsg,
  4173. })
  4174. return
  4175. } else {
  4176. c.ServeSuccessJSON(map[string]interface{}{
  4177. "msg": "查询成功",
  4178. })
  4179. }
  4180. }
  4181. func (c *HisApiController) Get4208() {
  4182. admin_user_id, _ := c.GetInt64("admin_user_id")
  4183. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4184. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4185. order_id, _ := c.GetInt64("order_id")
  4186. order, _ := service.GetHisOrderByIDTwo(order_id)
  4187. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4188. var struct4208 models.Struct4208
  4189. struct4208.PageNum = "1"
  4190. struct4208.PageSize = "1000"
  4191. struct4208.PsnCertType = "01"
  4192. struct4208.Certno = his.Certno
  4193. struct4208.MedType = order.MedType
  4194. struct4208.PsnName = his.Name
  4195. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  4196. saveLog(result, requestLog, "4208", "查询")
  4197. var res2 ResultSix
  4198. var respJSON2 map[string]interface{}
  4199. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4202. return
  4203. }
  4204. userJSONBytes2, _ := json.Marshal(respJSON2)
  4205. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4206. utils.ErrorLog("解析失败:%v", err)
  4207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4208. return
  4209. }
  4210. if res2.Infcode != 0 {
  4211. c.ServeSuccessJSON(map[string]interface{}{
  4212. "failed_code": -10,
  4213. "msg": res2.ErrMsg,
  4214. })
  4215. return
  4216. } else {
  4217. c.ServeSuccessJSON(map[string]interface{}{
  4218. "msg": "查询成功",
  4219. })
  4220. }
  4221. }
  4222. func (c *HisApiController) Get4209() {
  4223. admin_user_id, _ := c.GetInt64("admin_user_id")
  4224. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4225. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4226. order_id, _ := c.GetInt64("order_id")
  4227. order, _ := service.GetHisOrderByIDTwo(order_id)
  4228. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4229. var struct4209 models.Struct4209
  4230. struct4209.FixmedinsMdtrtID = order.Number
  4231. struct4209.FixmedinsCode = miConfig.Code
  4232. struct4209.PageSize = "1000"
  4233. struct4209.PageNum = "1"
  4234. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  4235. saveLog(result, requestLog, "4209", "查询")
  4236. var res2 ResultSix
  4237. var respJSON2 map[string]interface{}
  4238. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4241. return
  4242. }
  4243. userJSONBytes2, _ := json.Marshal(respJSON2)
  4244. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4245. utils.ErrorLog("解析失败:%v", err)
  4246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4247. return
  4248. }
  4249. if res2.Infcode != 0 {
  4250. c.ServeSuccessJSON(map[string]interface{}{
  4251. "failed_code": -10,
  4252. "msg": res2.ErrMsg,
  4253. })
  4254. return
  4255. } else {
  4256. c.ServeSuccessJSON(map[string]interface{}{
  4257. "msg": "查询成功",
  4258. })
  4259. }
  4260. }
  4261. type Result3101 struct {
  4262. Infcode string `json:"infcode"`
  4263. InfRefmsgid string `json:"inf_refmsgid"`
  4264. RefmsgTime string `json:"refmsg_time"`
  4265. RespondTime string `json:"respond_time"`
  4266. Enctype string `json:"enctype"`
  4267. Signtype string `json:"signtype"`
  4268. ErrMsg string `json:"err_msg"`
  4269. Output struct {
  4270. Result []struct {
  4271. JudgeResultDetailDtos []struct {
  4272. VolaItemType string `json:"vola_item_type"`
  4273. MdtrtID string `json:"mdtrt_id"`
  4274. JrdID string `json:"jrd_id"`
  4275. PatnID string `json:"patn_id"`
  4276. RxID string `json:"rx_id"`
  4277. VolaAmt interface{} `json:"vola_amt"`
  4278. } `json:"judge_result_detail_dtos"`
  4279. RuleID string `json:"rule_id"`
  4280. VolaEvid string `json:"vola_evid"`
  4281. MdtrtID string `json:"mdtrt_id"`
  4282. RuleName string `json:"rule_name"`
  4283. VolaAmtStas string `json:"vola_amt_stas"`
  4284. JrID string `json:"jr_id"`
  4285. PatnID string `json:"patn_id"`
  4286. SevDeg string `json:"sev_deg"`
  4287. VolaAmt float64 `json:"vola_amt"`
  4288. VolaBhvrType string `json:"vola_bhvr_type"`
  4289. VolaCont string `json:"vola_cont"`
  4290. } `json:"result"`
  4291. } `json:"output"`
  4292. }
  4293. type Resultgd3101 struct {
  4294. Infcode int64 `json:"infcode"`
  4295. InfRefmsgid string `json:"inf_refmsgid"`
  4296. RefmsgTime string `json:"refmsg_time"`
  4297. RespondTime string `json:"respond_time"`
  4298. Enctype string `json:"enctype"`
  4299. Signtype string `json:"signtype"`
  4300. ErrMsg string `json:"err_msg"`
  4301. Output struct {
  4302. Result []struct {
  4303. JudgeResultDetailDtos []struct {
  4304. VolaItemType string `json:"vola_item_type"`
  4305. MdtrtID string `json:"mdtrt_id"`
  4306. JrdID string `json:"jrd_id"`
  4307. PatnID string `json:"patn_id"`
  4308. RxID string `json:"rx_id"`
  4309. VolaAmt interface{} `json:"vola_amt"`
  4310. } `json:"judge_result_detail_dtos"`
  4311. RuleID string `json:"rule_id"`
  4312. VolaEvid string `json:"vola_evid"`
  4313. MdtrtID string `json:"mdtrt_id"`
  4314. RuleName string `json:"rule_name"`
  4315. VolaAmtStas string `json:"vola_amt_stas"`
  4316. JrID string `json:"jr_id"`
  4317. PatnID string `json:"patn_id"`
  4318. SevDeg string `json:"sev_deg"`
  4319. VolaAmt float64 `json:"vola_amt"`
  4320. VolaBhvrType string `json:"vola_bhvr_type"`
  4321. VolaCont string `json:"vola_cont"`
  4322. } `json:"result"`
  4323. } `json:"output"`
  4324. }
  4325. func (c *HisApiController) ReadEleToken() {
  4326. admin_user_id, _ := c.GetInt64("admin_user_id")
  4327. his_patient_id, _ := c.GetInt64("his_patient_id")
  4328. adminUser := c.GetAdminUserInfo()
  4329. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4330. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4331. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4332. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4333. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4334. if len(tokens) > 0 {
  4335. c.ServeSuccessJSON(map[string]interface{}{
  4336. "msg": "读取成功",
  4337. })
  4338. } else {
  4339. c.ServeSuccessJSON(map[string]interface{}{
  4340. "failed_code": -10,
  4341. "msg": "读取失败",
  4342. })
  4343. }
  4344. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4345. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4346. if len(tokens) > 0 {
  4347. c.ServeSuccessJSON(map[string]interface{}{
  4348. "msg": "读取成功",
  4349. })
  4350. } else {
  4351. c.ServeSuccessJSON(map[string]interface{}{
  4352. "failed_code": -10,
  4353. "msg": "读取失败",
  4354. })
  4355. }
  4356. } else if miConfig.MdtrtareaAdmvs == "150499" {
  4357. var api string
  4358. 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 +
  4359. "&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"
  4360. resp, requestErr := http.Get(api)
  4361. if requestErr != nil {
  4362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4363. }
  4364. body, ioErr := ioutil.ReadAll(resp.Body)
  4365. if ioErr != nil {
  4366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4368. }
  4369. var respJSON map[string]interface{}
  4370. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4373. return
  4374. }
  4375. var status string
  4376. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4377. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4378. var token string
  4379. var res ResultTwo //1101结果
  4380. var res10265 ResultTwo10265 //1101结果
  4381. if status == "0" { //读卡成功
  4382. var card_info string //卡信息
  4383. var busi_card_info string
  4384. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4385. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4386. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4387. fmt.Println(card_info)
  4388. fmt.Println(busi_card_info)
  4389. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4390. result, _ := json.Marshal(respJSON)
  4391. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4392. utils.ErrorLog("解析失败:%v", err)
  4393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4394. return
  4395. }
  4396. res.ErrMsg = res10265.ErrMsg
  4397. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4398. res.Infcode = infocode
  4399. res.Output = res10265.Output
  4400. res.InfRefmsgid = res10265.InfRefmsgid
  4401. if res.Infcode == 0 {
  4402. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4403. if err == gorm.ErrRecordNotFound {
  4404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4405. return
  4406. } else if err != nil {
  4407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4408. return
  4409. } else {
  4410. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4411. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4412. infoStr := string(Iinfos)
  4413. idetinfoStr := string(Idetinfos)
  4414. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  4415. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  4416. psn := &models.HisPsn{
  4417. PsnNo: res.Output.Baseinfo.PsnNo,
  4418. PatientId: patient.ID,
  4419. Certno: res.Output.Baseinfo.Certno,
  4420. Gend: res.Output.Baseinfo.Gend,
  4421. Naty: res.Output.Baseinfo.Naty,
  4422. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4423. PsnName: res.Output.Baseinfo.PsnName,
  4424. Age: float64(age),
  4425. Brdy: b,
  4426. Idetinfo: idetinfoStr,
  4427. Insuinfo: infoStr,
  4428. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4429. CardInfo: card_info,
  4430. VerifyNumber: token,
  4431. IdCardType: 4,
  4432. }
  4433. var rf []*ResultFive
  4434. json.Unmarshal([]byte(infoStr), &rf)
  4435. var insutypes []*ResultFive
  4436. var insutype string
  4437. var is390 int = 0
  4438. var is310 int = 0
  4439. for _, item := range rf {
  4440. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4441. insutypes = append(insutypes, item)
  4442. }
  4443. }
  4444. if len(insutypes) == 1 {
  4445. insutype = insutypes[0].Insutype
  4446. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4447. } else {
  4448. for _, i := range insutypes {
  4449. if i.Insutype == "390" {
  4450. is390 = 1
  4451. }
  4452. if i.Insutype == "310" {
  4453. is310 = 1
  4454. }
  4455. }
  4456. }
  4457. if is390 == 1 {
  4458. insutype = "390"
  4459. }
  4460. if is310 == 1 {
  4461. insutype = "310"
  4462. }
  4463. if len(insutypes) == 0 {
  4464. insutype = "310"
  4465. }
  4466. service.CreateHisPsn(psn)
  4467. c.ServeSuccessJSON(map[string]interface{}{
  4468. "patient": patient,
  4469. "number": token,
  4470. "insutype": insutype,
  4471. })
  4472. }
  4473. } else {
  4474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4475. return
  4476. }
  4477. } else { //读卡失败
  4478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4479. return
  4480. }
  4481. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4482. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  4483. if len(errMsg) == 0 {
  4484. type ELeData struct {
  4485. Data struct {
  4486. IdNo string `json:"idNo"`
  4487. IdType string `json:"idType"`
  4488. UserName string `json:"userName"`
  4489. EcToken string `json:"ecToken"`
  4490. InsuOrg string `json:"insuOrg"`
  4491. Gender string `json:"gender"`
  4492. Birthday string `json:"birthday"`
  4493. Nationality string `json:"nationality"`
  4494. Email string `json:"email"`
  4495. Extra string `json:"extra"`
  4496. } `json:"data"`
  4497. Code int `json:"code"`
  4498. Message string `json:"message"`
  4499. }
  4500. var ele ELeData
  4501. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4502. if err != nil {
  4503. utils.ErrorLog("解析失败:%v", err)
  4504. }
  4505. token := ele.Data.EcToken
  4506. if len(token) > 0 {
  4507. psn := &models.HisPsn{
  4508. PsnNo: his.PsnNo,
  4509. Age: 0,
  4510. PatientId: his.PatientId,
  4511. Certno: his.Certno,
  4512. Brdy: his.Brdy,
  4513. Gend: his.Gend,
  4514. Naty: his.Naty,
  4515. PsnCertType: his.PsnCertType,
  4516. PsnName: his.PsnName,
  4517. Idetinfo: his.Idetinfo,
  4518. Insuinfo: his.Iinfo,
  4519. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4520. CardInfo: outPutInfo,
  4521. VerifyNumber: token,
  4522. }
  4523. service.CreateHisPsn(psn)
  4524. }
  4525. if len(token) > 0 {
  4526. c.ServeSuccessJSON(map[string]interface{}{
  4527. "msg": "读取成功",
  4528. })
  4529. } else {
  4530. c.ServeSuccessJSON(map[string]interface{}{
  4531. "failed_code": -10,
  4532. "msg": "读取失败",
  4533. })
  4534. }
  4535. }
  4536. } else if miConfig.MdtrtareaAdmvs == "360302" {
  4537. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4538. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4539. type ELeData struct {
  4540. Data struct {
  4541. IdNo string `json:"idNo"`
  4542. IdType string `json:"idType"`
  4543. UserName string `json:"userName"`
  4544. EcToken string `json:"ecToken"`
  4545. InsuOrg string `json:"insuOrg"`
  4546. Gender string `json:"gender"`
  4547. Birthday string `json:"birthday"`
  4548. Nationality string `json:"nationality"`
  4549. Email string `json:"email"`
  4550. Extra string `json:"extra"`
  4551. } `json:"data"`
  4552. Code int `json:"code"`
  4553. Message string `json:"message"`
  4554. }
  4555. var ele ELeData
  4556. err := json.Unmarshal([]byte(result), &ele)
  4557. if err != nil {
  4558. utils.ErrorLog("解析失败:%v", err)
  4559. }
  4560. token := ele.Data.EcToken
  4561. token = Remove0000(token)
  4562. fmt.Println(ele.Data.UserName)
  4563. 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)
  4564. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4565. var res ResultTwo
  4566. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4567. utils.ErrorLog("解析失败:%v", err)
  4568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4569. return
  4570. }
  4571. if res.Infcode == 0 {
  4572. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4573. if err == gorm.ErrRecordNotFound {
  4574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4575. return
  4576. } else if err != nil {
  4577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4578. return
  4579. } else {
  4580. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4581. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4582. infoStr := string(Iinfos)
  4583. idetinfoStr := string(Idetinfos)
  4584. psn := &models.HisPsn{
  4585. PsnNo: res.Output.Baseinfo.PsnNo,
  4586. PatientId: patient.ID,
  4587. Certno: res.Output.Baseinfo.Certno,
  4588. Gend: res.Output.Baseinfo.Gend,
  4589. Naty: res.Output.Baseinfo.Naty,
  4590. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4591. PsnName: res.Output.Baseinfo.PsnName,
  4592. Idetinfo: idetinfoStr,
  4593. Insuinfo: infoStr,
  4594. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4595. CardInfo: "",
  4596. VerifyNumber: token,
  4597. }
  4598. service.CreateHisPsn(psn)
  4599. c.ServeSuccessJSON(map[string]interface{}{
  4600. "patient": patient,
  4601. "number": token,
  4602. })
  4603. }
  4604. } else {
  4605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4606. return
  4607. }
  4608. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4609. idNo := c.GetString("idNo")
  4610. userName := c.GetString("userName")
  4611. ecToken := c.GetString("ecToken")
  4612. insuOrg := c.GetString("insuOrg")
  4613. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4614. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4615. var res ResultTwo
  4616. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4617. utils.ErrorLog("解析失败:%v", err)
  4618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4619. return
  4620. }
  4621. if res.Infcode == 0 {
  4622. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4623. if err == gorm.ErrRecordNotFound {
  4624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4625. return
  4626. } else if err != nil {
  4627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4628. return
  4629. } else {
  4630. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4631. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4632. infoStr := string(Iinfos)
  4633. idetinfoStr := string(Idetinfos)
  4634. psn := &models.HisPsn{
  4635. PsnNo: res.Output.Baseinfo.PsnNo,
  4636. PatientId: patient.ID,
  4637. Certno: res.Output.Baseinfo.Certno,
  4638. Gend: res.Output.Baseinfo.Gend,
  4639. Naty: res.Output.Baseinfo.Naty,
  4640. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4641. PsnName: res.Output.Baseinfo.PsnName,
  4642. Idetinfo: idetinfoStr,
  4643. Insuinfo: infoStr,
  4644. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4645. CardInfo: "",
  4646. VerifyNumber: ecToken,
  4647. InsuplcAdmdvs: insuOrg,
  4648. }
  4649. service.CreateHisPsn(psn)
  4650. c.ServeSuccessJSON(map[string]interface{}{
  4651. "patient": patient,
  4652. "number": ecToken,
  4653. })
  4654. }
  4655. } else {
  4656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4657. return
  4658. }
  4659. } else if miConfig.MdtrtareaAdmvs == "450721" {
  4660. res := c.GetoleInfo()
  4661. if res.Infcode == 0 {
  4662. var result string
  4663. if res.Output.MdtrtCertType == "01" {
  4664. 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)
  4665. } else if res.Output.MdtrtCertType == "02" {
  4666. 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)
  4667. } else if res.Output.MdtrtCertType == "03" {
  4668. 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)
  4669. }
  4670. var dat map[string]interface{}
  4671. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4672. fmt.Println(dat)
  4673. } else {
  4674. fmt.Println(err)
  4675. }
  4676. userJSONBytes, _ := json.Marshal(dat)
  4677. var res2 ResultTwo
  4678. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4679. utils.ErrorLog("解析失败:%v", err)
  4680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4681. return
  4682. }
  4683. if res2.Infcode == 0 {
  4684. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  4685. if err == gorm.ErrRecordNotFound {
  4686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4687. return
  4688. } else if err != nil {
  4689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4690. return
  4691. } else {
  4692. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  4693. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  4694. infoStr := string(Iinfos)
  4695. idetinfoStr := string(Idetinfos)
  4696. var rf []*ResultFive
  4697. json.Unmarshal([]byte(infoStr), &rf)
  4698. var insutypes []*ResultFive
  4699. var insutype string
  4700. var is390 int = 0
  4701. var is310 int = 0
  4702. //var insuplc_admdvs string
  4703. for _, item := range rf {
  4704. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4705. insutypes = append(insutypes, item)
  4706. }
  4707. }
  4708. if len(insutypes) == 1 {
  4709. insutype = insutypes[0].Insutype
  4710. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4711. } else {
  4712. for _, i := range insutypes {
  4713. if i.Insutype == "390" {
  4714. is390 = 1
  4715. }
  4716. if i.Insutype == "310" {
  4717. is310 = 1
  4718. }
  4719. }
  4720. }
  4721. if is390 == 1 {
  4722. insutype = "390"
  4723. }
  4724. if is310 == 1 {
  4725. insutype = "310"
  4726. }
  4727. if len(insutypes) == 0 {
  4728. insutype = "310"
  4729. }
  4730. psn := &models.HisPsn{
  4731. PsnNo: res2.Output.Baseinfo.PsnNo,
  4732. PatientId: patient.ID,
  4733. Certno: res2.Output.Baseinfo.Certno,
  4734. Gend: res2.Output.Baseinfo.Gend,
  4735. Naty: res2.Output.Baseinfo.Naty,
  4736. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  4737. PsnName: res2.Output.Baseinfo.PsnName,
  4738. Idetinfo: idetinfoStr,
  4739. Insuinfo: infoStr,
  4740. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4741. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  4742. VerifyNumber: res.Output.EcToken,
  4743. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  4744. }
  4745. service.CreateHisPsn(psn)
  4746. c.ServeSuccessJSON(map[string]interface{}{
  4747. "patient": patient,
  4748. "number": res.Output.CardNo,
  4749. "insutype": insutype,
  4750. })
  4751. }
  4752. } else {
  4753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4754. return
  4755. }
  4756. } else {
  4757. c.ServeSuccessJSON(map[string]interface{}{
  4758. "failed_code": -10,
  4759. "msg": res.ErrMsg,
  4760. })
  4761. }
  4762. } else {
  4763. //if initFlag == 0 {
  4764. // c.TestGetBasBaseInit()
  4765. //}
  4766. //token := c.GetEleBaseInfo()
  4767. //token = Remove0000(token)
  4768. type ELeData struct {
  4769. Code string `json:"code"`
  4770. Data struct {
  4771. Aac002 string `json:"aac002"`
  4772. Aaz500 string `json:"aaz500"`
  4773. ActCardNo string `json:"actCardNo"`
  4774. Bab520 string `json:"bab520"`
  4775. Bkz543 string `json:"bkz543"`
  4776. BusinessType string `json:"businessType"`
  4777. CertfCodg string `json:"certfCodg"`
  4778. EcIndexNo string `json:"ecIndexNo"`
  4779. EcToken string `json:"ecToken"`
  4780. ID0000 string `json:"id0000"`
  4781. IDNo string `json:"idNo"`
  4782. IDType string `json:"idType"`
  4783. Idcode string `json:"idcode"`
  4784. IdentityToken string `json:"identity_token"`
  4785. InsuOrg string `json:"insuOrg"`
  4786. OfficeID string `json:"officeId"`
  4787. OfficeName string `json:"officeName"`
  4788. OperatorID string `json:"operatorId"`
  4789. OperatorName string `json:"operatorName"`
  4790. OrgID string `json:"orgId"`
  4791. UserName string `json:"userName"`
  4792. } `json:"data"`
  4793. Infno interface{} `json:"infno"`
  4794. Message string `json:"message"`
  4795. OrgID string `json:"orgId"`
  4796. TransType string `json:"transType"`
  4797. }
  4798. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4799. fmt.Println(result)
  4800. outPutInfo := Remove0000(result)
  4801. fmt.Println(outPutInfo)
  4802. var ele ELeData
  4803. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4804. if err != nil {
  4805. utils.ErrorLog("解析失败:%v", err)
  4806. }
  4807. token := ele.Data.EcToken
  4808. var result2 string
  4809. var requestLog2 string
  4810. if len(token) > 0 {
  4811. if strings.Contains(ele.Data.IDNo, "HKG") {
  4812. 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)
  4813. } else {
  4814. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  4815. }
  4816. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4817. var res ResultTwo
  4818. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4819. utils.ErrorLog("解析失败:%v", err)
  4820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4821. return
  4822. }
  4823. if res.Infcode == 0 {
  4824. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4825. if err == gorm.ErrRecordNotFound {
  4826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4827. return
  4828. } else if err != nil {
  4829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4830. return
  4831. } else {
  4832. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4833. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4834. infoStr := string(Iinfos)
  4835. idetinfoStr := string(Idetinfos)
  4836. psn := &models.HisPsn{
  4837. PsnNo: res.Output.Baseinfo.PsnNo,
  4838. PatientId: patient.ID,
  4839. Certno: res.Output.Baseinfo.Certno,
  4840. Gend: res.Output.Baseinfo.Gend,
  4841. Naty: res.Output.Baseinfo.Naty,
  4842. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4843. PsnName: res.Output.Baseinfo.PsnName,
  4844. Idetinfo: idetinfoStr,
  4845. Insuinfo: infoStr,
  4846. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4847. CardInfo: "",
  4848. VerifyNumber: token,
  4849. }
  4850. service.CreateHisPsn(psn)
  4851. c.ServeSuccessJSON(map[string]interface{}{
  4852. "msg": "读取成功",
  4853. })
  4854. }
  4855. } else {
  4856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4857. return
  4858. }
  4859. } else {
  4860. c.ServeSuccessJSON(map[string]interface{}{
  4861. "failed_code": -10,
  4862. "msg": "读取失败",
  4863. })
  4864. }
  4865. }
  4866. }
  4867. func (c *HisApiController) ReadEleFace() {
  4868. admin_user_id, _ := c.GetInt64("admin_user_id")
  4869. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4870. adminUser := c.GetAdminUserInfo()
  4871. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4872. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4873. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4874. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4875. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4876. if len(tokens) > 0 {
  4877. c.ServeSuccessJSON(map[string]interface{}{
  4878. "msg": "读取成功",
  4879. })
  4880. } else {
  4881. c.ServeSuccessJSON(map[string]interface{}{
  4882. "failed_code": -10,
  4883. "msg": "读取失败",
  4884. })
  4885. }
  4886. }
  4887. }
  4888. func (c *HisApiController) Get9001() {
  4889. adminUser := c.GetAdminUserInfo()
  4890. admin_user_id, _ := c.GetInt64("admin_user_id")
  4891. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4892. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4893. if miConfig.MdtrtareaAdmvs == "350500" {
  4894. service.GetFjAuthorizationInfo(miConfig.Code)
  4895. } else if miConfig.MdtrtareaAdmvs == "131023" {
  4896. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  4897. var dat map[string]interface{}
  4898. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4899. fmt.Println(dat)
  4900. } else {
  4901. fmt.Println(err)
  4902. }
  4903. userJSONBytes, _ := json.Marshal(dat)
  4904. var res models.Result9001
  4905. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4906. utils.ErrorLog("解析失败:%v", err)
  4907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4908. return
  4909. }
  4910. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4911. fmt.Println(miConfig.SecretKey)
  4912. var res models.Result9001Two
  4913. 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 +
  4914. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  4915. resp, requestErr := http.Get(api)
  4916. if requestErr != nil {
  4917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4918. return
  4919. }
  4920. body, ioErr := ioutil.ReadAll(resp.Body)
  4921. if ioErr != nil {
  4922. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4924. return
  4925. }
  4926. var respJSON map[string]interface{}
  4927. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4930. return
  4931. }
  4932. status := respJSON["data"].(map[string]interface{})["status"].(string)
  4933. if status == "0" {
  4934. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  4935. c.ServeSuccessJSON(map[string]interface{}{
  4936. "failed_code": -10,
  4937. "msg": err_msg,
  4938. })
  4939. return
  4940. }
  4941. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4942. result, _ := json.Marshal(respJSON)
  4943. fmt.Println("log")
  4944. fmt.Println(string(result))
  4945. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4946. utils.ErrorLog("解析失败:%v", err)
  4947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4948. return
  4949. }
  4950. if res.Infcode == 0 {
  4951. sign := models.HisSignIn{
  4952. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4953. SignNo: res.Output.Signinoutb.SignNo,
  4954. SignTime: "",
  4955. Ctime: time.Now().Unix(),
  4956. Mtime: time.Now().Unix(),
  4957. Status: 1,
  4958. InputLog: "",
  4959. OutputLog: "",
  4960. FixmedinsCode: miConfig.Code,
  4961. }
  4962. err := service.CreateSignIn(&sign)
  4963. if err == nil {
  4964. c.ServeSuccessJSON(map[string]interface{}{
  4965. "msg": "签到成功",
  4966. })
  4967. }
  4968. } else {
  4969. c.ServeSuccessJSON(map[string]interface{}{
  4970. "failed_code": -10,
  4971. "msg": res.ErrMsg,
  4972. })
  4973. return
  4974. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4975. //return
  4976. }
  4977. } else {
  4978. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  4979. var dat map[string]interface{}
  4980. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4981. fmt.Println(dat)
  4982. } else {
  4983. fmt.Println(err)
  4984. }
  4985. userJSONBytes, _ := json.Marshal(dat)
  4986. var res models.Result9001
  4987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4988. utils.ErrorLog("解析失败:%v", err)
  4989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4990. return
  4991. }
  4992. if res.Infcode == 0 {
  4993. sign := models.HisSignIn{
  4994. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4995. SignNo: res.Output.Signinoutb.SignNo,
  4996. SignTime: res.Output.Signinoutb.SignTime,
  4997. Ctime: time.Now().Unix(),
  4998. Mtime: time.Now().Unix(),
  4999. Status: 1,
  5000. InputLog: "",
  5001. OutputLog: "",
  5002. FixmedinsCode: miConfig.Code,
  5003. }
  5004. err := service.CreateSignIn(&sign)
  5005. if err == nil {
  5006. c.ServeSuccessJSON(map[string]interface{}{
  5007. "msg": "签到成功",
  5008. })
  5009. }
  5010. }
  5011. }
  5012. }
  5013. 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) {
  5014. var res Result3101
  5015. adminUser := c.GetAdminUserInfo()
  5016. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5017. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5018. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5019. //record_time := c.GetString("record_time")
  5020. //trig_scen := c.GetString("trig_scen")
  5021. timeLayout := "2006-01-02"
  5022. loc, _ := time.LoadLocation("Local")
  5023. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5024. if err != nil {
  5025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5026. return res
  5027. }
  5028. recordDateTime := theTime.Unix()
  5029. var patientPrescription models.HisPrescriptionInfo
  5030. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5031. //if patientPrescription.ID == 0 {
  5032. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5033. //}
  5034. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5035. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5036. //
  5037. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5038. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5039. var pp models.PublicParams
  5040. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5041. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5042. pp.FixmedinsName = miConfig.OrgName
  5043. pp.FixmedinsCode = miConfig.Code
  5044. pp.RequestUrl = miConfig.Url
  5045. pp.Cainfo = miConfig.Cainfo
  5046. pp.SecretKey = miConfig.SecretKey
  5047. pp.AccessKey = miConfig.AccessKey
  5048. pp.OpterName = roles.UserName
  5049. var config []*models.HisXtDiagnoseConfig
  5050. for _, item := range diagnosis_ids {
  5051. id, _ := strconv.ParseInt(item, 10, 64)
  5052. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5053. config = append(config, &diagnosisConfig)
  5054. }
  5055. var pd models.PatientDtos
  5056. pd.PatnID = his.PsnNo
  5057. pd.PatnName = his.Name
  5058. pd.Gend = his.Gend
  5059. pd.Brdy = his.Brdy
  5060. pd.Poolarea = miConfig.MdtrtareaAdmvs
  5061. pd.CurrMdtrtID = his.Number
  5062. var fed models.FsiEncounterDtos
  5063. fed.MdtrtID = his.Number
  5064. fed.MedinsID = miConfig.Code
  5065. fed.MedinsName = miConfig.OrgName
  5066. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5067. fed.MedMdtrtType = "1"
  5068. fed.MedinsType = "1"
  5069. fed.MedinsLv = "11"
  5070. tm := time.Unix(his.RecordDate, 0)
  5071. s_tm := tm.Format("2006-01-02 15:04:05")
  5072. fed.AdmDate = s_tm
  5073. fed.DscgDate = s_tm
  5074. fed.DscgMainDiseCodg = config[0].CountryCode
  5075. fed.DscgMainDiseName = config[0].CountryContentName
  5076. //诊断信息
  5077. var fdds []*models.FsiDiagnoseDtos
  5078. for index, item := range config {
  5079. if index == 0 {
  5080. var fdd models.FsiDiagnoseDtos
  5081. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5082. fdd.InoutDiseType = "1"
  5083. fdd.MaindiseFlag = "1"
  5084. fdd.DiseDate = s_tm
  5085. fdd.DiasSrtNo = "1"
  5086. fdd.DiseName = item.CountryContentName
  5087. fdd.DiseCodg = item.CountryCode
  5088. fdds = append(fdds, &fdd)
  5089. } else {
  5090. var fdd models.FsiDiagnoseDtos
  5091. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5092. fdd.InoutDiseType = "1"
  5093. fdd.MaindiseFlag = "1"
  5094. fdd.DiseDate = s_tm
  5095. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5096. fdd.DiseName = item.CountryContentName
  5097. fdd.DiseCodg = item.CountryCode
  5098. fdds = append(fdds, &fdd)
  5099. }
  5100. }
  5101. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5102. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5103. fed.AdmDeptName = department.Name
  5104. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5105. fed.DscgDeptName = department.Name
  5106. fed.MedMdtrtType = "1"
  5107. fed.MedType = "11"
  5108. //if his.Insutype == "390" {
  5109. // fed.MedType = "1402"
  5110. //} else {
  5111. // fed.MedType = "9933"
  5112. //}
  5113. var orders []*models.FsiOrderDtos
  5114. if trig_scen == "2" {
  5115. //处方医嘱信息
  5116. for _, item := range prescriptions {
  5117. for _, subItem := range item.HisDoctorAdviceInfo {
  5118. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5119. var order models.FsiOrderDtos
  5120. order.RxID = strconv.FormatInt(item.ID, 10)
  5121. order.Rxno = strconv.FormatInt(item.ID, 10)
  5122. order.LongDrordFlag = "0"
  5123. order.HilistType = "1"
  5124. order.ChrgType = "1"
  5125. order.DrordBhvr = "-"
  5126. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5127. order.HosplistName = subItem.BaseDrugLib.DrugName
  5128. order.HilistLv = "1"
  5129. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5130. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5131. order.HosplistName = subItem.BaseDrugLib.DrugName
  5132. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5133. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5134. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5135. order.OwnpayAmt = ""
  5136. order.SelfpayAmt = ""
  5137. order.Spec = ""
  5138. order.SpecUnt = ""
  5139. order.DrordBegnDate = s_tm
  5140. order.DrordStopDate = ""
  5141. order.DrordDrCodg = doctor_info.DoctorNumber
  5142. order.DrordDeptName = department.Name
  5143. order.DrordDeptCodg = department.Number
  5144. order.DrordDrName = doctor_info.UserName
  5145. order.DrordDrProfttl = "234"
  5146. order.CurrDrordFlag = "1"
  5147. orders = append(orders, &order)
  5148. }
  5149. }
  5150. for _, subItem := range item.HisPrescriptionProject {
  5151. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5152. var order models.FsiOrderDtos
  5153. order.RxID = strconv.FormatInt(item.ID, 10)
  5154. order.Rxno = strconv.FormatInt(item.ID, 10)
  5155. order.LongDrordFlag = "0"
  5156. order.HilistType = "1"
  5157. order.ChrgType = "1"
  5158. order.DrordBhvr = "-"
  5159. order.HilistCode = subItem.HisProject.MedicalCode
  5160. order.HosplistName = subItem.HisProject.ProjectName
  5161. order.HilistLv = "1"
  5162. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5163. order.HosplistCode = subItem.HisProject.MedicalCode
  5164. order.HosplistName = subItem.HisProject.ProjectName
  5165. order.Cnt = subItem.Count
  5166. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5167. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5168. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5169. order.OwnpayAmt = ""
  5170. order.SelfpayAmt = ""
  5171. order.Spec = ""
  5172. order.SpecUnt = ""
  5173. order.DrordBegnDate = s_tm
  5174. order.DrordStopDate = ""
  5175. order.DrordDrCodg = doctor_info.DoctorNumber
  5176. order.DrordDeptName = department.Name
  5177. order.DrordDeptCodg = department.Number
  5178. order.DrordDrName = doctor_info.UserName
  5179. order.DrordDrProfttl = "234"
  5180. order.CurrDrordFlag = "1"
  5181. orders = append(orders, &order)
  5182. }
  5183. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5184. var order models.FsiOrderDtos
  5185. order.RxID = strconv.FormatInt(item.ID, 10)
  5186. order.Rxno = strconv.FormatInt(item.ID, 10)
  5187. order.LongDrordFlag = "0"
  5188. order.HilistType = "1"
  5189. order.ChrgType = "1"
  5190. order.DrordBhvr = "-"
  5191. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5192. order.HosplistName = subItem.GoodInfo.GoodName
  5193. order.HilistLv = "1"
  5194. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5195. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5196. order.HosplistName = subItem.GoodInfo.GoodName
  5197. order.Cnt = subItem.Count
  5198. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5199. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5200. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5201. order.OwnpayAmt = ""
  5202. order.SelfpayAmt = ""
  5203. order.Spec = ""
  5204. order.SpecUnt = ""
  5205. order.DrordBegnDate = s_tm
  5206. order.DrordStopDate = ""
  5207. order.DrordDrCodg = doctor_info.DoctorNumber
  5208. order.DrordDeptName = department.Name
  5209. order.DrordDeptCodg = department.Number
  5210. order.DrordDrName = doctor_info.UserName
  5211. order.DrordDrProfttl = "234"
  5212. order.CurrDrordFlag = "1"
  5213. orders = append(orders, &order)
  5214. }
  5215. }
  5216. }
  5217. //处方医嘱信息
  5218. }
  5219. fed.MatnStas = "0"
  5220. fed.MedfeeSumamt = "0"
  5221. fed.OwnpayAmt = "0"
  5222. fed.SelfpayAmt = "0"
  5223. fed.AcctPayamt = "0"
  5224. fed.MaAmt = "0"
  5225. fed.HifpPayamt = "0"
  5226. fed.SetlTotlnum = "1"
  5227. fed.Insutype = his.Insutype
  5228. fed.ReimFlag = "0"
  5229. fed.OutSetlFlag = "0"
  5230. var fopd []*models.FsiOperationDtosData
  5231. data := make(map[string]interface{})
  5232. data["fed"] = fed
  5233. data["fdd"] = fdds
  5234. data["fod"] = orders
  5235. data["pd"] = pd
  5236. data["pp"] = pp
  5237. data["fopd"] = fopd
  5238. data["trig_scen"] = trig_scen
  5239. fmt.Println(data)
  5240. fmt.Println(fed)
  5241. fmt.Println(fdds)
  5242. fmt.Println(orders)
  5243. fmt.Println(pd)
  5244. fmt.Println(pp)
  5245. fmt.Println(fopd)
  5246. client := &http.Client{}
  5247. bytesData, _ := json.Marshal(data)
  5248. var req *http.Request
  5249. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5250. if miConfig.MdtrtareaAdmvs == "320921" {
  5251. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5252. } else {
  5253. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5254. }
  5255. resp, _ := client.Do(req)
  5256. defer resp.Body.Close()
  5257. body, ioErr := ioutil.ReadAll(resp.Body)
  5258. if ioErr != nil {
  5259. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5261. return res
  5262. }
  5263. var respJSON map[string]interface{}
  5264. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5267. return res
  5268. }
  5269. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5270. fmt.Println(respJSON)
  5271. result, _ := json.Marshal(respJSON)
  5272. fmt.Println(result)
  5273. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5274. utils.ErrorLog("解析失败:%v", err)
  5275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5276. return res
  5277. }
  5278. return res
  5279. } else {
  5280. //if miConfig.MdtrtareaAdmvs == "441202" {
  5281. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5282. saveLog(output, input, "3101", "事前")
  5283. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5284. utils.ErrorLog("解析失败:%v", err)
  5285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5286. return
  5287. }
  5288. return res
  5289. //}
  5290. }
  5291. }
  5292. 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) {
  5293. adminUser := c.GetAdminUserInfo()
  5294. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5295. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5296. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5297. //record_time := c.GetString("record_time")
  5298. //trig_scen := c.GetString("trig_scen")
  5299. timeLayout := "2006-01-02"
  5300. loc, _ := time.LoadLocation("Local")
  5301. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5302. if err != nil {
  5303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5304. return res
  5305. }
  5306. recordDateTime := theTime.Unix()
  5307. var patientPrescription models.HisPrescriptionInfo
  5308. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5309. if patientPrescription.ID == 0 {
  5310. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5311. }
  5312. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5313. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5314. //
  5315. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5316. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5317. var pp models.PublicParams
  5318. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5319. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5320. pp.FixmedinsName = miConfig.OrgName
  5321. pp.FixmedinsCode = miConfig.Code
  5322. pp.RequestUrl = miConfig.Url
  5323. pp.Cainfo = miConfig.Cainfo
  5324. pp.SecretKey = miConfig.SecretKey
  5325. pp.AccessKey = miConfig.AccessKey
  5326. pp.OpterName = roles.UserName
  5327. var config []*models.HisXtDiagnoseConfig
  5328. for _, item := range diagnosis_ids {
  5329. id, _ := strconv.ParseInt(item, 10, 64)
  5330. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5331. config = append(config, &diagnosisConfig)
  5332. }
  5333. var pd models.PatientDtos
  5334. pd.PatnID = his.PsnNo
  5335. pd.PatnName = his.Name
  5336. pd.Gend = his.Gend
  5337. pd.Brdy = his.Brdy
  5338. pd.Poolarea = his.InsuplcAdmdvs
  5339. pd.CurrMdtrtID = his.Number
  5340. var fed models.FsiEncounterDtos
  5341. fed.MdtrtID = his.Number
  5342. fed.MedinsID = miConfig.Code
  5343. fed.MedinsName = miConfig.OrgName
  5344. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5345. fed.MedMdtrtType = "1"
  5346. fed.MedinsType = "1"
  5347. fed.MedinsLv = "11"
  5348. tm := time.Unix(his.RecordDate, 0)
  5349. s_tm := tm.Format("2006-01-02 15:04:05")
  5350. fed.AdmDate = s_tm
  5351. fed.DscgDate = s_tm
  5352. fed.DscgMainDiseCodg = config[0].CountryCode
  5353. fed.DscgMainDiseName = config[0].CountryContentName
  5354. //诊断信息
  5355. var fdds []*models.FsiDiagnoseDtos
  5356. for index, item := range config {
  5357. if index == 0 {
  5358. var fdd models.FsiDiagnoseDtos
  5359. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5360. fdd.InoutDiseType = "1"
  5361. fdd.MaindiseFlag = "1"
  5362. fdd.DiseDate = s_tm
  5363. fdd.DiasSrtNo = "1"
  5364. fdd.DiseName = item.CountryContentName
  5365. fdd.DiseCodg = item.CountryCode
  5366. fdds = append(fdds, &fdd)
  5367. } else {
  5368. var fdd models.FsiDiagnoseDtos
  5369. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5370. fdd.InoutDiseType = "1"
  5371. fdd.MaindiseFlag = "1"
  5372. fdd.DiseDate = s_tm
  5373. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5374. fdd.DiseName = item.CountryContentName
  5375. fdd.DiseCodg = item.CountryCode
  5376. fdds = append(fdds, &fdd)
  5377. }
  5378. }
  5379. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5380. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5381. fed.AdmDeptName = department.Name
  5382. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5383. fed.DscgDeptName = department.Name
  5384. fed.MedMdtrtType = "1"
  5385. fed.MedType = "11"
  5386. //if his.Insutype == "390" {
  5387. // fed.MedType = "1402"
  5388. //} else {
  5389. // fed.MedType = "9933"
  5390. //}
  5391. var orders []*models.FsiOrderDtos
  5392. if trig_scen == "2" {
  5393. //处方医嘱信息
  5394. for _, item := range prescriptions {
  5395. for _, subItem := range item.HisDoctorAdviceInfo {
  5396. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5397. var order models.FsiOrderDtos
  5398. order.RxID = strconv.FormatInt(item.ID, 10)
  5399. order.Rxno = strconv.FormatInt(item.ID, 10)
  5400. order.LongDrordFlag = "0"
  5401. order.HilistType = "1"
  5402. order.ChrgType = "1"
  5403. order.DrordBhvr = "-"
  5404. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5405. order.HosplistName = subItem.BaseDrugLib.DrugName
  5406. order.HilistLv = "1"
  5407. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5408. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5409. order.HosplistName = subItem.BaseDrugLib.DrugName
  5410. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5411. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5412. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5413. order.OwnpayAmt = ""
  5414. order.SelfpayAmt = ""
  5415. order.Spec = ""
  5416. order.SpecUnt = ""
  5417. order.DrordBegnDate = s_tm
  5418. order.DrordStopDate = ""
  5419. order.DrordDrCodg = doctor_info.DoctorNumber
  5420. order.DrordDeptName = department.Name
  5421. order.DrordDeptCodg = department.Number
  5422. order.DrordDrName = doctor_info.UserName
  5423. order.DrordDrProfttl = "234"
  5424. order.CurrDrordFlag = "1"
  5425. orders = append(orders, &order)
  5426. }
  5427. }
  5428. for _, subItem := range item.HisPrescriptionProject {
  5429. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5430. var order models.FsiOrderDtos
  5431. order.RxID = strconv.FormatInt(item.ID, 10)
  5432. order.Rxno = strconv.FormatInt(item.ID, 10)
  5433. order.LongDrordFlag = "0"
  5434. order.HilistType = "1"
  5435. order.ChrgType = "1"
  5436. order.DrordBhvr = "-"
  5437. order.HilistCode = subItem.HisProject.MedicalCode
  5438. order.HosplistName = subItem.HisProject.ProjectName
  5439. order.HilistLv = "1"
  5440. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5441. order.HosplistCode = subItem.HisProject.MedicalCode
  5442. order.HosplistName = subItem.HisProject.ProjectName
  5443. order.Cnt = subItem.Count
  5444. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5445. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5446. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5447. order.OwnpayAmt = ""
  5448. order.SelfpayAmt = ""
  5449. order.Spec = ""
  5450. order.SpecUnt = ""
  5451. order.DrordBegnDate = s_tm
  5452. order.DrordStopDate = ""
  5453. order.DrordDrCodg = doctor_info.DoctorNumber
  5454. order.DrordDeptName = department.Name
  5455. order.DrordDeptCodg = department.Number
  5456. order.DrordDrName = doctor_info.UserName
  5457. order.DrordDrProfttl = "234"
  5458. order.CurrDrordFlag = "1"
  5459. orders = append(orders, &order)
  5460. }
  5461. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5462. var order models.FsiOrderDtos
  5463. order.RxID = strconv.FormatInt(item.ID, 10)
  5464. order.Rxno = strconv.FormatInt(item.ID, 10)
  5465. order.LongDrordFlag = "0"
  5466. order.HilistType = "1"
  5467. order.ChrgType = "1"
  5468. order.DrordBhvr = "-"
  5469. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5470. order.HosplistName = subItem.GoodInfo.GoodName
  5471. order.HilistLv = "1"
  5472. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5473. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5474. order.HosplistName = subItem.GoodInfo.GoodName
  5475. order.Cnt = subItem.Count
  5476. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5477. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5478. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5479. order.OwnpayAmt = ""
  5480. order.SelfpayAmt = ""
  5481. order.Spec = ""
  5482. order.SpecUnt = ""
  5483. order.DrordBegnDate = s_tm
  5484. order.DrordStopDate = ""
  5485. order.DrordDrCodg = doctor_info.DoctorNumber
  5486. order.DrordDeptName = department.Name
  5487. order.DrordDeptCodg = department.Number
  5488. order.DrordDrName = doctor_info.UserName
  5489. order.DrordDrProfttl = "234"
  5490. order.CurrDrordFlag = "1"
  5491. orders = append(orders, &order)
  5492. }
  5493. }
  5494. }
  5495. //处方医嘱信息
  5496. }
  5497. fed.MatnStas = "0"
  5498. fed.MedfeeSumamt = "0"
  5499. fed.OwnpayAmt = "0"
  5500. fed.SelfpayAmt = "0"
  5501. fed.AcctPayamt = "0"
  5502. fed.MaAmt = "0"
  5503. fed.HifpPayamt = "0"
  5504. fed.SetlTotlnum = "1"
  5505. fed.Insutype = his.Insutype
  5506. fed.ReimFlag = "0"
  5507. fed.OutSetlFlag = "0"
  5508. var fopd []*models.FsiOperationDtosData
  5509. data := make(map[string]interface{})
  5510. data["fed"] = fed
  5511. data["fdd"] = fdds
  5512. data["fod"] = orders
  5513. data["pd"] = pd
  5514. data["pp"] = pp
  5515. data["fopd"] = fopd
  5516. data["trig_scen"] = trig_scen
  5517. fmt.Println(data)
  5518. fmt.Println(fed)
  5519. fmt.Println(fdds)
  5520. fmt.Println(orders)
  5521. fmt.Println(pd)
  5522. fmt.Println(pp)
  5523. fmt.Println(fopd)
  5524. client := &http.Client{}
  5525. bytesData, _ := json.Marshal(data)
  5526. var req *http.Request
  5527. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5528. if miConfig.MdtrtareaAdmvs == "320921" {
  5529. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5530. } else {
  5531. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5532. }
  5533. resp, _ := client.Do(req)
  5534. defer resp.Body.Close()
  5535. body, ioErr := ioutil.ReadAll(resp.Body)
  5536. if ioErr != nil {
  5537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5539. return res
  5540. }
  5541. var respJSON map[string]interface{}
  5542. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5545. return res
  5546. }
  5547. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5548. fmt.Println(respJSON)
  5549. result, _ := json.Marshal(respJSON)
  5550. fmt.Println(result)
  5551. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5552. utils.ErrorLog("解析失败:%v", err)
  5553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5554. return res
  5555. }
  5556. return res
  5557. } else {
  5558. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5559. saveLog(output, input, "3101", "事前")
  5560. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5561. utils.ErrorLog("解析失败:%v", err)
  5562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5563. return
  5564. }
  5565. return res
  5566. }
  5567. return res
  5568. }
  5569. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  5570. ////patient_id, _ := c.GetInt64("patient_id")
  5571. //order_id, _ := c.GetInt64("order_id")
  5572. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  5573. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  5574. //trig_scen := c.GetString("trig_scen")
  5575. adminUser := c.GetAdminUserInfo()
  5576. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5577. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5578. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5579. record_time := c.GetString("record_time")
  5580. order, _ := service.GetHisOrderByID(order_id)
  5581. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5582. timeLayout := "2006-01-02"
  5583. loc, _ := time.LoadLocation("Local")
  5584. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5585. if err != nil {
  5586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5587. return
  5588. }
  5589. recordDateTime := theTime.Unix()
  5590. var patientPrescription models.HisPrescriptionInfo
  5591. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5592. if patientPrescription.ID == 0 {
  5593. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5594. }
  5595. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5596. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5597. //
  5598. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5599. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5600. var pp models.PublicParams
  5601. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5602. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5603. pp.FixmedinsName = miConfig.OrgName
  5604. pp.FixmedinsCode = miConfig.Code
  5605. pp.RequestUrl = miConfig.Url
  5606. pp.Cainfo = miConfig.Cainfo
  5607. pp.SecretKey = miConfig.SecretKey
  5608. pp.AccessKey = miConfig.AccessKey
  5609. pp.OpterName = roles.UserName
  5610. var config []*models.HisXtDiagnoseConfig
  5611. for _, item := range diagnosis_ids {
  5612. id, _ := strconv.ParseInt(item, 10, 64)
  5613. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5614. config = append(config, &diagnosisConfig)
  5615. }
  5616. var pd models.PatientDtos
  5617. pd.PatnID = his.PsnNo
  5618. pd.PatnName = his.Name
  5619. pd.Gend = his.Gend
  5620. pd.Brdy = psn_info.Brdy
  5621. pd.Poolarea = his.InsuplcAdmdvs
  5622. pd.CurrMdtrtID = his.Number
  5623. var fed models.FsiEncounterDtos
  5624. fed.MdtrtID = his.Number
  5625. fed.MedinsID = miConfig.Code
  5626. fed.MedinsName = miConfig.OrgName
  5627. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5628. fed.MedMdtrtType = "1"
  5629. fed.MedinsType = "1"
  5630. fed.MedinsLv = "11"
  5631. tm := time.Unix(his.RecordDate, 0)
  5632. s_tm := tm.Format("2006-01-02 15:04:05")
  5633. fed.AdmDate = s_tm
  5634. fed.DscgDate = s_tm
  5635. fed.DscgMainDiseCodg = config[0].CountryCode
  5636. fed.DscgMainDiseName = config[0].CountryContentName
  5637. //诊断信息
  5638. var fdds []*models.FsiDiagnoseDtos
  5639. for index, item := range config {
  5640. if index == 0 {
  5641. var fdd models.FsiDiagnoseDtos
  5642. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5643. fdd.InoutDiseType = "1"
  5644. fdd.MaindiseFlag = "1"
  5645. fdd.DiseDate = s_tm
  5646. fdd.DiasSrtNo = "1"
  5647. fdd.DiseName = item.CountryContentName
  5648. fdd.DiseCodg = item.CountryCode
  5649. fdds = append(fdds, &fdd)
  5650. } else {
  5651. var fdd models.FsiDiagnoseDtos
  5652. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5653. fdd.InoutDiseType = "1"
  5654. fdd.MaindiseFlag = "1"
  5655. fdd.DiseDate = s_tm
  5656. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5657. fdd.DiseName = item.CountryContentName
  5658. fdd.DiseCodg = item.CountryCode
  5659. fdds = append(fdds, &fdd)
  5660. }
  5661. }
  5662. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5663. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5664. fed.AdmDeptName = department.Name
  5665. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5666. fed.DscgDeptName = department.Name
  5667. fed.MedType = order.MedType
  5668. //处方医嘱信息
  5669. var orders []*models.FsiOrderDtos
  5670. //for _, item := range prescriptions {
  5671. // for _, subItem := range item.HisDoctorAdviceInfo {
  5672. // var order models.FsiOrderDtos
  5673. // order.RxID = strconv.FormatInt(item.ID, 10)
  5674. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5675. // order.LongDrordFlag = "0"
  5676. // order.HilistType = "1"
  5677. // order.ChrgType = "1"
  5678. // order.DrordBhvr = "-"
  5679. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5680. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5681. // order.HilistLv = "1"
  5682. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5683. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5684. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5685. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  5686. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5687. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  5688. // order.OwnpayAmt = ""
  5689. // order.SelfpayAmt = ""
  5690. // order.Spec = ""
  5691. // order.SpecUnt = ""
  5692. // order.DrordBegnDate = s_tm
  5693. // order.DrordStopDate = ""
  5694. // order.DrordDrCodg = "1"
  5695. // order.DrordDeptName = department.Name
  5696. // order.DrordDrCodg = "1"
  5697. // order.DrordDrName = doctor_info.UserName
  5698. // order.DrordDrProfttl = ""
  5699. // order.CurrDrordFlag = "1"
  5700. // orders = append(orders, &order)
  5701. // }
  5702. // for _, subItem := range item.HisPrescriptionProject {
  5703. // if subItem.Type == 2 {
  5704. // var order models.FsiOrderDtos
  5705. // order.RxID = strconv.FormatInt(item.ID, 10)
  5706. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5707. // order.LongDrordFlag = "0"
  5708. // order.HilistType = "1"
  5709. // order.ChrgType = "1"
  5710. // order.DrordBhvr = "-"
  5711. // order.HilistCode = subItem.HisProject.MedicalCode
  5712. // order.HosplistName = subItem.HisProject.ProjectName
  5713. // order.HilistLv = "1"
  5714. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5715. // order.HosplistCode = subItem.HisProject.MedicalCode
  5716. // order.HosplistName = subItem.HisProject.ProjectName
  5717. // order.Cnt = subItem.Count
  5718. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5719. //
  5720. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5721. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5722. // order.OwnpayAmt = ""
  5723. // order.SelfpayAmt = ""
  5724. // order.Spec = ""
  5725. // order.SpecUnt = ""
  5726. // order.DrordBegnDate = s_tm
  5727. // order.DrordStopDate = ""
  5728. // order.DrordDrCodg = "1"
  5729. // order.DrordDeptName = department.Name
  5730. // order.DrordDrCodg = "1"
  5731. // order.DrordDrName = doctor_info.UserName
  5732. // order.DrordDrProfttl = ""
  5733. // order.CurrDrordFlag = "1"
  5734. // orders = append(orders, &order)
  5735. //
  5736. // }
  5737. // if subItem.Type == 3 {
  5738. //
  5739. // var order models.FsiOrderDtos
  5740. // order.RxID = strconv.FormatInt(item.ID, 10)
  5741. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5742. // order.LongDrordFlag = "0"
  5743. // order.HilistType = "1"
  5744. // order.ChrgType = "1"
  5745. // order.DrordBhvr = "-"
  5746. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5747. // order.HosplistName = subItem.GoodInfo.GoodName
  5748. // order.HilistLv = "1"
  5749. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5750. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5751. // order.HosplistName = subItem.GoodInfo.GoodName
  5752. // order.Cnt = subItem.Count
  5753. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5754. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5755. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5756. // order.OwnpayAmt = ""
  5757. // order.SelfpayAmt = ""
  5758. // order.Spec = ""
  5759. // order.SpecUnt = ""
  5760. // order.DrordBegnDate = s_tm
  5761. // order.DrordStopDate = ""
  5762. // order.DrordDrCodg = "1"
  5763. // order.DrordDeptName = department.Name
  5764. // order.DrordDrCodg = "1"
  5765. // order.DrordDrName = doctor_info.UserName
  5766. // order.DrordDrProfttl = ""
  5767. // order.CurrDrordFlag = "1"
  5768. // orders = append(orders, &order)
  5769. //
  5770. // }
  5771. // }
  5772. //}
  5773. for _, item := range prescriptions {
  5774. for _, subItem := range item.HisDoctorAdviceInfo {
  5775. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5776. var order models.FsiOrderDtos
  5777. order.RxID = strconv.FormatInt(item.ID, 10)
  5778. order.Rxno = strconv.FormatInt(item.ID, 10)
  5779. order.LongDrordFlag = "0"
  5780. order.HilistType = "1"
  5781. order.ChrgType = "1"
  5782. order.DrordBhvr = "-"
  5783. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5784. order.HosplistName = subItem.BaseDrugLib.DrugName
  5785. order.HilistLv = "1"
  5786. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5787. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5788. order.HosplistName = subItem.BaseDrugLib.DrugName
  5789. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5790. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5791. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5792. order.OwnpayAmt = ""
  5793. order.SelfpayAmt = ""
  5794. order.Spec = ""
  5795. order.SpecUnt = ""
  5796. order.DrordBegnDate = s_tm
  5797. order.DrordStopDate = ""
  5798. order.DrordDrCodg = doctor_info.DoctorNumber
  5799. order.DrordDeptName = department.Name
  5800. order.DrordDeptCodg = department.Number
  5801. order.DrordDrName = doctor_info.UserName
  5802. order.DrordDrProfttl = "234"
  5803. order.CurrDrordFlag = "1"
  5804. orders = append(orders, &order)
  5805. }
  5806. }
  5807. for _, subItem := range item.HisPrescriptionProject {
  5808. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5809. var order models.FsiOrderDtos
  5810. order.RxID = strconv.FormatInt(item.ID, 10)
  5811. order.Rxno = strconv.FormatInt(item.ID, 10)
  5812. order.LongDrordFlag = "0"
  5813. order.HilistType = "1"
  5814. order.ChrgType = "1"
  5815. order.DrordBhvr = "-"
  5816. order.HilistCode = subItem.HisProject.MedicalCode
  5817. order.HosplistName = subItem.HisProject.ProjectName
  5818. order.HilistLv = "1"
  5819. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5820. order.HosplistCode = subItem.HisProject.MedicalCode
  5821. order.HosplistName = subItem.HisProject.ProjectName
  5822. order.Cnt = subItem.Count
  5823. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5824. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5825. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5826. order.OwnpayAmt = ""
  5827. order.SelfpayAmt = ""
  5828. order.Spec = ""
  5829. order.SpecUnt = ""
  5830. order.DrordBegnDate = s_tm
  5831. order.DrordStopDate = ""
  5832. order.DrordDrCodg = doctor_info.DoctorNumber
  5833. order.DrordDeptName = department.Name
  5834. order.DrordDeptCodg = department.Number
  5835. order.DrordDrName = doctor_info.UserName
  5836. order.DrordDrProfttl = "234"
  5837. order.CurrDrordFlag = "1"
  5838. orders = append(orders, &order)
  5839. }
  5840. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5841. var order models.FsiOrderDtos
  5842. order.RxID = strconv.FormatInt(item.ID, 10)
  5843. order.Rxno = strconv.FormatInt(item.ID, 10)
  5844. order.LongDrordFlag = "0"
  5845. order.HilistType = "1"
  5846. order.ChrgType = "1"
  5847. order.DrordBhvr = "0"
  5848. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5849. order.HosplistName = subItem.GoodInfo.GoodName
  5850. order.HilistLv = "1"
  5851. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5852. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5853. order.HosplistName = subItem.GoodInfo.GoodName
  5854. order.Cnt = subItem.Count
  5855. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5856. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5857. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5858. order.OwnpayAmt = ""
  5859. order.SelfpayAmt = ""
  5860. order.Spec = ""
  5861. order.SpecUnt = ""
  5862. order.DrordBegnDate = s_tm
  5863. order.DrordStopDate = ""
  5864. order.DrordDrCodg = doctor_info.DoctorNumber
  5865. order.DrordDeptName = department.Name
  5866. order.DrordDeptCodg = department.Number
  5867. order.DrordDrName = doctor_info.UserName
  5868. order.DrordDrProfttl = "234"
  5869. order.CurrDrordFlag = "1"
  5870. orders = append(orders, &order)
  5871. }
  5872. }
  5873. }
  5874. //处方医嘱信息
  5875. fed.MatnStas = "0"
  5876. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  5877. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  5878. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  5879. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  5880. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  5881. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  5882. fed.SetlTotlnum = "1"
  5883. fed.Insutype = his.Insutype
  5884. fed.ReimFlag = "0"
  5885. fed.OutSetlFlag = "0"
  5886. var fopd []*models.FsiOperationDtosData
  5887. data := make(map[string]interface{})
  5888. data["fed"] = fed
  5889. data["fdd"] = fdds
  5890. data["fod"] = orders
  5891. data["pd"] = pd
  5892. data["pp"] = pp
  5893. data["fopd"] = fopd
  5894. data["trig_scen"] = trig_scen
  5895. client := &http.Client{}
  5896. bytesData, _ := json.Marshal(data)
  5897. var req *http.Request
  5898. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5899. if miConfig.MdtrtareaAdmvs == "320921" {
  5900. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5901. } else {
  5902. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5903. }
  5904. resp, _ := client.Do(req)
  5905. defer resp.Body.Close()
  5906. body, ioErr := ioutil.ReadAll(resp.Body)
  5907. if ioErr != nil {
  5908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5910. return res
  5911. }
  5912. var respJSON map[string]interface{}
  5913. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5916. return res
  5917. }
  5918. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5919. result, _ := json.Marshal(respJSON)
  5920. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5921. utils.ErrorLog("解析失败:%v", err)
  5922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5923. return res
  5924. }
  5925. return res
  5926. } else {
  5927. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5928. saveLog(output, input, "3102", "事中")
  5929. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5930. utils.ErrorLog("解析失败:%v", err)
  5931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5932. return
  5933. }
  5934. return res
  5935. }
  5936. return res
  5937. }
  5938. 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) {
  5939. var res Resultgd3101
  5940. adminUser := c.GetAdminUserInfo()
  5941. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5942. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5943. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5944. //record_time := c.GetString("record_time")
  5945. //trig_scen := c.GetString("trig_scen")
  5946. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5947. timeLayout := "2006-01-02"
  5948. loc, _ := time.LoadLocation("Local")
  5949. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5950. if err != nil {
  5951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5952. return res
  5953. }
  5954. recordDateTime := theTime.Unix()
  5955. var patientPrescription models.HisPrescriptionInfo
  5956. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5957. //if patientPrescription.ID == 0 {
  5958. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5959. //}
  5960. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5961. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5962. //
  5963. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5964. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5965. var pp models.PublicParams
  5966. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5967. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5968. pp.FixmedinsName = miConfig.OrgName
  5969. pp.FixmedinsCode = miConfig.Code
  5970. pp.RequestUrl = miConfig.Url
  5971. pp.Cainfo = miConfig.Cainfo
  5972. pp.SecretKey = miConfig.SecretKey
  5973. pp.AccessKey = miConfig.AccessKey
  5974. pp.OpterName = roles.UserName
  5975. var config []*models.HisXtDiagnoseConfig
  5976. for _, item := range diagnosis_ids {
  5977. id, _ := strconv.ParseInt(item, 10, 64)
  5978. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5979. config = append(config, &diagnosisConfig)
  5980. }
  5981. var pd models.PatientDtos
  5982. pd.PatnID = his.PsnNo
  5983. pd.PatnName = his.Name
  5984. pd.Gend = his.Gend
  5985. pd.Brdy = psn_info.Brdy
  5986. pd.Poolarea = miConfig.MdtrtareaAdmvs
  5987. pd.CurrMdtrtID = his.Number
  5988. var fed models.FsiEncounterDtos
  5989. fed.MdtrtID = his.Number
  5990. fed.MedinsID = miConfig.Code
  5991. fed.MedinsName = miConfig.OrgName
  5992. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5993. fed.MedMdtrtType = "1"
  5994. fed.MedinsType = "1"
  5995. fed.MedinsLv = "11"
  5996. tm := time.Unix(his.RecordDate, 0)
  5997. s_tm := tm.Format("2006-01-02 15:04:05")
  5998. fed.AdmDate = s_tm
  5999. fed.DscgDate = s_tm
  6000. fed.DscgMainDiseCodg = config[0].CountryCode
  6001. fed.DscgMainDiseName = config[0].CountryContentName
  6002. //诊断信息
  6003. var fdds []*models.FsiDiagnoseDtos
  6004. for index, item := range config {
  6005. if index == 0 {
  6006. var fdd models.FsiDiagnoseDtos
  6007. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6008. fdd.InoutDiseType = "1"
  6009. fdd.MaindiseFlag = "1"
  6010. fdd.DiseDate = s_tm
  6011. fdd.DiasSrtNo = "1"
  6012. fdd.DiseName = item.CountryContentName
  6013. fdd.DiseCodg = item.CountryCode
  6014. fdds = append(fdds, &fdd)
  6015. } else {
  6016. var fdd models.FsiDiagnoseDtos
  6017. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6018. fdd.InoutDiseType = "1"
  6019. fdd.MaindiseFlag = "1"
  6020. fdd.DiseDate = s_tm
  6021. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6022. fdd.DiseName = item.CountryContentName
  6023. fdd.DiseCodg = item.CountryCode
  6024. fdds = append(fdds, &fdd)
  6025. }
  6026. }
  6027. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6028. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6029. fed.AdmDeptName = department.Name
  6030. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6031. fed.DscgDeptName = department.Name
  6032. fed.MedMdtrtType = "1"
  6033. fed.MedType = "11"
  6034. //if his.Insutype == "390" {
  6035. // fed.MedType = "1402"
  6036. //} else {
  6037. // fed.MedType = "9933"
  6038. //}
  6039. var orders []*models.FsiOrderDtos
  6040. if trig_scen == "2" {
  6041. //处方医嘱信息
  6042. for _, item := range prescriptions {
  6043. for _, subItem := range item.HisDoctorAdviceInfo {
  6044. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6045. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6046. var order models.FsiOrderDtos
  6047. order.RxID = strconv.FormatInt(item.ID, 10)
  6048. order.Rxno = strconv.FormatInt(item.ID, 10)
  6049. order.LongDrordFlag = "0"
  6050. order.HilistType = "1"
  6051. order.ChrgType = "1"
  6052. order.DrordBhvr = "0"
  6053. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6054. order.HosplistName = subItem.BaseDrugLib.DrugName
  6055. order.HilistLv = "1"
  6056. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6057. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6058. order.HosplistName = subItem.BaseDrugLib.DrugName
  6059. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6060. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6061. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6062. order.OwnpayAmt = ""
  6063. order.SelfpayAmt = ""
  6064. order.Spec = spec
  6065. order.SpecUnt = subItem.PrescribingNumberUnit
  6066. order.DrordBegnDate = s_tm
  6067. order.DrordStopDate = ""
  6068. order.DrordDrCodg = doctor_info.DoctorNumber
  6069. order.DrordDeptName = department.Name
  6070. order.DrordDeptCodg = department.Number
  6071. order.DrordDrName = doctor_info.UserName
  6072. order.DrordDrProfttl = "234"
  6073. order.CurrDrordFlag = "1"
  6074. orders = append(orders, &order)
  6075. }
  6076. }
  6077. for _, subItem := range item.HisPrescriptionProject {
  6078. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6079. var order models.FsiOrderDtos
  6080. order.RxID = strconv.FormatInt(item.ID, 10)
  6081. order.Rxno = strconv.FormatInt(item.ID, 10)
  6082. order.LongDrordFlag = "0"
  6083. order.HilistType = "1"
  6084. order.ChrgType = "1"
  6085. order.DrordBhvr = "0"
  6086. order.HilistCode = subItem.HisProject.MedicalCode
  6087. order.HosplistName = subItem.HisProject.ProjectName
  6088. order.HilistLv = "1"
  6089. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6090. order.HosplistCode = subItem.HisProject.MedicalCode
  6091. order.HosplistName = subItem.HisProject.ProjectName
  6092. order.Cnt = subItem.Count
  6093. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6094. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6095. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6096. order.OwnpayAmt = ""
  6097. order.SelfpayAmt = ""
  6098. order.Spec = subItem.Unit
  6099. order.SpecUnt = subItem.Unit
  6100. order.DrordBegnDate = s_tm
  6101. order.DrordStopDate = ""
  6102. order.DrordDrCodg = doctor_info.DoctorNumber
  6103. order.DrordDeptName = department.Name
  6104. order.DrordDeptCodg = department.Number
  6105. order.DrordDrName = doctor_info.UserName
  6106. order.DrordDrProfttl = "234"
  6107. order.CurrDrordFlag = "1"
  6108. orders = append(orders, &order)
  6109. }
  6110. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6111. var order models.FsiOrderDtos
  6112. order.RxID = strconv.FormatInt(item.ID, 10)
  6113. order.Rxno = strconv.FormatInt(item.ID, 10)
  6114. order.LongDrordFlag = "0"
  6115. order.HilistType = "1"
  6116. order.ChrgType = "1"
  6117. order.DrordBhvr = "0"
  6118. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6119. order.HosplistName = subItem.GoodInfo.GoodName
  6120. order.HilistLv = "1"
  6121. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6122. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6123. order.HosplistName = subItem.GoodInfo.GoodName
  6124. order.Cnt = subItem.Count
  6125. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6126. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6127. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6128. order.OwnpayAmt = ""
  6129. order.SelfpayAmt = ""
  6130. order.Spec = subItem.GoodInfo.SpecificationName
  6131. order.SpecUnt = subItem.Unit
  6132. order.DrordBegnDate = s_tm
  6133. order.DrordStopDate = ""
  6134. order.DrordDrCodg = doctor_info.DoctorNumber
  6135. order.DrordDeptName = department.Name
  6136. order.DrordDeptCodg = department.Number
  6137. order.DrordDrName = doctor_info.UserName
  6138. order.DrordDrProfttl = "234"
  6139. order.CurrDrordFlag = "1"
  6140. orders = append(orders, &order)
  6141. }
  6142. }
  6143. }
  6144. //处方医嘱信息
  6145. }
  6146. fed.MatnStas = "0"
  6147. fed.MedfeeSumamt = "0"
  6148. fed.OwnpayAmt = "0"
  6149. fed.SelfpayAmt = "0"
  6150. fed.AcctPayamt = "0"
  6151. fed.MaAmt = "0"
  6152. fed.HifpPayamt = "0"
  6153. fed.SetlTotlnum = "1"
  6154. fed.Insutype = his.Insutype
  6155. fed.ReimFlag = "0"
  6156. fed.OutSetlFlag = "0"
  6157. var fopd []*models.FsiOperationDtosData
  6158. data := make(map[string]interface{})
  6159. data["fed"] = fed
  6160. data["fdd"] = fdds
  6161. data["fod"] = orders
  6162. data["pd"] = pd
  6163. data["pp"] = pp
  6164. data["fopd"] = fopd
  6165. data["trig_scen"] = trig_scen
  6166. fmt.Println(data)
  6167. fmt.Println(fed)
  6168. fmt.Println(fdds)
  6169. fmt.Println(orders)
  6170. fmt.Println(pd)
  6171. fmt.Println(pp)
  6172. fmt.Println(fopd)
  6173. client := &http.Client{}
  6174. bytesData, _ := json.Marshal(data)
  6175. var req *http.Request
  6176. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6177. if miConfig.MdtrtareaAdmvs == "320921" {
  6178. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6179. } else {
  6180. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6181. }
  6182. resp, _ := client.Do(req)
  6183. defer resp.Body.Close()
  6184. body, ioErr := ioutil.ReadAll(resp.Body)
  6185. if ioErr != nil {
  6186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6188. return res
  6189. }
  6190. var respJSON map[string]interface{}
  6191. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6194. return res
  6195. }
  6196. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6197. fmt.Println(respJSON)
  6198. result, _ := json.Marshal(respJSON)
  6199. fmt.Println(result)
  6200. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6201. utils.ErrorLog("解析失败:%v", err)
  6202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6203. return res
  6204. }
  6205. return res
  6206. } else {
  6207. //if miConfig.MdtrtareaAdmvs == "441202" {
  6208. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6209. saveLog(output, input, "3101", "事前")
  6210. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6211. utils.ErrorLog("解析失败:%v", err)
  6212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6213. return
  6214. }
  6215. return res
  6216. //}
  6217. }
  6218. }
  6219. 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) {
  6220. adminUser := c.GetAdminUserInfo()
  6221. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6222. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6223. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6224. //record_time := c.GetString("record_time")
  6225. //trig_scen := c.GetString("trig_scen")
  6226. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6227. timeLayout := "2006-01-02"
  6228. loc, _ := time.LoadLocation("Local")
  6229. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6230. if err != nil {
  6231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6232. return res
  6233. }
  6234. recordDateTime := theTime.Unix()
  6235. var patientPrescription models.HisPrescriptionInfo
  6236. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6237. if patientPrescription.ID == 0 {
  6238. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6239. }
  6240. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6241. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6242. //
  6243. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6244. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6245. var pp models.PublicParams
  6246. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6247. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6248. pp.FixmedinsName = miConfig.OrgName
  6249. pp.FixmedinsCode = miConfig.Code
  6250. pp.RequestUrl = miConfig.Url
  6251. pp.Cainfo = miConfig.Cainfo
  6252. pp.SecretKey = miConfig.SecretKey
  6253. pp.AccessKey = miConfig.AccessKey
  6254. pp.OpterName = roles.UserName
  6255. var config []*models.HisXtDiagnoseConfig
  6256. for _, item := range diagnosis_ids {
  6257. id, _ := strconv.ParseInt(item, 10, 64)
  6258. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6259. config = append(config, &diagnosisConfig)
  6260. }
  6261. var pd models.PatientDtos
  6262. pd.PatnID = his.PsnNo
  6263. pd.PatnName = his.Name
  6264. pd.Gend = his.Gend
  6265. pd.Brdy = psn_info.Brdy
  6266. pd.Poolarea = his.InsuplcAdmdvs
  6267. pd.CurrMdtrtID = his.Number
  6268. var fed models.FsiEncounterDtos
  6269. fed.MdtrtID = his.Number
  6270. fed.MedinsID = miConfig.Code
  6271. fed.MedinsName = miConfig.OrgName
  6272. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6273. fed.MedMdtrtType = "1"
  6274. fed.MedinsType = "1"
  6275. fed.MedinsLv = "11"
  6276. tm := time.Unix(his.RecordDate, 0)
  6277. s_tm := tm.Format("2006-01-02 15:04:05")
  6278. fed.AdmDate = s_tm
  6279. fed.DscgDate = s_tm
  6280. fed.DscgMainDiseCodg = config[0].CountryCode
  6281. fed.DscgMainDiseName = config[0].CountryContentName
  6282. //诊断信息
  6283. var fdds []*models.FsiDiagnoseDtos
  6284. for index, item := range config {
  6285. if index == 0 {
  6286. var fdd models.FsiDiagnoseDtos
  6287. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6288. fdd.InoutDiseType = "1"
  6289. fdd.MaindiseFlag = "1"
  6290. fdd.DiseDate = s_tm
  6291. fdd.DiasSrtNo = "1"
  6292. fdd.DiseName = item.CountryContentName
  6293. fdd.DiseCodg = item.CountryCode
  6294. fdds = append(fdds, &fdd)
  6295. } else {
  6296. var fdd models.FsiDiagnoseDtos
  6297. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6298. fdd.InoutDiseType = "1"
  6299. fdd.MaindiseFlag = "1"
  6300. fdd.DiseDate = s_tm
  6301. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6302. fdd.DiseName = item.CountryContentName
  6303. fdd.DiseCodg = item.CountryCode
  6304. fdds = append(fdds, &fdd)
  6305. }
  6306. }
  6307. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6308. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6309. fed.AdmDeptName = department.Name
  6310. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6311. fed.DscgDeptName = department.Name
  6312. fed.MedMdtrtType = "1"
  6313. fed.MedType = "11"
  6314. //if his.Insutype == "390" {
  6315. // fed.MedType = "1402"
  6316. //} else {
  6317. // fed.MedType = "9933"
  6318. //}
  6319. var orders []*models.FsiOrderDtos
  6320. if trig_scen == "2" {
  6321. //处方医嘱信息
  6322. for _, item := range prescriptions {
  6323. for _, subItem := range item.HisDoctorAdviceInfo {
  6324. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6325. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6326. var order models.FsiOrderDtos
  6327. order.RxID = strconv.FormatInt(item.ID, 10)
  6328. order.Rxno = strconv.FormatInt(item.ID, 10)
  6329. order.LongDrordFlag = "0"
  6330. order.HilistType = "1"
  6331. order.ChrgType = "1"
  6332. order.DrordBhvr = "0"
  6333. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6334. order.HosplistName = subItem.BaseDrugLib.DrugName
  6335. order.HilistLv = "1"
  6336. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6337. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6338. order.HosplistName = subItem.BaseDrugLib.DrugName
  6339. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6340. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6341. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6342. order.OwnpayAmt = ""
  6343. order.SelfpayAmt = ""
  6344. order.Spec = spec
  6345. order.SpecUnt = subItem.PrescribingNumberUnit
  6346. order.DrordBegnDate = s_tm
  6347. order.DrordStopDate = ""
  6348. order.DrordDrCodg = doctor_info.DoctorNumber
  6349. order.DrordDeptName = department.Name
  6350. order.DrordDeptCodg = department.Number
  6351. order.DrordDrName = doctor_info.UserName
  6352. order.DrordDrProfttl = "234"
  6353. order.CurrDrordFlag = "1"
  6354. orders = append(orders, &order)
  6355. }
  6356. }
  6357. for _, subItem := range item.HisPrescriptionProject {
  6358. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6359. var order models.FsiOrderDtos
  6360. order.RxID = strconv.FormatInt(item.ID, 10)
  6361. order.Rxno = strconv.FormatInt(item.ID, 10)
  6362. order.LongDrordFlag = "0"
  6363. order.HilistType = "1"
  6364. order.ChrgType = "1"
  6365. order.DrordBhvr = "0"
  6366. order.HilistCode = subItem.HisProject.MedicalCode
  6367. order.HosplistName = subItem.HisProject.ProjectName
  6368. order.HilistLv = "1"
  6369. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6370. order.HosplistCode = subItem.HisProject.MedicalCode
  6371. order.HosplistName = subItem.HisProject.ProjectName
  6372. order.Cnt = subItem.Count
  6373. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6374. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6375. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6376. order.OwnpayAmt = ""
  6377. order.SelfpayAmt = ""
  6378. order.Spec = subItem.Unit
  6379. order.SpecUnt = subItem.Unit
  6380. order.DrordBegnDate = s_tm
  6381. order.DrordStopDate = ""
  6382. order.DrordDrCodg = doctor_info.DoctorNumber
  6383. order.DrordDeptName = department.Name
  6384. order.DrordDeptCodg = department.Number
  6385. order.DrordDrName = doctor_info.UserName
  6386. order.DrordDrProfttl = "234"
  6387. order.CurrDrordFlag = "1"
  6388. orders = append(orders, &order)
  6389. }
  6390. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6391. var order models.FsiOrderDtos
  6392. order.RxID = strconv.FormatInt(item.ID, 10)
  6393. order.Rxno = strconv.FormatInt(item.ID, 10)
  6394. order.LongDrordFlag = "0"
  6395. order.HilistType = "1"
  6396. order.ChrgType = "1"
  6397. order.DrordBhvr = "0"
  6398. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6399. order.HosplistName = subItem.GoodInfo.GoodName
  6400. order.HilistLv = "1"
  6401. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6402. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6403. order.HosplistName = subItem.GoodInfo.GoodName
  6404. order.Cnt = subItem.Count
  6405. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6406. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6407. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6408. order.OwnpayAmt = ""
  6409. order.SelfpayAmt = ""
  6410. order.Spec = subItem.GoodInfo.SpecificationName
  6411. order.SpecUnt = subItem.Unit
  6412. order.DrordBegnDate = s_tm
  6413. order.DrordStopDate = ""
  6414. order.DrordDrCodg = doctor_info.DoctorNumber
  6415. order.DrordDeptName = department.Name
  6416. order.DrordDeptCodg = department.Number
  6417. order.DrordDrName = doctor_info.UserName
  6418. order.DrordDrProfttl = "234"
  6419. order.CurrDrordFlag = "1"
  6420. orders = append(orders, &order)
  6421. }
  6422. }
  6423. }
  6424. //处方医嘱信息
  6425. }
  6426. fed.MatnStas = "0"
  6427. fed.MedfeeSumamt = "0"
  6428. fed.OwnpayAmt = "0"
  6429. fed.SelfpayAmt = "0"
  6430. fed.AcctPayamt = "0"
  6431. fed.MaAmt = "0"
  6432. fed.HifpPayamt = "0"
  6433. fed.SetlTotlnum = "1"
  6434. fed.Insutype = his.Insutype
  6435. fed.ReimFlag = "0"
  6436. fed.OutSetlFlag = "0"
  6437. var fopd []*models.FsiOperationDtosData
  6438. data := make(map[string]interface{})
  6439. data["fed"] = fed
  6440. data["fdd"] = fdds
  6441. data["fod"] = orders
  6442. data["pd"] = pd
  6443. data["pp"] = pp
  6444. data["fopd"] = fopd
  6445. data["trig_scen"] = trig_scen
  6446. fmt.Println(data)
  6447. fmt.Println(fed)
  6448. fmt.Println(fdds)
  6449. fmt.Println(orders)
  6450. fmt.Println(pd)
  6451. fmt.Println(pp)
  6452. fmt.Println(fopd)
  6453. client := &http.Client{}
  6454. bytesData, _ := json.Marshal(data)
  6455. var req *http.Request
  6456. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6457. if miConfig.MdtrtareaAdmvs == "320921" {
  6458. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6459. } else {
  6460. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6461. }
  6462. resp, _ := client.Do(req)
  6463. defer resp.Body.Close()
  6464. body, ioErr := ioutil.ReadAll(resp.Body)
  6465. if ioErr != nil {
  6466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6468. return res
  6469. }
  6470. var respJSON map[string]interface{}
  6471. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6474. return res
  6475. }
  6476. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6477. fmt.Println(respJSON)
  6478. result, _ := json.Marshal(respJSON)
  6479. fmt.Println(result)
  6480. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6481. utils.ErrorLog("解析失败:%v", err)
  6482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6483. return res
  6484. }
  6485. return res
  6486. } else {
  6487. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6488. saveLog(output, input, "3101", "事前")
  6489. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6490. utils.ErrorLog("解析失败:%v", err)
  6491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6492. return
  6493. }
  6494. return res
  6495. }
  6496. return res
  6497. }
  6498. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  6499. ////patient_id, _ := c.GetInt64("patient_id")
  6500. //order_id, _ := c.GetInt64("order_id")
  6501. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  6502. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  6503. //trig_scen := c.GetString("trig_scen")
  6504. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6505. utils.ErrorLog("解析失败:%v", psn_info)
  6506. adminUser := c.GetAdminUserInfo()
  6507. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6508. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6509. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6510. record_time := c.GetString("record_time")
  6511. order, _ := service.GetHisOrderByID(order_id)
  6512. timeLayout := "2006-01-02"
  6513. loc, _ := time.LoadLocation("Local")
  6514. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6515. if err != nil {
  6516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6517. return
  6518. }
  6519. recordDateTime := theTime.Unix()
  6520. var patientPrescription models.HisPrescriptionInfo
  6521. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6522. if patientPrescription.ID == 0 {
  6523. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6524. }
  6525. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6526. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6527. //
  6528. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6529. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6530. var pp models.PublicParams
  6531. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6532. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6533. pp.FixmedinsName = miConfig.OrgName
  6534. pp.FixmedinsCode = miConfig.Code
  6535. pp.RequestUrl = miConfig.Url
  6536. pp.Cainfo = miConfig.Cainfo
  6537. pp.SecretKey = miConfig.SecretKey
  6538. pp.AccessKey = miConfig.AccessKey
  6539. pp.OpterName = roles.UserName
  6540. var config []*models.HisXtDiagnoseConfig
  6541. for _, item := range diagnosis_ids {
  6542. id, _ := strconv.ParseInt(item, 10, 64)
  6543. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6544. config = append(config, &diagnosisConfig)
  6545. }
  6546. var pd models.PatientDtos
  6547. pd.PatnID = his.PsnNo
  6548. pd.PatnName = his.Name
  6549. pd.Gend = his.Gend
  6550. pd.Brdy = psn_info.Brdy
  6551. pd.Poolarea = his.InsuplcAdmdvs
  6552. pd.CurrMdtrtID = his.Number
  6553. var fed models.FsiEncounterDtos
  6554. fed.MdtrtID = his.Number
  6555. fed.MedinsID = miConfig.Code
  6556. fed.MedinsName = miConfig.OrgName
  6557. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6558. fed.MedMdtrtType = "1"
  6559. fed.MedinsType = "1"
  6560. fed.MedinsLv = "11"
  6561. tm := time.Unix(his.RecordDate, 0)
  6562. s_tm := tm.Format("2006-01-02 15:04:05")
  6563. fed.AdmDate = s_tm
  6564. fed.DscgDate = s_tm
  6565. fed.DscgMainDiseCodg = config[0].CountryCode
  6566. fed.DscgMainDiseName = config[0].CountryContentName
  6567. //诊断信息
  6568. var fdds []*models.FsiDiagnoseDtos
  6569. for index, item := range config {
  6570. if index == 0 {
  6571. var fdd models.FsiDiagnoseDtos
  6572. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6573. fdd.InoutDiseType = "1"
  6574. fdd.MaindiseFlag = "1"
  6575. fdd.DiseDate = s_tm
  6576. fdd.DiasSrtNo = "1"
  6577. fdd.DiseName = item.CountryContentName
  6578. fdd.DiseCodg = item.CountryCode
  6579. fdds = append(fdds, &fdd)
  6580. } else {
  6581. var fdd models.FsiDiagnoseDtos
  6582. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6583. fdd.InoutDiseType = "1"
  6584. fdd.MaindiseFlag = "1"
  6585. fdd.DiseDate = s_tm
  6586. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6587. fdd.DiseName = item.CountryContentName
  6588. fdd.DiseCodg = item.CountryCode
  6589. fdds = append(fdds, &fdd)
  6590. }
  6591. }
  6592. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6593. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6594. fed.AdmDeptName = department.Name
  6595. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6596. fed.DscgDeptName = department.Name
  6597. fed.MedType = order.MedType
  6598. //处方医嘱信息
  6599. var orders []*models.FsiOrderDtos
  6600. //for _, item := range prescriptions {
  6601. // for _, subItem := range item.HisDoctorAdviceInfo {
  6602. // var order models.FsiOrderDtos
  6603. // order.RxID = strconv.FormatInt(item.ID, 10)
  6604. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6605. // order.LongDrordFlag = "0"
  6606. // order.HilistType = "1"
  6607. // order.ChrgType = "1"
  6608. // order.DrordBhvr = "-"
  6609. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6610. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6611. // order.HilistLv = "1"
  6612. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6613. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6614. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6615. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6616. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6617. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6618. // order.OwnpayAmt = ""
  6619. // order.SelfpayAmt = ""
  6620. // order.Spec = ""
  6621. // order.SpecUnt = ""
  6622. // order.DrordBegnDate = s_tm
  6623. // order.DrordStopDate = ""
  6624. // order.DrordDrCodg = "1"
  6625. // order.DrordDeptName = department.Name
  6626. // order.DrordDrCodg = "1"
  6627. // order.DrordDrName = doctor_info.UserName
  6628. // order.DrordDrProfttl = ""
  6629. // order.CurrDrordFlag = "1"
  6630. // orders = append(orders, &order)
  6631. // }
  6632. // for _, subItem := range item.HisPrescriptionProject {
  6633. // if subItem.Type == 2 {
  6634. // var order models.FsiOrderDtos
  6635. // order.RxID = strconv.FormatInt(item.ID, 10)
  6636. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6637. // order.LongDrordFlag = "0"
  6638. // order.HilistType = "1"
  6639. // order.ChrgType = "1"
  6640. // order.DrordBhvr = "-"
  6641. // order.HilistCode = subItem.HisProject.MedicalCode
  6642. // order.HosplistName = subItem.HisProject.ProjectName
  6643. // order.HilistLv = "1"
  6644. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6645. // order.HosplistCode = subItem.HisProject.MedicalCode
  6646. // order.HosplistName = subItem.HisProject.ProjectName
  6647. // order.Cnt = subItem.Count
  6648. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6649. //
  6650. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6651. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6652. // order.OwnpayAmt = ""
  6653. // order.SelfpayAmt = ""
  6654. // order.Spec = ""
  6655. // order.SpecUnt = ""
  6656. // order.DrordBegnDate = s_tm
  6657. // order.DrordStopDate = ""
  6658. // order.DrordDrCodg = "1"
  6659. // order.DrordDeptName = department.Name
  6660. // order.DrordDrCodg = "1"
  6661. // order.DrordDrName = doctor_info.UserName
  6662. // order.DrordDrProfttl = ""
  6663. // order.CurrDrordFlag = "1"
  6664. // orders = append(orders, &order)
  6665. //
  6666. // }
  6667. // if subItem.Type == 3 {
  6668. //
  6669. // var order models.FsiOrderDtos
  6670. // order.RxID = strconv.FormatInt(item.ID, 10)
  6671. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6672. // order.LongDrordFlag = "0"
  6673. // order.HilistType = "1"
  6674. // order.ChrgType = "1"
  6675. // order.DrordBhvr = "-"
  6676. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6677. // order.HosplistName = subItem.GoodInfo.GoodName
  6678. // order.HilistLv = "1"
  6679. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6680. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6681. // order.HosplistName = subItem.GoodInfo.GoodName
  6682. // order.Cnt = subItem.Count
  6683. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6684. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6685. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6686. // order.OwnpayAmt = ""
  6687. // order.SelfpayAmt = ""
  6688. // order.Spec = ""
  6689. // order.SpecUnt = ""
  6690. // order.DrordBegnDate = s_tm
  6691. // order.DrordStopDate = ""
  6692. // order.DrordDrCodg = "1"
  6693. // order.DrordDeptName = department.Name
  6694. // order.DrordDrCodg = "1"
  6695. // order.DrordDrName = doctor_info.UserName
  6696. // order.DrordDrProfttl = ""
  6697. // order.CurrDrordFlag = "1"
  6698. // orders = append(orders, &order)
  6699. //
  6700. // }
  6701. // }
  6702. //}
  6703. for _, item := range prescriptions {
  6704. for _, subItem := range item.HisDoctorAdviceInfo {
  6705. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6706. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6707. var order models.FsiOrderDtos
  6708. order.RxID = strconv.FormatInt(item.ID, 10)
  6709. order.Rxno = strconv.FormatInt(item.ID, 10)
  6710. order.LongDrordFlag = "0"
  6711. order.HilistType = "1"
  6712. order.ChrgType = "1"
  6713. order.DrordBhvr = "0"
  6714. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6715. order.HosplistName = subItem.BaseDrugLib.DrugName
  6716. order.HilistLv = "1"
  6717. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6718. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6719. order.HosplistName = subItem.BaseDrugLib.DrugName
  6720. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6721. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6722. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6723. order.OwnpayAmt = ""
  6724. order.SelfpayAmt = ""
  6725. order.Spec = spec
  6726. order.SpecUnt = subItem.PrescribingNumberUnit
  6727. order.DrordBegnDate = s_tm
  6728. order.DrordStopDate = ""
  6729. order.DrordDrCodg = doctor_info.DoctorNumber
  6730. order.DrordDeptName = department.Name
  6731. order.DrordDeptCodg = department.Number
  6732. order.DrordDrName = doctor_info.UserName
  6733. order.DrordDrProfttl = "234"
  6734. order.CurrDrordFlag = "1"
  6735. orders = append(orders, &order)
  6736. }
  6737. }
  6738. for _, subItem := range item.HisPrescriptionProject {
  6739. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6740. var order models.FsiOrderDtos
  6741. order.RxID = strconv.FormatInt(item.ID, 10)
  6742. order.Rxno = strconv.FormatInt(item.ID, 10)
  6743. order.LongDrordFlag = "0"
  6744. order.HilistType = "1"
  6745. order.ChrgType = "1"
  6746. order.DrordBhvr = "0"
  6747. order.HilistCode = subItem.HisProject.MedicalCode
  6748. order.HosplistName = subItem.HisProject.ProjectName
  6749. order.HilistLv = "1"
  6750. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6751. order.HosplistCode = subItem.HisProject.MedicalCode
  6752. order.HosplistName = subItem.HisProject.ProjectName
  6753. order.Cnt = subItem.Count
  6754. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6755. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6756. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6757. order.OwnpayAmt = ""
  6758. order.SelfpayAmt = ""
  6759. order.Spec = subItem.Unit
  6760. order.SpecUnt = subItem.Unit
  6761. order.DrordBegnDate = s_tm
  6762. order.DrordStopDate = ""
  6763. order.DrordDrCodg = doctor_info.DoctorNumber
  6764. order.DrordDeptName = department.Name
  6765. order.DrordDeptCodg = department.Number
  6766. order.DrordDrName = doctor_info.UserName
  6767. order.DrordDrProfttl = "234"
  6768. order.CurrDrordFlag = "1"
  6769. orders = append(orders, &order)
  6770. }
  6771. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6772. var order models.FsiOrderDtos
  6773. order.RxID = strconv.FormatInt(item.ID, 10)
  6774. order.Rxno = strconv.FormatInt(item.ID, 10)
  6775. order.LongDrordFlag = "0"
  6776. order.HilistType = "1"
  6777. order.ChrgType = "1"
  6778. order.DrordBhvr = "0"
  6779. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6780. order.HosplistName = subItem.GoodInfo.GoodName
  6781. order.HilistLv = "1"
  6782. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6783. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6784. order.HosplistName = subItem.GoodInfo.GoodName
  6785. order.Cnt = subItem.Count
  6786. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6787. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6788. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6789. order.OwnpayAmt = ""
  6790. order.SelfpayAmt = ""
  6791. order.Spec = subItem.GoodInfo.SpecificationName
  6792. order.SpecUnt = subItem.Unit
  6793. order.DrordBegnDate = s_tm
  6794. order.DrordStopDate = ""
  6795. order.DrordDrCodg = doctor_info.DoctorNumber
  6796. order.DrordDeptName = department.Name
  6797. order.DrordDeptCodg = department.Number
  6798. order.DrordDrName = doctor_info.UserName
  6799. order.DrordDrProfttl = "234"
  6800. order.CurrDrordFlag = "1"
  6801. orders = append(orders, &order)
  6802. }
  6803. }
  6804. }
  6805. //处方医嘱信息
  6806. fed.MatnStas = "0"
  6807. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  6808. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  6809. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  6810. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  6811. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  6812. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  6813. fed.SetlTotlnum = "1"
  6814. fed.Insutype = his.Insutype
  6815. fed.ReimFlag = "0"
  6816. fed.OutSetlFlag = "0"
  6817. var fopd []*models.FsiOperationDtosData
  6818. data := make(map[string]interface{})
  6819. data["fed"] = fed
  6820. data["fdd"] = fdds
  6821. data["fod"] = orders
  6822. data["pd"] = pd
  6823. data["pp"] = pp
  6824. data["fopd"] = fopd
  6825. data["trig_scen"] = trig_scen
  6826. client := &http.Client{}
  6827. bytesData, _ := json.Marshal(data)
  6828. var req *http.Request
  6829. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6830. if miConfig.MdtrtareaAdmvs == "320921" {
  6831. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6832. } else {
  6833. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6834. }
  6835. resp, _ := client.Do(req)
  6836. defer resp.Body.Close()
  6837. body, ioErr := ioutil.ReadAll(resp.Body)
  6838. if ioErr != nil {
  6839. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6841. return res
  6842. }
  6843. var respJSON map[string]interface{}
  6844. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6845. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6847. return res
  6848. }
  6849. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6850. result, _ := json.Marshal(respJSON)
  6851. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6852. utils.ErrorLog("解析失败:%v", err)
  6853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6854. return res
  6855. }
  6856. return res
  6857. } else {
  6858. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6859. saveLog(output, input, "3102", "事中")
  6860. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6861. utils.ErrorLog("解析失败:%v", err)
  6862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6863. return
  6864. }
  6865. return res
  6866. }
  6867. return res
  6868. }
  6869. func (c *HisApiController) Check() {
  6870. psn_no := c.GetString("psn_no")
  6871. in := c.GetString("in")
  6872. mt := c.GetString("mt")
  6873. baseParams := models.BaseParams{
  6874. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  6875. FixmedinsCode: "H15049901371",
  6876. InsuplcAdmdvs: "150499",
  6877. MdtrtareaAdmvs: "150499",
  6878. OrgName: "赤峰费森血液透析中心",
  6879. Doctor: "1111",
  6880. }
  6881. service.Gdyb2001(baseParams, psn_no, in, mt)
  6882. }
  6883. func (c *HisApiController) GetPsnNcdsInfo() {
  6884. admin_user_id, _ := c.GetInt64("admin_user_id")
  6885. patient_id, _ := c.GetInt64("patient_id")
  6886. id, _ := c.GetInt64("id")
  6887. adminUser := c.GetAdminUserInfo()
  6888. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6889. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6890. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  6891. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6892. psn_record, _ := service.GetPsnNCDSRecordById(id)
  6893. //
  6894. //if psn_record.ID == 0 {
  6895. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6896. // return
  6897. //}
  6898. var res Result5301
  6899. var res10265 Result5301For10265
  6900. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6901. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6902. var api string
  6903. if miConfig.MdtrtareaAdmvs == "320921" {
  6904. 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 +
  6905. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6906. } else {
  6907. 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 +
  6908. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6909. }
  6910. resp, requestErr := http.Get(api)
  6911. if requestErr != nil {
  6912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6913. return
  6914. }
  6915. body, ioErr := ioutil.ReadAll(resp.Body)
  6916. if ioErr != nil {
  6917. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6919. return
  6920. }
  6921. var respJSON map[string]interface{}
  6922. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6925. return
  6926. }
  6927. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6928. result, _ := json.Marshal(respJSON)
  6929. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6930. utils.ErrorLog("解析失败:%v", err)
  6931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6932. return
  6933. }
  6934. res.ErrMsg = res10265.ErrMsg
  6935. res.Output = res10265.Output
  6936. res.InfRefmsgid = res10265.InfRefmsgid
  6937. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6938. res.Infcode = infocode
  6939. } else if miConfig.MdtrtareaAdmvs == "341203" {
  6940. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6941. var api string
  6942. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  6943. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6944. resp, requestErr := http.Get(api)
  6945. if requestErr != nil {
  6946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6947. return
  6948. }
  6949. body, ioErr := ioutil.ReadAll(resp.Body)
  6950. if ioErr != nil {
  6951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6953. return
  6954. }
  6955. var respJSON map[string]interface{}
  6956. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6959. return
  6960. }
  6961. status := respJSON["data"].(map[string]interface{})["status"].(string)
  6962. if status == "0" {
  6963. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  6964. c.ServeSuccessJSON(map[string]interface{}{
  6965. "failed_code": -10,
  6966. "msg": err_msg,
  6967. })
  6968. return
  6969. }
  6970. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6971. result, _ := json.Marshal(respJSON)
  6972. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6973. utils.ErrorLog("解析失败:%v", err)
  6974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6975. return
  6976. }
  6977. } else if miConfig.MdtrtareaAdmvs == "360302" {
  6978. p, _ := service.GetHisPatientById(patient_id)
  6979. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  6980. var dat map[string]interface{}
  6981. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6982. fmt.Println(dat)
  6983. } else {
  6984. fmt.Println(err)
  6985. }
  6986. userJSONBytes, _ := json.Marshal(dat)
  6987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6988. utils.ErrorLog("解析失败:%v", err)
  6989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6990. return
  6991. }
  6992. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6993. p, _ := service.GetHisPatientById(patient_id)
  6994. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  6995. var dat map[string]interface{}
  6996. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6997. fmt.Println(dat)
  6998. } else {
  6999. fmt.Println(err)
  7000. }
  7001. userJSONBytes, _ := json.Marshal(dat)
  7002. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7003. utils.ErrorLog("解析失败:%v", err)
  7004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7005. return
  7006. }
  7007. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7008. p, _ := service.GetHisPatientById(patient_id)
  7009. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7010. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7011. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7012. resp, requestErr := http.Get(api)
  7013. if requestErr != nil {
  7014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7015. return
  7016. }
  7017. body, ioErr := ioutil.ReadAll(resp.Body)
  7018. if ioErr != nil {
  7019. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7021. return
  7022. }
  7023. var respJSON map[string]interface{}
  7024. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7027. return
  7028. }
  7029. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7030. result, _ := json.Marshal(respJSON)
  7031. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7032. utils.ErrorLog("解析失败:%v", err)
  7033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7034. return
  7035. }
  7036. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7037. p, _ := service.GetHisPatientById(patient_id)
  7038. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7039. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7040. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7041. resp, requestErr := http.Get(api)
  7042. if requestErr != nil {
  7043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7044. return
  7045. }
  7046. body, ioErr := ioutil.ReadAll(resp.Body)
  7047. if ioErr != nil {
  7048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7050. return
  7051. }
  7052. var respJSON map[string]interface{}
  7053. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7056. return
  7057. }
  7058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7059. result, _ := json.Marshal(respJSON)
  7060. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7061. utils.ErrorLog("解析失败:%v", err)
  7062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7063. return
  7064. }
  7065. } else if miConfig.MdtrtareaAdmvs == "421300" {
  7066. p, _ := service.GetHisPatientById(patient_id)
  7067. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7068. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7069. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7070. resp, requestErr := http.Get(api)
  7071. if requestErr != nil {
  7072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7073. return
  7074. }
  7075. body, ioErr := ioutil.ReadAll(resp.Body)
  7076. if ioErr != nil {
  7077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7079. return
  7080. }
  7081. var respJSON map[string]interface{}
  7082. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7085. return
  7086. }
  7087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7088. result, _ := json.Marshal(respJSON)
  7089. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7090. utils.ErrorLog("解析失败:%v", err)
  7091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7092. return
  7093. }
  7094. } else if miConfig.MdtrtareaAdmvs == "441799" {
  7095. p, _ := service.GetHisPatientById(patient_id)
  7096. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  7097. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7098. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7099. resp, requestErr := http.Get(api)
  7100. if requestErr != nil {
  7101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7102. return
  7103. }
  7104. body, ioErr := ioutil.ReadAll(resp.Body)
  7105. if ioErr != nil {
  7106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7108. return
  7109. }
  7110. var respJSON map[string]interface{}
  7111. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7114. return
  7115. }
  7116. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7117. result, _ := json.Marshal(respJSON)
  7118. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7119. utils.ErrorLog("解析失败:%v", err)
  7120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7121. return
  7122. }
  7123. } else {
  7124. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  7125. var dat map[string]interface{}
  7126. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7127. fmt.Println(dat)
  7128. } else {
  7129. fmt.Println(err)
  7130. }
  7131. userJSONBytes, _ := json.Marshal(dat)
  7132. if miConfig.Code == "H15049901371" {
  7133. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7134. utils.ErrorLog("解析失败:%v", err)
  7135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7136. return
  7137. }
  7138. res.InfRefmsgid = res10265.InfRefmsgid
  7139. res.Output = res10265.Output
  7140. res.ErrMsg = res10265.ErrMsg
  7141. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7142. res.Infcode = infocode
  7143. } else {
  7144. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7145. utils.ErrorLog("解析失败:%v", err)
  7146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7147. return
  7148. }
  7149. }
  7150. }
  7151. if res.Infcode == 0 {
  7152. c.ServeSuccessJSON(map[string]interface{}{
  7153. "result": res.Output.Result,
  7154. })
  7155. }
  7156. }
  7157. func (c *HisApiController) CheckInsutype() {
  7158. his_patient_id, _ := c.GetInt64("his_patient_id")
  7159. admin_user_id, _ := c.GetInt64("admin_user_id")
  7160. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7161. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7162. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7163. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7164. var dat map[string]interface{}
  7165. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7166. fmt.Println(dat)
  7167. } else {
  7168. fmt.Println(err)
  7169. }
  7170. userJSONBytes, _ := json.Marshal(dat)
  7171. var res Result90100
  7172. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7173. utils.ErrorLog("解析失败:%v", err)
  7174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7175. return
  7176. }
  7177. if res.Infcode != 0 {
  7178. c.ServeSuccessJSON(map[string]interface{}{
  7179. "failed_code": -10,
  7180. "msg": res.ErrMsg,
  7181. })
  7182. return
  7183. } else {
  7184. fmt.Println(res)
  7185. }
  7186. }
  7187. func (c *HisApiController) CheckCardPWD() {
  7188. card_pwd := c.GetString("card_pwd")
  7189. his_patient_id, _ := c.GetInt64("his_patient_id")
  7190. admin_user_id, _ := c.GetInt64("admin_user_id")
  7191. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7192. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7193. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7194. psn, _ := service.GetPsnByPatientId(his.PatientId)
  7195. bas := strings.Split(psn.CardInfo, "|")
  7196. basNumber := bas[2]
  7197. if psn.InsuplcAdmdvs[:4] == "4403" {
  7198. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  7199. var dat map[string]interface{}
  7200. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7201. fmt.Println(dat)
  7202. } else {
  7203. fmt.Println(err)
  7204. }
  7205. userJSONBytes, _ := json.Marshal(dat)
  7206. var res Result90991
  7207. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7208. utils.ErrorLog("解析失败:%v", err)
  7209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7210. return
  7211. }
  7212. if res.Infcode != 0 {
  7213. c.ServeSuccessJSON(map[string]interface{}{
  7214. "failed_code": -10,
  7215. "msg": res.ErrMsg,
  7216. })
  7217. return
  7218. } else {
  7219. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  7220. var msg string
  7221. switch res.Output.Result.CardStat {
  7222. case "00":
  7223. msg = "未激活"
  7224. break
  7225. case "10":
  7226. msg = "激活"
  7227. break
  7228. case "20":
  7229. msg = "窗口挂失"
  7230. break
  7231. case "21":
  7232. msg = "电话挂失"
  7233. break
  7234. case "22":
  7235. msg = "单位网上申报挂失"
  7236. break
  7237. case "23":
  7238. msg = "保健办挂失"
  7239. break
  7240. case "24":
  7241. msg = "个人网上挂失"
  7242. break
  7243. case "25":
  7244. msg = "网上服务大厅挂失"
  7245. break
  7246. case "30":
  7247. msg = "注销"
  7248. break
  7249. case "40":
  7250. msg = "回收"
  7251. break
  7252. case "99":
  7253. msg = "制卡中(无效卡)"
  7254. break
  7255. }
  7256. c.ServeSuccessJSON(map[string]interface{}{
  7257. "failed_code": -10,
  7258. "msg": msg,
  7259. })
  7260. return
  7261. } else {
  7262. c.ServeSuccessJSON(map[string]interface{}{
  7263. "msg": "校验成功",
  7264. })
  7265. return
  7266. }
  7267. }
  7268. } else {
  7269. c.ServeSuccessJSON(map[string]interface{}{
  7270. "msg": "校验成功",
  7271. })
  7272. return
  7273. }
  7274. }
  7275. func (c *HisApiController) CheckCardPWDTwo() {
  7276. //card_pwd := c.GetString("card_pwd")
  7277. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7278. admin_user_id, _ := c.GetInt64("admin_user_id")
  7279. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7280. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7281. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  7282. var dat map[string]interface{}
  7283. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7284. fmt.Println(dat)
  7285. } else {
  7286. fmt.Println(err)
  7287. }
  7288. userJSONBytes, _ := json.Marshal(dat)
  7289. var res Result90991
  7290. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7291. utils.ErrorLog("解析失败:%v", err)
  7292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7293. return
  7294. }
  7295. if res.Infcode != 0 {
  7296. c.ServeSuccessJSON(map[string]interface{}{
  7297. "failed_code": -10,
  7298. "msg": res.ErrMsg,
  7299. })
  7300. return
  7301. } else {
  7302. if res.Output.Result.SscnoCheckStat == "0" {
  7303. var msg string
  7304. switch res.Output.Result.CardStat {
  7305. case "00":
  7306. msg = "未激活"
  7307. break
  7308. case "10":
  7309. msg = "激活"
  7310. break
  7311. case "20":
  7312. msg = "窗口挂失"
  7313. break
  7314. case "21":
  7315. msg = "电话挂失"
  7316. break
  7317. case "22":
  7318. msg = "单位网上申报挂失"
  7319. break
  7320. case "23":
  7321. msg = "保健办挂失"
  7322. break
  7323. case "24":
  7324. msg = "个人网上挂失"
  7325. break
  7326. case "25":
  7327. msg = "网上服务大厅挂失"
  7328. break
  7329. case "30":
  7330. msg = "注销"
  7331. break
  7332. case "40":
  7333. msg = "回收"
  7334. break
  7335. case "99":
  7336. msg = "制卡中(无效卡)"
  7337. break
  7338. }
  7339. c.ServeSuccessJSON(map[string]interface{}{
  7340. "failed_code": -10,
  7341. "msg": msg,
  7342. })
  7343. return
  7344. } else {
  7345. c.ServeSuccessJSON(map[string]interface{}{
  7346. "msg": "校验成功",
  7347. })
  7348. return
  7349. }
  7350. }
  7351. }
  7352. type ELeCertData struct {
  7353. Data struct {
  7354. Extra string `json:"extra"`
  7355. IDNo string `json:"idNo"`
  7356. IDType string `json:"idType"`
  7357. EcToken string `json:"ecToken"`
  7358. InsuOrg string `json:"insuOrg"`
  7359. UserName string `json:"userName"`
  7360. EcIndexNo string `json:"ecIndexNo"`
  7361. Gender string `json:"gender"`
  7362. Birthday string `json:"birthday"`
  7363. Nationality string `json:"nationality"`
  7364. Email string `json:"email"`
  7365. } `json:"OutData"`
  7366. }
  7367. func (c *HisApiController) ReadCard() {
  7368. id_card_type, _ := c.GetInt64("id_card_type")
  7369. admin_user_id, _ := c.GetInt64("admin_user_id")
  7370. certificates, _ := c.GetInt64("certificates")
  7371. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  7372. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7373. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7374. switch id_card_type {
  7375. case 1:
  7376. if miConfig.MdtrtareaAdmvs == "421300" {
  7377. var res ResultTwo
  7378. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7379. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7380. "&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)
  7381. resp, requestErr := http.Get(api)
  7382. if requestErr != nil {
  7383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7384. return
  7385. }
  7386. body, ioErr := ioutil.ReadAll(resp.Body)
  7387. if ioErr != nil {
  7388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7390. return
  7391. }
  7392. var respJSON map[string]interface{}
  7393. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7396. return
  7397. }
  7398. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7399. result, _ := json.Marshal(respJSON)
  7400. fmt.Println("log")
  7401. fmt.Println(string(result))
  7402. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7403. utils.ErrorLog("解析失败:%v", err)
  7404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7405. return
  7406. }
  7407. if res.Infcode == 0 {
  7408. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7409. if err == gorm.ErrRecordNotFound {
  7410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7411. return
  7412. } else if err != nil {
  7413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7414. return
  7415. } else {
  7416. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7417. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7418. infoStr := string(Iinfos)
  7419. idetinfoStr := string(Idetinfos)
  7420. var rf []*ResultFive
  7421. json.Unmarshal([]byte(infoStr), &rf)
  7422. var insutypes []*ResultFive
  7423. var insutype string
  7424. var is390 int = 0
  7425. var is310 int = 0
  7426. for _, item := range rf {
  7427. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7428. insutypes = append(insutypes, item)
  7429. }
  7430. }
  7431. if len(insutypes) == 1 {
  7432. insutype = insutypes[0].Insutype
  7433. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7434. } else {
  7435. for _, i := range insutypes {
  7436. if i.Insutype == "390" {
  7437. is390 = 1
  7438. }
  7439. if i.Insutype == "310" {
  7440. is310 = 1
  7441. }
  7442. }
  7443. }
  7444. if is390 == 1 {
  7445. insutype = "390"
  7446. }
  7447. if is310 == 1 {
  7448. insutype = "310"
  7449. }
  7450. if len(insutypes) == 0 {
  7451. insutype = "390"
  7452. }
  7453. var insuplc_admdvs string
  7454. for _, item := range rf {
  7455. if item.Insutype == insutype {
  7456. insuplc_admdvs = item.InsuplcAdmdvs
  7457. }
  7458. }
  7459. if strings.Contains(insuplc_admdvs, "4213") {
  7460. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  7461. }
  7462. psn := &models.HisPsn{
  7463. PsnNo: res.Output.Baseinfo.PsnNo,
  7464. PatientId: patient.ID,
  7465. Certno: res.Output.Baseinfo.Certno,
  7466. Gend: res.Output.Baseinfo.Gend,
  7467. Naty: res.Output.Baseinfo.Naty,
  7468. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7469. PsnName: res.Output.Baseinfo.PsnName,
  7470. Idetinfo: idetinfoStr,
  7471. Insuinfo: infoStr,
  7472. InsuplcAdmdvs: insuplc_admdvs,
  7473. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7474. }
  7475. service.CreateHisPsn(psn)
  7476. c.ServeSuccessJSON(map[string]interface{}{
  7477. "patient": patient,
  7478. "number": res.Output.Baseinfo.Certno,
  7479. })
  7480. }
  7481. } else {
  7482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7483. return
  7484. }
  7485. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7486. var res ResultTwo
  7487. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  7488. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7489. "&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)
  7490. resp, requestErr := http.Get(api)
  7491. if requestErr != nil {
  7492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7493. return
  7494. }
  7495. body, ioErr := ioutil.ReadAll(resp.Body)
  7496. if ioErr != nil {
  7497. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7499. return
  7500. }
  7501. var respJSON map[string]interface{}
  7502. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7503. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7505. return
  7506. }
  7507. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7508. result, _ := json.Marshal(respJSON)
  7509. fmt.Println("log")
  7510. fmt.Println(string(result))
  7511. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7512. utils.ErrorLog("解析失败:%v", err)
  7513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7514. return
  7515. }
  7516. if res.Infcode == 0 {
  7517. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7518. if err == gorm.ErrRecordNotFound {
  7519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7520. return
  7521. } else if err != nil {
  7522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7523. return
  7524. } else {
  7525. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7526. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7527. infoStr := string(Iinfos)
  7528. idetinfoStr := string(Idetinfos)
  7529. psn := &models.HisPsn{
  7530. PsnNo: res.Output.Baseinfo.PsnNo,
  7531. PatientId: patient.ID,
  7532. Certno: res.Output.Baseinfo.Certno,
  7533. Gend: res.Output.Baseinfo.Gend,
  7534. Naty: res.Output.Baseinfo.Naty,
  7535. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7536. PsnName: res.Output.Baseinfo.PsnName,
  7537. Idetinfo: idetinfoStr,
  7538. Insuinfo: infoStr,
  7539. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7540. }
  7541. service.CreateHisPsn(psn)
  7542. var rf []*ResultFive
  7543. json.Unmarshal([]byte(infoStr), &rf)
  7544. var insutypes []*ResultFive
  7545. var insutype string
  7546. var is390 int = 0
  7547. var is310 int = 0
  7548. for _, item := range rf {
  7549. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7550. insutypes = append(insutypes, item)
  7551. }
  7552. }
  7553. if len(insutypes) == 1 {
  7554. insutype = insutypes[0].Insutype
  7555. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7556. } else {
  7557. for _, i := range insutypes {
  7558. if i.Insutype == "390" {
  7559. is390 = 1
  7560. }
  7561. if i.Insutype == "310" {
  7562. is310 = 1
  7563. }
  7564. }
  7565. }
  7566. if is390 == 1 {
  7567. insutype = "390"
  7568. }
  7569. if is310 == 1 {
  7570. insutype = "310"
  7571. }
  7572. if len(insutypes) == 0 {
  7573. insutype = "310"
  7574. }
  7575. c.ServeSuccessJSON(map[string]interface{}{
  7576. "patient": patient,
  7577. "number": res.Output.Baseinfo.Certno,
  7578. "insutype": insutype,
  7579. })
  7580. }
  7581. } else {
  7582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7583. return
  7584. }
  7585. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7586. var res ResultTwo
  7587. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  7588. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7589. "&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)
  7590. resp, requestErr := http.Get(api)
  7591. if requestErr != nil {
  7592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7593. return
  7594. }
  7595. body, ioErr := ioutil.ReadAll(resp.Body)
  7596. if ioErr != nil {
  7597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7599. return
  7600. }
  7601. var respJSON map[string]interface{}
  7602. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7605. return
  7606. }
  7607. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7608. result, _ := json.Marshal(respJSON)
  7609. fmt.Println("log")
  7610. fmt.Println(string(result))
  7611. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7612. utils.ErrorLog("解析失败:%v", err)
  7613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7614. return
  7615. }
  7616. if res.Infcode == 0 {
  7617. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7618. if err == gorm.ErrRecordNotFound {
  7619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7620. return
  7621. } else if err != nil {
  7622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7623. return
  7624. } else {
  7625. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7626. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7627. infoStr := string(Iinfos)
  7628. idetinfoStr := string(Idetinfos)
  7629. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  7630. psn := &models.HisPsn{
  7631. PsnNo: res.Output.Baseinfo.PsnNo,
  7632. PatientId: patient.ID,
  7633. Certno: res.Output.Baseinfo.Certno,
  7634. Brdy: b,
  7635. Age: float64(age),
  7636. Gend: res.Output.Baseinfo.Gend,
  7637. Naty: res.Output.Baseinfo.Naty,
  7638. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7639. PsnName: res.Output.Baseinfo.PsnName,
  7640. Idetinfo: idetinfoStr,
  7641. Insuinfo: infoStr,
  7642. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7643. }
  7644. service.CreateHisPsn(psn)
  7645. var rf []*ResultFive
  7646. json.Unmarshal([]byte(infoStr), &rf)
  7647. var insutypes []*ResultFive
  7648. var insutype string
  7649. var is390 int = 0
  7650. var is310 int = 0
  7651. for _, item := range rf {
  7652. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7653. insutypes = append(insutypes, item)
  7654. }
  7655. }
  7656. if len(insutypes) == 1 {
  7657. insutype = insutypes[0].Insutype
  7658. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7659. } else {
  7660. for _, i := range insutypes {
  7661. if i.Insutype == "390" {
  7662. is390 = 1
  7663. }
  7664. if i.Insutype == "310" {
  7665. is310 = 1
  7666. }
  7667. }
  7668. }
  7669. if is390 == 1 {
  7670. insutype = "390"
  7671. }
  7672. if is310 == 1 {
  7673. insutype = "310"
  7674. }
  7675. if len(insutypes) == 0 {
  7676. insutype = "310"
  7677. }
  7678. c.ServeSuccessJSON(map[string]interface{}{
  7679. "patient": patient,
  7680. "number": res.Output.Baseinfo.Certno,
  7681. "insutype": insutype,
  7682. })
  7683. }
  7684. } else {
  7685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7686. return
  7687. }
  7688. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7689. var api string
  7690. if miConfig.MdtrtareaAdmvs == "320921" {
  7691. 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 +
  7692. "&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
  7693. fmt.Println(api)
  7694. } else {
  7695. 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 +
  7696. "&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)
  7697. }
  7698. resp, requestErr := http.Get(api)
  7699. if requestErr != nil {
  7700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7701. return
  7702. }
  7703. body, ioErr := ioutil.ReadAll(resp.Body)
  7704. if ioErr != nil {
  7705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7707. return
  7708. }
  7709. var respJSON map[string]interface{}
  7710. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7713. return
  7714. }
  7715. var status string
  7716. status = respJSON["data"].(map[string]interface{})["status"].(string)
  7717. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  7718. //console.log()
  7719. fmt.Println("type===")
  7720. fmt.Println(card_type)
  7721. var token string
  7722. var res ResultTwo //1101结果
  7723. var res10265 ResultTwo10265 //1101结果
  7724. var card_info string //卡信息
  7725. var busi_card_info string
  7726. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  7727. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7728. if status == "0" { //读卡成功
  7729. if card_type == "1" {
  7730. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7731. result, _ := json.Marshal(respJSON)
  7732. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7733. utils.ErrorLog("解析失败:%v", err)
  7734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7735. return
  7736. }
  7737. res.ErrMsg = res10265.ErrMsg
  7738. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7739. res.Infcode = infocode
  7740. res.Output = res10265.Output
  7741. res.InfRefmsgid = res10265.InfRefmsgid
  7742. } else {
  7743. //var card_info string //卡信息
  7744. //var busi_card_info string
  7745. token = respJSON["data"].(map[string]interface{})["token"].(string)
  7746. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7747. //fmt.Println(card_info)
  7748. //fmt.Println(busi_card_info)
  7749. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7750. result, _ := json.Marshal(respJSON)
  7751. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7752. utils.ErrorLog("解析失败:%v", err)
  7753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7754. return
  7755. }
  7756. res.ErrMsg = res10265.ErrMsg
  7757. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7758. res.Infcode = infocode
  7759. res.Output = res10265.Output
  7760. res.InfRefmsgid = res10265.InfRefmsgid
  7761. }
  7762. if res.Infcode == 0 {
  7763. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7764. if err == gorm.ErrRecordNotFound {
  7765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7766. return
  7767. } else if err != nil {
  7768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7769. return
  7770. } else {
  7771. if card_type == "1" {
  7772. bas := strings.Split(card_info, "|")
  7773. basNumber := bas[2]
  7774. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7775. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7776. infoStr := string(Iinfos)
  7777. idetinfoStr := string(Idetinfos)
  7778. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  7779. psn := &models.HisPsn{
  7780. PsnNo: res.Output.Baseinfo.PsnNo,
  7781. PatientId: patient.ID,
  7782. Certno: res.Output.Baseinfo.Certno,
  7783. Brdy: b,
  7784. Age: float64(age),
  7785. Gend: res.Output.Baseinfo.Gend,
  7786. Naty: res.Output.Baseinfo.Naty,
  7787. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7788. PsnName: res.Output.Baseinfo.PsnName,
  7789. Idetinfo: idetinfoStr,
  7790. Insuinfo: infoStr,
  7791. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7792. CardInfo: card_info,
  7793. VerifyNumber: busi_card_info,
  7794. }
  7795. service.CreateHisPsn(psn)
  7796. var rf []*ResultFive
  7797. json.Unmarshal([]byte(infoStr), &rf)
  7798. var insutypes []*ResultFive
  7799. var insutype string
  7800. var is390 int = 0
  7801. var is310 int = 0
  7802. for _, item := range rf {
  7803. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7804. insutypes = append(insutypes, item)
  7805. }
  7806. }
  7807. if len(insutypes) == 1 {
  7808. insutype = insutypes[0].Insutype
  7809. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7810. } else {
  7811. for _, i := range insutypes {
  7812. if i.Insutype == "390" {
  7813. is390 = 1
  7814. }
  7815. if i.Insutype == "310" {
  7816. is310 = 1
  7817. }
  7818. }
  7819. }
  7820. if is390 == 1 {
  7821. insutype = "390"
  7822. }
  7823. if is310 == 1 {
  7824. insutype = "310"
  7825. }
  7826. if len(insutypes) == 0 {
  7827. insutype = "310"
  7828. }
  7829. c.ServeSuccessJSON(map[string]interface{}{
  7830. "patient": patient,
  7831. "number": basNumber,
  7832. "insutype": insutype,
  7833. })
  7834. } else {
  7835. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7836. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7837. infoStr := string(Iinfos)
  7838. idetinfoStr := string(Idetinfos)
  7839. psn := &models.HisPsn{
  7840. PsnNo: res.Output.Baseinfo.PsnNo,
  7841. PatientId: patient.ID,
  7842. Certno: res.Output.Baseinfo.Certno,
  7843. Gend: res.Output.Baseinfo.Gend,
  7844. Naty: res.Output.Baseinfo.Naty,
  7845. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7846. PsnName: res.Output.Baseinfo.PsnName,
  7847. Idetinfo: idetinfoStr,
  7848. Insuinfo: infoStr,
  7849. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7850. CardInfo: card_info,
  7851. VerifyNumber: token,
  7852. }
  7853. service.CreateHisPsn(psn)
  7854. c.ServeSuccessJSON(map[string]interface{}{
  7855. "patient": patient,
  7856. "number": token,
  7857. })
  7858. }
  7859. }
  7860. } else {
  7861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7862. return
  7863. }
  7864. } else { //读卡失败
  7865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7866. return
  7867. }
  7868. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7869. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  7870. cardnum = DeleteExtraSpaceTwo(cardnum)
  7871. cardCode = DeleteExtraSpaceTwo(cardCode)
  7872. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  7873. name = DeleteExtraSpaceTwo(name)
  7874. errmsg = DeleteExtraSpaceTwo(errmsg)
  7875. cardnum = Remove0000(cardnum)
  7876. cardCode = Remove0000(cardCode)
  7877. id_card_no = Remove0000(id_card_no)
  7878. name = Remove0000(name)
  7879. errmsg = Remove0000(errmsg)
  7880. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  7881. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  7882. //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)
  7883. //fmt.Println(result2)
  7884. //fmt.Println(requestLog2)
  7885. //fmt.Println(errMsgLog2)
  7886. 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)
  7887. saveLog(result, requestLog, "1101", "获取人员信息")
  7888. fmt.Println(errMsgLog)
  7889. if len(errMsgLog) > 0 {
  7890. } else {
  7891. var dat map[string]interface{}
  7892. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7893. fmt.Println(dat)
  7894. } else {
  7895. fmt.Println(err)
  7896. }
  7897. userJSONBytes, _ := json.Marshal(dat)
  7898. var res ResultTwo
  7899. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7900. utils.ErrorLog("解析失败:%v", err)
  7901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7902. return
  7903. }
  7904. res.ErrMsg = errMsgLog
  7905. if res.Infcode == 0 {
  7906. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  7907. if err == gorm.ErrRecordNotFound {
  7908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7909. return
  7910. } else if err != nil {
  7911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7912. return
  7913. } else {
  7914. fmt.Println(res)
  7915. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7916. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7917. infoStr := string(Iinfos)
  7918. idetinfoStr := string(Idetinfos)
  7919. var rf []*ResultFive
  7920. json.Unmarshal([]byte(infoStr), &rf)
  7921. var insutypes []*ResultFive
  7922. var insutype string
  7923. var is390 int = 0
  7924. var is310 int = 0
  7925. for _, item := range rf {
  7926. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7927. insutypes = append(insutypes, item)
  7928. }
  7929. }
  7930. if len(insutypes) == 1 {
  7931. insutype = insutypes[0].Insutype
  7932. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7933. } else {
  7934. for _, i := range insutypes {
  7935. if i.Insutype == "390" {
  7936. is390 = 1
  7937. }
  7938. if i.Insutype == "310" {
  7939. is310 = 1
  7940. }
  7941. }
  7942. }
  7943. if is390 == 1 {
  7944. insutype = "390"
  7945. }
  7946. if is310 == 1 {
  7947. insutype = "310"
  7948. }
  7949. if len(insutypes) == 0 {
  7950. insutype = "390"
  7951. }
  7952. var insuplc_admdvs string
  7953. for _, item := range rf {
  7954. if item.Insutype == insutype {
  7955. insuplc_admdvs = item.InsuplcAdmdvs
  7956. }
  7957. }
  7958. psn := &models.HisPsn{
  7959. PsnNo: res.Output.Baseinfo.PsnNo,
  7960. PatientId: patient.ID,
  7961. Certno: res.Output.Baseinfo.Certno,
  7962. Gend: res.Output.Baseinfo.Gend,
  7963. Naty: res.Output.Baseinfo.Naty,
  7964. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7965. PsnName: res.Output.Baseinfo.PsnName,
  7966. Idetinfo: idetinfoStr,
  7967. Insuinfo: infoStr,
  7968. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7969. CardInfo: basStr,
  7970. VerifyNumber: "",
  7971. InsuplcAdmdvs: insuplc_admdvs,
  7972. }
  7973. service.CreateHisPsn(psn)
  7974. c.ServeSuccessJSON(map[string]interface{}{
  7975. "patient": patient,
  7976. "number": cardnum,
  7977. "insutype": insutype,
  7978. })
  7979. }
  7980. } else {
  7981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7982. return
  7983. }
  7984. }
  7985. } else if miConfig.MdtrtareaAdmvs == "360302" {
  7986. fmt.Println(initFlag)
  7987. fmt.Println("initFlag")
  7988. if initFlag == 0 {
  7989. c.TestGetJiangXiBasBaseInit()
  7990. }
  7991. basStr := c.GetBasBaseInfo()
  7992. if len(basStr) == 0 {
  7993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  7994. return
  7995. }
  7996. fmt.Println(basStr)
  7997. bas := strings.Split(basStr, "|")
  7998. basNumber := bas[1]
  7999. fmt.Println(basNumber)
  8000. card_sn := bas[3]
  8001. fmt.Println(card_sn)
  8002. 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, "")
  8003. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8004. var dat map[string]interface{}
  8005. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8006. fmt.Println(dat)
  8007. } else {
  8008. fmt.Println(err)
  8009. }
  8010. userJSONBytes, _ := json.Marshal(dat)
  8011. var res ResultTwo
  8012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8013. utils.ErrorLog("解析失败:%v", err)
  8014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8015. return
  8016. }
  8017. if res.Infcode == 0 {
  8018. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8019. if err == gorm.ErrRecordNotFound {
  8020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8021. return
  8022. } else if err != nil {
  8023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8024. return
  8025. } else {
  8026. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8027. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8028. infoStr := string(Iinfos)
  8029. idetinfoStr := string(Idetinfos)
  8030. var rf []*ResultFive
  8031. json.Unmarshal([]byte(infoStr), &rf)
  8032. var insutypes []*ResultFive
  8033. var insutype string
  8034. var is390 int = 0
  8035. var is310 int = 0
  8036. var insuplc_admdvs string
  8037. for _, item := range rf {
  8038. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8039. insutypes = append(insutypes, item)
  8040. }
  8041. }
  8042. if len(insutypes) == 1 {
  8043. insutype = insutypes[0].Insutype
  8044. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8045. } else {
  8046. for _, i := range insutypes {
  8047. if i.Insutype == "390" {
  8048. is390 = 1
  8049. }
  8050. if i.Insutype == "310" {
  8051. is310 = 1
  8052. }
  8053. }
  8054. }
  8055. if is390 == 1 {
  8056. insutype = "390"
  8057. }
  8058. if is310 == 1 {
  8059. insutype = "310"
  8060. }
  8061. if len(insutypes) == 0 {
  8062. insutype = "310"
  8063. }
  8064. for _, item := range rf {
  8065. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  8066. insuplc_admdvs = item.InsuplcAdmdvs
  8067. }
  8068. }
  8069. psn := &models.HisPsn{
  8070. PsnNo: res.Output.Baseinfo.PsnNo,
  8071. PatientId: patient.ID,
  8072. Certno: res.Output.Baseinfo.Certno,
  8073. Gend: res.Output.Baseinfo.Gend,
  8074. Naty: res.Output.Baseinfo.Naty,
  8075. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8076. PsnName: res.Output.Baseinfo.PsnName,
  8077. Idetinfo: idetinfoStr,
  8078. Insuinfo: infoStr,
  8079. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8080. CardInfo: basStr,
  8081. InsuplcAdmdvs: insuplc_admdvs,
  8082. VerifyNumber: "",
  8083. }
  8084. service.CreateHisPsn(psn)
  8085. c.ServeSuccessJSON(map[string]interface{}{
  8086. "patient": patient,
  8087. "number": basNumber,
  8088. "insutype": insutype,
  8089. })
  8090. }
  8091. } else {
  8092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8093. return
  8094. }
  8095. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8096. fmt.Println(initFlag)
  8097. fmt.Println("initFlag")
  8098. if initFlag == 0 {
  8099. c.TestGetHnBasBaseInit()
  8100. }
  8101. basStr := c.GetBasBaseInfo()
  8102. if len(basStr) == 0 {
  8103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8104. return
  8105. }
  8106. fmt.Println(basStr)
  8107. bas := strings.Split(basStr, "|")
  8108. basNumber := bas[1]
  8109. fmt.Println(basNumber)
  8110. card_sn := bas[3]
  8111. card_no := bas[2]
  8112. fmt.Println(card_sn)
  8113. name := bas[4]
  8114. name = ConvertToString(name, "gbk", "utf-8")
  8115. 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)
  8116. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8117. var dat map[string]interface{}
  8118. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8119. fmt.Println(dat)
  8120. } else {
  8121. fmt.Println(err)
  8122. }
  8123. userJSONBytes, _ := json.Marshal(dat)
  8124. var res ResultTwo
  8125. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8126. utils.ErrorLog("解析失败:%v", err)
  8127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8128. return
  8129. }
  8130. if res.Infcode == 0 {
  8131. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8132. if err == gorm.ErrRecordNotFound {
  8133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8134. return
  8135. } else if err != nil {
  8136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8137. return
  8138. } else {
  8139. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8140. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8141. infoStr := string(Iinfos)
  8142. idetinfoStr := string(Idetinfos)
  8143. psn := &models.HisPsn{
  8144. PsnNo: res.Output.Baseinfo.PsnNo,
  8145. PatientId: patient.ID,
  8146. Certno: res.Output.Baseinfo.Certno,
  8147. Gend: res.Output.Baseinfo.Gend,
  8148. Naty: res.Output.Baseinfo.Naty,
  8149. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8150. PsnName: res.Output.Baseinfo.PsnName,
  8151. Idetinfo: idetinfoStr,
  8152. Insuinfo: infoStr,
  8153. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8154. CardInfo: basStr,
  8155. VerifyNumber: "",
  8156. }
  8157. service.CreateHisPsn(psn)
  8158. var rf []*ResultFive
  8159. json.Unmarshal([]byte(infoStr), &rf)
  8160. var insutypes []*ResultFive
  8161. var insutype string
  8162. var is390 int = 0
  8163. var is310 int = 0
  8164. for _, item := range rf {
  8165. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8166. insutypes = append(insutypes, item)
  8167. }
  8168. }
  8169. if len(insutypes) == 1 {
  8170. insutype = insutypes[0].Insutype
  8171. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8172. } else {
  8173. for _, i := range insutypes {
  8174. if i.Insutype == "390" {
  8175. is390 = 1
  8176. }
  8177. if i.Insutype == "310" {
  8178. is310 = 1
  8179. }
  8180. }
  8181. }
  8182. if is390 == 1 {
  8183. insutype = "390"
  8184. }
  8185. if is310 == 1 {
  8186. insutype = "310"
  8187. }
  8188. if len(insutypes) == 0 {
  8189. insutype = "310"
  8190. }
  8191. c.ServeSuccessJSON(map[string]interface{}{
  8192. "patient": patient,
  8193. "number": basNumber,
  8194. "insutype": insutype,
  8195. })
  8196. }
  8197. } else {
  8198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8199. return
  8200. }
  8201. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8202. var api string
  8203. 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 +
  8204. "&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
  8205. fmt.Println(api)
  8206. resp, requestErr := http.Get(api)
  8207. if requestErr != nil {
  8208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8209. return
  8210. }
  8211. body, ioErr := ioutil.ReadAll(resp.Body)
  8212. if ioErr != nil {
  8213. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8215. return
  8216. }
  8217. var respJSON map[string]interface{}
  8218. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8221. return
  8222. }
  8223. var res ResultTwo //1101结果
  8224. var res10265 ResultTwo10265 //1101结果
  8225. var card_info string //卡信息
  8226. token := respJSON["data"].(map[string]interface{})["token"].(string)
  8227. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8228. result, _ := json.Marshal(respJSON)
  8229. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8230. utils.ErrorLog("解析失败:%v", err)
  8231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8232. return
  8233. }
  8234. res.ErrMsg = res10265.ErrMsg
  8235. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8236. res.Infcode = infocode
  8237. res.Output = res10265.Output
  8238. res.InfRefmsgid = res10265.InfRefmsgid
  8239. if res.Infcode == 0 {
  8240. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8241. if err == gorm.ErrRecordNotFound {
  8242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8243. return
  8244. } else if err != nil {
  8245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8246. return
  8247. } else {
  8248. bas := strings.Split(card_info, "|")
  8249. basNumber := bas[2]
  8250. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8251. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8252. infoStr := string(Iinfos)
  8253. idetinfoStr := string(Idetinfos)
  8254. psn := &models.HisPsn{
  8255. PsnNo: res.Output.Baseinfo.PsnNo,
  8256. PatientId: patient.ID,
  8257. Certno: res.Output.Baseinfo.Certno,
  8258. Gend: res.Output.Baseinfo.Gend,
  8259. Naty: res.Output.Baseinfo.Naty,
  8260. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8261. PsnName: res.Output.Baseinfo.PsnName,
  8262. Idetinfo: idetinfoStr,
  8263. Insuinfo: infoStr,
  8264. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8265. CardInfo: card_info,
  8266. VerifyNumber: token,
  8267. }
  8268. service.CreateHisPsn(psn)
  8269. var rf []*ResultFive
  8270. json.Unmarshal([]byte(infoStr), &rf)
  8271. var insutypes []*ResultFive
  8272. var insutype string
  8273. var is390 int = 0
  8274. var is310 int = 0
  8275. for _, item := range rf {
  8276. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8277. insutypes = append(insutypes, item)
  8278. }
  8279. }
  8280. if len(insutypes) == 1 {
  8281. insutype = insutypes[0].Insutype
  8282. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8283. } else {
  8284. for _, i := range insutypes {
  8285. if i.Insutype == "390" {
  8286. is390 = 1
  8287. }
  8288. if i.Insutype == "310" {
  8289. is310 = 1
  8290. }
  8291. }
  8292. }
  8293. if is390 == 1 {
  8294. insutype = "390"
  8295. }
  8296. if is310 == 1 {
  8297. insutype = "310"
  8298. }
  8299. if len(insutypes) == 0 {
  8300. insutype = "310"
  8301. }
  8302. c.ServeSuccessJSON(map[string]interface{}{
  8303. "patient": patient,
  8304. "number": basNumber,
  8305. "insutype": insutype,
  8306. })
  8307. }
  8308. } else {
  8309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8310. return
  8311. }
  8312. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8313. res := c.GetoleInfo()
  8314. if res.Infcode == 0 {
  8315. var result string
  8316. if res.Output.MdtrtCertType == "01" {
  8317. 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)
  8318. } else if res.Output.MdtrtCertType == "02" {
  8319. 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)
  8320. } else if res.Output.MdtrtCertType == "03" {
  8321. 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)
  8322. }
  8323. var dat map[string]interface{}
  8324. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8325. fmt.Println(dat)
  8326. } else {
  8327. fmt.Println(err)
  8328. }
  8329. userJSONBytes, _ := json.Marshal(dat)
  8330. var res2 ResultTwo
  8331. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8332. utils.ErrorLog("解析失败:%v", err)
  8333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8334. return
  8335. }
  8336. if res2.Infcode == 0 {
  8337. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8338. if err == gorm.ErrRecordNotFound {
  8339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8340. return
  8341. } else if err != nil {
  8342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8343. return
  8344. } else {
  8345. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8346. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8347. infoStr := string(Iinfos)
  8348. idetinfoStr := string(Idetinfos)
  8349. var rf []*ResultFive
  8350. json.Unmarshal([]byte(infoStr), &rf)
  8351. var insutypes []*ResultFive
  8352. var insutype string
  8353. var is390 int = 0
  8354. var is310 int = 0
  8355. //var insuplc_admdvs string
  8356. for _, item := range rf {
  8357. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8358. insutypes = append(insutypes, item)
  8359. }
  8360. }
  8361. if len(insutypes) == 1 {
  8362. insutype = insutypes[0].Insutype
  8363. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8364. } else {
  8365. for _, i := range insutypes {
  8366. if i.Insutype == "390" {
  8367. is390 = 1
  8368. }
  8369. if i.Insutype == "310" {
  8370. is310 = 1
  8371. }
  8372. }
  8373. }
  8374. if is390 == 1 {
  8375. insutype = "390"
  8376. }
  8377. if is310 == 1 {
  8378. insutype = "310"
  8379. }
  8380. if len(insutypes) == 0 {
  8381. insutype = "310"
  8382. }
  8383. psn := &models.HisPsn{
  8384. PsnNo: res2.Output.Baseinfo.PsnNo,
  8385. PatientId: patient.ID,
  8386. Certno: res2.Output.Baseinfo.Certno,
  8387. Gend: res2.Output.Baseinfo.Gend,
  8388. Naty: res2.Output.Baseinfo.Naty,
  8389. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8390. PsnName: res2.Output.Baseinfo.PsnName,
  8391. Idetinfo: idetinfoStr,
  8392. Insuinfo: infoStr,
  8393. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8394. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8395. VerifyNumber: res.Output.EcToken,
  8396. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8397. }
  8398. if res.Output.MdtrtCertType == "01" {
  8399. psn.VerifyNumber = res.Output.EcToken
  8400. //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)
  8401. } else if res.Output.MdtrtCertType == "02" {
  8402. psn.VerifyNumber = res.Output.MdtrtCertNo
  8403. //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)
  8404. } else if res.Output.MdtrtCertType == "03" {
  8405. psn.VerifyNumber = res.Output.MdtrtCertNo
  8406. //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)
  8407. }
  8408. var balc float64
  8409. for _, item := range rf {
  8410. if item.Insutype == insutype {
  8411. balc = item.Balc
  8412. }
  8413. }
  8414. service.CreateHisPsn(psn)
  8415. c.ServeSuccessJSON(map[string]interface{}{
  8416. "patient": patient,
  8417. "number": res.Output.CardNo,
  8418. "insutype": insutype,
  8419. "blac": balc,
  8420. "desc": idetinfoStr,
  8421. })
  8422. }
  8423. } else {
  8424. c.ServeSuccessJSON(map[string]interface{}{
  8425. "failed_code": -10,
  8426. "msg": res2.ErrMsg,
  8427. })
  8428. }
  8429. } else {
  8430. c.ServeSuccessJSON(map[string]interface{}{
  8431. "failed_code": -10,
  8432. "msg": res.ErrMsg,
  8433. })
  8434. }
  8435. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8436. var api string
  8437. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8438. "&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
  8439. fmt.Println(api)
  8440. resp, requestErr := http.Get(api)
  8441. if requestErr != nil {
  8442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8443. return
  8444. }
  8445. body, ioErr := ioutil.ReadAll(resp.Body)
  8446. if ioErr != nil {
  8447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8449. return
  8450. }
  8451. var respJSON map[string]interface{}
  8452. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8455. return
  8456. }
  8457. var status string
  8458. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8459. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8460. //console.log()
  8461. fmt.Println("type===")
  8462. fmt.Println(card_type)
  8463. var token string
  8464. var res ResultTwo //1101结果
  8465. //var res10265 ResultTwoesultTwo10265 //1101结果
  8466. var card_info string //卡信息
  8467. var busi_card_info string
  8468. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8469. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8470. if status == "0" { //读卡成功
  8471. if card_type == "1" {
  8472. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8473. result, _ := json.Marshal(respJSON)
  8474. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8475. utils.ErrorLog("解析失败:%v", err)
  8476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8477. return
  8478. }
  8479. } else {
  8480. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8481. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8482. result, _ := json.Marshal(respJSON)
  8483. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8484. utils.ErrorLog("解析失败:%v", err)
  8485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8486. return
  8487. }
  8488. }
  8489. if res.Infcode == 0 {
  8490. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8491. if err == gorm.ErrRecordNotFound {
  8492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8493. return
  8494. } else if err != nil {
  8495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8496. return
  8497. } else {
  8498. if card_type == "1" {
  8499. bas := strings.Split(card_info, "|")
  8500. basNumber := bas[2]
  8501. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8502. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8503. infoStr := string(Iinfos)
  8504. idetinfoStr := string(Idetinfos)
  8505. psn := &models.HisPsn{
  8506. PsnNo: res.Output.Baseinfo.PsnNo,
  8507. PatientId: patient.ID,
  8508. Certno: res.Output.Baseinfo.Certno,
  8509. Gend: res.Output.Baseinfo.Gend,
  8510. Naty: res.Output.Baseinfo.Naty,
  8511. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8512. PsnName: res.Output.Baseinfo.PsnName,
  8513. Idetinfo: idetinfoStr,
  8514. Insuinfo: infoStr,
  8515. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8516. CardInfo: card_info,
  8517. VerifyNumber: busi_card_info,
  8518. }
  8519. service.CreateHisPsn(psn)
  8520. var rf []*ResultFive
  8521. json.Unmarshal([]byte(infoStr), &rf)
  8522. var insutypes []*ResultFive
  8523. var insutype string
  8524. var is390 int = 0
  8525. var is310 int = 0
  8526. for _, item := range rf {
  8527. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8528. insutypes = append(insutypes, item)
  8529. }
  8530. }
  8531. if len(insutypes) == 1 {
  8532. insutype = insutypes[0].Insutype
  8533. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8534. } else {
  8535. for _, i := range insutypes {
  8536. if i.Insutype == "390" {
  8537. is390 = 1
  8538. }
  8539. if i.Insutype == "310" {
  8540. is310 = 1
  8541. }
  8542. }
  8543. }
  8544. if is390 == 1 {
  8545. insutype = "390"
  8546. }
  8547. if is310 == 1 {
  8548. insutype = "310"
  8549. }
  8550. if len(insutypes) == 0 {
  8551. insutype = "310"
  8552. }
  8553. c.ServeSuccessJSON(map[string]interface{}{
  8554. "patient": patient,
  8555. "number": basNumber,
  8556. "insutype": insutype,
  8557. })
  8558. } else {
  8559. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8560. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8561. infoStr := string(Iinfos)
  8562. idetinfoStr := string(Idetinfos)
  8563. psn := &models.HisPsn{
  8564. PsnNo: res.Output.Baseinfo.PsnNo,
  8565. PatientId: patient.ID,
  8566. Certno: res.Output.Baseinfo.Certno,
  8567. Gend: res.Output.Baseinfo.Gend,
  8568. Naty: res.Output.Baseinfo.Naty,
  8569. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8570. PsnName: res.Output.Baseinfo.PsnName,
  8571. Idetinfo: idetinfoStr,
  8572. Insuinfo: infoStr,
  8573. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8574. CardInfo: card_info,
  8575. VerifyNumber: token,
  8576. }
  8577. service.CreateHisPsn(psn)
  8578. c.ServeSuccessJSON(map[string]interface{}{
  8579. "patient": patient,
  8580. "number": token,
  8581. })
  8582. }
  8583. }
  8584. } else {
  8585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8586. return
  8587. }
  8588. } else { //读卡失败
  8589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8590. return
  8591. }
  8592. } else {
  8593. if initFlag == 0 {
  8594. c.TestGetBasBaseInit()
  8595. }
  8596. basStr := c.GetBasBaseInfo()
  8597. if len(basStr) == 0 {
  8598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8599. return
  8600. }
  8601. fmt.Println(basStr)
  8602. bas := strings.Split(basStr, "|")
  8603. basNumber := bas[1]
  8604. fmt.Println(basNumber)
  8605. card_sn := bas[3]
  8606. fmt.Println(card_sn)
  8607. cardNumber := bas[2]
  8608. fmt.Println(cardNumber)
  8609. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  8610. var result string
  8611. if bas[0][:2] == "44" {
  8612. 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)
  8613. } else {
  8614. 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)
  8615. }
  8616. var dat map[string]interface{}
  8617. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8618. fmt.Println(dat)
  8619. } else {
  8620. fmt.Println(err)
  8621. }
  8622. userJSONBytes, _ := json.Marshal(dat)
  8623. var res ResultTwo
  8624. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8625. utils.ErrorLog("解析失败:%v", err)
  8626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8627. return
  8628. }
  8629. if res.Infcode == 0 {
  8630. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8631. if err == gorm.ErrRecordNotFound {
  8632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8633. return
  8634. } else if err != nil {
  8635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8636. return
  8637. } else {
  8638. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8639. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8640. infoStr := string(Iinfos)
  8641. idetinfoStr := string(Idetinfos)
  8642. var rf []*ResultFive
  8643. json.Unmarshal([]byte(infoStr), &rf)
  8644. var insutypes []*ResultFive
  8645. var insutype string
  8646. var is390 int = 0
  8647. var is310 int = 0
  8648. var insuplc_admdvs string
  8649. for _, item := range rf {
  8650. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8651. insutypes = append(insutypes, item)
  8652. }
  8653. }
  8654. if len(insutypes) == 1 {
  8655. insutype = insutypes[0].Insutype
  8656. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8657. } else {
  8658. for _, i := range insutypes {
  8659. if i.Insutype == "390" {
  8660. is390 = 1
  8661. }
  8662. if i.Insutype == "310" {
  8663. is310 = 1
  8664. }
  8665. }
  8666. }
  8667. if is390 == 1 {
  8668. insutype = "390"
  8669. }
  8670. if is310 == 1 {
  8671. insutype = "310"
  8672. }
  8673. if len(insutypes) == 0 {
  8674. insutype = "310"
  8675. }
  8676. for _, item := range rf {
  8677. if item.Insutype == insutype {
  8678. insuplc_admdvs = item.InsuplcAdmdvs
  8679. }
  8680. }
  8681. psn := &models.HisPsn{
  8682. PsnNo: res.Output.Baseinfo.PsnNo,
  8683. PatientId: patient.ID,
  8684. Certno: res.Output.Baseinfo.Certno,
  8685. Gend: res.Output.Baseinfo.Gend,
  8686. Naty: res.Output.Baseinfo.Naty,
  8687. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8688. PsnName: res.Output.Baseinfo.PsnName,
  8689. Idetinfo: idetinfoStr,
  8690. Insuinfo: infoStr,
  8691. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8692. CardInfo: basStr,
  8693. VerifyNumber: "",
  8694. InsuplcAdmdvs: insuplc_admdvs,
  8695. }
  8696. service.CreateHisPsn(psn)
  8697. c.ServeSuccessJSON(map[string]interface{}{
  8698. "patient": patient,
  8699. "number": basNumber,
  8700. })
  8701. }
  8702. } else {
  8703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8704. return
  8705. }
  8706. break
  8707. }
  8708. case 2:
  8709. if miConfig.MdtrtareaAdmvs == "430800" {
  8710. if initFlag == 0 {
  8711. c.TestGetHnBasBaseInit()
  8712. }
  8713. SFZStr := c.GetSFZBaseInfo()
  8714. if len(SFZStr) == 0 {
  8715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8716. return
  8717. }
  8718. fmt.Println(SFZStr)
  8719. id_card_str := strings.Split(SFZStr, "^")
  8720. card_no := id_card_str[0]
  8721. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  8722. //name := id_card_str[1]
  8723. //name = ConvertToString(name, "gbk", "utf-8")
  8724. 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)
  8725. var dat map[string]interface{}
  8726. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8727. fmt.Println(dat)
  8728. } else {
  8729. fmt.Println(err)
  8730. }
  8731. userJSONBytes, _ := json.Marshal(dat)
  8732. var res ResultTwo
  8733. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8734. utils.ErrorLog("解析失败:%v", err)
  8735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8736. return
  8737. }
  8738. if res.Infcode == 0 {
  8739. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  8740. if err == gorm.ErrRecordNotFound {
  8741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8742. return
  8743. } else if err != nil {
  8744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8745. return
  8746. } else {
  8747. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8748. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8749. infoStr := string(Iinfos)
  8750. idetinfoStr := string(Idetinfos)
  8751. var rf []*ResultFive
  8752. json.Unmarshal([]byte(infoStr), &rf)
  8753. var insutypes []*ResultFive
  8754. var insutype string
  8755. var is390 int = 0
  8756. var is310 int = 0
  8757. for _, item := range rf {
  8758. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8759. insutypes = append(insutypes, item)
  8760. }
  8761. }
  8762. if len(insutypes) == 1 {
  8763. insutype = insutypes[0].Insutype
  8764. } else {
  8765. for _, i := range insutypes {
  8766. if i.Insutype == "390" {
  8767. is390 = 1
  8768. }
  8769. if i.Insutype == "310" {
  8770. is310 = 1
  8771. }
  8772. }
  8773. }
  8774. if is390 == 1 {
  8775. insutype = "390"
  8776. }
  8777. if is310 == 1 {
  8778. insutype = "310"
  8779. }
  8780. if len(insutypes) == 0 {
  8781. insutype = "310"
  8782. }
  8783. var InsuplcAdmdvs string
  8784. for _, item := range rf {
  8785. if item.Insutype == insutype {
  8786. InsuplcAdmdvs = item.InsuplcAdmdvs
  8787. }
  8788. }
  8789. psn := &models.HisPsn{
  8790. PsnNo: res.Output.Baseinfo.PsnNo,
  8791. PatientId: patient.ID,
  8792. Certno: res.Output.Baseinfo.Certno,
  8793. Gend: res.Output.Baseinfo.Gend,
  8794. Naty: res.Output.Baseinfo.Naty,
  8795. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8796. PsnName: res.Output.Baseinfo.PsnName,
  8797. Idetinfo: idetinfoStr,
  8798. Insuinfo: infoStr,
  8799. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8800. CardInfo: SFZStr,
  8801. VerifyNumber: "",
  8802. InsuplcAdmdvs: InsuplcAdmdvs,
  8803. }
  8804. service.CreateHisPsn(psn)
  8805. c.ServeSuccessJSON(map[string]interface{}{
  8806. "patient": patient,
  8807. "number": card_no,
  8808. "insutype": insutype,
  8809. })
  8810. }
  8811. } else {
  8812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8813. return
  8814. }
  8815. } else if miConfig.MdtrtareaAdmvs == "420200" {
  8816. var res ResultTwo
  8817. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  8818. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8819. "&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)
  8820. resp, requestErr := http.Get(api)
  8821. if requestErr != nil {
  8822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8823. return
  8824. }
  8825. body, ioErr := ioutil.ReadAll(resp.Body)
  8826. if ioErr != nil {
  8827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8829. return
  8830. }
  8831. var respJSON map[string]interface{}
  8832. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8835. return
  8836. }
  8837. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8838. result, _ := json.Marshal(respJSON)
  8839. fmt.Println("log")
  8840. fmt.Println(string(result))
  8841. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8842. utils.ErrorLog("解析失败:%v", err)
  8843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8844. return
  8845. }
  8846. if res.Infcode == 0 {
  8847. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8848. if err == gorm.ErrRecordNotFound {
  8849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8850. return
  8851. } else if err != nil {
  8852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8853. return
  8854. } else {
  8855. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8856. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8857. infoStr := string(Iinfos)
  8858. idetinfoStr := string(Idetinfos)
  8859. psn := &models.HisPsn{
  8860. PsnNo: res.Output.Baseinfo.PsnNo,
  8861. PatientId: patient.ID,
  8862. Certno: res.Output.Baseinfo.Certno,
  8863. Gend: res.Output.Baseinfo.Gend,
  8864. Naty: res.Output.Baseinfo.Naty,
  8865. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8866. PsnName: res.Output.Baseinfo.PsnName,
  8867. Idetinfo: idetinfoStr,
  8868. Insuinfo: infoStr,
  8869. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8870. }
  8871. service.CreateHisPsn(psn)
  8872. c.ServeSuccessJSON(map[string]interface{}{
  8873. "patient": patient,
  8874. "number": res.Output.Baseinfo.Certno,
  8875. })
  8876. }
  8877. } else {
  8878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8879. return
  8880. }
  8881. } else if miConfig.MdtrtareaAdmvs == "421182" {
  8882. var res ResultTwo
  8883. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  8884. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8885. "&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)
  8886. resp, requestErr := http.Get(api)
  8887. if requestErr != nil {
  8888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8889. return
  8890. }
  8891. body, ioErr := ioutil.ReadAll(resp.Body)
  8892. if ioErr != nil {
  8893. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8895. return
  8896. }
  8897. var respJSON map[string]interface{}
  8898. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8899. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8901. return
  8902. }
  8903. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8904. result, _ := json.Marshal(respJSON)
  8905. fmt.Println("log")
  8906. fmt.Println(string(result))
  8907. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8908. utils.ErrorLog("解析失败:%v", err)
  8909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8910. return
  8911. }
  8912. if res.Infcode == 0 {
  8913. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8914. if err == gorm.ErrRecordNotFound {
  8915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8916. return
  8917. } else if err != nil {
  8918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8919. return
  8920. } else {
  8921. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8922. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8923. infoStr := string(Iinfos)
  8924. idetinfoStr := string(Idetinfos)
  8925. psn := &models.HisPsn{
  8926. PsnNo: res.Output.Baseinfo.PsnNo,
  8927. PatientId: patient.ID,
  8928. Certno: res.Output.Baseinfo.Certno,
  8929. Gend: res.Output.Baseinfo.Gend,
  8930. Naty: res.Output.Baseinfo.Naty,
  8931. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8932. PsnName: res.Output.Baseinfo.PsnName,
  8933. Idetinfo: idetinfoStr,
  8934. Insuinfo: infoStr,
  8935. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8936. }
  8937. service.CreateHisPsn(psn)
  8938. c.ServeSuccessJSON(map[string]interface{}{
  8939. "patient": patient,
  8940. "number": res.Output.Baseinfo.Certno,
  8941. })
  8942. }
  8943. } else {
  8944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8945. return
  8946. }
  8947. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8948. res := c.GetoleInfo()
  8949. if res.Infcode == 0 {
  8950. var result string
  8951. if res.Output.MdtrtCertType == "01" {
  8952. 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)
  8953. } else if res.Output.MdtrtCertType == "02" {
  8954. 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)
  8955. } else if res.Output.MdtrtCertType == "03" {
  8956. 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)
  8957. }
  8958. var dat map[string]interface{}
  8959. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8960. fmt.Println(dat)
  8961. } else {
  8962. fmt.Println(err)
  8963. }
  8964. userJSONBytes, _ := json.Marshal(dat)
  8965. var res2 ResultTwo
  8966. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8967. utils.ErrorLog("解析失败:%v", err)
  8968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8969. return
  8970. }
  8971. if res2.Infcode == 0 {
  8972. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8973. if err == gorm.ErrRecordNotFound {
  8974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8975. return
  8976. } else if err != nil {
  8977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8978. return
  8979. } else {
  8980. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8981. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8982. infoStr := string(Iinfos)
  8983. idetinfoStr := string(Idetinfos)
  8984. var rf []*ResultFive
  8985. json.Unmarshal([]byte(infoStr), &rf)
  8986. var insutypes []*ResultFive
  8987. var insutype string
  8988. var is390 int = 0
  8989. var is310 int = 0
  8990. //var insuplc_admdvs string
  8991. for _, item := range rf {
  8992. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8993. insutypes = append(insutypes, item)
  8994. }
  8995. }
  8996. if len(insutypes) == 1 {
  8997. insutype = insutypes[0].Insutype
  8998. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8999. } else {
  9000. for _, i := range insutypes {
  9001. if i.Insutype == "390" {
  9002. is390 = 1
  9003. }
  9004. if i.Insutype == "310" {
  9005. is310 = 1
  9006. }
  9007. }
  9008. }
  9009. if is390 == 1 {
  9010. insutype = "390"
  9011. }
  9012. if is310 == 1 {
  9013. insutype = "310"
  9014. }
  9015. if len(insutypes) == 0 {
  9016. insutype = "310"
  9017. }
  9018. psn := &models.HisPsn{
  9019. PsnNo: res2.Output.Baseinfo.PsnNo,
  9020. PatientId: patient.ID,
  9021. //Brdy: res2.Output.Baseinfo.Brdy,
  9022. Certno: res2.Output.Baseinfo.Certno,
  9023. Gend: res2.Output.Baseinfo.Gend,
  9024. Naty: res2.Output.Baseinfo.Naty,
  9025. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9026. PsnName: res2.Output.Baseinfo.PsnName,
  9027. Idetinfo: idetinfoStr,
  9028. Insuinfo: infoStr,
  9029. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9030. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9031. VerifyNumber: res.Output.EcToken,
  9032. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9033. }
  9034. service.CreateHisPsn(psn)
  9035. var balc float64
  9036. for _, item := range rf {
  9037. if item.Insutype == insutype {
  9038. balc = item.Balc
  9039. }
  9040. }
  9041. c.ServeSuccessJSON(map[string]interface{}{
  9042. "patient": patient,
  9043. "number": res.Output.CardNo,
  9044. "insutype": insutype,
  9045. "blac": balc,
  9046. "desc": idetinfoStr,
  9047. })
  9048. }
  9049. } else {
  9050. c.ServeSuccessJSON(map[string]interface{}{
  9051. "failed_code": -10,
  9052. "msg": res2.ErrMsg,
  9053. })
  9054. }
  9055. } else {
  9056. c.ServeSuccessJSON(map[string]interface{}{
  9057. "failed_code": -10,
  9058. "msg": res.ErrMsg,
  9059. })
  9060. }
  9061. } else {
  9062. SFZStr := c.GetSFZBaseInfo()
  9063. id_card_str := strings.Split(SFZStr, "^")
  9064. id_card_number := id_card_str[0]
  9065. card_sn := ""
  9066. 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)
  9067. var dat map[string]interface{}
  9068. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9069. fmt.Println(dat)
  9070. } else {
  9071. fmt.Println(err)
  9072. }
  9073. userJSONBytes, _ := json.Marshal(dat)
  9074. var res ResultTwo
  9075. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9076. utils.ErrorLog("解析失败:%v", err)
  9077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9078. return
  9079. }
  9080. if res.Infcode == 0 {
  9081. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  9082. if err == gorm.ErrRecordNotFound {
  9083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9084. return
  9085. } else if err != nil {
  9086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9087. return
  9088. } else {
  9089. c.ServeSuccessJSON(map[string]interface{}{
  9090. "patient": patient,
  9091. "number": id_card_number,
  9092. })
  9093. }
  9094. } else {
  9095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9096. return
  9097. }
  9098. }
  9099. break
  9100. case 3:
  9101. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9102. var api string
  9103. if miConfig.MdtrtareaAdmvs == "320921" {
  9104. 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 +
  9105. "&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
  9106. fmt.Println(api)
  9107. } else {
  9108. 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 +
  9109. "&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)
  9110. }
  9111. resp, requestErr := http.Get(api)
  9112. if requestErr != nil {
  9113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9114. return
  9115. }
  9116. body, ioErr := ioutil.ReadAll(resp.Body)
  9117. if ioErr != nil {
  9118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9120. return
  9121. }
  9122. var respJSON map[string]interface{}
  9123. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9126. return
  9127. }
  9128. var status string
  9129. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9130. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9131. var token string
  9132. var res ResultTwo //1101结果
  9133. var res10265 ResultTwo10265 //1101结果
  9134. var card_info string //卡信息
  9135. var busi_card_info string
  9136. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9137. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9138. if status == "0" { //读卡成功
  9139. if card_type == "1" {
  9140. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9141. result, _ := json.Marshal(respJSON)
  9142. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9143. utils.ErrorLog("解析失败:%v", err)
  9144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9145. return
  9146. }
  9147. res.ErrMsg = res10265.ErrMsg
  9148. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9149. res.Infcode = infocode
  9150. res.Output = res10265.Output
  9151. res.InfRefmsgid = res10265.InfRefmsgid
  9152. } else {
  9153. //var card_info string //卡信息
  9154. //var busi_card_info string
  9155. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9156. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9157. //fmt.Println(card_info)
  9158. //fmt.Println(busi_card_info)
  9159. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9160. result, _ := json.Marshal(respJSON)
  9161. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9162. utils.ErrorLog("解析失败:%v", err)
  9163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9164. return
  9165. }
  9166. res.ErrMsg = res10265.ErrMsg
  9167. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9168. res.Infcode = infocode
  9169. res.Output = res10265.Output
  9170. res.InfRefmsgid = res10265.InfRefmsgid
  9171. }
  9172. if res.Infcode == 0 {
  9173. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9174. if err == gorm.ErrRecordNotFound {
  9175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9176. return
  9177. } else if err != nil {
  9178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9179. return
  9180. } else {
  9181. if card_type == "1" {
  9182. bas := strings.Split(card_info, "|")
  9183. basNumber := bas[2]
  9184. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9185. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9186. infoStr := string(Iinfos)
  9187. idetinfoStr := string(Idetinfos)
  9188. psn := &models.HisPsn{
  9189. PsnNo: res.Output.Baseinfo.PsnNo,
  9190. PatientId: patient.ID,
  9191. Certno: res.Output.Baseinfo.Certno,
  9192. //Brdy: res.Output.Baseinfo.Brdy,
  9193. Gend: res.Output.Baseinfo.Gend,
  9194. Naty: res.Output.Baseinfo.Naty,
  9195. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9196. PsnName: res.Output.Baseinfo.PsnName,
  9197. Idetinfo: idetinfoStr,
  9198. Insuinfo: infoStr,
  9199. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9200. CardInfo: card_info,
  9201. VerifyNumber: busi_card_info,
  9202. }
  9203. service.CreateHisPsn(psn)
  9204. c.ServeSuccessJSON(map[string]interface{}{
  9205. "patient": patient,
  9206. "number": basNumber,
  9207. })
  9208. } else {
  9209. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9210. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9211. infoStr := string(Iinfos)
  9212. idetinfoStr := string(Idetinfos)
  9213. psn := &models.HisPsn{
  9214. PsnNo: res.Output.Baseinfo.PsnNo,
  9215. PatientId: patient.ID,
  9216. Certno: res.Output.Baseinfo.Certno,
  9217. Gend: res.Output.Baseinfo.Gend,
  9218. Naty: res.Output.Baseinfo.Naty,
  9219. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9220. PsnName: res.Output.Baseinfo.PsnName,
  9221. Idetinfo: idetinfoStr,
  9222. Insuinfo: infoStr,
  9223. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9224. CardInfo: card_info,
  9225. VerifyNumber: token,
  9226. }
  9227. service.CreateHisPsn(psn)
  9228. var rf []*ResultFive
  9229. json.Unmarshal([]byte(infoStr), &rf)
  9230. var insutypes []*ResultFive
  9231. var insutype string
  9232. var is390 int = 0
  9233. var is310 int = 0
  9234. for _, item := range rf {
  9235. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9236. insutypes = append(insutypes, item)
  9237. }
  9238. }
  9239. if len(insutypes) == 1 {
  9240. insutype = insutypes[0].Insutype
  9241. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9242. } else {
  9243. for _, i := range insutypes {
  9244. if i.Insutype == "390" {
  9245. is390 = 1
  9246. }
  9247. if i.Insutype == "310" {
  9248. is310 = 1
  9249. }
  9250. }
  9251. }
  9252. if is390 == 1 {
  9253. insutype = "390"
  9254. }
  9255. if is310 == 1 {
  9256. insutype = "310"
  9257. }
  9258. if len(insutypes) == 0 {
  9259. insutype = "310"
  9260. }
  9261. c.ServeSuccessJSON(map[string]interface{}{
  9262. "patient": patient,
  9263. "number": token,
  9264. "insutype": insutype,
  9265. })
  9266. }
  9267. }
  9268. } else {
  9269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9270. return
  9271. }
  9272. } else { //读卡失败
  9273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9274. return
  9275. }
  9276. }
  9277. break
  9278. case 4:
  9279. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9280. var api string
  9281. if miConfig.MdtrtareaAdmvs == "320921" {
  9282. 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 +
  9283. "&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
  9284. fmt.Println(api)
  9285. } else {
  9286. 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 +
  9287. "&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)
  9288. }
  9289. resp, requestErr := http.Get(api)
  9290. if requestErr != nil {
  9291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9292. return
  9293. }
  9294. body, ioErr := ioutil.ReadAll(resp.Body)
  9295. if ioErr != nil {
  9296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9298. return
  9299. }
  9300. var respJSON map[string]interface{}
  9301. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9304. return
  9305. }
  9306. var status string
  9307. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9308. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9309. var token string
  9310. var res ResultTwo //1101结果
  9311. var res10265 ResultTwo10265 //1101结果
  9312. if status == "0" { //读卡成功
  9313. var card_info string //卡信息
  9314. var busi_card_info string
  9315. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9316. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9317. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9318. fmt.Println(card_info)
  9319. fmt.Println(busi_card_info)
  9320. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9321. result, _ := json.Marshal(respJSON)
  9322. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9323. utils.ErrorLog("解析失败:%v", err)
  9324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9325. return
  9326. }
  9327. res.ErrMsg = res10265.ErrMsg
  9328. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9329. res.Infcode = infocode
  9330. res.Output = res10265.Output
  9331. res.InfRefmsgid = res10265.InfRefmsgid
  9332. if res.Infcode == 0 {
  9333. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9334. if err == gorm.ErrRecordNotFound {
  9335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9336. return
  9337. } else if err != nil {
  9338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9339. return
  9340. } else {
  9341. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9342. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9343. infoStr := string(Iinfos)
  9344. idetinfoStr := string(Idetinfos)
  9345. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9346. psn := &models.HisPsn{
  9347. PsnNo: res.Output.Baseinfo.PsnNo,
  9348. PatientId: patient.ID,
  9349. Certno: res.Output.Baseinfo.Certno,
  9350. Brdy: b,
  9351. Age: float64(age),
  9352. //Brdy: res.Output.Baseinfo.Brdy,
  9353. Gend: res.Output.Baseinfo.Gend,
  9354. Naty: res.Output.Baseinfo.Naty,
  9355. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9356. PsnName: res.Output.Baseinfo.PsnName,
  9357. Idetinfo: idetinfoStr,
  9358. Insuinfo: infoStr,
  9359. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9360. CardInfo: card_info,
  9361. VerifyNumber: token,
  9362. }
  9363. var rf []*ResultFive
  9364. json.Unmarshal([]byte(infoStr), &rf)
  9365. var insutypes []*ResultFive
  9366. var insutype string
  9367. var is390 int = 0
  9368. var is310 int = 0
  9369. for _, item := range rf {
  9370. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9371. insutypes = append(insutypes, item)
  9372. }
  9373. }
  9374. if len(insutypes) == 1 {
  9375. insutype = insutypes[0].Insutype
  9376. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9377. } else {
  9378. for _, i := range insutypes {
  9379. if i.Insutype == "390" {
  9380. is390 = 1
  9381. }
  9382. if i.Insutype == "310" {
  9383. is310 = 1
  9384. }
  9385. }
  9386. }
  9387. if is390 == 1 {
  9388. insutype = "390"
  9389. }
  9390. if is310 == 1 {
  9391. insutype = "310"
  9392. }
  9393. if len(insutypes) == 0 {
  9394. insutype = "310"
  9395. }
  9396. service.CreateHisPsn(psn)
  9397. c.ServeSuccessJSON(map[string]interface{}{
  9398. "patient": patient,
  9399. "number": token,
  9400. "insutype": insutype,
  9401. })
  9402. }
  9403. } else {
  9404. c.ServeSuccessJSON(map[string]interface{}{
  9405. "failed_code": -10,
  9406. "msg": res.ErrMsg,
  9407. })
  9408. }
  9409. } else { //读卡失败
  9410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9411. return
  9412. }
  9413. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9414. var api string
  9415. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9416. "&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
  9417. resp, requestErr := http.Get(api)
  9418. if requestErr != nil {
  9419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9420. return
  9421. }
  9422. body, ioErr := ioutil.ReadAll(resp.Body)
  9423. if ioErr != nil {
  9424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9426. return
  9427. }
  9428. var respJSON map[string]interface{}
  9429. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9432. return
  9433. }
  9434. var status string
  9435. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9436. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9437. var token string
  9438. var res ResultTwo //1101结果
  9439. if status == "1" { //读卡成功
  9440. var card_info string //卡信息
  9441. var busi_card_info string
  9442. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9443. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9444. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9445. fmt.Println(card_info)
  9446. fmt.Println(busi_card_info)
  9447. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9448. result, _ := json.Marshal(respJSON)
  9449. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9450. utils.ErrorLog("解析失败:%v", err)
  9451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9452. return
  9453. }
  9454. if res.Infcode == 0 {
  9455. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9456. if err == gorm.ErrRecordNotFound {
  9457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9458. return
  9459. } else if err != nil {
  9460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9461. return
  9462. } else {
  9463. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9464. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9465. infoStr := string(Iinfos)
  9466. idetinfoStr := string(Idetinfos)
  9467. psn := &models.HisPsn{
  9468. PsnNo: res.Output.Baseinfo.PsnNo,
  9469. PatientId: patient.ID,
  9470. Certno: res.Output.Baseinfo.Certno,
  9471. Gend: res.Output.Baseinfo.Gend,
  9472. Naty: res.Output.Baseinfo.Naty,
  9473. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9474. PsnName: res.Output.Baseinfo.PsnName,
  9475. Idetinfo: idetinfoStr,
  9476. Insuinfo: infoStr,
  9477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9478. CardInfo: card_info,
  9479. VerifyNumber: token,
  9480. }
  9481. var rf []*ResultFive
  9482. json.Unmarshal([]byte(infoStr), &rf)
  9483. var insutypes []*ResultFive
  9484. var insutype string
  9485. var is390 int = 0
  9486. var is310 int = 0
  9487. for _, item := range rf {
  9488. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9489. insutypes = append(insutypes, item)
  9490. }
  9491. }
  9492. if len(insutypes) == 1 {
  9493. insutype = insutypes[0].Insutype
  9494. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9495. } else {
  9496. for _, i := range insutypes {
  9497. if i.Insutype == "390" {
  9498. is390 = 1
  9499. }
  9500. if i.Insutype == "310" {
  9501. is310 = 1
  9502. }
  9503. }
  9504. }
  9505. if is390 == 1 {
  9506. insutype = "390"
  9507. }
  9508. if is310 == 1 {
  9509. insutype = "310"
  9510. }
  9511. if len(insutypes) == 0 {
  9512. insutype = "310"
  9513. }
  9514. service.CreateHisPsn(psn)
  9515. c.ServeSuccessJSON(map[string]interface{}{
  9516. "patient": patient,
  9517. "number": token,
  9518. "insutype": insutype,
  9519. })
  9520. }
  9521. } else {
  9522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9523. return
  9524. }
  9525. } else { //读卡失败
  9526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9527. return
  9528. }
  9529. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9530. idNo := c.GetString("idNo")
  9531. userName := c.GetString("userName")
  9532. ecToken := c.GetString("ecToken")
  9533. insuOrg := c.GetString("insuOrg")
  9534. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9535. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9536. var res ResultTwo
  9537. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9538. utils.ErrorLog("解析失败:%v", err)
  9539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9540. return
  9541. }
  9542. if res.Infcode == 0 {
  9543. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9544. if err == gorm.ErrRecordNotFound {
  9545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9546. return
  9547. } else if err != nil {
  9548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9549. return
  9550. } else {
  9551. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9552. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9553. infoStr := string(Iinfos)
  9554. idetinfoStr := string(Idetinfos)
  9555. psn := &models.HisPsn{
  9556. PsnNo: res.Output.Baseinfo.PsnNo,
  9557. PatientId: patient.ID,
  9558. Certno: res.Output.Baseinfo.Certno,
  9559. Gend: res.Output.Baseinfo.Gend,
  9560. Naty: res.Output.Baseinfo.Naty,
  9561. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9562. PsnName: res.Output.Baseinfo.PsnName,
  9563. Idetinfo: idetinfoStr,
  9564. Insuinfo: infoStr,
  9565. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9566. CardInfo: "",
  9567. Stage: "1",
  9568. VerifyNumber: ecToken,
  9569. InsuplcAdmdvs: insuOrg,
  9570. }
  9571. service.CreateHisPsn(psn)
  9572. var rf []*ResultFive
  9573. json.Unmarshal([]byte(infoStr), &rf)
  9574. var insutypes []*ResultFive
  9575. var insutype string
  9576. var is390 int = 0
  9577. var is310 int = 0
  9578. for _, item := range rf {
  9579. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9580. insutypes = append(insutypes, item)
  9581. }
  9582. }
  9583. if len(insutypes) == 1 {
  9584. insutype = insutypes[0].Insutype
  9585. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9586. } else {
  9587. for _, i := range insutypes {
  9588. if i.Insutype == "390" {
  9589. is390 = 1
  9590. }
  9591. if i.Insutype == "310" {
  9592. is310 = 1
  9593. }
  9594. }
  9595. }
  9596. if is390 == 1 {
  9597. insutype = "390"
  9598. }
  9599. if is310 == 1 {
  9600. insutype = "310"
  9601. }
  9602. if len(insutypes) == 0 {
  9603. insutype = "310"
  9604. }
  9605. c.ServeSuccessJSON(map[string]interface{}{
  9606. "patient": patient,
  9607. "number": ecToken,
  9608. "insutype": insutype,
  9609. })
  9610. }
  9611. } else {
  9612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9613. return
  9614. }
  9615. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9616. //if initFlag == 0 {
  9617. //c.TestGetJiangXiBasBaseInit()
  9618. //}
  9619. //if initEleFlag == 0 {
  9620. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9621. //}
  9622. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  9623. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  9624. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9625. type ELeData struct {
  9626. Data struct {
  9627. IdNo string `json:"idNo"`
  9628. IdType string `json:"idType"`
  9629. UserName string `json:"userName"`
  9630. EcToken string `json:"ecToken"`
  9631. InsuOrg string `json:"insuOrg"`
  9632. Gender string `json:"gender"`
  9633. Birthday string `json:"birthday"`
  9634. Nationality string `json:"nationality"`
  9635. Email string `json:"email"`
  9636. Extra string `json:"extra"`
  9637. } `json:"data"`
  9638. Code int `json:"code"`
  9639. Message string `json:"message"`
  9640. }
  9641. var ele ELeData
  9642. err := json.Unmarshal([]byte(result), &ele)
  9643. if err != nil {
  9644. utils.ErrorLog("解析失败:%v", err)
  9645. }
  9646. token := ele.Data.EcToken
  9647. token = Remove0000(token)
  9648. 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)
  9649. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9650. var res ResultTwo
  9651. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9652. utils.ErrorLog("解析失败:%v", err)
  9653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9654. return
  9655. }
  9656. if res.Infcode == 0 {
  9657. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9658. if err == gorm.ErrRecordNotFound {
  9659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9660. return
  9661. } else if err != nil {
  9662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9663. return
  9664. } else {
  9665. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9666. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9667. infoStr := string(Iinfos)
  9668. idetinfoStr := string(Idetinfos)
  9669. psn := &models.HisPsn{
  9670. PsnNo: res.Output.Baseinfo.PsnNo,
  9671. PatientId: patient.ID,
  9672. Certno: res.Output.Baseinfo.Certno,
  9673. Gend: res.Output.Baseinfo.Gend,
  9674. Naty: res.Output.Baseinfo.Naty,
  9675. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9676. PsnName: res.Output.Baseinfo.PsnName,
  9677. Idetinfo: idetinfoStr,
  9678. Insuinfo: infoStr,
  9679. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9680. CardInfo: "",
  9681. VerifyNumber: token,
  9682. }
  9683. service.CreateHisPsn(psn)
  9684. var rf []*ResultFive
  9685. json.Unmarshal([]byte(infoStr), &rf)
  9686. var insutypes []*ResultFive
  9687. var insutype string
  9688. var is390 int = 0
  9689. var is310 int = 0
  9690. for _, item := range rf {
  9691. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9692. insutypes = append(insutypes, item)
  9693. }
  9694. }
  9695. if len(insutypes) == 1 {
  9696. insutype = insutypes[0].Insutype
  9697. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9698. } else {
  9699. for _, i := range insutypes {
  9700. if i.Insutype == "390" {
  9701. is390 = 1
  9702. }
  9703. if i.Insutype == "310" {
  9704. is310 = 1
  9705. }
  9706. }
  9707. }
  9708. if is390 == 1 {
  9709. insutype = "390"
  9710. }
  9711. if is310 == 1 {
  9712. insutype = "310"
  9713. }
  9714. if len(insutypes) == 0 {
  9715. insutype = "310"
  9716. }
  9717. c.ServeSuccessJSON(map[string]interface{}{
  9718. "patient": patient,
  9719. "number": token,
  9720. "insutype": insutype,
  9721. })
  9722. }
  9723. } else {
  9724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9725. return
  9726. }
  9727. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9728. //if initFlag == 0 {
  9729. c.TestGetJiangXiBasBaseInit()
  9730. //}
  9731. //if initEleFlag == 0 {
  9732. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9733. //}
  9734. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9735. type ELeData struct {
  9736. Data struct {
  9737. IdNo string `json:"idNo"`
  9738. IdType string `json:"idType"`
  9739. UserName string `json:"userName"`
  9740. EcToken string `json:"ecToken"`
  9741. InsuOrg string `json:"insuOrg"`
  9742. Gender string `json:"gender"`
  9743. Birthday string `json:"birthday"`
  9744. Nationality string `json:"nationality"`
  9745. Email string `json:"email"`
  9746. Extra string `json:"extra"`
  9747. } `json:"data"`
  9748. Code int `json:"code"`
  9749. Message string `json:"message"`
  9750. }
  9751. var ele ELeData
  9752. err := json.Unmarshal([]byte(json_result), &ele)
  9753. if err != nil {
  9754. utils.ErrorLog("解析失败:%v", err)
  9755. }
  9756. token := ele.Data.EcToken
  9757. token = Remove0000(token)
  9758. 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)
  9759. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9760. var res ResultTwo
  9761. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9762. utils.ErrorLog("解析失败:%v", err)
  9763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9764. return
  9765. }
  9766. if res.Infcode == 0 {
  9767. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9768. if err == gorm.ErrRecordNotFound {
  9769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9770. return
  9771. } else if err != nil {
  9772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9773. return
  9774. } else {
  9775. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9776. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9777. infoStr := string(Iinfos)
  9778. idetinfoStr := string(Idetinfos)
  9779. psn := &models.HisPsn{
  9780. PsnNo: res.Output.Baseinfo.PsnNo,
  9781. PatientId: patient.ID,
  9782. Certno: res.Output.Baseinfo.Certno,
  9783. Gend: res.Output.Baseinfo.Gend,
  9784. Naty: res.Output.Baseinfo.Naty,
  9785. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9786. PsnName: res.Output.Baseinfo.PsnName,
  9787. Idetinfo: idetinfoStr,
  9788. Insuinfo: infoStr,
  9789. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9790. CardInfo: "",
  9791. VerifyNumber: token,
  9792. }
  9793. service.CreateHisPsn(psn)
  9794. var rf []*ResultFive
  9795. json.Unmarshal([]byte(infoStr), &rf)
  9796. var insutypes []*ResultFive
  9797. var insutype string
  9798. var is390 int = 0
  9799. var is310 int = 0
  9800. for _, item := range rf {
  9801. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9802. insutypes = append(insutypes, item)
  9803. }
  9804. }
  9805. if len(insutypes) == 1 {
  9806. insutype = insutypes[0].Insutype
  9807. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9808. } else {
  9809. for _, i := range insutypes {
  9810. if i.Insutype == "390" {
  9811. is390 = 1
  9812. }
  9813. if i.Insutype == "310" {
  9814. is310 = 1
  9815. }
  9816. }
  9817. }
  9818. if is390 == 1 {
  9819. insutype = "390"
  9820. }
  9821. if is310 == 1 {
  9822. insutype = "310"
  9823. }
  9824. if len(insutypes) == 0 {
  9825. insutype = "310"
  9826. }
  9827. c.ServeSuccessJSON(map[string]interface{}{
  9828. "patient": patient,
  9829. "number": token,
  9830. "insutype": insutype,
  9831. })
  9832. }
  9833. } else {
  9834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9835. return
  9836. }
  9837. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9838. type ELeData struct {
  9839. Code string `json:"code"`
  9840. Data struct {
  9841. Aac002 string `json:"aac002"`
  9842. Aaz500 string `json:"aaz500"`
  9843. ActCardNo string `json:"actCardNo"`
  9844. Bab520 string `json:"bab520"`
  9845. Bkz543 string `json:"bkz543"`
  9846. BusinessType string `json:"businessType"`
  9847. CertfCodg string `json:"certfCodg"`
  9848. EcIndexNo string `json:"ecIndexNo"`
  9849. EcToken string `json:"ecToken"`
  9850. ID0000 string `json:"id0000"`
  9851. IDNo string `json:"idNo"`
  9852. IDType string `json:"idType"`
  9853. Idcode string `json:"idcode"`
  9854. IdentityToken string `json:"identity_token"`
  9855. InsuOrg string `json:"insuOrg"`
  9856. OfficeID string `json:"officeId"`
  9857. OfficeName string `json:"officeName"`
  9858. OperatorID string `json:"operatorId"`
  9859. OperatorName string `json:"operatorName"`
  9860. OrgID string `json:"orgId"`
  9861. UserName string `json:"userName"`
  9862. } `json:"data"`
  9863. Infno interface{} `json:"infno"`
  9864. Message string `json:"message"`
  9865. OrgID string `json:"orgId"`
  9866. TransType string `json:"transType"`
  9867. }
  9868. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  9869. outPutInfo = Remove0000(outPutInfo)
  9870. if len(outPutInfo) > 0 {
  9871. var ele ELeData
  9872. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9873. if err != nil {
  9874. utils.ErrorLog("解析失败:%v", err)
  9875. }
  9876. token := ele.Data.EcToken
  9877. fmt.Println(inputInfo)
  9878. fmt.Println(outPutInfo)
  9879. 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)
  9880. saveLog(result, requestLog, "1101", "获取人员信息")
  9881. var dat map[string]interface{}
  9882. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9883. fmt.Println(dat)
  9884. } else {
  9885. fmt.Println(err)
  9886. }
  9887. userJSONBytes, _ := json.Marshal(dat)
  9888. var res ResultTwo
  9889. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9890. utils.ErrorLog("解析失败:%v", err)
  9891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9892. return
  9893. }
  9894. res.ErrMsg = errMsgLog
  9895. if res.Infcode == 0 {
  9896. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  9897. if err == gorm.ErrRecordNotFound {
  9898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9899. return
  9900. } else if err != nil {
  9901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9902. return
  9903. } else {
  9904. fmt.Println(res)
  9905. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9906. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9907. infoStr := string(Iinfos)
  9908. idetinfoStr := string(Idetinfos)
  9909. psn := &models.HisPsn{
  9910. PsnNo: res.Output.Baseinfo.PsnNo,
  9911. PatientId: patient.ID,
  9912. Certno: res.Output.Baseinfo.Certno,
  9913. Gend: res.Output.Baseinfo.Gend,
  9914. Naty: res.Output.Baseinfo.Naty,
  9915. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9916. PsnName: res.Output.Baseinfo.PsnName,
  9917. Idetinfo: idetinfoStr,
  9918. Insuinfo: infoStr,
  9919. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9920. CardInfo: outPutInfo,
  9921. VerifyNumber: token,
  9922. InsuplcAdmdvs: ele.Data.InsuOrg,
  9923. }
  9924. service.CreateHisPsn(psn)
  9925. var rf []*ResultFive
  9926. json.Unmarshal([]byte(infoStr), &rf)
  9927. var insutypes []*ResultFive
  9928. var insutype string
  9929. var is390 int = 0
  9930. var is310 int = 0
  9931. for _, item := range rf {
  9932. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  9933. insutypes = append(insutypes, item)
  9934. }
  9935. }
  9936. if len(insutypes) == 1 {
  9937. insutype = insutypes[0].Insutype
  9938. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9939. } else {
  9940. for _, i := range insutypes {
  9941. if i.Insutype == "390" {
  9942. is390 = 1
  9943. }
  9944. if i.Insutype == "310" {
  9945. is310 = 1
  9946. }
  9947. }
  9948. }
  9949. if is390 == 1 {
  9950. insutype = "390"
  9951. }
  9952. if is310 == 1 {
  9953. insutype = "310"
  9954. }
  9955. if len(insutypes) == 0 {
  9956. insutype = "310"
  9957. }
  9958. c.ServeSuccessJSON(map[string]interface{}{
  9959. "patient": patient,
  9960. "number": token,
  9961. "insutype": insutype,
  9962. })
  9963. }
  9964. } else {
  9965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9966. return
  9967. }
  9968. }
  9969. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9970. var api string
  9971. 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 +
  9972. "&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
  9973. resp, requestErr := http.Get(api)
  9974. if requestErr != nil {
  9975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9976. return
  9977. }
  9978. body, ioErr := ioutil.ReadAll(resp.Body)
  9979. if ioErr != nil {
  9980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9982. return
  9983. }
  9984. var respJSON map[string]interface{}
  9985. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9988. return
  9989. }
  9990. var status string
  9991. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9992. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9993. var token string
  9994. var res ResultTwo //1101结果
  9995. var res10265 ResultTwo10265 //1101结果
  9996. if status == "0" { //读卡成功
  9997. var card_info string //卡信息
  9998. var busi_card_info string
  9999. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10000. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10001. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10002. fmt.Println(card_info)
  10003. fmt.Println(busi_card_info)
  10004. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10005. result, _ := json.Marshal(respJSON)
  10006. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10007. utils.ErrorLog("解析失败:%v", err)
  10008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10009. return
  10010. }
  10011. res.ErrMsg = res10265.ErrMsg
  10012. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10013. res.Infcode = infocode
  10014. res.Output = res10265.Output
  10015. res.InfRefmsgid = res10265.InfRefmsgid
  10016. if res.Infcode == 0 {
  10017. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10018. if err == gorm.ErrRecordNotFound {
  10019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10020. return
  10021. } else if err != nil {
  10022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10023. return
  10024. } else {
  10025. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10026. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10027. infoStr := string(Iinfos)
  10028. idetinfoStr := string(Idetinfos)
  10029. psn := &models.HisPsn{
  10030. PsnNo: res.Output.Baseinfo.PsnNo,
  10031. PatientId: patient.ID,
  10032. Certno: res.Output.Baseinfo.Certno,
  10033. Gend: res.Output.Baseinfo.Gend,
  10034. Naty: res.Output.Baseinfo.Naty,
  10035. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10036. PsnName: res.Output.Baseinfo.PsnName,
  10037. Idetinfo: idetinfoStr,
  10038. Insuinfo: infoStr,
  10039. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10040. CardInfo: card_info,
  10041. VerifyNumber: token,
  10042. }
  10043. var rf []*ResultFive
  10044. json.Unmarshal([]byte(infoStr), &rf)
  10045. var insutypes []*ResultFive
  10046. var insutype string
  10047. var is390 int = 0
  10048. var is310 int = 0
  10049. for _, item := range rf {
  10050. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10051. insutypes = append(insutypes, item)
  10052. }
  10053. }
  10054. if len(insutypes) == 1 {
  10055. insutype = insutypes[0].Insutype
  10056. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10057. } else {
  10058. for _, i := range insutypes {
  10059. if i.Insutype == "390" {
  10060. is390 = 1
  10061. }
  10062. if i.Insutype == "310" {
  10063. is310 = 1
  10064. }
  10065. }
  10066. }
  10067. if is390 == 1 {
  10068. insutype = "390"
  10069. }
  10070. if is310 == 1 {
  10071. insutype = "310"
  10072. }
  10073. if len(insutypes) == 0 {
  10074. insutype = "310"
  10075. }
  10076. service.CreateHisPsn(psn)
  10077. c.ServeSuccessJSON(map[string]interface{}{
  10078. "patient": patient,
  10079. "number": token,
  10080. "insutype": insutype,
  10081. })
  10082. }
  10083. } else {
  10084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10085. return
  10086. }
  10087. } else { //读卡失败
  10088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10089. return
  10090. }
  10091. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10092. res := c.GetoleInfo()
  10093. if res.Infcode == 0 {
  10094. var result string
  10095. if res.Output.MdtrtCertType == "01" {
  10096. 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)
  10097. } else if res.Output.MdtrtCertType == "02" {
  10098. 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)
  10099. } else if res.Output.MdtrtCertType == "03" {
  10100. 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)
  10101. }
  10102. var dat map[string]interface{}
  10103. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10104. fmt.Println(dat)
  10105. } else {
  10106. fmt.Println(err)
  10107. }
  10108. userJSONBytes, _ := json.Marshal(dat)
  10109. var res2 ResultTwo
  10110. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10111. utils.ErrorLog("解析失败:%v", err)
  10112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10113. return
  10114. }
  10115. if res2.Infcode == 0 {
  10116. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10117. if err == gorm.ErrRecordNotFound {
  10118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10119. return
  10120. } else if err != nil {
  10121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10122. return
  10123. } else {
  10124. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10125. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10126. infoStr := string(Iinfos)
  10127. idetinfoStr := string(Idetinfos)
  10128. var rf []*ResultFive
  10129. json.Unmarshal([]byte(infoStr), &rf)
  10130. var insutypes []*ResultFive
  10131. var insutype string
  10132. var is390 int = 0
  10133. var is310 int = 0
  10134. //var insuplc_admdvs string
  10135. for _, item := range rf {
  10136. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10137. insutypes = append(insutypes, item)
  10138. }
  10139. }
  10140. if len(insutypes) == 1 {
  10141. insutype = insutypes[0].Insutype
  10142. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10143. } else {
  10144. for _, i := range insutypes {
  10145. if i.Insutype == "390" {
  10146. is390 = 1
  10147. }
  10148. if i.Insutype == "310" {
  10149. is310 = 1
  10150. }
  10151. }
  10152. }
  10153. if is390 == 1 {
  10154. insutype = "390"
  10155. }
  10156. if is310 == 1 {
  10157. insutype = "310"
  10158. }
  10159. if len(insutypes) == 0 {
  10160. insutype = "310"
  10161. }
  10162. psn := &models.HisPsn{
  10163. PsnNo: res2.Output.Baseinfo.PsnNo,
  10164. PatientId: patient.ID,
  10165. Certno: res2.Output.Baseinfo.Certno,
  10166. Gend: res2.Output.Baseinfo.Gend,
  10167. Naty: res2.Output.Baseinfo.Naty,
  10168. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10169. PsnName: res2.Output.Baseinfo.PsnName,
  10170. Idetinfo: idetinfoStr,
  10171. Insuinfo: infoStr,
  10172. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10173. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10174. VerifyNumber: res.Output.EcToken,
  10175. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10176. }
  10177. if res.Output.MdtrtCertType == "01" {
  10178. psn.VerifyNumber = res.Output.EcToken
  10179. //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)
  10180. } else if res.Output.MdtrtCertType == "02" {
  10181. psn.VerifyNumber = res.Output.CardNo
  10182. //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)
  10183. } else if res.Output.MdtrtCertType == "03" {
  10184. psn.VerifyNumber = res.Output.MdtrtCertNo
  10185. //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)
  10186. }
  10187. service.CreateHisPsn(psn)
  10188. var balc float64
  10189. for _, item := range rf {
  10190. if item.Insutype == insutype {
  10191. balc = item.Balc
  10192. }
  10193. }
  10194. c.ServeSuccessJSON(map[string]interface{}{
  10195. "patient": patient,
  10196. "number": res.Output.CardNo,
  10197. "insutype": insutype,
  10198. "blac": balc,
  10199. "desc": idetinfoStr,
  10200. })
  10201. }
  10202. } else {
  10203. c.ServeSuccessJSON(map[string]interface{}{
  10204. "failed_code": -10,
  10205. "msg": res2.ErrMsg,
  10206. })
  10207. }
  10208. } else {
  10209. c.ServeSuccessJSON(map[string]interface{}{
  10210. "failed_code": -10,
  10211. "msg": res.ErrMsg,
  10212. })
  10213. }
  10214. } else {
  10215. type ELeData struct {
  10216. Code string `json:"code"`
  10217. Data struct {
  10218. Aac002 string `json:"aac002"`
  10219. Aaz500 string `json:"aaz500"`
  10220. ActCardNo string `json:"actCardNo"`
  10221. Bab520 string `json:"bab520"`
  10222. Bkz543 string `json:"bkz543"`
  10223. BusinessType string `json:"businessType"`
  10224. CertfCodg string `json:"certfCodg"`
  10225. EcIndexNo string `json:"ecIndexNo"`
  10226. EcToken string `json:"ecToken"`
  10227. ID0000 string `json:"id0000"`
  10228. IDNo string `json:"idNo"`
  10229. IDType string `json:"idType"`
  10230. Idcode string `json:"idcode"`
  10231. IdentityToken string `json:"identity_token"`
  10232. InsuOrg string `json:"insuOrg"`
  10233. OfficeID string `json:"officeId"`
  10234. OfficeName string `json:"officeName"`
  10235. OperatorID string `json:"operatorId"`
  10236. OperatorName string `json:"operatorName"`
  10237. OrgID string `json:"orgId"`
  10238. UserName string `json:"userName"`
  10239. } `json:"data"`
  10240. Infno interface{} `json:"infno"`
  10241. Message string `json:"message"`
  10242. OrgID string `json:"orgId"`
  10243. TransType string `json:"transType"`
  10244. }
  10245. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  10246. fmt.Println(result)
  10247. outPutInfo := Remove0000(result)
  10248. fmt.Println(outPutInfo)
  10249. if len(outPutInfo) > 0 {
  10250. var ele ELeData
  10251. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10252. if err != nil {
  10253. utils.ErrorLog("解析失败:%v", err)
  10254. }
  10255. token := ele.Data.EcToken
  10256. fmt.Println(outPutInfo)
  10257. 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)
  10258. saveLog(result, requestLog, "1101", "获取人员信息")
  10259. var dat map[string]interface{}
  10260. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10261. fmt.Println(dat)
  10262. } else {
  10263. fmt.Println(err)
  10264. }
  10265. userJSONBytes, _ := json.Marshal(dat)
  10266. var res ResultTwo
  10267. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10268. utils.ErrorLog("解析失败:%v", err)
  10269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10270. return
  10271. }
  10272. if res.Infcode == 0 {
  10273. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10274. if err == gorm.ErrRecordNotFound {
  10275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10276. return
  10277. } else if err != nil {
  10278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10279. return
  10280. } else {
  10281. fmt.Println(res)
  10282. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10283. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10284. infoStr := string(Iinfos)
  10285. idetinfoStr := string(Idetinfos)
  10286. psn := &models.HisPsn{
  10287. PsnNo: res.Output.Baseinfo.PsnNo,
  10288. PatientId: patient.ID,
  10289. Certno: res.Output.Baseinfo.Certno,
  10290. Gend: res.Output.Baseinfo.Gend,
  10291. Naty: res.Output.Baseinfo.Naty,
  10292. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10293. PsnName: res.Output.Baseinfo.PsnName,
  10294. Idetinfo: idetinfoStr,
  10295. Insuinfo: infoStr,
  10296. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10297. CardInfo: outPutInfo,
  10298. VerifyNumber: token,
  10299. InsuplcAdmdvs: ele.Data.InsuOrg,
  10300. }
  10301. service.CreateHisPsn(psn)
  10302. var rf []*ResultFive
  10303. json.Unmarshal([]byte(infoStr), &rf)
  10304. var insutypes []*ResultFive
  10305. var insutype string
  10306. var is390 int = 0
  10307. var is310 int = 0
  10308. for _, item := range rf {
  10309. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10310. insutypes = append(insutypes, item)
  10311. }
  10312. }
  10313. if len(insutypes) == 1 {
  10314. insutype = insutypes[0].Insutype
  10315. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10316. } else {
  10317. for _, i := range insutypes {
  10318. if i.Insutype == "390" {
  10319. is390 = 1
  10320. }
  10321. if i.Insutype == "310" {
  10322. is310 = 1
  10323. }
  10324. }
  10325. }
  10326. if is390 == 1 {
  10327. insutype = "390"
  10328. }
  10329. if is310 == 1 {
  10330. insutype = "310"
  10331. }
  10332. if len(insutypes) == 0 {
  10333. insutype = "310"
  10334. }
  10335. c.ServeSuccessJSON(map[string]interface{}{
  10336. "patient": patient,
  10337. "number": token,
  10338. "insutype": insutype,
  10339. })
  10340. }
  10341. } else {
  10342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10343. return
  10344. }
  10345. }
  10346. //fmt.Println(result)
  10347. //
  10348. //if initFlag == 0 {
  10349. // c.TestGetBasBaseInit()
  10350. //}
  10351. //token := c.GetEleBaseInfo()
  10352. //
  10353. //token = Remove0000(token)
  10354. //
  10355. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  10356. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  10357. ////
  10358. //var res ResultTwo
  10359. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10360. // utils.ErrorLog("解析失败:%v", err)
  10361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10362. // return
  10363. //}
  10364. //
  10365. //if res.Infcode == 0 {
  10366. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10367. // if err == gorm.ErrRecordNotFound {
  10368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10369. // return
  10370. // } else if err != nil {
  10371. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10372. // return
  10373. //
  10374. // } else {
  10375. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10376. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10377. // infoStr := string(Iinfos)
  10378. // idetinfoStr := string(Idetinfos)
  10379. //
  10380. //
  10381. //
  10382. //
  10383. // var rf []*ResultFive
  10384. // json.Unmarshal([]byte(infoStr), &rf)
  10385. //
  10386. // var insutypes []*ResultFive
  10387. // var insutype string
  10388. // var is390 int = 0
  10389. // var is310 int = 0
  10390. // var insuplc_admdvs string
  10391. //
  10392. // for _, item := range rf {
  10393. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10394. // insutypes = append(insutypes, item)
  10395. // }
  10396. // }
  10397. //
  10398. // if len(insutypes) == 1 {
  10399. // insutype = insutypes[0].Insutype
  10400. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10401. // } else {
  10402. // for _, i := range insutypes {
  10403. // if i.Insutype == "390" {
  10404. // is390 = 1
  10405. // }
  10406. //
  10407. // if i.Insutype == "310" {
  10408. // is310 = 1
  10409. // }
  10410. // }
  10411. // }
  10412. // if is390 == 1 {
  10413. // insutype = "390"
  10414. // }
  10415. //
  10416. // if is310 == 1 {
  10417. // insutype = "310"
  10418. // }
  10419. // if len(insutypes) == 0 {
  10420. // insutype = "310"
  10421. // }
  10422. // for _, item := range rf {
  10423. // if item.Insutype == insutype {
  10424. // insuplc_admdvs = item.InsuplcAdmdvs
  10425. // }
  10426. // }
  10427. // psn := &models.HisPsn{
  10428. // PsnNo: res.Output.Baseinfo.PsnNo,
  10429. // Age: res.Output.Baseinfo.Age,
  10430. // PatientId: patient.ID,
  10431. // Certno: res.Output.Baseinfo.Certno,
  10432. // Brdy: res.Output.Baseinfo.Brdy,
  10433. // Gend: res.Output.Baseinfo.Gend,
  10434. // Naty: res.Output.Baseinfo.Naty,
  10435. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10436. // PsnName: res.Output.Baseinfo.PsnName,
  10437. // Idetinfo: idetinfoStr,
  10438. // Insuinfo: infoStr,
  10439. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10440. // CardInfo: "",
  10441. // VerifyNumber: token,
  10442. // InsuplcAdmdvs: insuplc_admdvs,
  10443. // }
  10444. // service.CreateHisPsn(psn)
  10445. //
  10446. // c.ServeSuccessJSON(map[string]interface{}{
  10447. // "patient": patient,
  10448. // "number": token,
  10449. // })
  10450. // }
  10451. //} else {
  10452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10453. // return
  10454. //}
  10455. }
  10456. break
  10457. case 5:
  10458. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10459. var api string
  10460. if miConfig.MdtrtareaAdmvs == "320921" {
  10461. 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 +
  10462. "&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
  10463. fmt.Println(api)
  10464. } else {
  10465. 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 +
  10466. "&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)
  10467. }
  10468. resp, requestErr := http.Get(api)
  10469. if requestErr != nil {
  10470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10471. return
  10472. }
  10473. body, ioErr := ioutil.ReadAll(resp.Body)
  10474. if ioErr != nil {
  10475. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10477. return
  10478. }
  10479. var respJSON map[string]interface{}
  10480. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10481. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10483. return
  10484. }
  10485. var status string
  10486. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10487. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10488. var token string
  10489. var res ResultTwo //1101结果
  10490. var res10265 ResultTwo10265 //1101结果
  10491. if status == "0" { //读卡成功
  10492. var card_info string //卡信息
  10493. //var busi_card_info string
  10494. var auth_info string
  10495. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10496. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10497. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10498. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  10499. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10500. result, _ := json.Marshal(respJSON)
  10501. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10502. utils.ErrorLog("解析失败:%v", err)
  10503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10504. return
  10505. }
  10506. res.ErrMsg = res10265.ErrMsg
  10507. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10508. res.Infcode = infocode
  10509. res.Output = res10265.Output
  10510. res.InfRefmsgid = res10265.InfRefmsgid
  10511. if res.Infcode == 0 {
  10512. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10513. if err == gorm.ErrRecordNotFound {
  10514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10515. return
  10516. } else if err != nil {
  10517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10518. return
  10519. } else {
  10520. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10521. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10522. infoStr := string(Iinfos)
  10523. idetinfoStr := string(Idetinfos)
  10524. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10525. psn := &models.HisPsn{
  10526. PsnNo: res.Output.Baseinfo.PsnNo,
  10527. PatientId: patient.ID,
  10528. Certno: res.Output.Baseinfo.Certno,
  10529. Gend: res.Output.Baseinfo.Gend,
  10530. Brdy: b,
  10531. Age: float64(age),
  10532. Naty: res.Output.Baseinfo.Naty,
  10533. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10534. PsnName: res.Output.Baseinfo.PsnName,
  10535. Idetinfo: idetinfoStr,
  10536. Insuinfo: infoStr,
  10537. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10538. CardInfo: card_info,
  10539. VerifyNumber: token,
  10540. AuthInfo: auth_info,
  10541. }
  10542. var rf []*ResultFive
  10543. json.Unmarshal([]byte(infoStr), &rf)
  10544. var insutypes []*ResultFive
  10545. var insutype string
  10546. var is390 int = 0
  10547. var is310 int = 0
  10548. for _, item := range rf {
  10549. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10550. insutypes = append(insutypes, item)
  10551. }
  10552. }
  10553. if len(insutypes) == 1 {
  10554. insutype = insutypes[0].Insutype
  10555. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10556. } else {
  10557. for _, i := range insutypes {
  10558. if i.Insutype == "390" {
  10559. is390 = 1
  10560. }
  10561. if i.Insutype == "310" {
  10562. is310 = 1
  10563. }
  10564. }
  10565. }
  10566. if is390 == 1 {
  10567. insutype = "390"
  10568. }
  10569. if is310 == 1 {
  10570. insutype = "310"
  10571. }
  10572. if len(insutypes) == 0 {
  10573. insutype = "310"
  10574. }
  10575. service.CreateHisPsn(psn)
  10576. c.ServeSuccessJSON(map[string]interface{}{
  10577. "patient": patient,
  10578. "number": token,
  10579. "insutype": insutype,
  10580. })
  10581. }
  10582. } else {
  10583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10584. return
  10585. }
  10586. } else { //读卡失败
  10587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10588. return
  10589. }
  10590. }
  10591. break
  10592. }
  10593. }
  10594. var initFlag int64 = 0
  10595. var initEleFlag int64 = 0
  10596. func (c *HisApiController) TestGetBasBaseInit() {
  10597. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10598. Iinit := DllDef.MustFindProc("Init")
  10599. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10600. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  10601. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  10602. if ret != 0 {
  10603. fmt.Println("SSCard的报错原因:", err)
  10604. fmt.Println("SSCard的运算结果为:", ret)
  10605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10606. return
  10607. }
  10608. result := int(ret)
  10609. fmt.Println("SSCard的运算结果为1:", result)
  10610. initFlag = 1
  10611. return
  10612. }
  10613. func (c *HisApiController) HandleJiangXiReadCard() {
  10614. fmt.Println("~~~~~~")
  10615. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10616. admin_user_id, _ := c.GetInt64("admin_user_id")
  10617. id_card_type, _ := c.GetInt64("id_card_type")
  10618. //certificates, _ := c.GetInt64("certificates")
  10619. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10620. if initFlag == 0 {
  10621. c.TestGetJiangXiBasBaseInit()
  10622. }
  10623. basStr := c.GetBasBaseInfo()
  10624. if len(basStr) == 0 {
  10625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10626. return
  10627. }
  10628. fmt.Println(basStr)
  10629. bas := strings.Split(basStr, "|")
  10630. basNumber := bas[1]
  10631. fmt.Println(basNumber)
  10632. card_sn := bas[3]
  10633. fmt.Println(card_sn)
  10634. 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, "")
  10635. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  10636. var dat map[string]interface{}
  10637. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10638. fmt.Println(dat)
  10639. } else {
  10640. fmt.Println(err)
  10641. }
  10642. userJSONBytes, _ := json.Marshal(dat)
  10643. var res ResultTwo
  10644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10645. utils.ErrorLog("解析失败:%v", err)
  10646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10647. return
  10648. }
  10649. if res.Infcode == 0 {
  10650. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  10651. if err == gorm.ErrRecordNotFound {
  10652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10653. return
  10654. } else if err != nil {
  10655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10656. return
  10657. } else {
  10658. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10659. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10660. infoStr := string(Iinfos)
  10661. idetinfoStr := string(Idetinfos)
  10662. psn := &models.HisPsn{
  10663. PsnNo: res.Output.Baseinfo.PsnNo,
  10664. PatientId: patient.ID,
  10665. Certno: res.Output.Baseinfo.Certno,
  10666. Gend: res.Output.Baseinfo.Gend,
  10667. Naty: res.Output.Baseinfo.Naty,
  10668. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10669. PsnName: res.Output.Baseinfo.PsnName,
  10670. Idetinfo: idetinfoStr,
  10671. Insuinfo: infoStr,
  10672. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10673. CardInfo: basStr,
  10674. VerifyNumber: "",
  10675. }
  10676. service.CreateHisPsn(psn)
  10677. c.ServeSuccessJSON(map[string]interface{}{
  10678. "patient": patient,
  10679. "number": basNumber,
  10680. })
  10681. }
  10682. } else {
  10683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10684. return
  10685. }
  10686. }
  10687. func (c *HisApiController) TestGetHnBasBaseInit() {
  10688. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10689. Iinit := DllDef.MustFindProc("Init")
  10690. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10691. //http://10.77.211.236/CSB/hsa-fsi-1303
  10692. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  10693. if ret != 0 {
  10694. fmt.Println("SSCard的报错原因:", err)
  10695. fmt.Println("SSCard的运算结果为:", ret)
  10696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10697. return
  10698. }
  10699. result := int(ret)
  10700. fmt.Println("SSCard的运算结果为1:", result)
  10701. initFlag = 1
  10702. return
  10703. }
  10704. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  10705. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10706. Iinit := DllDef.MustFindProc("Init")
  10707. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10708. //http://10.77.211.236/CSB/hsa-fsi-1303
  10709. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  10710. if ret != 0 {
  10711. fmt.Println("SSCard的报错原因:", err)
  10712. fmt.Println("SSCard的运算结果为:", ret)
  10713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10714. return
  10715. }
  10716. result := int(ret)
  10717. fmt.Println("SSCard的运算结果为1:", result)
  10718. initFlag = 1
  10719. return
  10720. }
  10721. func (c *HisApiController) GetSFZBaseInfo() string {
  10722. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10723. readCard := DllDef.MustFindProc("ReadSFZ")
  10724. if readCard == nil {
  10725. fmt.Println("readcard is nil")
  10726. readCard = DllDef.MustFindProc("ReadSFZ")
  10727. }
  10728. str := make([]byte, 8096)
  10729. str1 := make([]byte, 8096)
  10730. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  10731. fmt.Println(r)
  10732. return Remove0000(string(str))
  10733. }
  10734. func (c *HisApiController) GetEleBaseInfo() string {
  10735. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10736. readCard := DllDef.MustFindProc("GetQRBase")
  10737. fmt.Println(readCard)
  10738. if readCard == nil {
  10739. fmt.Println("readcard is nil")
  10740. readCard = DllDef.MustFindProc("GetQRBase")
  10741. }
  10742. str := make([]byte, 1024)
  10743. str1 := make([]byte, 1024)
  10744. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  10745. fmt.Println(ret2)
  10746. fmt.Println(string(str1))
  10747. fmt.Println(string(str))
  10748. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10749. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  10750. if ret2 != 0 {
  10751. return ""
  10752. }
  10753. return string(str)
  10754. }
  10755. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  10756. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10757. readCard := DllDef.MustFindProc("NationEcTrans")
  10758. fmt.Println(readCard)
  10759. fmt.Println("!!!!!")
  10760. pBusiCardInfo := make([]byte, 2048)
  10761. input := make(map[string]interface{})
  10762. inputData := make(map[string]interface{})
  10763. inputData["orgId"] = code
  10764. inputData["businessType"] = "01101"
  10765. inputData["operatorId"] = "1"
  10766. inputData["operatorName"] = "admin"
  10767. inputData["officeId"] = "001"
  10768. inputData["officeName"] = "血透室"
  10769. inputData["deviceType"] = ""
  10770. input["data"] = inputData
  10771. input["orgId"] = code
  10772. input["transType"] = "ec.query"
  10773. bytesData, _ := json.Marshal(input)
  10774. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  10775. fmt.Println(ret2)
  10776. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10777. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10778. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  10779. }
  10780. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  10781. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10782. readCard := DllDef.MustFindProc("NationEcTrans")
  10783. fmt.Println(readCard)
  10784. fmt.Println("!!!!!")
  10785. pBusiCardInfo := make([]byte, 2048)
  10786. input := make(map[string]interface{})
  10787. inputData := make(map[string]interface{})
  10788. inputData["orgId"] = code
  10789. inputData["businessType"] = "01101"
  10790. inputData["operatorId"] = "9"
  10791. inputData["operatorName"] = "admin"
  10792. inputData["officeId"] = "001"
  10793. inputData["officeName"] = "血透室"
  10794. inputData["deviceType"] = ""
  10795. input["data"] = inputData
  10796. input["orgId"] = code
  10797. input["transType"] = "ec.query"
  10798. bytesData, _ := json.Marshal(input)
  10799. 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])))
  10800. fmt.Println(ret2)
  10801. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10802. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10803. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  10804. }
  10805. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  10806. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10807. readCard := DllDef.MustFindProc("NationEcTrans")
  10808. fmt.Println(readCard)
  10809. fmt.Println("!!!!!")
  10810. pBusiCardInfo := make([]byte, 2048)
  10811. input := make(map[string]interface{})
  10812. inputData := make(map[string]interface{})
  10813. inputData["orgId"] = code
  10814. inputData["businessType"] = "01301"
  10815. inputData["operatorId"] = "9"
  10816. inputData["operatorName"] = "admin"
  10817. inputData["officeId"] = "001"
  10818. inputData["officeName"] = "血透室"
  10819. inputData["deviceType"] = ""
  10820. input["data"] = inputData
  10821. input["orgId"] = code
  10822. input["transType"] = "ec.query"
  10823. bytesData, _ := json.Marshal(input)
  10824. 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])))
  10825. fmt.Println(ret2)
  10826. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10827. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10828. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  10829. }
  10830. func GetJxEleBaseInfo(org_id int64) string {
  10831. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10832. readCard := DllDef.MustFindProc("NationEcTrans")
  10833. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10834. if readCard == nil {
  10835. fmt.Println("readcard is nil")
  10836. readCard = DllDef.MustFindProc("NationEcTrans")
  10837. }
  10838. str1 := make([]byte, 1024)
  10839. data := make(map[string]interface{})
  10840. inputData := make(map[string]interface{})
  10841. inputData["orgId"] = miConfig.Code
  10842. inputData["businessType"] = "01101"
  10843. inputData["operatorId"] = "test001"
  10844. inputData["operatorName"] = "cn"
  10845. inputData["officeId"] = "32760"
  10846. inputData["officeName"] = "waike"
  10847. inputData["deviceType"] = ""
  10848. data["data"] = inputData
  10849. data["transType"] = "ec.query"
  10850. data["extra "] = ""
  10851. data["orgId"] = miConfig.Code
  10852. bytesData, _ := json.Marshal(data)
  10853. //bytesData, _ := json.Marshal(data)
  10854. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  10855. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  10856. fmt.Println(ret2)
  10857. fmt.Println(string(str1))
  10858. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10859. if ret2 != 0 {
  10860. return ""
  10861. }
  10862. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  10863. }
  10864. func GetJxEleBaseInitInfo(org_id int64) string {
  10865. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10866. readCard := DllDef.MustFindProc("NationEcTrans")
  10867. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10868. if readCard == nil {
  10869. fmt.Println("readcard is nil")
  10870. readCard = DllDef.MustFindProc("NationEcTrans")
  10871. }
  10872. str1 := make([]byte, 2048)
  10873. data := make(map[string]interface{})
  10874. inputData := make(map[string]interface{})
  10875. inputData["orgId"] = miConfig.Code
  10876. inputData["businessType"] = "01101"
  10877. inputData["operatorId"] = "1"
  10878. inputData["operatorName"] = "huangchuang"
  10879. inputData["officeId"] = "101"
  10880. inputData["officeName"] = "xuetou"
  10881. inputData["deviceType"] = ""
  10882. data["data"] = inputData
  10883. data["transType"] = "ec.query"
  10884. data["orgId"] = miConfig.Code
  10885. bytesData, _ := json.Marshal(data)
  10886. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  10887. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  10888. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  10889. fmt.Println(ret2)
  10890. fmt.Println(string(str1))
  10891. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10892. if ret2 != 0 {
  10893. return ""
  10894. }
  10895. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  10896. initEleFlag = 1
  10897. }
  10898. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  10899. }
  10900. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  10901. // // 构建命令
  10902. // cmd := exec.Command("python", "b.py")
  10903. //
  10904. // // 执行命令并等待完成
  10905. // output, err := cmd.CombinedOutput()
  10906. // if err != nil {
  10907. // fmt.Println("Error executing Python script:", err)
  10908. // return
  10909. // }
  10910. //
  10911. // // 打印Python脚本的输出
  10912. // fmt.Println(string(output))
  10913. //}
  10914. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  10915. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  10916. readCard := DllDef.MustFindProc("gxyb_call")
  10917. if readCard == nil {
  10918. fmt.Println("readcard is nil")
  10919. readCard = DllDef.MustFindProc("gxyb_call")
  10920. }
  10921. str := make([]byte, 1024)
  10922. str1 := make([]byte, 1024)
  10923. //data := make(map[string]interface{})
  10924. currentTime := time.Now()
  10925. // 格式化时间为 "YYYYMMDDHH24MISS"
  10926. formattedTime := currentTime.Format("20060102150405")
  10927. inputData := make(map[string]interface{})
  10928. inputData2 := make(map[string]interface{})
  10929. inputData["transNo"] = "1401"
  10930. inputData["transType"] = "passwordCheck"
  10931. inputData["timestamp"] = formattedTime
  10932. inputData2["fixmedinsCode"] = code
  10933. inputData2["psnNo"] = ""
  10934. inputData["data"] = inputData2
  10935. jsonBytes, err := json.Marshal(inputData)
  10936. if err != nil {
  10937. fmt.Println("Error encoding map to JSON:", err)
  10938. }
  10939. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  10940. fmt.Println(string(str1))
  10941. fmt.Println(string(str))
  10942. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10943. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  10944. if ret2 != 0 {
  10945. return ""
  10946. }
  10947. return string(str)
  10948. }
  10949. func (c *HisApiController) GetoleInfo() Response {
  10950. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  10951. defer ole.CoUninitialize()
  10952. // Replace with the ProgID or CLSID of your COM object
  10953. progID := "YinHai.XJ.Actual.Interface.New"
  10954. // Create COM object
  10955. unknown, err := oleutil.CreateObject(progID)
  10956. if err != nil {
  10957. fmt.Println("Unable to create COM object:", err)
  10958. }
  10959. defer unknown.Release()
  10960. // Query for the IDispatch interface
  10961. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  10962. if err != nil {
  10963. fmt.Println("Unable to get IDispatch interface:", err)
  10964. }
  10965. defer dispatch.Release()
  10966. // Prepare parameters
  10967. transNo := "1401"
  10968. transType := "passwordCheck"
  10969. timestamp := time.Now().Unix()
  10970. fixmedinsCode := "H45072101171"
  10971. psnNo := ""
  10972. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  10973. result2 := ""
  10974. // Call COM object's method using the IDispatch interface
  10975. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  10976. fmt.Println(resulr)
  10977. fmt.Println(result2)
  10978. if err != nil {
  10979. fmt.Println("调用COM对象方法失败:", err)
  10980. }
  10981. var response Response
  10982. err2 := json.Unmarshal([]byte(result2), &response)
  10983. if err2 != nil {
  10984. fmt.Println("解析JSON失败:", err)
  10985. }
  10986. return response
  10987. }
  10988. func (c *HisApiController) GetBasBaseInfo() string {
  10989. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10990. readCard := DllDef.MustFindProc("ReadCardBas")
  10991. if readCard == nil {
  10992. fmt.Println("readcard is nil")
  10993. readCard = DllDef.MustFindProc("ReadCardBas")
  10994. }
  10995. str := make([]byte, 1024)
  10996. str1 := make([]byte, 1024)
  10997. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  10998. fmt.Println(string(str1))
  10999. fmt.Println(string(str))
  11000. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11001. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11002. if ret2 != 0 {
  11003. return ""
  11004. }
  11005. return string(str)
  11006. }
  11007. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  11008. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  11009. readCard := DllDef.MustFindProc("read_cardinfo")
  11010. if readCard == nil {
  11011. fmt.Println("readcard is nil")
  11012. readCard = DllDef.MustFindProc("read_cardinfo")
  11013. }
  11014. str := make([]byte, 1024) //卡号
  11015. str1 := make([]byte, 1024) //卡识别码
  11016. str2 := make([]byte, 1024) //身份证号
  11017. str3 := make([]byte, 1024) //姓名
  11018. str4 := make([]byte, 1024) //错误信息
  11019. 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])))
  11020. fmt.Println(string(str1))
  11021. fmt.Println(string(str))
  11022. fmt.Println(string(str2))
  11023. fmt.Println(string(str3))
  11024. fmt.Println(string(str4))
  11025. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11026. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11027. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  11028. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  11029. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  11030. if ret2 != 0 {
  11031. return "", "", "", "", ""
  11032. }
  11033. return string(str), string(str1), string(str2), string(str3), string(str4)
  11034. }
  11035. type CustomFundPay struct {
  11036. FundPayType string `json:"fund_pay_type"`
  11037. FundPayamt float64 `json:"fund_payamt"`
  11038. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11039. }
  11040. //func (c *HisApiController) GetBatchSettleList() {
  11041. // start_time_str := c.GetString("start_time")
  11042. // //end_time_str := c.GetString("end_time")
  11043. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11044. //
  11045. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  11046. //
  11047. // for _, item := range orders {
  11048. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  11049. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11050. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11051. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11052. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11053. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11054. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11055. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11056. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11057. //
  11058. // if order.ID == 0 {
  11059. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  11060. // return
  11061. // }
  11062. //
  11063. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11064. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11065. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11066. // //fmt.Println(count)
  11067. // //var zero string
  11068. // //number := count + 1
  11069. // //if number >= 1000 {
  11070. // // zero = "0000" + strconv.FormatInt(number, 10)
  11071. // //} else if number >= 10000 {
  11072. // // zero = "000" + strconv.FormatInt(number, 10)
  11073. // //} else if number >= 100000 {
  11074. // // zero = "00" + strconv.FormatInt(number, 10)
  11075. // //} else if number >= 1000000 {
  11076. // // zero = "0" + strconv.FormatInt(number, 10)
  11077. // //} else {
  11078. // // zero = strconv.FormatInt(number, 10)
  11079. // //}
  11080. // //fmt.Println(zero)
  11081. //
  11082. // struct4101 := service.Struct4101{
  11083. // PsnNo: order.PsnNo,
  11084. // MdtrtId: order.MdtrtId,
  11085. // SetlId: order.SetlId,
  11086. // PsnName: order.PsnName,
  11087. // Gend: order.Gend,
  11088. // Brdy: his.Brdy,
  11089. // Age: his.Age,
  11090. // Naty: order.Naty,
  11091. // PatnCertType: "01",
  11092. // Certno: order.Certno,
  11093. // Prfs: "90",
  11094. // ConerName: roles[0].UserName,
  11095. // PatnRlts: "99",
  11096. // ConerAddr: miConfig.OrgName,
  11097. // ConerTel: admin.Mobile,
  11098. // HiType: order.Insutype,
  11099. // Insuplc: miConfig.InsuplcAdmdvs,
  11100. // MaindiagFlag: "1",
  11101. // BillCode: order.SetlId,
  11102. // BillNo: order.SetlId,
  11103. // BizSn: order.Number,
  11104. // PsnSelfPay: order.PsnPartAmt,
  11105. // PsnOwnPay: order.PsnPartAmt,
  11106. // AcctPay: order.AcctPay,
  11107. // PsnCashpay: order.PsnCashPay,
  11108. // HiPaymtd: "1",
  11109. // Hsorg: miConfig.InsuplcAdmdvs,
  11110. // HsorgOpter: miConfig.InsuplcAdmdvs,
  11111. // MedinsFillPsn: curRoles.UserName,
  11112. // MedinsFillDept: miConfig.OrgName,
  11113. // IptMedType: "2",
  11114. // }
  11115. // struct4101.SetlBegnDate = order.SetlTime
  11116. // struct4101.SetlEndDate = order.SetlTime
  11117. // time_arr := strings.Split(order.SetlTime, " ")
  11118. // struct4101.AdmTime = time_arr[0]
  11119. // struct4101.AdmEndTime = time_arr[0]
  11120. //
  11121. // var rf []CustomFundPay
  11122. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  11123. //
  11124. // var tempFunPays []service.CustomStruct
  11125. // for _, item := range rf {
  11126. // var tempFunPay service.CustomStruct
  11127. // tempFunPay.FundPayamt = item.FundPayamt
  11128. // tempFunPay.FundPayType = item.FundPayType
  11129. // tempFunPays = append(tempFunPays, tempFunPay)
  11130. // }
  11131. // struct4101.CustomStruct = tempFunPays
  11132. //
  11133. // var tempDiaginfos []service.DiaginfoStructTwo
  11134. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11135. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11136. //
  11137. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11138. // var config []*models.HisXtDiagnoseConfig
  11139. // for _, item := range diagnosis_ids {
  11140. // id, _ := strconv.ParseInt(item, 10, 64)
  11141. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  11142. // config = append(config, &diagnosisConfig)
  11143. // }
  11144. //
  11145. // for index, item := range config {
  11146. // if index == 0 {
  11147. // var tempDiaginfo service.DiaginfoStructTwo
  11148. // tempDiaginfo.DiagCode = item.CountryCode
  11149. // tempDiaginfo.DiagName = item.CountryContentName
  11150. // tempDiaginfo.DiagType = "1"
  11151. // tempDiaginfo.MaindiagFlag = "1"
  11152. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11153. // } else {
  11154. // var tempDiaginfo service.DiaginfoStructTwo
  11155. // tempDiaginfo.DiagCode = item.CountryCode
  11156. // tempDiaginfo.DiagName = item.CountryContentName
  11157. // tempDiaginfo.DiagType = "1"
  11158. // tempDiaginfo.MaindiagFlag = "0"
  11159. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11160. // }
  11161. // }
  11162. // struct4101.Diseinfo = tempDiaginfos
  11163. //
  11164. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  11165. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11166. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11167. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11168. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11169. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11170. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11171. //
  11172. // var iteminfo service.IteminfoStruct
  11173. //
  11174. // var bedCostTotal float64 = 0 //床位总费
  11175. // var bedCostSelfTotal float64 = 0 //床位自费
  11176. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11177. //
  11178. // var operationCostTotal float64 = 0 //手术费
  11179. // var operationCostSelfTotal float64 = 0 //手术费
  11180. // var operationCostPartSelfTotal float64 = 0 //手术费
  11181. //
  11182. // var otherCostTotal float64 = 0 //其他费用
  11183. // var otherCostSelfTotal float64 = 0 //其他费用
  11184. // var otherCostPartSelfTotal float64 = 0 //其他费用
  11185. //
  11186. // var materialCostTotal float64 = 0 //材料费
  11187. // var materialCostSelfTotal float64 = 0 //材料费
  11188. // var materialCostPartSelfTotal float64 = 0 //材料费
  11189. //
  11190. // var westernMedicineCostTotal float64 = 0 //西药费
  11191. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  11192. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11193. //
  11194. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11195. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11196. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11197. //
  11198. // var checkCostTotal float64 = 0 //检查费
  11199. // var checkCostSelfTotal float64 = 0 //检查费
  11200. // var checkCostPartSelfTotal float64 = 0 //检查费
  11201. //
  11202. // var laboratoryCostTotal float64 = 0 //化验费
  11203. // var laboratoryCostSelfTotal float64 = 0 //化验费
  11204. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11205. //
  11206. // var treatCostTotal float64 = 0 //治疗费用
  11207. // var treatCostSelfTotal float64 = 0 //治疗费用
  11208. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  11209. //
  11210. // decimal.DivisionPrecision = 2
  11211. //
  11212. // var bed_fulamt_ownpay_amt float64 = 0
  11213. // var operation_fulamt_ownpay_amt float64 = 0
  11214. // var other_fulamt_ownpay_amt float64 = 0
  11215. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  11216. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  11217. // var check_fulamt_ownpay_amt float64 = 0
  11218. // var material_fulamt_ownpay_amt float64 = 0
  11219. // var laboratory_fulamt_ownpay_amt float64 = 0
  11220. // var treat_fulamt_ownpay_amt float64 = 0
  11221. //
  11222. // var bed_claa_sunmfee float64 = 0
  11223. // var bed_clab_amt float64 = 0
  11224. // var bed_other_amt float64 = 0
  11225. //
  11226. // var operation_claa_sunmfee float64 = 0
  11227. // var operation_clab_amt float64 = 0
  11228. // var operation_other_amt float64 = 0
  11229. //
  11230. // var other_claa_sunmfee float64 = 0
  11231. // var other_clab_amt float64 = 0
  11232. // var other_other_amt float64 = 0
  11233. //
  11234. // var westernMedicine_claa_sunmfee float64 = 0
  11235. // var westernMedicine_clab_amt float64 = 0
  11236. // var westernMedicine_other_amt float64 = 0
  11237. //
  11238. // var chineseTraditional_claa_sunmfee float64 = 0
  11239. // var chineseTraditional_clab_amt float64 = 0
  11240. // var chineseTraditional_other_amt float64 = 0
  11241. //
  11242. // var check_claa_sunmfee float64 = 0
  11243. // var check_clab_amt float64 = 0
  11244. // var check_other_amt float64 = 0
  11245. //
  11246. // var material_claa_sunmfee float64 = 0
  11247. // var material_clab_amt float64 = 0
  11248. // var material_other_amt float64 = 0
  11249. //
  11250. // var laboratory_claa_sunmfee float64 = 0
  11251. // var laboratory_clab_amt float64 = 0
  11252. // var laboratory_other_amt float64 = 0
  11253. //
  11254. // var treat_claa_sunmfee float64 = 0
  11255. // var treat_clab_amt float64 = 0
  11256. // var treat_other_amt float64 = 0
  11257. //
  11258. // for _, item := range order.HisOrderInfo {
  11259. // if item.MedChrgitmType == "01" { //床位费
  11260. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11261. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11262. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11263. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11264. // if item.ChrgitmLv == "1" {
  11265. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11266. // }
  11267. // if item.ChrgitmLv == "2" {
  11268. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11269. //
  11270. // }
  11271. // if item.ChrgitmLv == "3" {
  11272. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11273. // }
  11274. //
  11275. // }
  11276. //
  11277. // if item.MedChrgitmType == "03" { //检查费
  11278. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11279. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11280. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11281. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11282. // if item.ChrgitmLv == "1" {
  11283. //
  11284. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11285. //
  11286. // }
  11287. // if item.ChrgitmLv == "2" {
  11288. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11289. //
  11290. // }
  11291. // if item.ChrgitmLv == "3" {
  11292. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11293. // }
  11294. // }
  11295. //
  11296. // if item.MedChrgitmType == "04" { //化验费
  11297. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11298. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11299. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11300. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11301. // if item.ChrgitmLv == "1" {
  11302. //
  11303. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11304. //
  11305. // }
  11306. // if item.ChrgitmLv == "2" {
  11307. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11308. //
  11309. // }
  11310. // if item.ChrgitmLv == "3" {
  11311. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11312. // }
  11313. // }
  11314. //
  11315. // if item.MedChrgitmType == "05" { //治疗费
  11316. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11317. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11318. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11319. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11320. // if item.ChrgitmLv == "1" {
  11321. //
  11322. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11323. //
  11324. // }
  11325. // if item.ChrgitmLv == "2" {
  11326. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11327. //
  11328. // }
  11329. // if item.ChrgitmLv == "3" {
  11330. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11331. // }
  11332. // }
  11333. //
  11334. // if item.MedChrgitmType == "06" { //手术费
  11335. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11336. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11337. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11338. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11339. //
  11340. // if item.ChrgitmLv == "1" {
  11341. //
  11342. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11343. //
  11344. // }
  11345. // if item.ChrgitmLv == "2" {
  11346. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11347. //
  11348. // }
  11349. // if item.ChrgitmLv == "3" {
  11350. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11351. // }
  11352. // }
  11353. //
  11354. // if item.MedChrgitmType == "08" { //材料费
  11355. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11356. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11357. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11358. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11359. // if item.ChrgitmLv == "1" {
  11360. //
  11361. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11362. //
  11363. // }
  11364. // if item.ChrgitmLv == "2" {
  11365. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11366. //
  11367. // }
  11368. // if item.ChrgitmLv == "3" {
  11369. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11370. // }
  11371. // }
  11372. //
  11373. // if item.MedChrgitmType == "09" { //西药费
  11374. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11375. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11376. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11377. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11378. // if item.ChrgitmLv == "1" {
  11379. //
  11380. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11381. //
  11382. // }
  11383. // if item.ChrgitmLv == "2" {
  11384. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11385. //
  11386. // }
  11387. // if item.ChrgitmLv == "3" {
  11388. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11389. // }
  11390. // }
  11391. //
  11392. // if item.MedChrgitmType == "11" { //中成费
  11393. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11394. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11395. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11396. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11397. // if item.ChrgitmLv == "1" {
  11398. //
  11399. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11400. //
  11401. // }
  11402. // if item.ChrgitmLv == "2" {
  11403. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11404. //
  11405. // }
  11406. // if item.ChrgitmLv == "3" {
  11407. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11408. // }
  11409. // }
  11410. //
  11411. // if item.MedChrgitmType == "14" { //其他费
  11412. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11413. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11414. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11415. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11416. // if item.ChrgitmLv == "1" {
  11417. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11418. //
  11419. // }
  11420. // if item.ChrgitmLv == "2" {
  11421. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11422. //
  11423. // }
  11424. // if item.ChrgitmLv == "3" {
  11425. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11426. // }
  11427. // }
  11428. //
  11429. // }
  11430. //
  11431. // var iteminfoStructs []service.IteminfoStruct
  11432. //
  11433. // if bedCostTotal != 0 {
  11434. // iteminfo.MedChrgitm = "01"
  11435. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11436. // iteminfo.Amt = bedCostTotal
  11437. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  11438. // iteminfo.ClabAmt = bed_clab_amt
  11439. // iteminfo.OthAmt = bed_other_amt
  11440. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11441. // }
  11442. //
  11443. // if checkCostTotal != 0 {
  11444. // iteminfo.MedChrgitm = "03"
  11445. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  11446. // iteminfo.Amt = checkCostTotal
  11447. // iteminfo.ClaaSumfee = check_claa_sunmfee
  11448. // iteminfo.ClabAmt = check_clab_amt
  11449. // iteminfo.OthAmt = check_other_amt
  11450. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11451. //
  11452. // }
  11453. //
  11454. // if laboratoryCostTotal != 0 {
  11455. // iteminfo.MedChrgitm = "04"
  11456. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  11457. // iteminfo.Amt = laboratoryCostTotal
  11458. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  11459. // iteminfo.ClabAmt = laboratory_clab_amt
  11460. // iteminfo.OthAmt = laboratory_other_amt
  11461. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11462. //
  11463. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11464. //
  11465. // }
  11466. //
  11467. // if treatCostTotal != 0 {
  11468. // iteminfo.MedChrgitm = "05"
  11469. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  11470. // iteminfo.Amt = treatCostTotal
  11471. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  11472. // iteminfo.ClabAmt = treat_clab_amt
  11473. // iteminfo.OthAmt = treat_other_amt
  11474. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11475. // //(struct4101.IteminfoStruct, iteminfo)
  11476. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11477. // }
  11478. //
  11479. // if operationCostTotal != 0 {
  11480. // iteminfo.MedChrgitm = "06"
  11481. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11482. // iteminfo.Amt = operationCostTotal
  11483. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  11484. // iteminfo.ClabAmt = operation_clab_amt
  11485. // iteminfo.OthAmt = operation_other_amt
  11486. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11487. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11488. // }
  11489. //
  11490. // if materialCostTotal != 0 {
  11491. // iteminfo.MedChrgitm = "08"
  11492. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  11493. // iteminfo.Amt = materialCostTotal
  11494. // iteminfo.ClaaSumfee = material_claa_sunmfee
  11495. // iteminfo.ClabAmt = material_clab_amt
  11496. // iteminfo.OthAmt = material_other_amt
  11497. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11498. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11499. // }
  11500. //
  11501. // if westernMedicineCostTotal != 0 {
  11502. // iteminfo.MedChrgitm = "09"
  11503. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11504. // iteminfo.Amt = westernMedicineCostTotal
  11505. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11506. // iteminfo.ClabAmt = westernMedicine_clab_amt
  11507. // iteminfo.OthAmt = westernMedicine_other_amt
  11508. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11509. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11510. //
  11511. // }
  11512. // if chineseTraditionalMedicineCostTotal != 0 {
  11513. // iteminfo.MedChrgitm = "11"
  11514. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11515. // iteminfo.Amt = westernMedicineCostTotal
  11516. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11517. // iteminfo.ClabAmt = westernMedicine_clab_amt
  11518. // iteminfo.OthAmt = westernMedicine_other_amt
  11519. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11520. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11521. //
  11522. // }
  11523. // if otherCostTotal != 0 {
  11524. // iteminfo.MedChrgitm = "14"
  11525. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  11526. // iteminfo.Amt = otherCostTotal
  11527. // iteminfo.ClaaSumfee = other_claa_sunmfee
  11528. // iteminfo.ClabAmt = other_clab_amt
  11529. // iteminfo.OthAmt = other_other_amt
  11530. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11531. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11532. //
  11533. // }
  11534. // struct4101.IteminfoStruct = iteminfoStructs
  11535. // struct4101.Ntly = "中国"
  11536. // struct4101.AdmCaty = "A03.06"
  11537. //
  11538. // struct4101.DoctorName = doctor.UserName
  11539. // struct4101.DoctorCode = doctor.DoctorNumber
  11540. //
  11541. // var res ResultSeventeen
  11542. //
  11543. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11544. // struct4101.BillCode = order.Number
  11545. // struct4101.BillNo = order.SetlId
  11546. // var resOther ResultSeventeenOther
  11547. // var pp models.PublicParams
  11548. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11549. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11550. // pp.FixmedinsName = miConfig.OrgName
  11551. // pp.FixmedinsCode = miConfig.Code
  11552. // pp.RequestUrl = miConfig.Url
  11553. // pp.Cainfo = miConfig.Cainfo
  11554. // pp.SecretKey = miConfig.SecretKey
  11555. // pp.AccessKey = miConfig.AccessKey
  11556. // pp.OpterName = curRoles.UserName
  11557. //
  11558. // client := &http.Client{}
  11559. // var req *http.Request
  11560. // data := make(map[string]interface{})
  11561. // data["struct4101"] = struct4101
  11562. // data["pp"] = pp
  11563. // bytesData, _ := json.Marshal(data)
  11564. // if miConfig.MdtrtareaAdmvs == "320921" {
  11565. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11566. // } else {
  11567. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11568. // }
  11569. // resp, _ := client.Do(req)
  11570. // defer resp.Body.Close()
  11571. // body, ioErr := ioutil.ReadAll(resp.Body)
  11572. // if ioErr != nil {
  11573. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11575. // return
  11576. // }
  11577. // var respJSON map[string]interface{}
  11578. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11579. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11580. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11581. // return
  11582. // }
  11583. //
  11584. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11585. // userJSONBytes, _ := json.Marshal(respJSON)
  11586. // fmt.Println("log")
  11587. // fmt.Println(string(userJSONBytes))
  11588. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11589. // utils.ErrorLog("解析失败:%v", err)
  11590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11591. // return
  11592. // }
  11593. // res.InfRefmsgid = resOther.InfRefmsgid
  11594. // res.Output = resOther.Output
  11595. // res.ErrMsg = resOther.ErrMsg
  11596. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11597. // res.Infcode = infocode
  11598. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  11599. //
  11600. // var pp models.PublicParams
  11601. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11602. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11603. // pp.FixmedinsName = miConfig.OrgName
  11604. // pp.FixmedinsCode = miConfig.Code
  11605. // pp.RequestUrl = miConfig.Url
  11606. // pp.Cainfo = miConfig.Cainfo
  11607. // pp.SecretKey = miConfig.SecretKey
  11608. // pp.AccessKey = miConfig.AccessKey
  11609. // pp.OpterName = curRoles.UserName
  11610. // result, _ := service.Jxyb4101(struct4101, pp)
  11611. // var dat map[string]interface{}
  11612. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11613. // fmt.Println(dat)
  11614. // } else {
  11615. // fmt.Println(err)
  11616. // }
  11617. // userJSONBytes, _ := json.Marshal(dat)
  11618. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11619. // utils.ErrorLog("解析失败:%v", err)
  11620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11621. // return
  11622. // }
  11623. //
  11624. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  11625. // var pp models.PublicParams
  11626. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11627. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11628. // pp.FixmedinsName = miConfig.OrgName
  11629. // pp.FixmedinsCode = miConfig.Code
  11630. // pp.RequestUrl = miConfig.Url
  11631. // pp.Cainfo = miConfig.Cainfo
  11632. // pp.SecretKey = miConfig.SecretKey
  11633. // pp.AccessKey = miConfig.AccessKey
  11634. // pp.OpterName = curRoles.UserName
  11635. // result, _ := service.Hnyb4101(struct4101, pp)
  11636. // var dat map[string]interface{}
  11637. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11638. // fmt.Println(dat)
  11639. // } else {
  11640. // fmt.Println(err)
  11641. // }
  11642. // userJSONBytes, _ := json.Marshal(dat)
  11643. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11644. // utils.ErrorLog("解析失败:%v", err)
  11645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11646. // return
  11647. // }
  11648. //
  11649. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  11650. // var resOther ResultSeventeenOther
  11651. //
  11652. // var pp models.PublicParams
  11653. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11654. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11655. // pp.FixmedinsName = miConfig.OrgName
  11656. // pp.FixmedinsCode = miConfig.Code
  11657. // pp.RequestUrl = miConfig.Url
  11658. // pp.Cainfo = miConfig.Cainfo
  11659. // pp.SecretKey = miConfig.SecretKey
  11660. // pp.AccessKey = miConfig.AccessKey
  11661. // pp.OpterName = curRoles.UserName
  11662. // client := &http.Client{}
  11663. // var req *http.Request
  11664. // data := make(map[string]interface{})
  11665. // data["struct4101"] = struct4101
  11666. // data["pp"] = pp
  11667. // bytesData, _ := json.Marshal(data)
  11668. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  11669. // resp, _ := client.Do(req)
  11670. // defer resp.Body.Close()
  11671. // body, ioErr := ioutil.ReadAll(resp.Body)
  11672. // if ioErr != nil {
  11673. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11674. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11675. // return
  11676. // }
  11677. // var respJSON map[string]interface{}
  11678. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11679. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11680. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11681. // return
  11682. // }
  11683. //
  11684. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11685. // userJSONBytes, _ := json.Marshal(respJSON)
  11686. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11687. // utils.ErrorLog("解析失败:%v", err)
  11688. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11689. // return
  11690. // }
  11691. // res.InfRefmsgid = resOther.InfRefmsgid
  11692. // res.Output = resOther.Output
  11693. // res.ErrMsg = resOther.ErrMsg
  11694. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11695. // res.Infcode = infocode
  11696. //
  11697. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  11698. // var pp models.PublicParams
  11699. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11700. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11701. // pp.FixmedinsName = miConfig.OrgName
  11702. // pp.FixmedinsCode = miConfig.Code
  11703. // pp.RequestUrl = miConfig.Url
  11704. // pp.Cainfo = miConfig.Cainfo
  11705. // pp.SecretKey = miConfig.SecretKey
  11706. // pp.AccessKey = miConfig.AccessKey
  11707. // pp.OpterName = curRoles.UserName
  11708. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  11709. // fmt.Println(requestLog)
  11710. // fmt.Println(errMsgLog)
  11711. //
  11712. // saveLog(result, requestLog, "4101a", "上传清单")
  11713. //
  11714. // var dat map[string]interface{}
  11715. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11716. // fmt.Println(dat)
  11717. // } else {
  11718. // fmt.Println(err)
  11719. // }
  11720. // userJSONBytes, _ := json.Marshal(dat)
  11721. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11722. // utils.ErrorLog("解析失败:%v", err)
  11723. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11724. // return
  11725. // }
  11726. //
  11727. // } else {
  11728. //
  11729. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  11730. // var dat map[string]interface{}
  11731. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11732. // fmt.Println(dat)
  11733. // } else {
  11734. // fmt.Println(err)
  11735. // }
  11736. // userJSONBytes, _ := json.Marshal(dat)
  11737. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11738. // utils.ErrorLog("解析失败:%v", err)
  11739. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11740. // return
  11741. // }
  11742. // }
  11743. //
  11744. // if res.Infcode != 0 {
  11745. // adminUser := c.GetAdminUserInfo()
  11746. // errlog := &models.HisOrderError{
  11747. // UserOrgId: adminUser.CurrentOrgId,
  11748. // Ctime: time.Now().Unix(),
  11749. // Mtime: time.Now().Unix(),
  11750. // ErrMsg: res.ErrMsg,
  11751. // Status: 1,
  11752. // PatientId: order.ID,
  11753. // Stage: 10265,
  11754. // }
  11755. // service.CreateErrMsgLog(errlog)
  11756. // continue
  11757. // } else {
  11758. // //order.FaPiaoNumber = zero
  11759. // //order.FaPiaoCode = last_order.FaPiaoCode
  11760. // //service.UpdateOrder(order)
  11761. // hisFundSettleListResult := &models.HisFundSettleListResult{
  11762. // Number: res.Output.SetlListId,
  11763. // Status: 1,
  11764. // Ctime: time.Now().Unix(),
  11765. // Mtime: time.Now().Unix(),
  11766. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11767. // IsUpload: 1,
  11768. // OrderId: order.ID,
  11769. // }
  11770. // service.CreateUploadRecord(hisFundSettleListResult)
  11771. // c.ServeSuccessJSON(map[string]interface{}{
  11772. // "msg": "上传成功",
  11773. // "result": hisFundSettleListResult,
  11774. // })
  11775. // continue
  11776. // }
  11777. // }
  11778. //}
  11779. func (c *HisApiController) GetbatchSettleList() {
  11780. //order_id, _ := c.GetInt64("order_id")
  11781. admin_user_id, _ := c.GetInt64("admin_user_id")
  11782. orders, _ := service.GetAllHisOrderTwo10485()
  11783. for _, item := range orders {
  11784. order, _ := service.GetHisOrderByIDTwo(item.ID)
  11785. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11786. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11787. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11788. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11789. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11790. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11791. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11792. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11793. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11794. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11795. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11796. //fmt.Println(count)
  11797. //var zero string
  11798. //number := count + 1
  11799. //if number >= 1000 {
  11800. // zero = "0000" + strconv.FormatInt(number, 10)
  11801. //} else if number >= 10000 {
  11802. // zero = "000" + strconv.FormatInt(number, 10)
  11803. //} else if number >= 100000 {
  11804. // zero = "00" + strconv.FormatInt(number, 10)
  11805. //} else if number >= 1000000 {
  11806. // zero = "0" + strconv.FormatInt(number, 10)
  11807. //} else {
  11808. // zero = strconv.FormatInt(number, 10)
  11809. //}
  11810. //fmt.Println(zero)
  11811. struct4101 := service.Struct4101{
  11812. PsnNo: order.PsnNo,
  11813. MdtrtId: order.MdtrtId,
  11814. SetlId: order.SetlId,
  11815. PsnName: order.PsnName,
  11816. Gend: order.Gend,
  11817. Brdy: his.Brdy,
  11818. Age: his.Age,
  11819. Naty: order.Naty,
  11820. PatnCertType: "01",
  11821. Certno: order.Certno,
  11822. Prfs: "90",
  11823. ConerName: roles[0].UserName,
  11824. PatnRlts: "99",
  11825. ConerAddr: miConfig.OrgName,
  11826. ConerTel: admin.Mobile,
  11827. HiType: order.Insutype,
  11828. Insuplc: miConfig.InsuplcAdmdvs,
  11829. MaindiagFlag: "1",
  11830. BillCode: order.SetlId,
  11831. BillNo: order.SetlId,
  11832. BizSn: order.Number,
  11833. PsnSelfPay: order.PsnPartAmt,
  11834. PsnOwnPay: order.PsnPartAmt,
  11835. AcctPay: order.AcctPay,
  11836. PsnCashpay: order.PsnCashPay,
  11837. HiPaymtd: "1",
  11838. Hsorg: miConfig.InsuplcAdmdvs,
  11839. HsorgOpter: miConfig.InsuplcAdmdvs,
  11840. MedinsFillPsn: curRoles.UserName,
  11841. MedinsFillDept: miConfig.OrgName,
  11842. IptMedType: "2",
  11843. }
  11844. struct4101.SetlBegnDate = order.SetlTime
  11845. struct4101.SetlEndDate = order.SetlTime
  11846. time_arr := strings.Split(order.SetlTime, " ")
  11847. struct4101.AdmTime = time_arr[0]
  11848. struct4101.AdmEndTime = time_arr[0]
  11849. //var rf []CustomFundPay
  11850. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  11851. //
  11852. //var tempFunPays []service.CustomStruct
  11853. //for _, item := range rf {
  11854. // var tempFunPay service.CustomStruct
  11855. // tempFunPay.FundPayamt = item.FundPayamt
  11856. // tempFunPay.FundPayType = item.FundPayType
  11857. // tempFunPays = append(tempFunPays, tempFunPay)
  11858. //}
  11859. //struct4101.CustomStruct = tempFunPays
  11860. var tempDiaginfos []service.DiaginfoStructTwo
  11861. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11862. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11863. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11864. var config []*models.HisXtDiagnoseConfig
  11865. for _, item := range diagnosis_ids {
  11866. id, _ := strconv.ParseInt(item, 10, 64)
  11867. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11868. config = append(config, &diagnosisConfig)
  11869. }
  11870. for index, item := range config {
  11871. if index == 0 {
  11872. var tempDiaginfo service.DiaginfoStructTwo
  11873. tempDiaginfo.DiagCode = item.CountryCode
  11874. tempDiaginfo.DiagName = item.CountryContentName
  11875. tempDiaginfo.DiagType = "1"
  11876. tempDiaginfo.MaindiagFlag = "1"
  11877. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11878. } else {
  11879. var tempDiaginfo service.DiaginfoStructTwo
  11880. tempDiaginfo.DiagCode = item.CountryCode
  11881. tempDiaginfo.DiagName = item.CountryContentName
  11882. tempDiaginfo.DiagType = "1"
  11883. tempDiaginfo.MaindiagFlag = "0"
  11884. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11885. }
  11886. }
  11887. struct4101.Diseinfo = tempDiaginfos
  11888. sickConfigTwo, _ := service.FindSickById(his.SickType)
  11889. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11890. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11891. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11892. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11893. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11894. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11895. var iteminfo service.IteminfoStruct
  11896. var bedCostTotal float64 = 0 //床位总费
  11897. var bedCostSelfTotal float64 = 0 //床位自费
  11898. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11899. var operationCostTotal float64 = 0 //手术费
  11900. var operationCostSelfTotal float64 = 0 //手术费
  11901. var operationCostPartSelfTotal float64 = 0 //手术费
  11902. var otherCostTotal float64 = 0 //其他费用
  11903. var otherCostSelfTotal float64 = 0 //其他费用
  11904. var otherCostPartSelfTotal float64 = 0 //其他费用
  11905. var materialCostTotal float64 = 0 //材料费
  11906. var materialCostSelfTotal float64 = 0 //材料费
  11907. var materialCostPartSelfTotal float64 = 0 //材料费
  11908. var westernMedicineCostTotal float64 = 0 //西药费
  11909. var westernMedicineCostSelfTotal float64 = 0 //西药费
  11910. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11911. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11912. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11913. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11914. var checkCostTotal float64 = 0 //检查费
  11915. var checkCostSelfTotal float64 = 0 //检查费
  11916. var checkCostPartSelfTotal float64 = 0 //检查费
  11917. var laboratoryCostTotal float64 = 0 //化验费
  11918. var laboratoryCostSelfTotal float64 = 0 //化验费
  11919. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11920. var treatCostTotal float64 = 0 //治疗费用
  11921. var treatCostSelfTotal float64 = 0 //治疗费用
  11922. var treatCostPartSelfTotal float64 = 0 //治疗费用
  11923. decimal.DivisionPrecision = 2
  11924. var bed_fulamt_ownpay_amt float64 = 0
  11925. var operation_fulamt_ownpay_amt float64 = 0
  11926. var other_fulamt_ownpay_amt float64 = 0
  11927. var westernMedicine_fulamt_ownpay_amt float64 = 0
  11928. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  11929. var check_fulamt_ownpay_amt float64 = 0
  11930. var material_fulamt_ownpay_amt float64 = 0
  11931. var laboratory_fulamt_ownpay_amt float64 = 0
  11932. var treat_fulamt_ownpay_amt float64 = 0
  11933. var bed_claa_sunmfee float64 = 0
  11934. var bed_clab_amt float64 = 0
  11935. var bed_other_amt float64 = 0
  11936. var operation_claa_sunmfee float64 = 0
  11937. var operation_clab_amt float64 = 0
  11938. var operation_other_amt float64 = 0
  11939. var other_claa_sunmfee float64 = 0
  11940. var other_clab_amt float64 = 0
  11941. var other_other_amt float64 = 0
  11942. var westernMedicine_claa_sunmfee float64 = 0
  11943. var westernMedicine_clab_amt float64 = 0
  11944. var westernMedicine_other_amt float64 = 0
  11945. var chineseTraditional_claa_sunmfee float64 = 0
  11946. var chineseTraditional_clab_amt float64 = 0
  11947. var chineseTraditional_other_amt float64 = 0
  11948. var check_claa_sunmfee float64 = 0
  11949. var check_clab_amt float64 = 0
  11950. var check_other_amt float64 = 0
  11951. var material_claa_sunmfee float64 = 0
  11952. var material_clab_amt float64 = 0
  11953. var material_other_amt float64 = 0
  11954. var laboratory_claa_sunmfee float64 = 0
  11955. var laboratory_clab_amt float64 = 0
  11956. var laboratory_other_amt float64 = 0
  11957. var treat_claa_sunmfee float64 = 0
  11958. var treat_clab_amt float64 = 0
  11959. var treat_other_amt float64 = 0
  11960. for _, item := range order.HisOrderInfo {
  11961. if item.MedChrgitmType == "01" { //床位费
  11962. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11963. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11964. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11965. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11966. if item.ChrgitmLv == "1" {
  11967. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11968. }
  11969. if item.ChrgitmLv == "2" {
  11970. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11971. }
  11972. if item.ChrgitmLv == "3" {
  11973. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11974. }
  11975. }
  11976. if item.MedChrgitmType == "03" { //检查费
  11977. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11978. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11979. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11980. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11981. if item.ChrgitmLv == "1" {
  11982. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11983. }
  11984. if item.ChrgitmLv == "2" {
  11985. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11986. }
  11987. if item.ChrgitmLv == "3" {
  11988. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11989. }
  11990. }
  11991. if item.MedChrgitmType == "04" { //化验费
  11992. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11993. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11994. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11995. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11996. if item.ChrgitmLv == "1" {
  11997. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11998. }
  11999. if item.ChrgitmLv == "2" {
  12000. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12001. }
  12002. if item.ChrgitmLv == "3" {
  12003. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12004. }
  12005. }
  12006. if item.MedChrgitmType == "05" { //治疗费
  12007. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12008. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12009. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12010. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12011. if item.ChrgitmLv == "1" {
  12012. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12013. }
  12014. if item.ChrgitmLv == "2" {
  12015. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12016. }
  12017. if item.ChrgitmLv == "3" {
  12018. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12019. }
  12020. }
  12021. if item.MedChrgitmType == "06" { //手术费
  12022. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12023. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12024. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12025. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12026. if item.ChrgitmLv == "1" {
  12027. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12028. }
  12029. if item.ChrgitmLv == "2" {
  12030. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12031. }
  12032. if item.ChrgitmLv == "3" {
  12033. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12034. }
  12035. }
  12036. if item.MedChrgitmType == "08" { //材料费
  12037. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12038. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12039. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12040. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12041. if item.ChrgitmLv == "1" {
  12042. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12043. }
  12044. if item.ChrgitmLv == "2" {
  12045. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12046. }
  12047. if item.ChrgitmLv == "3" {
  12048. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12049. }
  12050. }
  12051. if item.MedChrgitmType == "09" { //西药费
  12052. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12053. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12054. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12055. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12056. if item.ChrgitmLv == "1" {
  12057. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12058. }
  12059. if item.ChrgitmLv == "2" {
  12060. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12061. }
  12062. if item.ChrgitmLv == "3" {
  12063. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12064. }
  12065. }
  12066. if item.MedChrgitmType == "11" { //中成费
  12067. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12068. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12069. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12070. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12071. if item.ChrgitmLv == "1" {
  12072. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12073. }
  12074. if item.ChrgitmLv == "2" {
  12075. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12076. }
  12077. if item.ChrgitmLv == "3" {
  12078. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12079. }
  12080. }
  12081. if item.MedChrgitmType == "14" { //其他费
  12082. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12083. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12084. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12085. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12086. if item.ChrgitmLv == "1" {
  12087. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12088. }
  12089. if item.ChrgitmLv == "2" {
  12090. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12091. }
  12092. if item.ChrgitmLv == "3" {
  12093. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12094. }
  12095. }
  12096. }
  12097. var iteminfoStructs []service.IteminfoStruct
  12098. if bedCostTotal != 0 {
  12099. iteminfo.MedChrgitm = "01"
  12100. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12101. iteminfo.Amt = bedCostTotal
  12102. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12103. iteminfo.ClabAmt = bed_clab_amt
  12104. iteminfo.OthAmt = bed_other_amt
  12105. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12106. }
  12107. if checkCostTotal != 0 {
  12108. iteminfo.MedChrgitm = "03"
  12109. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12110. iteminfo.Amt = checkCostTotal
  12111. iteminfo.ClaaSumfee = check_claa_sunmfee
  12112. iteminfo.ClabAmt = check_clab_amt
  12113. iteminfo.OthAmt = check_other_amt
  12114. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12115. }
  12116. if laboratoryCostTotal != 0 {
  12117. iteminfo.MedChrgitm = "04"
  12118. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12119. iteminfo.Amt = laboratoryCostTotal
  12120. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12121. iteminfo.ClabAmt = laboratory_clab_amt
  12122. iteminfo.OthAmt = laboratory_other_amt
  12123. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12124. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12125. }
  12126. if treatCostTotal != 0 {
  12127. iteminfo.MedChrgitm = "05"
  12128. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12129. iteminfo.Amt = treatCostTotal
  12130. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12131. iteminfo.ClabAmt = treat_clab_amt
  12132. iteminfo.OthAmt = treat_other_amt
  12133. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12134. //(struct4101.IteminfoStruct, iteminfo)
  12135. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12136. }
  12137. if operationCostTotal != 0 {
  12138. iteminfo.MedChrgitm = "06"
  12139. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12140. iteminfo.Amt = operationCostTotal
  12141. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12142. iteminfo.ClabAmt = operation_clab_amt
  12143. iteminfo.OthAmt = operation_other_amt
  12144. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12145. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12146. }
  12147. if materialCostTotal != 0 {
  12148. iteminfo.MedChrgitm = "08"
  12149. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12150. iteminfo.Amt = materialCostTotal
  12151. iteminfo.ClaaSumfee = material_claa_sunmfee
  12152. iteminfo.ClabAmt = material_clab_amt
  12153. iteminfo.OthAmt = material_other_amt
  12154. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12155. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12156. }
  12157. if westernMedicineCostTotal != 0 {
  12158. iteminfo.MedChrgitm = "09"
  12159. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12160. iteminfo.Amt = westernMedicineCostTotal
  12161. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12162. iteminfo.ClabAmt = westernMedicine_clab_amt
  12163. iteminfo.OthAmt = westernMedicine_other_amt
  12164. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12165. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12166. }
  12167. if chineseTraditionalMedicineCostTotal != 0 {
  12168. iteminfo.MedChrgitm = "11"
  12169. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12170. iteminfo.Amt = westernMedicineCostTotal
  12171. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12172. iteminfo.ClabAmt = westernMedicine_clab_amt
  12173. iteminfo.OthAmt = westernMedicine_other_amt
  12174. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12175. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12176. }
  12177. if otherCostTotal != 0 {
  12178. iteminfo.MedChrgitm = "14"
  12179. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12180. iteminfo.Amt = otherCostTotal
  12181. iteminfo.ClaaSumfee = other_claa_sunmfee
  12182. iteminfo.ClabAmt = other_clab_amt
  12183. iteminfo.OthAmt = other_other_amt
  12184. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12185. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12186. }
  12187. struct4101.IteminfoStruct = iteminfoStructs
  12188. struct4101.Ntly = "中国"
  12189. struct4101.AdmCaty = "A03.06"
  12190. struct4101.DoctorName = doctor.UserName
  12191. struct4101.DoctorCode = doctor.DoctorNumber
  12192. var res ResultSeventeen
  12193. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12194. struct4101.BillCode = order.Number
  12195. struct4101.BillNo = order.SetlId
  12196. var resOther ResultSeventeenOther
  12197. var pp models.PublicParams
  12198. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12199. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12200. pp.FixmedinsName = miConfig.OrgName
  12201. pp.FixmedinsCode = miConfig.Code
  12202. pp.RequestUrl = miConfig.Url
  12203. pp.Cainfo = miConfig.Cainfo
  12204. pp.SecretKey = miConfig.SecretKey
  12205. pp.AccessKey = miConfig.AccessKey
  12206. pp.OpterName = curRoles.UserName
  12207. client := &http.Client{}
  12208. var req *http.Request
  12209. data := make(map[string]interface{})
  12210. data["struct4101"] = struct4101
  12211. data["pp"] = pp
  12212. bytesData, _ := json.Marshal(data)
  12213. if miConfig.MdtrtareaAdmvs == "320921" {
  12214. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12215. } else {
  12216. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12217. }
  12218. resp, _ := client.Do(req)
  12219. defer resp.Body.Close()
  12220. body, ioErr := ioutil.ReadAll(resp.Body)
  12221. if ioErr != nil {
  12222. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12224. return
  12225. }
  12226. var respJSON map[string]interface{}
  12227. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12230. return
  12231. }
  12232. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12233. userJSONBytes, _ := json.Marshal(respJSON)
  12234. fmt.Println("log")
  12235. fmt.Println(string(userJSONBytes))
  12236. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12237. utils.ErrorLog("解析失败:%v", err)
  12238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12239. return
  12240. }
  12241. res.InfRefmsgid = resOther.InfRefmsgid
  12242. res.Output = resOther.Output
  12243. res.ErrMsg = resOther.ErrMsg
  12244. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12245. res.Infcode = infocode
  12246. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12247. var pp models.PublicParams
  12248. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12249. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12250. pp.FixmedinsName = miConfig.OrgName
  12251. pp.FixmedinsCode = miConfig.Code
  12252. pp.RequestUrl = miConfig.Url
  12253. pp.Cainfo = miConfig.Cainfo
  12254. pp.SecretKey = miConfig.SecretKey
  12255. pp.AccessKey = miConfig.AccessKey
  12256. pp.OpterName = curRoles.UserName
  12257. result, _ := service.Jxyb4101(struct4101, pp)
  12258. var dat map[string]interface{}
  12259. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12260. fmt.Println(dat)
  12261. } else {
  12262. fmt.Println(err)
  12263. }
  12264. userJSONBytes, _ := json.Marshal(dat)
  12265. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12266. utils.ErrorLog("解析失败:%v", err)
  12267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12268. return
  12269. }
  12270. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12271. var pp models.PublicParams
  12272. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12273. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12274. pp.FixmedinsName = miConfig.OrgName
  12275. pp.FixmedinsCode = miConfig.Code
  12276. pp.RequestUrl = miConfig.Url
  12277. pp.Cainfo = miConfig.Cainfo
  12278. pp.SecretKey = miConfig.SecretKey
  12279. pp.AccessKey = miConfig.AccessKey
  12280. pp.OpterName = curRoles.UserName
  12281. result, _ := service.Hnyb4101(struct4101, pp)
  12282. var dat map[string]interface{}
  12283. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12284. fmt.Println(dat)
  12285. } else {
  12286. fmt.Println(err)
  12287. }
  12288. userJSONBytes, _ := json.Marshal(dat)
  12289. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12290. utils.ErrorLog("解析失败:%v", err)
  12291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12292. return
  12293. }
  12294. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12295. var resOther ResultSeventeenOther
  12296. var pp models.PublicParams
  12297. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12298. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12299. pp.FixmedinsName = miConfig.OrgName
  12300. pp.FixmedinsCode = miConfig.Code
  12301. pp.RequestUrl = miConfig.Url
  12302. pp.Cainfo = miConfig.Cainfo
  12303. pp.SecretKey = miConfig.SecretKey
  12304. pp.AccessKey = miConfig.AccessKey
  12305. pp.OpterName = curRoles.UserName
  12306. client := &http.Client{}
  12307. var req *http.Request
  12308. data := make(map[string]interface{})
  12309. data["struct4101"] = struct4101
  12310. data["pp"] = pp
  12311. bytesData, _ := json.Marshal(data)
  12312. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12313. resp, _ := client.Do(req)
  12314. defer resp.Body.Close()
  12315. body, ioErr := ioutil.ReadAll(resp.Body)
  12316. if ioErr != nil {
  12317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12319. return
  12320. }
  12321. var respJSON map[string]interface{}
  12322. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12325. return
  12326. }
  12327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12328. userJSONBytes, _ := json.Marshal(respJSON)
  12329. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12330. utils.ErrorLog("解析失败:%v", err)
  12331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12332. return
  12333. }
  12334. res.InfRefmsgid = resOther.InfRefmsgid
  12335. res.Output = resOther.Output
  12336. res.ErrMsg = resOther.ErrMsg
  12337. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12338. res.Infcode = infocode
  12339. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12340. var pp models.PublicParams
  12341. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12342. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12343. pp.FixmedinsName = miConfig.OrgName
  12344. pp.FixmedinsCode = miConfig.Code
  12345. pp.RequestUrl = miConfig.Url
  12346. pp.Cainfo = miConfig.Cainfo
  12347. pp.SecretKey = miConfig.SecretKey
  12348. pp.AccessKey = miConfig.AccessKey
  12349. pp.OpterName = curRoles.UserName
  12350. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12351. fmt.Println(requestLog)
  12352. fmt.Println(errMsgLog)
  12353. saveLog(result, requestLog, "4101a", "上传清单")
  12354. var dat map[string]interface{}
  12355. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12356. fmt.Println(dat)
  12357. } else {
  12358. fmt.Println(err)
  12359. }
  12360. userJSONBytes, _ := json.Marshal(dat)
  12361. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12362. utils.ErrorLog("解析失败:%v", err)
  12363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12364. return
  12365. }
  12366. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12367. var pp models.PublicParams
  12368. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12369. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12370. pp.FixmedinsName = miConfig.OrgName
  12371. pp.FixmedinsCode = miConfig.Code
  12372. pp.RequestUrl = miConfig.Url
  12373. pp.Cainfo = miConfig.Cainfo
  12374. pp.SecretKey = miConfig.SecretKey
  12375. pp.AccessKey = miConfig.AccessKey
  12376. pp.OpterName = curRoles.UserName
  12377. client := &http.Client{}
  12378. var req *http.Request
  12379. data := make(map[string]interface{})
  12380. data["struct4101"] = struct4101
  12381. data["pp"] = pp
  12382. bytesData, _ := json.Marshal(data)
  12383. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  12384. resp, _ := client.Do(req)
  12385. defer resp.Body.Close()
  12386. body, ioErr := ioutil.ReadAll(resp.Body)
  12387. if ioErr != nil {
  12388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12390. return
  12391. }
  12392. var respJSON map[string]interface{}
  12393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12396. return
  12397. }
  12398. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12399. userJSONBytes, _ := json.Marshal(respJSON)
  12400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12401. utils.ErrorLog("解析失败:%v", err)
  12402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12403. return
  12404. }
  12405. } else {
  12406. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  12407. var dat map[string]interface{}
  12408. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12409. fmt.Println(dat)
  12410. } else {
  12411. fmt.Println(err)
  12412. }
  12413. userJSONBytes, _ := json.Marshal(dat)
  12414. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12415. utils.ErrorLog("解析失败:%v", err)
  12416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12417. return
  12418. }
  12419. }
  12420. if res.Infcode != 0 {
  12421. errlog := &models.HisOrderError{
  12422. UserOrgId: order.UserOrgId,
  12423. Ctime: time.Now().Unix(),
  12424. Mtime: time.Now().Unix(),
  12425. ErrMsg: res.ErrMsg + "解析失败",
  12426. Status: 1,
  12427. PatientId: order.ID,
  12428. Stage: 10485,
  12429. }
  12430. service.CreateErrMsgLog(errlog)
  12431. continue
  12432. //c.ServeSuccessJSON(map[string]interface{}{
  12433. // "failed_code": -10,
  12434. // "msg": res.ErrMsg,
  12435. //})
  12436. } else {
  12437. //order.FaPiaoNumber = zero
  12438. //order.FaPiaoCode = last_order.FaPiaoCode
  12439. //service.UpdateOrder(order)
  12440. hisFundSettleListResult := &models.HisFundSettleListResult{
  12441. Number: res.Output.SetlListId,
  12442. Status: 1,
  12443. Ctime: time.Now().Unix(),
  12444. Mtime: time.Now().Unix(),
  12445. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12446. IsUpload: 1,
  12447. OrderId: order.ID,
  12448. }
  12449. service.CreateUploadRecord(hisFundSettleListResult)
  12450. continue
  12451. }
  12452. }
  12453. }
  12454. func (c *HisApiController) GetSettleList() {
  12455. order_id, _ := c.GetInt64("order_id")
  12456. admin_user_id, _ := c.GetInt64("admin_user_id")
  12457. order, _ := service.GetHisOrderByIDTwo(order_id)
  12458. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12459. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12460. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12461. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12462. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12463. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12464. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12465. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12466. if order.ID == 0 {
  12467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  12468. return
  12469. }
  12470. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12471. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12472. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12473. //fmt.Println(count)
  12474. //var zero string
  12475. //number := count + 1
  12476. //if number >= 1000 {
  12477. // zero = "0000" + strconv.FormatInt(number, 10)
  12478. //} else if number >= 10000 {
  12479. // zero = "000" + strconv.FormatInt(number, 10)
  12480. //} else if number >= 100000 {
  12481. // zero = "00" + strconv.FormatInt(number, 10)
  12482. //} else if number >= 1000000 {
  12483. // zero = "0" + strconv.FormatInt(number, 10)
  12484. //} else {
  12485. // zero = strconv.FormatInt(number, 10)
  12486. //}
  12487. //fmt.Println(zero)
  12488. struct4101 := service.Struct4101{
  12489. PsnNo: order.PsnNo,
  12490. MdtrtId: order.MdtrtId,
  12491. SetlId: order.SetlId,
  12492. PsnName: order.PsnName,
  12493. Gend: order.Gend,
  12494. Brdy: his.Brdy,
  12495. Age: his.Age,
  12496. Naty: order.Naty,
  12497. PatnCertType: "01",
  12498. Certno: order.Certno,
  12499. Prfs: "90",
  12500. ConerName: roles[0].UserName,
  12501. PatnRlts: "99",
  12502. ConerAddr: miConfig.OrgName,
  12503. ConerTel: admin.Mobile,
  12504. HiType: order.Insutype,
  12505. Insuplc: miConfig.InsuplcAdmdvs,
  12506. MaindiagFlag: "1",
  12507. BillCode: order.SetlId,
  12508. BillNo: order.SetlId,
  12509. BizSn: order.Number,
  12510. PsnSelfPay: order.PsnPartAmt,
  12511. PsnOwnPay: order.PsnPartAmt,
  12512. AcctPay: order.AcctPay,
  12513. PsnCashpay: order.PsnCashPay,
  12514. HiPaymtd: "1",
  12515. Hsorg: miConfig.InsuplcAdmdvs,
  12516. HsorgOpter: miConfig.InsuplcAdmdvs,
  12517. MedinsFillPsn: curRoles.UserName,
  12518. MedinsFillDept: miConfig.OrgName,
  12519. IptMedType: "2",
  12520. }
  12521. struct4101.SetlBegnDate = order.SetlTime
  12522. struct4101.SetlEndDate = order.SetlTime
  12523. time_arr := strings.Split(order.SetlTime, " ")
  12524. struct4101.AdmTime = time_arr[0]
  12525. struct4101.AdmEndTime = time_arr[0]
  12526. //
  12527. //var rf []CustomFundPay
  12528. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12529. //
  12530. //var tempFunPays []service.CustomStruct
  12531. //for _, item := range rf {
  12532. // var tempFunPay service.CustomStruct
  12533. // tempFunPay.FundPayamt = item.FundPayamt
  12534. // tempFunPay.FundPayType = item.FundPayType
  12535. // tempFunPays = append(tempFunPays, tempFunPay)
  12536. //}
  12537. //struct4101.CustomStruct = tempFunPays
  12538. var tempDiaginfos []service.DiaginfoStructTwo
  12539. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12540. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12541. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  12542. var config []*models.HisXtDiagnoseConfig
  12543. for _, item := range diagnosis_ids {
  12544. id, _ := strconv.ParseInt(item, 10, 64)
  12545. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12546. config = append(config, &diagnosisConfig)
  12547. }
  12548. if miConfig.Code == "H15049901371" {
  12549. //for _, item := range config {
  12550. // if item.ID == 138 {
  12551. diagnosisConfig, _ := service.FindDiagnoseById(138)
  12552. var tempDiaginfo service.DiaginfoStructTwo
  12553. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  12554. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  12555. tempDiaginfo.DiagType = "1"
  12556. tempDiaginfo.MaindiagFlag = "1"
  12557. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12558. //}
  12559. //}
  12560. for _, item := range config {
  12561. if item.ID != 138 {
  12562. var tempDiaginfo service.DiaginfoStructTwo
  12563. tempDiaginfo.DiagCode = item.CountryCode
  12564. tempDiaginfo.DiagName = item.CountryContentName
  12565. tempDiaginfo.DiagType = "1"
  12566. tempDiaginfo.MaindiagFlag = "0"
  12567. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12568. }
  12569. }
  12570. } else {
  12571. for index, item := range config {
  12572. if index == 0 {
  12573. var tempDiaginfo service.DiaginfoStructTwo
  12574. tempDiaginfo.DiagCode = item.CountryCode
  12575. tempDiaginfo.DiagName = item.CountryContentName
  12576. tempDiaginfo.DiagType = "1"
  12577. tempDiaginfo.MaindiagFlag = "1"
  12578. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12579. } else {
  12580. var tempDiaginfo service.DiaginfoStructTwo
  12581. tempDiaginfo.DiagCode = item.CountryCode
  12582. tempDiaginfo.DiagName = item.CountryContentName
  12583. tempDiaginfo.DiagType = "1"
  12584. tempDiaginfo.MaindiagFlag = "0"
  12585. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12586. }
  12587. }
  12588. }
  12589. struct4101.Diseinfo = tempDiaginfos
  12590. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12591. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12592. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12593. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12594. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12595. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12596. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12597. var iteminfo service.IteminfoStruct
  12598. var bedCostTotal float64 = 0 //床位总费
  12599. var bedCostSelfTotal float64 = 0 //床位自费
  12600. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12601. var operationCostTotal float64 = 0 //手术费
  12602. var operationCostSelfTotal float64 = 0 //手术费
  12603. var operationCostPartSelfTotal float64 = 0 //手术费
  12604. var otherCostTotal float64 = 0 //其他费用
  12605. var otherCostSelfTotal float64 = 0 //其他费用
  12606. var otherCostPartSelfTotal float64 = 0 //其他费用
  12607. var materialCostTotal float64 = 0 //材料费
  12608. var materialCostSelfTotal float64 = 0 //材料费
  12609. var materialCostPartSelfTotal float64 = 0 //材料费
  12610. var westernMedicineCostTotal float64 = 0 //西药费
  12611. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12612. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12613. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12614. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12615. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12616. var checkCostTotal float64 = 0 //检查费
  12617. var checkCostSelfTotal float64 = 0 //检查费
  12618. var checkCostPartSelfTotal float64 = 0 //检查费
  12619. var laboratoryCostTotal float64 = 0 //化验费
  12620. var laboratoryCostSelfTotal float64 = 0 //化验费
  12621. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12622. var treatCostTotal float64 = 0 //治疗费用
  12623. var treatCostSelfTotal float64 = 0 //治疗费用
  12624. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12625. decimal.DivisionPrecision = 2
  12626. var bed_fulamt_ownpay_amt float64 = 0
  12627. var operation_fulamt_ownpay_amt float64 = 0
  12628. var other_fulamt_ownpay_amt float64 = 0
  12629. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12630. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12631. var check_fulamt_ownpay_amt float64 = 0
  12632. var material_fulamt_ownpay_amt float64 = 0
  12633. var laboratory_fulamt_ownpay_amt float64 = 0
  12634. var treat_fulamt_ownpay_amt float64 = 0
  12635. var bed_claa_sunmfee float64 = 0
  12636. var bed_clab_amt float64 = 0
  12637. var bed_other_amt float64 = 0
  12638. var operation_claa_sunmfee float64 = 0
  12639. var operation_clab_amt float64 = 0
  12640. var operation_other_amt float64 = 0
  12641. var other_claa_sunmfee float64 = 0
  12642. var other_clab_amt float64 = 0
  12643. var other_other_amt float64 = 0
  12644. var westernMedicine_claa_sunmfee float64 = 0
  12645. var westernMedicine_clab_amt float64 = 0
  12646. var westernMedicine_other_amt float64 = 0
  12647. var chineseTraditional_claa_sunmfee float64 = 0
  12648. var chineseTraditional_clab_amt float64 = 0
  12649. var chineseTraditional_other_amt float64 = 0
  12650. var check_claa_sunmfee float64 = 0
  12651. var check_clab_amt float64 = 0
  12652. var check_other_amt float64 = 0
  12653. var material_claa_sunmfee float64 = 0
  12654. var material_clab_amt float64 = 0
  12655. var material_other_amt float64 = 0
  12656. var laboratory_claa_sunmfee float64 = 0
  12657. var laboratory_clab_amt float64 = 0
  12658. var laboratory_other_amt float64 = 0
  12659. var treat_claa_sunmfee float64 = 0
  12660. var treat_clab_amt float64 = 0
  12661. var treat_other_amt float64 = 0
  12662. for _, item := range order.HisOrderInfo {
  12663. if item.MedChrgitmType == "01" { //床位费
  12664. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12665. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12666. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12667. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12668. if item.ChrgitmLv == "1" {
  12669. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12670. }
  12671. if item.ChrgitmLv == "2" {
  12672. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12673. }
  12674. if item.ChrgitmLv == "3" {
  12675. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12676. }
  12677. }
  12678. if item.MedChrgitmType == "03" { //检查费
  12679. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12680. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12681. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12682. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12683. if item.ChrgitmLv == "1" {
  12684. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12685. }
  12686. if item.ChrgitmLv == "2" {
  12687. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12688. }
  12689. if item.ChrgitmLv == "3" {
  12690. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12691. }
  12692. }
  12693. if item.MedChrgitmType == "04" { //化验费
  12694. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12695. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12696. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12697. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12698. if item.ChrgitmLv == "1" {
  12699. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12700. }
  12701. if item.ChrgitmLv == "2" {
  12702. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12703. }
  12704. if item.ChrgitmLv == "3" {
  12705. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12706. }
  12707. }
  12708. if item.MedChrgitmType == "05" { //治疗费
  12709. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12710. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12711. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12712. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12713. if item.ChrgitmLv == "1" {
  12714. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12715. }
  12716. if item.ChrgitmLv == "2" {
  12717. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12718. }
  12719. if item.ChrgitmLv == "3" {
  12720. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12721. }
  12722. }
  12723. if item.MedChrgitmType == "06" { //手术费
  12724. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12725. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12726. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12727. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12728. if item.ChrgitmLv == "1" {
  12729. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12730. }
  12731. if item.ChrgitmLv == "2" {
  12732. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12733. }
  12734. if item.ChrgitmLv == "3" {
  12735. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12736. }
  12737. }
  12738. if item.MedChrgitmType == "08" { //材料费
  12739. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12740. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12741. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12742. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12743. if item.ChrgitmLv == "1" {
  12744. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12745. }
  12746. if item.ChrgitmLv == "2" {
  12747. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12748. }
  12749. if item.ChrgitmLv == "3" {
  12750. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12751. }
  12752. }
  12753. if item.MedChrgitmType == "09" { //西药费
  12754. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12755. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12756. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12757. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12758. if item.ChrgitmLv == "1" {
  12759. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12760. }
  12761. if item.ChrgitmLv == "2" {
  12762. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12763. }
  12764. if item.ChrgitmLv == "3" {
  12765. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12766. }
  12767. }
  12768. if item.MedChrgitmType == "11" { //中成费
  12769. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12770. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12771. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12772. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12773. if item.ChrgitmLv == "1" {
  12774. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12775. }
  12776. if item.ChrgitmLv == "2" {
  12777. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12778. }
  12779. if item.ChrgitmLv == "3" {
  12780. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12781. }
  12782. }
  12783. if item.MedChrgitmType == "14" { //其他费
  12784. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12785. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12786. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12787. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12788. if item.ChrgitmLv == "1" {
  12789. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12790. }
  12791. if item.ChrgitmLv == "2" {
  12792. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12793. }
  12794. if item.ChrgitmLv == "3" {
  12795. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12796. }
  12797. }
  12798. }
  12799. var iteminfoStructs []service.IteminfoStruct
  12800. if bedCostTotal != 0 {
  12801. iteminfo.MedChrgitm = "01"
  12802. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12803. iteminfo.Amt = bedCostTotal
  12804. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12805. iteminfo.ClabAmt = bed_clab_amt
  12806. iteminfo.OthAmt = bed_other_amt
  12807. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12808. }
  12809. if checkCostTotal != 0 {
  12810. iteminfo.MedChrgitm = "03"
  12811. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12812. iteminfo.Amt = checkCostTotal
  12813. iteminfo.ClaaSumfee = check_claa_sunmfee
  12814. iteminfo.ClabAmt = check_clab_amt
  12815. iteminfo.OthAmt = check_other_amt
  12816. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12817. }
  12818. if laboratoryCostTotal != 0 {
  12819. iteminfo.MedChrgitm = "04"
  12820. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12821. iteminfo.Amt = laboratoryCostTotal
  12822. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12823. iteminfo.ClabAmt = laboratory_clab_amt
  12824. iteminfo.OthAmt = laboratory_other_amt
  12825. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12826. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12827. }
  12828. if treatCostTotal != 0 {
  12829. iteminfo.MedChrgitm = "05"
  12830. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12831. iteminfo.Amt = treatCostTotal
  12832. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12833. iteminfo.ClabAmt = treat_clab_amt
  12834. iteminfo.OthAmt = treat_other_amt
  12835. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12836. //(struct4101.IteminfoStruct, iteminfo)
  12837. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12838. }
  12839. if operationCostTotal != 0 {
  12840. iteminfo.MedChrgitm = "06"
  12841. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12842. iteminfo.Amt = operationCostTotal
  12843. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12844. iteminfo.ClabAmt = operation_clab_amt
  12845. iteminfo.OthAmt = operation_other_amt
  12846. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12847. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12848. }
  12849. if materialCostTotal != 0 {
  12850. iteminfo.MedChrgitm = "08"
  12851. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12852. iteminfo.Amt = materialCostTotal
  12853. iteminfo.ClaaSumfee = material_claa_sunmfee
  12854. iteminfo.ClabAmt = material_clab_amt
  12855. iteminfo.OthAmt = material_other_amt
  12856. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12857. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12858. }
  12859. if westernMedicineCostTotal != 0 {
  12860. iteminfo.MedChrgitm = "09"
  12861. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12862. iteminfo.Amt = westernMedicineCostTotal
  12863. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12864. iteminfo.ClabAmt = westernMedicine_clab_amt
  12865. iteminfo.OthAmt = westernMedicine_other_amt
  12866. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12867. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12868. }
  12869. if chineseTraditionalMedicineCostTotal != 0 {
  12870. iteminfo.MedChrgitm = "11"
  12871. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12872. iteminfo.Amt = westernMedicineCostTotal
  12873. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12874. iteminfo.ClabAmt = westernMedicine_clab_amt
  12875. iteminfo.OthAmt = westernMedicine_other_amt
  12876. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12877. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12878. }
  12879. if otherCostTotal != 0 {
  12880. iteminfo.MedChrgitm = "14"
  12881. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12882. iteminfo.Amt = otherCostTotal
  12883. iteminfo.ClaaSumfee = other_claa_sunmfee
  12884. iteminfo.ClabAmt = other_clab_amt
  12885. iteminfo.OthAmt = other_other_amt
  12886. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12887. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12888. }
  12889. struct4101.IteminfoStruct = iteminfoStructs
  12890. struct4101.Ntly = "中国"
  12891. struct4101.AdmCaty = "A03.06"
  12892. struct4101.DoctorName = doctor.UserName
  12893. struct4101.DoctorCode = doctor.DoctorNumber
  12894. var res ResultSeventeen
  12895. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12896. struct4101.BillCode = order.Number
  12897. struct4101.BillNo = order.SetlId
  12898. var resOther ResultSeventeenOther
  12899. var pp models.PublicParams
  12900. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12901. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12902. pp.FixmedinsName = miConfig.OrgName
  12903. pp.FixmedinsCode = miConfig.Code
  12904. pp.RequestUrl = miConfig.Url
  12905. pp.Cainfo = miConfig.Cainfo
  12906. pp.SecretKey = miConfig.SecretKey
  12907. pp.AccessKey = miConfig.AccessKey
  12908. pp.OpterName = curRoles.UserName
  12909. client := &http.Client{}
  12910. var req *http.Request
  12911. data := make(map[string]interface{})
  12912. data["struct4101"] = struct4101
  12913. data["pp"] = pp
  12914. bytesData, _ := json.Marshal(data)
  12915. if miConfig.MdtrtareaAdmvs == "320921" {
  12916. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12917. } else {
  12918. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12919. }
  12920. resp, _ := client.Do(req)
  12921. defer resp.Body.Close()
  12922. body, ioErr := ioutil.ReadAll(resp.Body)
  12923. if ioErr != nil {
  12924. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12926. return
  12927. }
  12928. var respJSON map[string]interface{}
  12929. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12932. return
  12933. }
  12934. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12935. userJSONBytes, _ := json.Marshal(respJSON)
  12936. fmt.Println("log")
  12937. fmt.Println(string(userJSONBytes))
  12938. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12939. utils.ErrorLog("解析失败:%v", err)
  12940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12941. return
  12942. }
  12943. res.InfRefmsgid = resOther.InfRefmsgid
  12944. res.Output = resOther.Output
  12945. res.ErrMsg = resOther.ErrMsg
  12946. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12947. res.Infcode = infocode
  12948. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12949. var pp models.PublicParams
  12950. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12951. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12952. pp.FixmedinsName = miConfig.OrgName
  12953. pp.FixmedinsCode = miConfig.Code
  12954. pp.RequestUrl = miConfig.Url
  12955. pp.Cainfo = miConfig.Cainfo
  12956. pp.SecretKey = miConfig.SecretKey
  12957. pp.AccessKey = miConfig.AccessKey
  12958. pp.OpterName = curRoles.UserName
  12959. result, _ := service.Jxyb4101(struct4101, pp)
  12960. var dat map[string]interface{}
  12961. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12962. fmt.Println(dat)
  12963. } else {
  12964. fmt.Println(err)
  12965. }
  12966. userJSONBytes, _ := json.Marshal(dat)
  12967. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12968. utils.ErrorLog("解析失败:%v", err)
  12969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12970. return
  12971. }
  12972. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12973. var pp models.PublicParams
  12974. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12975. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12976. pp.FixmedinsName = miConfig.OrgName
  12977. pp.FixmedinsCode = miConfig.Code
  12978. pp.RequestUrl = miConfig.Url
  12979. pp.Cainfo = miConfig.Cainfo
  12980. pp.SecretKey = miConfig.SecretKey
  12981. pp.AccessKey = miConfig.AccessKey
  12982. pp.OpterName = curRoles.UserName
  12983. result, _ := service.Hnyb4101(struct4101, pp)
  12984. var dat map[string]interface{}
  12985. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12986. fmt.Println(dat)
  12987. } else {
  12988. fmt.Println(err)
  12989. }
  12990. userJSONBytes, _ := json.Marshal(dat)
  12991. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12992. utils.ErrorLog("解析失败:%v", err)
  12993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12994. return
  12995. }
  12996. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12997. var resOther ResultSeventeenOther
  12998. var pp models.PublicParams
  12999. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13000. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13001. pp.FixmedinsName = miConfig.OrgName
  13002. pp.FixmedinsCode = miConfig.Code
  13003. pp.RequestUrl = miConfig.Url
  13004. pp.Cainfo = miConfig.Cainfo
  13005. pp.SecretKey = miConfig.SecretKey
  13006. pp.AccessKey = miConfig.AccessKey
  13007. pp.OpterName = curRoles.UserName
  13008. client := &http.Client{}
  13009. var req *http.Request
  13010. data := make(map[string]interface{})
  13011. data["struct4101"] = struct4101
  13012. data["pp"] = pp
  13013. bytesData, _ := json.Marshal(data)
  13014. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13015. resp, _ := client.Do(req)
  13016. defer resp.Body.Close()
  13017. body, ioErr := ioutil.ReadAll(resp.Body)
  13018. if ioErr != nil {
  13019. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13021. return
  13022. }
  13023. var respJSON map[string]interface{}
  13024. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13027. return
  13028. }
  13029. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13030. userJSONBytes, _ := json.Marshal(respJSON)
  13031. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13032. utils.ErrorLog("解析失败:%v", err)
  13033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13034. return
  13035. }
  13036. res.InfRefmsgid = resOther.InfRefmsgid
  13037. res.Output = resOther.Output
  13038. res.ErrMsg = resOther.ErrMsg
  13039. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13040. res.Infcode = infocode
  13041. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13042. var pp models.PublicParams
  13043. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13044. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13045. pp.FixmedinsName = miConfig.OrgName
  13046. pp.FixmedinsCode = miConfig.Code
  13047. pp.RequestUrl = miConfig.Url
  13048. pp.Cainfo = miConfig.Cainfo
  13049. pp.SecretKey = miConfig.SecretKey
  13050. pp.AccessKey = miConfig.AccessKey
  13051. pp.OpterName = curRoles.UserName
  13052. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13053. fmt.Println(requestLog)
  13054. fmt.Println(errMsgLog)
  13055. saveLog(result, requestLog, "4101a", "上传清单")
  13056. var dat map[string]interface{}
  13057. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13058. fmt.Println(dat)
  13059. } else {
  13060. fmt.Println(err)
  13061. }
  13062. userJSONBytes, _ := json.Marshal(dat)
  13063. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13064. utils.ErrorLog("解析失败:%v", err)
  13065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13066. return
  13067. }
  13068. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13069. var pp models.PublicParams
  13070. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13071. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13072. pp.FixmedinsName = miConfig.OrgName
  13073. pp.FixmedinsCode = miConfig.Code
  13074. pp.RequestUrl = miConfig.Url
  13075. pp.Cainfo = miConfig.Cainfo
  13076. pp.SecretKey = miConfig.SecretKey
  13077. pp.AccessKey = miConfig.AccessKey
  13078. pp.OpterName = curRoles.UserName
  13079. client := &http.Client{}
  13080. var req *http.Request
  13081. data := make(map[string]interface{})
  13082. data["struct4101"] = struct4101
  13083. data["pp"] = pp
  13084. bytesData, _ := json.Marshal(data)
  13085. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13086. resp, _ := client.Do(req)
  13087. defer resp.Body.Close()
  13088. body, ioErr := ioutil.ReadAll(resp.Body)
  13089. if ioErr != nil {
  13090. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13092. return
  13093. }
  13094. var respJSON map[string]interface{}
  13095. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13098. return
  13099. }
  13100. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13101. userJSONBytes, _ := json.Marshal(respJSON)
  13102. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13103. utils.ErrorLog("解析失败:%v", err)
  13104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13105. return
  13106. }
  13107. } else {
  13108. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13109. var dat map[string]interface{}
  13110. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13111. fmt.Println(dat)
  13112. } else {
  13113. fmt.Println(err)
  13114. }
  13115. userJSONBytes, _ := json.Marshal(dat)
  13116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13117. utils.ErrorLog("解析失败:%v", err)
  13118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13119. return
  13120. }
  13121. }
  13122. if res.Infcode != 0 {
  13123. c.ServeSuccessJSON(map[string]interface{}{
  13124. "failed_code": -10,
  13125. "msg": res.ErrMsg,
  13126. })
  13127. return
  13128. } else {
  13129. //order.FaPiaoNumber = zero
  13130. //order.FaPiaoCode = last_order.FaPiaoCode
  13131. //service.UpdateOrder(order)
  13132. hisFundSettleListResult := &models.HisFundSettleListResult{
  13133. Number: res.Output.SetlListId,
  13134. Status: 1,
  13135. Ctime: time.Now().Unix(),
  13136. Mtime: time.Now().Unix(),
  13137. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13138. IsUpload: 1,
  13139. OrderId: order_id,
  13140. }
  13141. service.CreateUploadRecord(hisFundSettleListResult)
  13142. c.ServeSuccessJSON(map[string]interface{}{
  13143. "msg": "上传成功",
  13144. "result": hisFundSettleListResult,
  13145. })
  13146. return
  13147. }
  13148. }
  13149. func (c *HisApiController) GetSettleListHospital() {
  13150. order_id, _ := c.GetInt64("order_id")
  13151. admin_user_id, _ := c.GetInt64("admin_user_id")
  13152. order, _ := service.GetHisOrderByIDTwo(order_id)
  13153. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13154. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13155. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13156. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13157. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13158. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13159. if order.ID == 0 {
  13160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13161. return
  13162. }
  13163. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13164. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13165. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13166. fmt.Println(count)
  13167. var zero string
  13168. number := count + 1
  13169. if number >= 1000 {
  13170. zero = "0000" + strconv.FormatInt(number, 10)
  13171. } else if number >= 10000 {
  13172. zero = "000" + strconv.FormatInt(number, 10)
  13173. } else if number >= 100000 {
  13174. zero = "00" + strconv.FormatInt(number, 10)
  13175. } else if number >= 1000000 {
  13176. zero = "0" + strconv.FormatInt(number, 10)
  13177. } else {
  13178. zero = strconv.FormatInt(number, 10)
  13179. }
  13180. fmt.Println(zero)
  13181. struct4101 := service.Struct4101{
  13182. PsnNo: order.PsnNo,
  13183. MdtrtId: order.MdtrtId,
  13184. SetlId: order.SetlId,
  13185. PsnName: order.PsnName,
  13186. Gend: order.Gend,
  13187. Brdy: his.Brdy,
  13188. Age: int64(order.Age),
  13189. Naty: order.Naty,
  13190. PatnCertType: "01",
  13191. Certno: order.Certno,
  13192. Prfs: "90",
  13193. ConerName: roles[0].UserName,
  13194. PatnRlts: "99",
  13195. ConerAddr: miConfig.OrgName,
  13196. ConerTel: admin.Mobile,
  13197. HiType: order.Insutype,
  13198. Insuplc: miConfig.InsuplcAdmdvs,
  13199. MaindiagFlag: "1",
  13200. BillCode: order.SetlId,
  13201. BillNo: order.SetlId,
  13202. BizSn: order.Number,
  13203. PsnSelfPay: order.PsnPartAmt,
  13204. PsnOwnPay: order.PsnPartAmt,
  13205. AcctPay: order.AcctPay,
  13206. PsnCashpay: order.PsnCashPay,
  13207. HiPaymtd: "1",
  13208. Hsorg: miConfig.InsuplcAdmdvs,
  13209. HsorgOpter: miConfig.InsuplcAdmdvs,
  13210. MedinsFillPsn: curRoles.UserName,
  13211. MedinsFillDept: depart.Name,
  13212. IptMedType: "2",
  13213. AdmTime: his.InHosptialTime,
  13214. AdmEndTime: his.OutHosptialTime,
  13215. }
  13216. struct4101.SetlBegnDate = order.SetlTime
  13217. struct4101.SetlEndDate = order.SetlTime
  13218. //var rf []CustomFundPay
  13219. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13220. //
  13221. //var tempFunPays []service.CustomStruct
  13222. //for _, item := range rf {
  13223. // var tempFunPay service.CustomStruct
  13224. // tempFunPay.FundPayamt = item.FundPayamt
  13225. // tempFunPay.FundPayType = item.FundPayType
  13226. // tempFunPays = append(tempFunPays, tempFunPay)
  13227. //}
  13228. //struct4101.CustomStruct = tempFunPays
  13229. var tempDiaginfos []service.DiaginfoStructTwo
  13230. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13231. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13232. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  13233. //for _, item := range infos {
  13234. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  13235. //}
  13236. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  13237. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  13238. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13239. fmt.Println(diagnosis_ids_arr)
  13240. if order.UserOrgId == 10210 {
  13241. var diagnosis_ids_arr_two []int64
  13242. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  13243. var config []*models.HisXtDiagnoseConfig
  13244. for _, id := range diagnosis_ids_arr_two {
  13245. //id, _ := strconv.ParseInt(item, 10, 64)
  13246. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13247. if diagnosisConfig.ID > 0 {
  13248. config = append(config, &diagnosisConfig)
  13249. }
  13250. }
  13251. for index, item := range config {
  13252. if item.ID > 0 {
  13253. if index == 0 {
  13254. var tempDiaginfo service.DiaginfoStructTwo
  13255. tempDiaginfo.DiagCode = item.CountryCode
  13256. tempDiaginfo.DiagName = item.CountryContentName
  13257. tempDiaginfo.DiagType = "1"
  13258. tempDiaginfo.MaindiagFlag = "1"
  13259. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13260. } else {
  13261. var tempDiaginfo service.DiaginfoStructTwo
  13262. tempDiaginfo.DiagCode = item.CountryCode
  13263. tempDiaginfo.DiagName = item.CountryContentName
  13264. tempDiaginfo.DiagType = "1"
  13265. tempDiaginfo.MaindiagFlag = "0"
  13266. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13267. }
  13268. }
  13269. }
  13270. struct4101.Diseinfo = tempDiaginfos
  13271. } else {
  13272. var config []*models.HisXtDiagnoseConfig
  13273. for _, item := range diagnosis_ids_arr {
  13274. id, _ := strconv.ParseInt(item, 10, 64)
  13275. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13276. if diagnosisConfig.ID > 0 {
  13277. config = append(config, &diagnosisConfig)
  13278. }
  13279. }
  13280. for index, item := range config {
  13281. if item.ID > 0 {
  13282. if index == 0 {
  13283. var tempDiaginfo service.DiaginfoStructTwo
  13284. tempDiaginfo.DiagCode = item.CountryCode
  13285. tempDiaginfo.DiagName = item.CountryContentName
  13286. tempDiaginfo.DiagType = "1"
  13287. tempDiaginfo.MaindiagFlag = "1"
  13288. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13289. } else {
  13290. var tempDiaginfo service.DiaginfoStructTwo
  13291. tempDiaginfo.DiagCode = item.CountryCode
  13292. tempDiaginfo.DiagName = item.CountryContentName
  13293. tempDiaginfo.DiagType = "1"
  13294. tempDiaginfo.MaindiagFlag = "0"
  13295. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13296. }
  13297. }
  13298. }
  13299. struct4101.Diseinfo = tempDiaginfos
  13300. }
  13301. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13302. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13303. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13304. tempOpspdiseinfo2.OprnOprtCode = ""
  13305. tempOpspdiseinfo2.OprnOprtName = ""
  13306. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13307. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13308. var iteminfo service.IteminfoStruct
  13309. var bedCostTotal float64 = 0 //床位总费
  13310. var bedCostSelfTotal float64 = 0 //床位自费
  13311. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13312. var operationCostTotal float64 = 0 //手术费
  13313. var operationCostSelfTotal float64 = 0 //手术费
  13314. var operationCostPartSelfTotal float64 = 0 //手术费
  13315. var otherCostTotal float64 = 0 //其他费用
  13316. var otherCostSelfTotal float64 = 0 //其他费用
  13317. var otherCostPartSelfTotal float64 = 0 //其他费用
  13318. var materialCostTotal float64 = 0 //材料费
  13319. var materialCostSelfTotal float64 = 0 //材料费
  13320. var materialCostPartSelfTotal float64 = 0 //材料费
  13321. var westernMedicineCostTotal float64 = 0 //西药费
  13322. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13323. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13324. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13325. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13326. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13327. var checkCostTotal float64 = 0 //检查费
  13328. var checkCostSelfTotal float64 = 0 //检查费
  13329. var checkCostPartSelfTotal float64 = 0 //检查费
  13330. var laboratoryCostTotal float64 = 0 //化验费
  13331. var laboratoryCostSelfTotal float64 = 0 //化验费
  13332. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13333. var treatCostTotal float64 = 0 //治疗费用
  13334. var treatCostSelfTotal float64 = 0 //治疗费用
  13335. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13336. decimal.DivisionPrecision = 2
  13337. var bed_fulamt_ownpay_amt float64 = 0
  13338. var operation_fulamt_ownpay_amt float64 = 0
  13339. var other_fulamt_ownpay_amt float64 = 0
  13340. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13341. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13342. var check_fulamt_ownpay_amt float64 = 0
  13343. var material_fulamt_ownpay_amt float64 = 0
  13344. var laboratory_fulamt_ownpay_amt float64 = 0
  13345. var treat_fulamt_ownpay_amt float64 = 0
  13346. var bed_claa_sunmfee float64 = 0
  13347. var bed_clab_amt float64 = 0
  13348. var bed_other_amt float64 = 0
  13349. var operation_claa_sunmfee float64 = 0
  13350. var operation_clab_amt float64 = 0
  13351. var operation_other_amt float64 = 0
  13352. var other_claa_sunmfee float64 = 0
  13353. var other_clab_amt float64 = 0
  13354. var other_other_amt float64 = 0
  13355. var westernMedicine_claa_sunmfee float64 = 0
  13356. var westernMedicine_clab_amt float64 = 0
  13357. var westernMedicine_other_amt float64 = 0
  13358. var chineseTraditional_claa_sunmfee float64 = 0
  13359. var chineseTraditional_clab_amt float64 = 0
  13360. var chineseTraditional_other_amt float64 = 0
  13361. var check_claa_sunmfee float64 = 0
  13362. var check_clab_amt float64 = 0
  13363. var check_other_amt float64 = 0
  13364. var material_claa_sunmfee float64 = 0
  13365. var material_clab_amt float64 = 0
  13366. var material_other_amt float64 = 0
  13367. var laboratory_claa_sunmfee float64 = 0
  13368. var laboratory_clab_amt float64 = 0
  13369. var laboratory_other_amt float64 = 0
  13370. var treat_claa_sunmfee float64 = 0
  13371. var treat_clab_amt float64 = 0
  13372. var treat_other_amt float64 = 0
  13373. for _, item := range order.HisOrderInfo {
  13374. if item.MedChrgitmType == "01" { //床位费
  13375. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13376. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13377. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13378. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13379. if item.ChrgitmLv == "1" {
  13380. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13381. }
  13382. if item.ChrgitmLv == "2" {
  13383. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13384. }
  13385. if item.ChrgitmLv == "3" {
  13386. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13387. }
  13388. }
  13389. if item.MedChrgitmType == "03" { //检查费
  13390. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13391. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13392. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13393. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13394. if item.ChrgitmLv == "1" {
  13395. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13396. }
  13397. if item.ChrgitmLv == "2" {
  13398. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13399. }
  13400. if item.ChrgitmLv == "3" {
  13401. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13402. }
  13403. }
  13404. if item.MedChrgitmType == "04" { //化验费
  13405. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13406. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13407. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13408. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13409. if item.ChrgitmLv == "1" {
  13410. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13411. }
  13412. if item.ChrgitmLv == "2" {
  13413. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13414. }
  13415. if item.ChrgitmLv == "3" {
  13416. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13417. }
  13418. }
  13419. if item.MedChrgitmType == "05" { //治疗费
  13420. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13421. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13422. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13423. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13424. if item.ChrgitmLv == "1" {
  13425. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13426. }
  13427. if item.ChrgitmLv == "2" {
  13428. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13429. }
  13430. if item.ChrgitmLv == "3" {
  13431. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13432. }
  13433. }
  13434. if item.MedChrgitmType == "06" { //手术费
  13435. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13436. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13437. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13438. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13439. if item.ChrgitmLv == "1" {
  13440. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13441. }
  13442. if item.ChrgitmLv == "2" {
  13443. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13444. }
  13445. if item.ChrgitmLv == "3" {
  13446. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13447. }
  13448. }
  13449. if item.MedChrgitmType == "08" { //材料费
  13450. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13451. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13452. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13453. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13454. if item.ChrgitmLv == "1" {
  13455. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13456. }
  13457. if item.ChrgitmLv == "2" {
  13458. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13459. }
  13460. if item.ChrgitmLv == "3" {
  13461. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13462. }
  13463. }
  13464. if item.MedChrgitmType == "09" { //西药费
  13465. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13466. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13467. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13468. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13469. if item.ChrgitmLv == "1" {
  13470. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13471. }
  13472. if item.ChrgitmLv == "2" {
  13473. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13474. }
  13475. if item.ChrgitmLv == "3" {
  13476. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13477. }
  13478. }
  13479. if item.MedChrgitmType == "11" { //中成费
  13480. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13481. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13482. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13483. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13484. if item.ChrgitmLv == "1" {
  13485. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13486. }
  13487. if item.ChrgitmLv == "2" {
  13488. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13489. }
  13490. if item.ChrgitmLv == "3" {
  13491. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13492. }
  13493. }
  13494. if item.MedChrgitmType == "14" { //其他费
  13495. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13496. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13497. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13498. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13499. if item.ChrgitmLv == "1" {
  13500. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13501. }
  13502. if item.ChrgitmLv == "2" {
  13503. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13504. }
  13505. if item.ChrgitmLv == "3" {
  13506. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13507. }
  13508. }
  13509. }
  13510. var iteminfoStructs []service.IteminfoStruct
  13511. if bedCostTotal != 0 {
  13512. iteminfo.MedChrgitm = "01"
  13513. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13514. iteminfo.Amt = bedCostTotal
  13515. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13516. iteminfo.ClabAmt = bed_clab_amt
  13517. iteminfo.OthAmt = bed_other_amt
  13518. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13519. }
  13520. if checkCostTotal != 0 {
  13521. iteminfo.MedChrgitm = "03"
  13522. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13523. iteminfo.Amt = checkCostTotal
  13524. iteminfo.ClaaSumfee = check_claa_sunmfee
  13525. iteminfo.ClabAmt = check_clab_amt
  13526. iteminfo.OthAmt = check_other_amt
  13527. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13528. }
  13529. if laboratoryCostTotal != 0 {
  13530. iteminfo.MedChrgitm = "04"
  13531. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13532. iteminfo.Amt = laboratoryCostTotal
  13533. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13534. iteminfo.ClabAmt = laboratory_clab_amt
  13535. iteminfo.OthAmt = laboratory_other_amt
  13536. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13537. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13538. }
  13539. if treatCostTotal != 0 {
  13540. iteminfo.MedChrgitm = "05"
  13541. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13542. iteminfo.Amt = treatCostTotal
  13543. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13544. iteminfo.ClabAmt = treat_clab_amt
  13545. iteminfo.OthAmt = treat_other_amt
  13546. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13547. //(struct4101.IteminfoStruct, iteminfo)
  13548. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13549. }
  13550. if operationCostTotal != 0 {
  13551. iteminfo.MedChrgitm = "06"
  13552. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13553. iteminfo.Amt = operationCostTotal
  13554. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13555. iteminfo.ClabAmt = operation_clab_amt
  13556. iteminfo.OthAmt = operation_other_amt
  13557. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13558. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13559. }
  13560. if materialCostTotal != 0 {
  13561. iteminfo.MedChrgitm = "08"
  13562. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13563. iteminfo.Amt = materialCostTotal
  13564. iteminfo.ClaaSumfee = material_claa_sunmfee
  13565. iteminfo.ClabAmt = material_clab_amt
  13566. iteminfo.OthAmt = material_other_amt
  13567. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13568. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13569. }
  13570. if westernMedicineCostTotal != 0 {
  13571. iteminfo.MedChrgitm = "09"
  13572. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13573. iteminfo.Amt = westernMedicineCostTotal
  13574. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13575. iteminfo.ClabAmt = westernMedicine_clab_amt
  13576. iteminfo.OthAmt = westernMedicine_other_amt
  13577. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13578. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13579. }
  13580. if chineseTraditionalMedicineCostTotal != 0 {
  13581. iteminfo.MedChrgitm = "11"
  13582. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13583. iteminfo.Amt = westernMedicineCostTotal
  13584. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13585. iteminfo.ClabAmt = westernMedicine_clab_amt
  13586. iteminfo.OthAmt = westernMedicine_other_amt
  13587. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13588. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13589. }
  13590. if otherCostTotal != 0 {
  13591. iteminfo.MedChrgitm = "14"
  13592. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13593. iteminfo.Amt = otherCostTotal
  13594. iteminfo.ClaaSumfee = other_claa_sunmfee
  13595. iteminfo.ClabAmt = other_clab_amt
  13596. iteminfo.OthAmt = other_other_amt
  13597. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13598. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13599. }
  13600. struct4101.IteminfoStruct = iteminfoStructs
  13601. struct4101.Ntly = "中国"
  13602. struct4101.AdmCaty = "A03.06"
  13603. var resOther ResultSeventeenOther
  13604. var res ResultSeventeen
  13605. if miConfig.MdtrtareaAdmvs == "150499" {
  13606. var pp models.PublicParams
  13607. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13608. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13609. pp.FixmedinsName = miConfig.OrgName
  13610. pp.FixmedinsCode = miConfig.Code
  13611. pp.RequestUrl = miConfig.Url
  13612. pp.Cainfo = miConfig.Cainfo
  13613. pp.SecretKey = miConfig.SecretKey
  13614. pp.AccessKey = miConfig.AccessKey
  13615. pp.OpterName = curRoles.UserName
  13616. client := &http.Client{}
  13617. var req *http.Request
  13618. data := make(map[string]interface{})
  13619. data["struct4101"] = struct4101
  13620. data["pp"] = pp
  13621. bytesData, _ := json.Marshal(data)
  13622. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13623. resp, _ := client.Do(req)
  13624. defer resp.Body.Close()
  13625. body, ioErr := ioutil.ReadAll(resp.Body)
  13626. if ioErr != nil {
  13627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13629. return
  13630. }
  13631. var respJSON map[string]interface{}
  13632. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13635. return
  13636. }
  13637. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13638. userJSONBytes, _ := json.Marshal(respJSON)
  13639. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13640. utils.ErrorLog("解析失败:%v", err)
  13641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13642. return
  13643. }
  13644. res.InfRefmsgid = resOther.InfRefmsgid
  13645. res.Output = resOther.Output
  13646. res.ErrMsg = resOther.ErrMsg
  13647. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13648. res.Infcode = infocode
  13649. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13650. var pp models.PublicParams
  13651. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13652. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13653. pp.FixmedinsName = miConfig.OrgName
  13654. pp.FixmedinsCode = miConfig.Code
  13655. pp.RequestUrl = miConfig.Url
  13656. pp.Cainfo = miConfig.Cainfo
  13657. pp.SecretKey = miConfig.SecretKey
  13658. pp.AccessKey = miConfig.AccessKey
  13659. pp.OpterName = curRoles.UserName
  13660. result, _ := service.Jxyb4101(struct4101, pp)
  13661. var dat map[string]interface{}
  13662. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13663. fmt.Println(dat)
  13664. } else {
  13665. fmt.Println(err)
  13666. }
  13667. userJSONBytes, _ := json.Marshal(dat)
  13668. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13669. utils.ErrorLog("解析失败:%v", err)
  13670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13671. return
  13672. }
  13673. } else {
  13674. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13675. var dat map[string]interface{}
  13676. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13677. fmt.Println(dat)
  13678. } else {
  13679. fmt.Println(err)
  13680. }
  13681. userJSONBytes, _ := json.Marshal(dat)
  13682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13683. utils.ErrorLog("解析失败:%v", err)
  13684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13685. return
  13686. }
  13687. }
  13688. if res.Infcode != 0 {
  13689. c.ServeSuccessJSON(map[string]interface{}{
  13690. "failed_code": -10,
  13691. "msg": res.ErrMsg,
  13692. })
  13693. return
  13694. } else {
  13695. if miConfig.MdtrtareaAdmvs != "150499" {
  13696. order.FaPiaoNumber = zero
  13697. order.FaPiaoCode = last_order.FaPiaoCode
  13698. service.UpdateOrder(order)
  13699. }
  13700. hisFundSettleListResult := &models.HisFundSettleListResult{
  13701. Number: res.Output.SetlListId,
  13702. Status: 1,
  13703. Ctime: time.Now().Unix(),
  13704. Mtime: time.Now().Unix(),
  13705. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13706. IsUpload: 1,
  13707. OrderId: order_id,
  13708. }
  13709. service.CreateUploadRecord(hisFundSettleListResult)
  13710. c.ServeSuccessJSON(map[string]interface{}{
  13711. "msg": "上传成功",
  13712. "result": hisFundSettleListResult,
  13713. })
  13714. return
  13715. }
  13716. }
  13717. //func (c *HisApiController) GetBatchSettleList() {
  13718. // orders, _ := service.GetAllHisOrder(10106)
  13719. // for _, item := range orders {
  13720. // order_id := item.ID
  13721. // order, _ := service.GetHisOrderByIDTwo(order_id)
  13722. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13723. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13724. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13725. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  13726. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13727. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13728. //
  13729. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  13730. //
  13731. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  13732. //
  13733. // if order.ID == 0 {
  13734. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13735. // return
  13736. // }
  13737. // if his.BalanceAccountsType == 2 {
  13738. // continue
  13739. // }
  13740. // struct4101 := service.Struct4101{
  13741. // PsnNo: order.PsnNo,
  13742. // MdtrtId: order.MdtrtId,
  13743. // SetlId: order.SetlId,
  13744. // PsnName: order.PsnName,
  13745. // Gend: order.Gend,
  13746. // Brdy: his.Brdy,
  13747. // Age: his.Age,
  13748. // Naty: order.Naty,
  13749. // PatnCertType: "01",
  13750. // Certno: order.Certno,
  13751. // Prfs: "90",
  13752. // ConerName: roles[0].UserName,
  13753. // PatnRlts: "99",
  13754. // ConerAddr: miConfig.OrgName,
  13755. // ConerTel: admin.Mobile,
  13756. // HiType: order.Insutype,
  13757. // Insuplc: his.InsuplcAdmdvs,
  13758. // MaindiagFlag: "1",
  13759. // BillCode: order.SetlId,
  13760. // BillNo: order.SetlId,
  13761. // BizSn: order.Number,
  13762. // PsnSelfPay: order.PsnPartAmt,
  13763. // PsnOwnPay: order.PsnPartAmt,
  13764. // AcctPay: order.AcctPay,
  13765. // PsnCashpay: order.PsnCashPay,
  13766. // HiPaymtd: "1",
  13767. // Hsorg: his.InsuplcAdmdvs,
  13768. // HsorgOpter: his.InsuplcAdmdvs,
  13769. // MedinsFillPsn: curRoles.UserName,
  13770. // MedinsFillDept: depart.Name,
  13771. // IptMedType: "2",
  13772. // }
  13773. // struct4101.SetlBegnDate = order.SetlTime
  13774. // struct4101.SetlEndDate = order.SetlTime
  13775. // //if order.SettleType == 1 {
  13776. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  13777. // // dateStr := t.Format("2006-01-02")
  13778. // // struct4101.SetlBegnDate = dateStr
  13779. // // struct4101.SetlEndDate = dateStr
  13780. // //} else {
  13781. // // t := time.Unix(int64(order.SettleStartTime), 0)
  13782. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  13783. // // dateStartStr := t.Format("2006-01-02")
  13784. // // dateEndStr := t2.Format("2006-01-02")
  13785. // // struct4101.SetlBegnDate = dateStartStr
  13786. // // struct4101.SetlEndDate = dateEndStr
  13787. // //}
  13788. //
  13789. // var rf []CustomFundPay
  13790. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  13791. //
  13792. // var tempFunPays []service.CustomStruct
  13793. // var tempFunPay610100 service.CustomStruct
  13794. //
  13795. // for _, item := range rf {
  13796. // if item.FundPayType == "610100" {
  13797. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  13798. // tempFunPay610100.FundPayType = item.FundPayType
  13799. // } else {
  13800. // var tempFunPay service.CustomStruct
  13801. // tempFunPay.FundPayamt = item.FundPayamt
  13802. // tempFunPay.FundPayType = item.FundPayType
  13803. // tempFunPays = append(tempFunPays, tempFunPay)
  13804. // }
  13805. // }
  13806. // tempFunPays = append(tempFunPays, tempFunPay610100)
  13807. // struct4101.CustomStruct = tempFunPays
  13808. //
  13809. // var tempDiaginfos []service.DiaginfoStructTwo
  13810. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13811. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13812. //
  13813. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13814. // var config []*models.HisXtDiagnoseConfig
  13815. // for _, item := range diagnosis_ids {
  13816. // id, _ := strconv.ParseInt(item, 10, 64)
  13817. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  13818. // config = append(config, &diagnosisConfig)
  13819. // }
  13820. //
  13821. // for index, item := range config {
  13822. // if index == 0 {
  13823. // var tempDiaginfo service.DiaginfoStructTwo
  13824. // tempDiaginfo.DiagCode = item.CountryCode
  13825. // tempDiaginfo.DiagName = item.CountryContentName
  13826. // tempDiaginfo.DiagType = "1"
  13827. // tempDiaginfo.MaindiagFlag = "1"
  13828. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13829. // } else {
  13830. //
  13831. // var tempDiaginfo service.DiaginfoStructTwo
  13832. // tempDiaginfo.DiagCode = item.CountryCode
  13833. // tempDiaginfo.DiagName = item.CountryContentName
  13834. // tempDiaginfo.DiagType = "2"
  13835. // tempDiaginfo.MaindiagFlag = "0"
  13836. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13837. // }
  13838. // }
  13839. // struct4101.Diseinfo = tempDiaginfos
  13840. //
  13841. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  13842. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13843. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13844. // tempOpspdiseinfo2.OprnOprtCode = ""
  13845. // tempOpspdiseinfo2.OprnOprtName = ""
  13846. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13847. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13848. //
  13849. // var iteminfo service.IteminfoStruct
  13850. //
  13851. // var bedCostTotal float64 = 0 //床位总费
  13852. // var bedCostSelfTotal float64 = 0 //床位自费
  13853. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13854. //
  13855. // var examineCostTotal float64 = 0 //诊查总费
  13856. // var examineCostSelfTotal float64 = 0 //诊查自费
  13857. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  13858. //
  13859. // var nursingCostTotal float64 = 0 //护理总费
  13860. // var nursingCostSelfTotal float64 = 0 //护理自费
  13861. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  13862. //
  13863. // var chineseMedicineCostTotal float64 = 0 //中成药
  13864. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  13865. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  13866. //
  13867. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  13868. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  13869. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  13870. //
  13871. // var registerCostTotal float64 = 0 //一般诊疗费
  13872. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  13873. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  13874. //
  13875. // var operationCostTotal float64 = 0 //手术费
  13876. // var operationCostSelfTotal float64 = 0 //手术费
  13877. // var operationCostPartSelfTotal float64 = 0 //手术费
  13878. //
  13879. // var otherCostTotal float64 = 0 //其他费用
  13880. // var otherCostSelfTotal float64 = 0 //其他费用
  13881. // var otherCostPartSelfTotal float64 = 0 //其他费用
  13882. //
  13883. // var materialCostTotal float64 = 0 //材料费
  13884. // var materialCostSelfTotal float64 = 0 //材料费
  13885. // var materialCostPartSelfTotal float64 = 0 //材料费
  13886. //
  13887. // var westernMedicineCostTotal float64 = 0 //西药费
  13888. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  13889. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13890. //
  13891. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13892. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13893. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13894. //
  13895. // var checkCostTotal float64 = 0 //检查费
  13896. // var checkCostSelfTotal float64 = 0 //检查费
  13897. // var checkCostPartSelfTotal float64 = 0 //检查费
  13898. //
  13899. // var laboratoryCostTotal float64 = 0 //化验费
  13900. // var laboratoryCostSelfTotal float64 = 0 //化验费
  13901. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13902. //
  13903. // var treatCostTotal float64 = 0 //治疗费用
  13904. // var treatCostSelfTotal float64 = 0 //治疗费用
  13905. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  13906. //
  13907. // decimal.DivisionPrecision = 2
  13908. //
  13909. // var bed_fulamt_ownpay_amt float64 = 0
  13910. //
  13911. // var examine_fulamt_ownpay_amt float64 = 0
  13912. //
  13913. // var nursing_fulamt_ownpay_amt float64 = 0
  13914. //
  13915. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  13916. //
  13917. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  13918. //
  13919. // var register_fulamt_ownpay_amt float64 = 0
  13920. //
  13921. // var operation_fulamt_ownpay_amt float64 = 0
  13922. // var other_fulamt_ownpay_amt float64 = 0
  13923. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  13924. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13925. // var check_fulamt_ownpay_amt float64 = 0
  13926. // var material_fulamt_ownpay_amt float64 = 0
  13927. // var laboratory_fulamt_ownpay_amt float64 = 0
  13928. // var treat_fulamt_ownpay_amt float64 = 0
  13929. //
  13930. // var bed_claa_sunmfee float64 = 0
  13931. // var bed_clab_amt float64 = 0
  13932. // var bed_other_amt float64 = 0
  13933. //
  13934. // var examine_claa_sunmfee float64 = 0
  13935. // var examine_clab_amt float64 = 0
  13936. // var examine_other_amt float64 = 0
  13937. //
  13938. // var nursing_claa_sunmfee float64 = 0
  13939. // var nursing_clab_amt float64 = 0
  13940. // var nursing_other_amt float64 = 0
  13941. //
  13942. // var chinese_medicine_claa_sunmfee float64 = 0
  13943. // var chinese_medicine_clab_amt float64 = 0
  13944. // var chinese_medicine_other_amt float64 = 0
  13945. //
  13946. // var commonly_treatment_claa_sunmfee float64 = 0
  13947. // var commonly_treatment_clab_amt float64 = 0
  13948. // var commonly_treatment_other_amt float64 = 0
  13949. //
  13950. // var operation_claa_sunmfee float64 = 0
  13951. // var operation_clab_amt float64 = 0
  13952. // var operation_other_amt float64 = 0
  13953. //
  13954. // var other_claa_sunmfee float64 = 0
  13955. // var other_clab_amt float64 = 0
  13956. // var other_other_amt float64 = 0
  13957. //
  13958. // var westernMedicine_claa_sunmfee float64 = 0
  13959. // var westernMedicine_clab_amt float64 = 0
  13960. // var westernMedicine_other_amt float64 = 0
  13961. //
  13962. // var chineseTraditional_claa_sunmfee float64 = 0
  13963. // var chineseTraditional_clab_amt float64 = 0
  13964. // var chineseTraditional_other_amt float64 = 0
  13965. //
  13966. // var check_claa_sunmfee float64 = 0
  13967. // var check_clab_amt float64 = 0
  13968. // var check_other_amt float64 = 0
  13969. //
  13970. // var material_claa_sunmfee float64 = 0
  13971. // var material_clab_amt float64 = 0
  13972. // var material_other_amt float64 = 0
  13973. //
  13974. // var laboratory_claa_sunmfee float64 = 0
  13975. // var laboratory_clab_amt float64 = 0
  13976. // var laboratory_other_amt float64 = 0
  13977. //
  13978. // var treat_claa_sunmfee float64 = 0
  13979. // var treat_clab_amt float64 = 0
  13980. // var treat_other_amt float64 = 0
  13981. //
  13982. // var register_claa_sunmfee float64 = 0
  13983. // var register_clab_amt float64 = 0
  13984. // var register_other_amt float64 = 0
  13985. //
  13986. // for _, item := range order.HisOrderInfo {
  13987. // if item.MedChrgitmType == "01" { //床位费
  13988. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13989. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13990. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13991. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13992. // if item.ChrgitmLv == "1" {
  13993. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13994. // }
  13995. // if item.ChrgitmLv == "2" {
  13996. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13997. //
  13998. // }
  13999. // if item.ChrgitmLv == "3" {
  14000. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14001. // }
  14002. //
  14003. // }
  14004. //
  14005. // if item.MedChrgitmType == "02" { //诊查
  14006. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14007. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14008. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14009. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14010. // if item.ChrgitmLv == "1" {
  14011. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14012. // }
  14013. // if item.ChrgitmLv == "2" {
  14014. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14015. //
  14016. // }
  14017. // if item.ChrgitmLv == "3" {
  14018. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14019. // }
  14020. //
  14021. // }
  14022. //
  14023. // if item.MedChrgitmType == "03" { //检查费
  14024. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14025. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14026. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14027. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14028. // if item.ChrgitmLv == "1" {
  14029. //
  14030. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14031. //
  14032. // }
  14033. // if item.ChrgitmLv == "2" {
  14034. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14035. //
  14036. // }
  14037. // if item.ChrgitmLv == "3" {
  14038. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14039. // }
  14040. // }
  14041. //
  14042. // if item.MedChrgitmType == "04" { //化验费
  14043. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14044. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14045. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14046. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14047. // if item.ChrgitmLv == "1" {
  14048. //
  14049. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14050. //
  14051. // }
  14052. // if item.ChrgitmLv == "2" {
  14053. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14054. //
  14055. // }
  14056. // if item.ChrgitmLv == "3" {
  14057. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14058. // }
  14059. // }
  14060. //
  14061. // if item.MedChrgitmType == "05" { //治疗费
  14062. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14063. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14064. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14065. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14066. // if item.ChrgitmLv == "1" {
  14067. //
  14068. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14069. //
  14070. // }
  14071. // if item.ChrgitmLv == "2" {
  14072. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14073. //
  14074. // }
  14075. // if item.ChrgitmLv == "3" {
  14076. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14077. // }
  14078. // }
  14079. //
  14080. // if item.MedChrgitmType == "06" { //手术费
  14081. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14082. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14083. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14084. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14085. //
  14086. // if item.ChrgitmLv == "1" {
  14087. //
  14088. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14089. //
  14090. // }
  14091. // if item.ChrgitmLv == "2" {
  14092. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14093. //
  14094. // }
  14095. // if item.ChrgitmLv == "3" {
  14096. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14097. // }
  14098. // }
  14099. //
  14100. // if item.MedChrgitmType == "07" { //手术费
  14101. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14102. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14103. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14104. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14105. //
  14106. // if item.ChrgitmLv == "1" {
  14107. //
  14108. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14109. //
  14110. // }
  14111. // if item.ChrgitmLv == "2" {
  14112. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14113. //
  14114. // }
  14115. // if item.ChrgitmLv == "3" {
  14116. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14117. // }
  14118. // }
  14119. //
  14120. // if item.MedChrgitmType == "08" { //材料费
  14121. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14122. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14123. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14124. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14125. // if item.ChrgitmLv == "1" {
  14126. //
  14127. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14128. //
  14129. // }
  14130. // if item.ChrgitmLv == "2" {
  14131. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14132. //
  14133. // }
  14134. // if item.ChrgitmLv == "3" {
  14135. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14136. // }
  14137. // }
  14138. // if item.MedChrgitmType == "09" { //西药费
  14139. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14140. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14141. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14142. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14143. // if item.ChrgitmLv == "1" {
  14144. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14145. // }
  14146. // if item.ChrgitmLv == "2" {
  14147. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14148. // }
  14149. // if item.ChrgitmLv == "3" {
  14150. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14151. // }
  14152. // }
  14153. // if item.MedChrgitmType == "10" { //中药饮片
  14154. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14155. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14156. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14157. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14158. // if item.ChrgitmLv == "1" {
  14159. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14160. // }
  14161. // if item.ChrgitmLv == "2" {
  14162. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14163. // }
  14164. // if item.ChrgitmLv == "3" {
  14165. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14166. // }
  14167. // }
  14168. //
  14169. // if item.MedChrgitmType == "11" { //中成费
  14170. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14171. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14172. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14173. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14174. // if item.ChrgitmLv == "1" {
  14175. //
  14176. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14177. //
  14178. // }
  14179. // if item.ChrgitmLv == "2" {
  14180. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14181. //
  14182. // }
  14183. // if item.ChrgitmLv == "3" {
  14184. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14185. // }
  14186. // }
  14187. //
  14188. // if item.MedChrgitmType == "12" { //中成费
  14189. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14190. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14191. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14192. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14193. // if item.ChrgitmLv == "1" {
  14194. //
  14195. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14196. //
  14197. // }
  14198. // if item.ChrgitmLv == "2" {
  14199. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14200. //
  14201. // }
  14202. // if item.ChrgitmLv == "3" {
  14203. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14204. // }
  14205. // }
  14206. //
  14207. // if item.MedChrgitmType == "13" { //中成费
  14208. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14209. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14210. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14211. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14212. // if item.ChrgitmLv == "1" {
  14213. //
  14214. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14215. //
  14216. // }
  14217. // if item.ChrgitmLv == "2" {
  14218. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14219. //
  14220. // }
  14221. // if item.ChrgitmLv == "3" {
  14222. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14223. // }
  14224. // }
  14225. //
  14226. // if item.MedChrgitmType == "14" { //其他费
  14227. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14228. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14229. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14230. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14231. // if item.ChrgitmLv == "1" {
  14232. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14233. //
  14234. // }
  14235. // if item.ChrgitmLv == "2" {
  14236. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14237. //
  14238. // }
  14239. // if item.ChrgitmLv == "3" {
  14240. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14241. // }
  14242. // }
  14243. //
  14244. // }
  14245. //
  14246. // var iteminfoStructs []service.IteminfoStruct
  14247. //
  14248. // if bedCostTotal != 0 {
  14249. // iteminfo.MedChrgitm = "01"
  14250. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14251. // iteminfo.Amt = bedCostTotal
  14252. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  14253. // iteminfo.ClabAmt = bed_clab_amt
  14254. // iteminfo.OthAmt = bed_other_amt
  14255. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14256. // }
  14257. //
  14258. // if examineCostTotal != 0 {
  14259. // iteminfo.MedChrgitm = "02"
  14260. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  14261. // iteminfo.Amt = examineCostTotal
  14262. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  14263. // iteminfo.ClabAmt = examine_clab_amt
  14264. // iteminfo.OthAmt = examine_other_amt
  14265. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14266. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14267. // }
  14268. //
  14269. // if checkCostTotal != 0 {
  14270. // iteminfo.MedChrgitm = "03"
  14271. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14272. // iteminfo.Amt = checkCostTotal
  14273. // iteminfo.ClaaSumfee = check_claa_sunmfee
  14274. // iteminfo.ClabAmt = check_clab_amt
  14275. // iteminfo.OthAmt = check_other_amt
  14276. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14277. //
  14278. // }
  14279. //
  14280. // if laboratoryCostTotal != 0 {
  14281. // iteminfo.MedChrgitm = "04"
  14282. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14283. // iteminfo.Amt = laboratoryCostTotal
  14284. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14285. // iteminfo.ClabAmt = laboratory_clab_amt
  14286. // iteminfo.OthAmt = laboratory_other_amt
  14287. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14288. //
  14289. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14290. //
  14291. // }
  14292. //
  14293. // if treatCostTotal != 0 {
  14294. // iteminfo.MedChrgitm = "05"
  14295. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14296. // iteminfo.Amt = treatCostTotal
  14297. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  14298. // iteminfo.ClabAmt = treat_clab_amt
  14299. // iteminfo.OthAmt = treat_other_amt
  14300. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14301. // //(struct4101.IteminfoStruct, iteminfo)
  14302. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14303. // }
  14304. //
  14305. // if operationCostTotal != 0 {
  14306. // iteminfo.MedChrgitm = "06"
  14307. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14308. // iteminfo.Amt = operationCostTotal
  14309. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  14310. // iteminfo.ClabAmt = operation_clab_amt
  14311. // iteminfo.OthAmt = operation_other_amt
  14312. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14313. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14314. // }
  14315. //
  14316. // if nursingCostTotal != 0 {
  14317. // iteminfo.MedChrgitm = "07"
  14318. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  14319. // iteminfo.Amt = nursingCostTotal
  14320. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  14321. // iteminfo.ClabAmt = nursing_clab_amt
  14322. // iteminfo.OthAmt = nursing_other_amt
  14323. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14324. // }
  14325. //
  14326. // if materialCostTotal != 0 {
  14327. // iteminfo.MedChrgitm = "08"
  14328. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14329. // iteminfo.Amt = materialCostTotal
  14330. // iteminfo.ClaaSumfee = material_claa_sunmfee
  14331. // iteminfo.ClabAmt = material_clab_amt
  14332. // iteminfo.OthAmt = material_other_amt
  14333. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14334. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14335. // }
  14336. //
  14337. // if westernMedicineCostTotal != 0 {
  14338. // iteminfo.MedChrgitm = "09"
  14339. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14340. // iteminfo.Amt = westernMedicineCostTotal
  14341. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14342. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14343. // iteminfo.OthAmt = westernMedicine_other_amt
  14344. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14345. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14346. //
  14347. // }
  14348. //
  14349. // if chineseMedicineCostTotal != 0 {
  14350. // iteminfo.MedChrgitm = "10"
  14351. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  14352. // iteminfo.Amt = chineseMedicineCostTotal
  14353. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  14354. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  14355. // iteminfo.OthAmt = chinese_medicine_other_amt
  14356. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14357. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14358. //
  14359. // }
  14360. //
  14361. // if chineseTraditionalMedicineCostTotal != 0 {
  14362. // iteminfo.MedChrgitm = "11"
  14363. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14364. // iteminfo.Amt = westernMedicineCostTotal
  14365. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14366. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14367. // iteminfo.OthAmt = westernMedicine_other_amt
  14368. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14369. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14370. //
  14371. // }
  14372. //
  14373. // if commonlyTreatmentCostTotal != 0 {
  14374. // iteminfo.MedChrgitm = "12"
  14375. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  14376. // iteminfo.Amt = commonlyTreatmentCostTotal
  14377. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  14378. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  14379. // iteminfo.OthAmt = commonly_treatment_other_amt
  14380. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14381. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14382. //
  14383. // }
  14384. //
  14385. // if registerCostTotal != 0 {
  14386. // iteminfo.MedChrgitm = "13"
  14387. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  14388. // iteminfo.Amt = registerCostTotal
  14389. // iteminfo.ClaaSumfee = register_claa_sunmfee
  14390. // iteminfo.ClabAmt = register_clab_amt
  14391. // iteminfo.OthAmt = register_other_amt
  14392. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14393. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14394. //
  14395. // }
  14396. //
  14397. // if otherCostTotal != 0 {
  14398. // iteminfo.MedChrgitm = "14"
  14399. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14400. // iteminfo.Amt = otherCostTotal
  14401. // iteminfo.ClaaSumfee = other_claa_sunmfee
  14402. // iteminfo.ClabAmt = other_clab_amt
  14403. // iteminfo.OthAmt = other_other_amt
  14404. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14405. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14406. //
  14407. // }
  14408. // struct4101.IteminfoStruct = iteminfoStructs
  14409. // time_arr := strings.Split(order.SetlTime, " ")
  14410. // struct4101.AdmTime = time_arr[0]
  14411. // struct4101.AdmEndTime = time_arr[0]
  14412. //
  14413. // struct4101.DoctorName = doctor.UserName
  14414. // struct4101.DoctorCode = doctor.DoctorNumber
  14415. //
  14416. // struct4101.Ntly = "中国"
  14417. // struct4101.AdmCaty = "A03.06"
  14418. // var res ResultSeventeen
  14419. // if miConfig.MdtrtareaAdmvs == "421300" {
  14420. // data := make(map[string]interface{})
  14421. // data["struct4101"] = struct4101
  14422. // data["secret_key"] = miConfig.SecretKey
  14423. // data["org_name"] = miConfig.OrgName
  14424. // data["opera"] = curRoles.UserName
  14425. // data["code"] = miConfig.Code
  14426. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14427. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14428. //
  14429. // client := &http.Client{}
  14430. // bytesData, _ := json.Marshal(data)
  14431. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14432. // resp, _ := client.Do(req)
  14433. // defer resp.Body.Close()
  14434. // body, ioErr := ioutil.ReadAll(resp.Body)
  14435. // if ioErr != nil {
  14436. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14437. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14438. // return
  14439. // }
  14440. // var respJSON map[string]interface{}
  14441. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14442. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14444. // return
  14445. // }
  14446. //
  14447. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14448. // userJSONBytes, _ := json.Marshal(respJSON)
  14449. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14450. // utils.ErrorLog("解析失败:%v", err)
  14451. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14452. // adminUser := c.GetAdminUserInfo()
  14453. // errlog := &models.HisOrderError{
  14454. // UserOrgId: adminUser.CurrentOrgId,
  14455. // Ctime: time.Now().Unix(),
  14456. // Mtime: time.Now().Unix(),
  14457. // ErrMsg: res.ErrMsg + "解析失败",
  14458. // Status: 1,
  14459. // PatientId: order_id,
  14460. // Stage: 10088,
  14461. // }
  14462. // service.CreateErrMsgLog(errlog)
  14463. // continue
  14464. // }
  14465. //
  14466. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  14467. // data := make(map[string]interface{})
  14468. // data["struct4101"] = struct4101
  14469. // data["secret_key"] = miConfig.SecretKey
  14470. // data["org_name"] = miConfig.OrgName
  14471. // data["opera"] = curRoles.UserName
  14472. // data["code"] = miConfig.Code
  14473. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14474. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14475. //
  14476. // client := &http.Client{}
  14477. // bytesData, _ := json.Marshal(data)
  14478. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14479. // resp, _ := client.Do(req)
  14480. // defer resp.Body.Close()
  14481. // body, ioErr := ioutil.ReadAll(resp.Body)
  14482. // if ioErr != nil {
  14483. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14485. // return
  14486. // }
  14487. // var respJSON map[string]interface{}
  14488. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14489. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14490. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14491. // return
  14492. // }
  14493. //
  14494. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14495. // userJSONBytes, _ := json.Marshal(respJSON)
  14496. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14497. // utils.ErrorLog("解析失败:%v", err)
  14498. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14499. // adminUser := c.GetAdminUserInfo()
  14500. // errlog := &models.HisOrderError{
  14501. // UserOrgId: adminUser.CurrentOrgId,
  14502. // Ctime: time.Now().Unix(),
  14503. // Mtime: time.Now().Unix(),
  14504. // ErrMsg: res.ErrMsg + "解析失败",
  14505. // Status: 1,
  14506. // PatientId: order_id,
  14507. // Stage: 10088,
  14508. // }
  14509. // service.CreateErrMsgLog(errlog)
  14510. // continue
  14511. // }
  14512. //
  14513. // } else {
  14514. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  14515. // fmt.Println(result)
  14516. //
  14517. // var dat map[string]interface{}
  14518. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14519. // fmt.Println(dat)
  14520. // } else {
  14521. // fmt.Println(err)
  14522. // }
  14523. // userJSONBytes, _ := json.Marshal(dat)
  14524. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14525. // utils.ErrorLog("解析失败:%v", err)
  14526. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14527. // adminUser := c.GetAdminUserInfo()
  14528. // errlog := &models.HisOrderError{
  14529. // UserOrgId: adminUser.CurrentOrgId,
  14530. // Ctime: time.Now().Unix(),
  14531. // Mtime: time.Now().Unix(),
  14532. // ErrMsg: res.ErrMsg + "解析失败",
  14533. // Status: 1,
  14534. // PatientId: order_id,
  14535. // Stage: 10106,
  14536. // }
  14537. // service.CreateErrMsgLog(errlog)
  14538. // continue
  14539. // }
  14540. // }
  14541. //
  14542. // if res.Infcode != 0 {
  14543. // adminUser := c.GetAdminUserInfo()
  14544. // errlog := &models.HisOrderError{
  14545. // UserOrgId: adminUser.CurrentOrgId,
  14546. // Ctime: time.Now().Unix(),
  14547. // Mtime: time.Now().Unix(),
  14548. // ErrMsg: res.ErrMsg,
  14549. // Status: 1,
  14550. // PatientId: order_id,
  14551. // Stage: 10106,
  14552. // }
  14553. // service.CreateErrMsgLog(errlog)
  14554. // continue
  14555. // } else {
  14556. // hisFundSettleListResult := &models.HisFundSettleListResult{
  14557. // Number: res.Output.SetlListId,
  14558. // Status: 1,
  14559. // Ctime: time.Now().Unix(),
  14560. // Mtime: time.Now().Unix(),
  14561. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14562. // IsUpload: 1,
  14563. // OrderId: order_id,
  14564. // }
  14565. // service.CreateUploadRecord(hisFundSettleListResult)
  14566. // continue
  14567. // }
  14568. // }
  14569. //}
  14570. func (c *HisApiController) GetOrgInfo() {
  14571. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  14572. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  14573. }
  14574. func (c *HisApiController) GetHisPatientInfo() {
  14575. medical_insurance_card := c.GetString("medical_insurance_card")
  14576. id_card_type, _ := c.GetInt64("id_card_type")
  14577. id_card := c.GetString("id_card")
  14578. adminInfo := c.GetAdminUserInfo()
  14579. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  14580. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  14581. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  14582. IdCardNo := ""
  14583. if id_card_type == 1 {
  14584. IdCardNo = medical_insurance_card
  14585. } else if id_card_type == 2 {
  14586. IdCardNo = id_card
  14587. }
  14588. if config.IsOpen == 1 {
  14589. 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
  14590. resp, requestErr := http.Get(api)
  14591. if requestErr != nil {
  14592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14593. return
  14594. }
  14595. defer resp.Body.Close()
  14596. body, ioErr := ioutil.ReadAll(resp.Body)
  14597. if ioErr != nil {
  14598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14600. return
  14601. }
  14602. var respJSON map[string]interface{}
  14603. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14606. return
  14607. }
  14608. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14609. userJSONBytes, _ := json.Marshal(userJSON)
  14610. var res ResultTwo
  14611. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14612. utils.ErrorLog("解析失败:%v", err)
  14613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14614. return
  14615. }
  14616. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14617. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14618. infoStr := string(Iinfos)
  14619. idetinfoStr := string(Idetinfos)
  14620. if res.Infcode == 0 {
  14621. his := models.VMHisPatient{
  14622. Status: 1,
  14623. Ctime: time.Now().Unix(),
  14624. Mtime: time.Now().Unix(),
  14625. PsnNo: res.Output.Baseinfo.PsnNo,
  14626. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14627. Certno: res.Output.Baseinfo.Certno,
  14628. PsnName: res.Output.Baseinfo.PsnName,
  14629. Gend: res.Output.Baseinfo.Gend,
  14630. Naty: res.Output.Baseinfo.Naty,
  14631. Iinfo: infoStr,
  14632. Idetinfo: idetinfoStr,
  14633. UserOrgId: adminInfo.CurrentOrgId,
  14634. IsReturn: 1,
  14635. IdCardType: id_card_type,
  14636. }
  14637. c.ServeSuccessJSON(map[string]interface{}{
  14638. "info": his,
  14639. })
  14640. } else {
  14641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14642. return
  14643. }
  14644. }
  14645. }
  14646. //func GetBasBaseInfo() (jsonStr string, err error) {
  14647. //
  14648. // handle := syscall.NewLazyDLL("SSCard.dll")
  14649. // add := handle.NewProc("ReadCardBas")
  14650. // str := make([]byte, 1024)
  14651. // str1 := make([]byte, 1024)
  14652. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  14653. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  14654. //
  14655. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  14656. //
  14657. // fmt.Println("> Add(4,5)的结果为:", ret)
  14658. // handle.Release()
  14659. //
  14660. // return "", nil
  14661. //
  14662. //}
  14663. //func GetQRBaseInfo() (jsonStr string, err error) {
  14664. // handle := syscall.LoadDLL("SSCard.dll")
  14665. // ReadCardBas := handle.FindProc("GetQRBase")
  14666. //
  14667. // str := make([]byte, 256)
  14668. // str1 := make([]byte, 256)
  14669. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  14670. //
  14671. // fmt.Println(string(str))
  14672. // fmt.Println(r)
  14673. // return string(str), nil
  14674. //}
  14675. //func CardInit() int {
  14676. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  14677. // add := DllTestDef.MustFindProc("Init")
  14678. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  14679. // if err != nil {
  14680. // fmt.Println("SSCard的运算结果为:", ret)
  14681. // }
  14682. // result := int(ret)
  14683. // return result
  14684. //}
  14685. //func CardInit() int {
  14686. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  14687. // if err != nil {
  14688. // fmt.Println("SSCard的运算结果为:", ret)
  14689. // }
  14690. // fmt.Println(err)
  14691. // result := int(ret)
  14692. // return result
  14693. //}
  14694. func IntPtr(n int) uintptr {
  14695. return uintptr(n)
  14696. }
  14697. func StrPtr(s string) uintptr {
  14698. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  14699. }
  14700. type Result2001 struct {
  14701. Cainfo interface{} `json:"cainfo"`
  14702. ErrMsg string `json:"err_msg"`
  14703. InfRefmsgid string `json:"inf_refmsgid"`
  14704. Infcode int64 `json:"infcode"`
  14705. Output struct {
  14706. Trtinfo struct {
  14707. PsnNo string `json:"psn_no"`
  14708. TrtChkType string `json:"trt_chk_type"`
  14709. FundPayType string `json:"fund_pay_type"`
  14710. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  14711. Begndate string `json:"begndate"`
  14712. Enddate string `json:"enddate"`
  14713. TrtChkRslt string `json:"trt_chk_rslt"`
  14714. } `json:"trtinfo"`
  14715. } `json:"output"`
  14716. RefmsgTime string `json:"refmsg_time"`
  14717. RespondTime string `json:"respond_time"`
  14718. Signtype interface{} `json:"signtype"`
  14719. WarnMsg interface{} `json:"warn_msg"`
  14720. }
  14721. type Result2001Org10265 struct {
  14722. Cainfo interface{} `json:"cainfo"`
  14723. ErrMsg string `json:"err_msg"`
  14724. InfRefmsgid string `json:"inf_refmsgid"`
  14725. Infcode string `json:"infcode"`
  14726. Output struct {
  14727. Trtinfo struct {
  14728. PsnNo string `json:"psn_no"`
  14729. TrtChkType string `json:"trt_chk_type"`
  14730. FundPayType string `json:"fund_pay_type"`
  14731. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  14732. Begndate string `json:"begndate"`
  14733. Enddate string `json:"enddate"`
  14734. TrtChkRslt string `json:"trt_chk_rslt"`
  14735. } `json:"trtinfo"`
  14736. } `json:"output"`
  14737. RefmsgTime string `json:"refmsg_time"`
  14738. RespondTime string `json:"respond_time"`
  14739. Signtype interface{} `json:"signtype"`
  14740. WarnMsg interface{} `json:"warn_msg"`
  14741. }
  14742. type ResultTwo struct {
  14743. ErrMsg string `json:"err_msg"`
  14744. InfRefmsgid string `json:"inf_refmsgid"`
  14745. Infcode int64 `json:"infcode"`
  14746. Output struct {
  14747. Baseinfo struct {
  14748. //Brdy string `json:"brdy"`
  14749. Certno string `json:"certno"`
  14750. Gend string `json:"gend"`
  14751. Naty string `json:"naty"`
  14752. PsnCertType string `json:"psn_cert_type"`
  14753. PsnName string `json:"psn_name"`
  14754. PsnNo string `json:"psn_no"`
  14755. } `json:"baseinfo"`
  14756. Idetinfo []interface{} `json:"idetinfo"`
  14757. Iinfo []struct {
  14758. Balc float64 `json:"balc"`
  14759. CvlservFlag string `json:"cvlserv_flag"`
  14760. EmpName string `json:"emp_name"`
  14761. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14762. Insutype string `json:"insutype"`
  14763. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14764. //PausInsuDate string `json:"paus_insu_date"`
  14765. //PsnInsuDate string `json:"psn_insu_date"`
  14766. PsnInsuStas string `json:"psn_insu_stas"`
  14767. PsnType string `json:"psn_type"`
  14768. } `json:"insuinfo"`
  14769. } `json:"output"`
  14770. RefmsgTime string `json:"refmsg_time"`
  14771. RespondTime string `json:"respond_time"`
  14772. Signtype interface{} `json:"signtype"`
  14773. WarnInfo interface{} `json:"warn_info"`
  14774. }
  14775. type ResultTwo10265 struct {
  14776. ErrMsg string `json:"err_msg"`
  14777. InfRefmsgid string `json:"inf_refmsgid"`
  14778. Infcode string `json:"infcode"`
  14779. Output struct {
  14780. Baseinfo struct {
  14781. //Brdy string `json:"brdy"`
  14782. Certno string `json:"certno"`
  14783. Gend string `json:"gend"`
  14784. Naty string `json:"naty"`
  14785. PsnCertType string `json:"psn_cert_type"`
  14786. PsnName string `json:"psn_name"`
  14787. PsnNo string `json:"psn_no"`
  14788. } `json:"baseinfo"`
  14789. Idetinfo []interface{} `json:"idetinfo"`
  14790. Iinfo []struct {
  14791. Balc float64 `json:"balc"`
  14792. CvlservFlag string `json:"cvlserv_flag"`
  14793. EmpName string `json:"emp_name"`
  14794. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14795. Insutype string `json:"insutype"`
  14796. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14797. PsnInsuStas string `json:"psn_insu_stas"`
  14798. PsnType string `json:"psn_type"`
  14799. } `json:"insuinfo"`
  14800. } `json:"output"`
  14801. RefmsgTime string `json:"refmsg_time"`
  14802. RespondTime string `json:"respond_time"`
  14803. Signtype interface{} `json:"signtype"`
  14804. WarnInfo interface{} `json:"warn_info"`
  14805. }
  14806. type ResultThree struct {
  14807. Cainfo interface{} `json:"cainfo"`
  14808. ErrMsg string `json:"err_msg"`
  14809. InfRefmsgid string `json:"inf_refmsgid"`
  14810. Infcode int64 `json:"infcode"`
  14811. Output struct {
  14812. Data struct {
  14813. IptOtpNo string `json:"ipt_otp_no"`
  14814. MdtrtID string `json:"mdtrt_id"`
  14815. PsnNo string `json:"psn_no"`
  14816. } `json:"data"`
  14817. } `json:"output"`
  14818. RefmsgTime string `json:"refmsg_time"`
  14819. RespondTime string `json:"respond_time"`
  14820. Signtype interface{} `json:"signtype"`
  14821. WarnMsg interface{} `json:"warn_msg"`
  14822. }
  14823. type ResultThree10265 struct {
  14824. Cainfo interface{} `json:"cainfo"`
  14825. ErrMsg string `json:"err_msg"`
  14826. InfRefmsgid string `json:"inf_refmsgid"`
  14827. Infcode string `json:"infcode"`
  14828. Output struct {
  14829. Data struct {
  14830. IptOtpNo string `json:"ipt_otp_no"`
  14831. MdtrtID string `json:"mdtrt_id"`
  14832. PsnNo string `json:"psn_no"`
  14833. } `json:"data"`
  14834. } `json:"output"`
  14835. RefmsgTime string `json:"refmsg_time"`
  14836. RespondTime string `json:"respond_time"`
  14837. Signtype interface{} `json:"signtype"`
  14838. WarnMsg interface{} `json:"warn_msg"`
  14839. }
  14840. type ResultFour struct {
  14841. Cainfo string `json:"cainfo"`
  14842. ErrMsg string `json:"err_msg"`
  14843. InfRefmsgid string `json:"inf_refmsgid"`
  14844. Infcode int64 `json:"infcode"`
  14845. Output struct {
  14846. Result []struct {
  14847. BasMednFlag string `json:"bas_medn_flag"`
  14848. ChldMedcFlag string `json:"chld_medc_flag"`
  14849. ChrgitmLv string `json:"chrgitm_lv"`
  14850. Cnt float64 `json:"cnt"`
  14851. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  14852. DrtReimFlag string `json:"drt_reim_flag"`
  14853. FeedetlSn string `json:"feedetl_sn"`
  14854. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14855. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  14856. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14857. ListSpItemFlag string `json:"list_sp_item_flag"`
  14858. LmtUsedFlag string `json:"lmt_used_flag"`
  14859. MedChrgitmType string `json:"med_chrgitm_type"`
  14860. Memo string `json:"memo"`
  14861. OverlmtAmt float64 `json:"overlmt_amt"`
  14862. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14863. Pric float64 `json:"pric"`
  14864. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  14865. SelfpayProp float64 `json:"selfpay_prop"`
  14866. } `json:"result"`
  14867. } `json:"output"`
  14868. RefmsgTime string `json:"refmsg_time"`
  14869. RespondTime string `json:"respond_time"`
  14870. Signtype string `json:"signtype"`
  14871. WarnMsg string `json:"warn_msg"`
  14872. }
  14873. type ResultFour10265 struct {
  14874. Cainfo string `json:"cainfo"`
  14875. ErrMsg string `json:"err_msg"`
  14876. InfRefmsgid string `json:"inf_refmsgid"`
  14877. Infcode string `json:"infcode"`
  14878. Output struct {
  14879. Result []struct {
  14880. BasMednFlag string `json:"bas_medn_flag"`
  14881. ChldMedcFlag string `json:"chld_medc_flag"`
  14882. ChrgitmLv string `json:"chrgitm_lv"`
  14883. Cnt float64 `json:"cnt"`
  14884. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  14885. DrtReimFlag string `json:"drt_reim_flag"`
  14886. FeedetlSn string `json:"feedetl_sn"`
  14887. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14888. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  14889. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14890. ListSpItemFlag string `json:"list_sp_item_flag"`
  14891. LmtUsedFlag string `json:"lmt_used_flag"`
  14892. MedChrgitmType string `json:"med_chrgitm_type"`
  14893. Memo string `json:"memo"`
  14894. OverlmtAmt float64 `json:"overlmt_amt"`
  14895. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14896. Pric float64 `json:"pric"`
  14897. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  14898. SelfpayProp float64 `json:"selfpay_prop"`
  14899. } `json:"result"`
  14900. } `json:"output"`
  14901. RefmsgTime string `json:"refmsg_time"`
  14902. RespondTime string `json:"respond_time"`
  14903. Signtype string `json:"signtype"`
  14904. WarnMsg string `json:"warn_msg"`
  14905. }
  14906. type ResultMemo struct {
  14907. InsuAdmdvs string `json:"insuAdmdvs"`
  14908. }
  14909. // [{"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}]
  14910. type ResultIDInfo struct {
  14911. Begntime string `json:"begntime"`
  14912. Endtime string `json:"endtime"`
  14913. Memo string `json:"memo"`
  14914. }
  14915. type ResultFive struct {
  14916. Balc float64 `json:"balc"`
  14917. CvlservFlag string `json:"cvlserv_flag"`
  14918. EmpName string `json:"emp_name"`
  14919. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14920. Insutype string `json:"insutype"`
  14921. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14922. PausInsuDate string `json:"paus_insu_date"`
  14923. PsnInsuDate string `json:"psn_insu_date"`
  14924. PsnInsuStas string `json:"psn_insu_stas"`
  14925. PsnType string `json:"psn_type"`
  14926. }
  14927. type ResultSix struct {
  14928. Cainfo interface{} `json:"cainfo"`
  14929. ErrMsg string `json:"err_msg"`
  14930. InfRefmsgid string `json:"inf_refmsgid"`
  14931. Infcode int64 `json:"infcode"`
  14932. Output struct {
  14933. } `json:"output"`
  14934. RefmsgTime string `json:"refmsg_time"`
  14935. RespondTime string `json:"respond_time"`
  14936. Signtype interface{} `json:"signtype"`
  14937. WarnMsg interface{} `json:"warn_msg"`
  14938. }
  14939. type Result2406 struct {
  14940. Cainfo interface{} `json:"cainfo"`
  14941. ErrMsg string `json:"err_msg"`
  14942. InfRefmsgid string `json:"inf_refmsgid"`
  14943. Infcode int64 `json:"infcode"`
  14944. Output struct {
  14945. Result struct {
  14946. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  14947. } `json:"result"`
  14948. } `json:"output"`
  14949. RefmsgTime string `json:"refmsg_time"`
  14950. RespondTime string `json:"respond_time"`
  14951. Signtype interface{} `json:"signtype"`
  14952. WarnMsg interface{} `json:"warn_msg"`
  14953. }
  14954. type GZResultSix struct {
  14955. Cainfo interface{} `json:"cainfo"`
  14956. ErrMsg string `json:"err_msg"`
  14957. InfRefmsgid string `json:"inf_refmsgid"`
  14958. Infcode int64 `json:"infcode"`
  14959. Output string `json:"output"`
  14960. RefmsgTime string `json:"refmsg_time"`
  14961. RespondTime string `json:"respond_time"`
  14962. Signtype interface{} `json:"signtype"`
  14963. WarnMsg interface{} `json:"warn_msg"`
  14964. }
  14965. type ResultSix10265 struct {
  14966. Cainfo interface{} `json:"cainfo"`
  14967. ErrMsg string `json:"err_msg"`
  14968. InfRefmsgid string `json:"inf_refmsgid"`
  14969. Infcode string `json:"infcode"`
  14970. Output struct {
  14971. } `json:"output"`
  14972. RefmsgTime string `json:"refmsg_time"`
  14973. RespondTime string `json:"respond_time"`
  14974. Signtype interface{} `json:"signtype"`
  14975. WarnMsg interface{} `json:"warn_msg"`
  14976. }
  14977. type ResultSeven struct {
  14978. Cainfo string `json:"cainfo"`
  14979. ErrMsg string `json:"err_msg"`
  14980. InfRefmsgid string `json:"inf_refmsgid"`
  14981. Infcode int64 `json:"infcode"`
  14982. Output struct {
  14983. Setlinfo struct {
  14984. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  14985. AcctPay float64 `json:"acct_pay"`
  14986. ActPayDedc float64 `json:"act_pay_dedc"`
  14987. Age float64 `json:"age"`
  14988. Balc float64 `json:"balc"`
  14989. Certno string `json:"certno"`
  14990. ClrOptins string `json:"clr_optins"`
  14991. ClrType string `json:"clr_type"`
  14992. ClrWay string `json:"clr_way"`
  14993. CvlservFlag string `json:"cvlserv_flag"`
  14994. CvlservPay float64 `json:"cvlserv_pay"`
  14995. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14996. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  14997. Gend string `json:"gend"`
  14998. HifesPay float64 `json:"hifes_pay"`
  14999. HifmiPay float64 `json:"hifmi_pay"`
  15000. HifpPay float64 `json:"hifp_pay"`
  15001. HospPartAmt float64 `json:"hosp_part_amt"`
  15002. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15003. Insutype string `json:"insutype"`
  15004. MafPay float64 `json:"maf_pay"`
  15005. MdtrtCertType string `json:"mdtrt_cert_type"`
  15006. HifobPay float64 `json:"hifob_pay"`
  15007. MdtrtID string `json:"mdtrt_id"`
  15008. MedType string `json:"med_type"`
  15009. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15010. MedinsSetlID string `json:"medins_setl_id"`
  15011. Naty string `json:"naty"`
  15012. OthPay float64 `json:"oth_pay"`
  15013. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15014. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15015. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15016. PsnCashPay float64 `json:"psn_cash_pay"`
  15017. PsnCertType string `json:"psn_cert_type"`
  15018. PsnName string `json:"psn_name"`
  15019. PsnNo string `json:"psn_no"`
  15020. PsnPartAmt float64 `json:"psn_part_amt"`
  15021. PsnType string `json:"psn_type"`
  15022. SetlID string `json:"setl_id"`
  15023. SetlTime string `json:"setl_time"`
  15024. } `json:"setlinfo"`
  15025. Setldetail interface{} `json:"setldetail"`
  15026. } `json:"output"`
  15027. RefmsgTime string `json:"refmsg_time"`
  15028. RespondTime string `json:"respond_time"`
  15029. Signtype interface{} `json:"signtype"`
  15030. WarnMsg interface{} `json:"warn_msg"`
  15031. }
  15032. type ResultSevenAH struct {
  15033. Cainfo string `json:"cainfo"`
  15034. ErrMsg string `json:"err_msg"`
  15035. InfRefmsgid string `json:"inf_refmsgid"`
  15036. Infcode int64 `json:"infcode"`
  15037. Output struct {
  15038. Setlinfo struct {
  15039. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15040. AcctPay float64 `json:"acct_pay"`
  15041. ActPayDedc float64 `json:"act_pay_dedc"`
  15042. Age float64 `json:"age"`
  15043. Balc float64 `json:"balc"`
  15044. Certno string `json:"certno"`
  15045. ClrOptins string `json:"clr_optins"`
  15046. ClrType string `json:"clr_type"`
  15047. ClrWay string `json:"clr_way"`
  15048. CvlservFlag string `json:"cvlserv_flag"`
  15049. CvlservPay float64 `json:"cvlserv_pay"`
  15050. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15051. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15052. Gend string `json:"gend"`
  15053. HifesPay float64 `json:"hifes_pay"`
  15054. HifmiPay float64 `json:"hifmi_pay"`
  15055. HifpPay float64 `json:"hifp_pay"`
  15056. HospPartAmt float64 `json:"hosp_part_amt"`
  15057. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15058. Insutype string `json:"insutype"`
  15059. MafPay float64 `json:"maf_pay"`
  15060. MdtrtCertType string `json:"mdtrt_cert_type"`
  15061. HifobPay float64 `json:"hifob_pay"`
  15062. MdtrtID string `json:"mdtrt_id"`
  15063. MedType string `json:"med_type"`
  15064. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15065. MedinsSetlID string `json:"medins_setl_id"`
  15066. Naty string `json:"naty"`
  15067. OthPay float64 `json:"oth_pay"`
  15068. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15069. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15070. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15071. PsnCashPay float64 `json:"psn_cash_pay"`
  15072. PsnCertType string `json:"psn_cert_type"`
  15073. PsnName string `json:"psn_name"`
  15074. PsnNo string `json:"psn_no"`
  15075. PsnPartAmt float64 `json:"psn_part_amt"`
  15076. PsnType string `json:"psn_type"`
  15077. SetlID string `json:"setl_id"`
  15078. SetlTime int64 `json:"setl_time"`
  15079. } `json:"setlinfo"`
  15080. Setldetail interface{} `json:"setldetail"`
  15081. } `json:"output"`
  15082. RefmsgTime string `json:"refmsg_time"`
  15083. RespondTime string `json:"respond_time"`
  15084. Signtype interface{} `json:"signtype"`
  15085. WarnMsg interface{} `json:"warn_msg"`
  15086. }
  15087. type ResultSeven10265 struct {
  15088. Cainfo string `json:"cainfo"`
  15089. ErrMsg string `json:"err_msg"`
  15090. InfRefmsgid string `json:"inf_refmsgid"`
  15091. Infcode string `json:"infcode"`
  15092. Output struct {
  15093. Setlinfo struct {
  15094. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15095. AcctPay float64 `json:"acct_pay"`
  15096. ActPayDedc float64 `json:"act_pay_dedc"`
  15097. Age float64 `json:"age"`
  15098. Balc float64 `json:"balc"`
  15099. Certno string `json:"certno"`
  15100. ClrOptins string `json:"clr_optins"`
  15101. ClrType string `json:"clr_type"`
  15102. ClrWay string `json:"clr_way"`
  15103. CvlservFlag string `json:"cvlserv_flag"`
  15104. CvlservPay float64 `json:"cvlserv_pay"`
  15105. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15106. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15107. Gend string `json:"gend"`
  15108. HifesPay float64 `json:"hifes_pay"`
  15109. HifmiPay float64 `json:"hifmi_pay"`
  15110. HifpPay float64 `json:"hifp_pay"`
  15111. HospPartAmt float64 `json:"hosp_part_amt"`
  15112. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15113. Insutype string `json:"insutype"`
  15114. MafPay float64 `json:"maf_pay"`
  15115. MdtrtCertType string `json:"mdtrt_cert_type"`
  15116. HifobPay float64 `json:"hifob_pay"`
  15117. MdtrtID string `json:"mdtrt_id"`
  15118. MedType string `json:"med_type"`
  15119. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15120. MedinsSetlID string `json:"medins_setl_id"`
  15121. Naty string `json:"naty"`
  15122. OthPay float64 `json:"oth_pay"`
  15123. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15124. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15125. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15126. PsnCashPay float64 `json:"psn_cash_pay"`
  15127. PsnCertType string `json:"psn_cert_type"`
  15128. PsnName string `json:"psn_name"`
  15129. PsnNo string `json:"psn_no"`
  15130. PsnPartAmt float64 `json:"psn_part_amt"`
  15131. PsnType string `json:"psn_type"`
  15132. SetlID string `json:"setl_id"`
  15133. SetlTime string `json:"setl_time"`
  15134. } `json:"setlinfo"`
  15135. Setldetail interface{} `json:"setldetail"`
  15136. } `json:"output"`
  15137. RefmsgTime string `json:"refmsg_time"`
  15138. RespondTime string `json:"respond_time"`
  15139. Signtype interface{} `json:"signtype"`
  15140. WarnMsg interface{} `json:"warn_msg"`
  15141. }
  15142. type ResultSeven10265Two struct {
  15143. Cainfo string `json:"cainfo"`
  15144. ErrMsg string `json:"err_msg"`
  15145. InfRefmsgid string `json:"inf_refmsgid"`
  15146. Infcode string `json:"infcode"`
  15147. Output struct {
  15148. Setlinfo struct {
  15149. AcctMulaidPay string `json:"acct_mulaid_pay"`
  15150. AcctPay float64 `json:"acct_pay"`
  15151. ActPayDedc float64 `json:"act_pay_dedc"`
  15152. Age float64 `json:"age"`
  15153. Balc float64 `json:"balc"`
  15154. Certno string `json:"certno"`
  15155. ClrOptins string `json:"clr_optins"`
  15156. ClrType string `json:"clr_type"`
  15157. ClrWay string `json:"clr_way"`
  15158. CvlservFlag string `json:"cvlserv_flag"`
  15159. CvlservPay float64 `json:"cvlserv_pay"`
  15160. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15161. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15162. Gend string `json:"gend"`
  15163. HifesPay float64 `json:"hifes_pay"`
  15164. HifmiPay float64 `json:"hifmi_pay"`
  15165. HifpPay float64 `json:"hifp_pay"`
  15166. HospPartAmt string `json:"hosp_part_amt"`
  15167. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15168. Insutype string `json:"insutype"`
  15169. MafPay float64 `json:"maf_pay"`
  15170. MdtrtCertType string `json:"mdtrt_cert_type"`
  15171. HifobPay float64 `json:"hifob_pay"`
  15172. MdtrtID string `json:"mdtrt_id"`
  15173. MedType string `json:"med_type"`
  15174. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15175. MedinsSetlID string `json:"medins_setl_id"`
  15176. Naty string `json:"naty"`
  15177. OthPay float64 `json:"oth_pay"`
  15178. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15179. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15180. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15181. PsnCashPay float64 `json:"psn_cash_pay"`
  15182. PsnCertType string `json:"psn_cert_type"`
  15183. PsnName string `json:"psn_name"`
  15184. PsnNo string `json:"psn_no"`
  15185. PsnPartAmt float64 `json:"psn_part_amt"`
  15186. PsnType string `json:"psn_type"`
  15187. SetlID string `json:"setl_id"`
  15188. SetlTime string `json:"setl_time"`
  15189. } `json:"setlinfo"`
  15190. Setldetail interface{} `json:"setldetail"`
  15191. } `json:"output"`
  15192. RefmsgTime string `json:"refmsg_time"`
  15193. RespondTime string `json:"respond_time"`
  15194. Signtype interface{} `json:"signtype"`
  15195. WarnMsg interface{} `json:"warn_msg"`
  15196. }
  15197. type GZResultSeven10265Two struct {
  15198. Cainfo string `json:"cainfo"`
  15199. ErrMsg string `json:"err_msg"`
  15200. InfRefmsgid string `json:"inf_refmsgid"`
  15201. Infcode int64 `json:"infcode"`
  15202. Output struct {
  15203. Setlinfo struct {
  15204. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15205. AcctPay float64 `json:"acct_pay"`
  15206. ActPayDedc float64 `json:"act_pay_dedc"`
  15207. Age float64 `json:"age"`
  15208. Balc float64 `json:"balc"`
  15209. Certno string `json:"certno"`
  15210. ClrOptins string `json:"clr_optins"`
  15211. ClrType string `json:"clr_type"`
  15212. ClrWay string `json:"clr_way"`
  15213. CvlservFlag string `json:"cvlserv_flag"`
  15214. CvlservPay float64 `json:"cvlserv_pay"`
  15215. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15216. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15217. Gend string `json:"gend"`
  15218. HifesPay float64 `json:"hifes_pay"`
  15219. HifmiPay float64 `json:"hifmi_pay"`
  15220. HifpPay float64 `json:"hifp_pay"`
  15221. HospPartAmt float64 `json:"hosp_part_amt"`
  15222. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15223. Insutype string `json:"insutype"`
  15224. MafPay float64 `json:"maf_pay"`
  15225. MdtrtCertType string `json:"mdtrt_cert_type"`
  15226. HifobPay float64 `json:"hifob_pay"`
  15227. MdtrtID string `json:"mdtrt_id"`
  15228. MedType string `json:"med_type"`
  15229. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15230. MedinsSetlID string `json:"medins_setl_id"`
  15231. Naty string `json:"naty"`
  15232. OthPay float64 `json:"oth_pay"`
  15233. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15234. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15235. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15236. PsnCashPay float64 `json:"psn_cash_pay"`
  15237. PsnCertType string `json:"psn_cert_type"`
  15238. PsnName string `json:"psn_name"`
  15239. PsnNo string `json:"psn_no"`
  15240. PsnPartAmt float64 `json:"psn_part_amt"`
  15241. PsnType string `json:"psn_type"`
  15242. SetlID string `json:"setl_id"`
  15243. SetlTime string `json:"setl_time"`
  15244. } `json:"setlinfo"`
  15245. Setldetail interface{} `json:"setldetail"`
  15246. } `json:"output"`
  15247. RefmsgTime string `json:"refmsg_time"`
  15248. RespondTime string `json:"respond_time"`
  15249. Signtype interface{} `json:"signtype"`
  15250. WarnMsg interface{} `json:"warn_msg"`
  15251. }
  15252. type ResultEight struct {
  15253. Cainfo string `json:"cainfo"`
  15254. ErrMsg string `json:"err_msg"`
  15255. InfRefmsgid string `json:"inf_refmsgid"`
  15256. Infcode int64 `json:"infcode"`
  15257. Output struct {
  15258. Stmtinfo struct {
  15259. SetlOptins string `json:"setl_optins"`
  15260. StmtRslt string `json:"stmt_rslt"`
  15261. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15262. } `json:"stmtinfo"`
  15263. } `json:"output"`
  15264. RefmsgTime string `json:"refmsg_time"`
  15265. RespondTime string `json:"respond_time"`
  15266. Signtype interface{} `json:"signtype"`
  15267. WarnMsg interface{} `json:"warn_msg"`
  15268. }
  15269. type ResultEightFor10188 struct {
  15270. Cainfo string `json:"cainfo"`
  15271. ErrMsg string `json:"err_msg"`
  15272. InfRefmsgid string `json:"inf_refmsgid"`
  15273. Infcode string `json:"infcode"`
  15274. Output struct {
  15275. Stmtinfo struct {
  15276. SetlOptins string `json:"setl_optins"`
  15277. StmtRslt string `json:"stmt_rslt"`
  15278. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15279. } `json:"stmtinfo"`
  15280. } `json:"output"`
  15281. RefmsgTime string `json:"refmsg_time"`
  15282. RespondTime string `json:"respond_time"`
  15283. Signtype interface{} `json:"signtype"`
  15284. WarnMsg interface{} `json:"warn_msg"`
  15285. }
  15286. type ResultNine struct {
  15287. Cainfo string `json:"cainfo"`
  15288. ErrMsg string `json:"err_msg"`
  15289. InfRefmsgid string `json:"inf_refmsgid"`
  15290. Infcode int64 `json:"infcode"`
  15291. Output struct {
  15292. FileQuryNo string `json:"file_qury_no"`
  15293. } `json:"output"`
  15294. RefmsgTime string `json:"refmsg_time"`
  15295. RespondTime string `json:"respond_time"`
  15296. Signtype interface{} `json:"signtype"`
  15297. WarnMsg interface{} `json:"warn_msg"`
  15298. }
  15299. type ResultTen struct {
  15300. Cainfo string `json:"cainfo"`
  15301. ErrMsg string `json:"err_msg"`
  15302. InfRefmsgid string `json:"inf_refmsgid"`
  15303. Infcode int64 `json:"infcode"`
  15304. Output struct {
  15305. Fileinfo struct {
  15306. DldEndtime string `json:"dld_endtime"`
  15307. FileQuryNo string `json:"file_qury_no"`
  15308. Filename string `json:"filename"`
  15309. } `json:"fileinfo"`
  15310. } `json:"output"`
  15311. RefmsgTime string `json:"refmsg_time"`
  15312. RespondTime string `json:"respond_time"`
  15313. Signtype interface{} `json:"signtype"`
  15314. WarnMsg interface{} `json:"warn_msg"`
  15315. }
  15316. type Result5262 struct {
  15317. ErrMsg string `json:"err_msg"`
  15318. InfRefmsgid string `json:"inf_refmsgid"`
  15319. Infcode int64 `json:"infcode"`
  15320. Output struct {
  15321. PageInfo struct {
  15322. Size int `json:"size"`
  15323. RecordCounts int `json:"record_counts"`
  15324. } `json:"page_info"`
  15325. Idetinfo []interface{} `json:"idetinfo"`
  15326. Result []struct {
  15327. SetlID string `json:"setl_id"`
  15328. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15329. MdtrtID string `json:"mdtrt_id"`
  15330. InitSetlID string `json:"init_setl_id,omitempty"`
  15331. PsnNo string `json:"psn_no"`
  15332. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15333. PsnName string `json:"psn_name"`
  15334. PsnCertType string `json:"psn_cert_type"`
  15335. Certno string `json:"certno"`
  15336. Gend string `json:"gend,omitempty"`
  15337. Naty string `json:"naty,omitempty"`
  15338. Brdy string `json:"brdy,omitempty"`
  15339. Age float64 `json:"age,omitempty"`
  15340. Insutype string `json:"insutype,omitempty"`
  15341. PsnType string `json:"psn_type"`
  15342. CvlservFlag string `json:"cvlserv_flag"`
  15343. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15344. SpPsnType string `json:"sp_psn_type,omitempty"`
  15345. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15346. ClctGrde string `json:"clct_grde,omitempty"`
  15347. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15348. NwbFlag string `json:"nwb_flag,omitempty"`
  15349. InsuAdmdvs string `json:"insu_admdvs"`
  15350. EmpNo string `json:"emp_no,omitempty"`
  15351. EmpName string `json:"emp_name,omitempty"`
  15352. EmpType string `json:"emp_type,omitempty"`
  15353. EconType string `json:"econ_type,omitempty"`
  15354. AfilIndu string `json:"afil_indu,omitempty"`
  15355. AfilRlts string `json:"afil_rlts,omitempty"`
  15356. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15357. PayLoc string `json:"pay_loc,omitempty"`
  15358. FixmedinsCode string `json:"fixmedins_code"`
  15359. FixmedinsName string `json:"fixmedins_name"`
  15360. HospLv string `json:"hosp_lv,omitempty"`
  15361. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15362. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15363. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15364. Begndate string `json:"begndate"`
  15365. Enddate string `json:"enddate"`
  15366. SetlTime string `json:"setl_time"`
  15367. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15368. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15369. MedType string `json:"med_type"`
  15370. SetlType string `json:"setl_type,omitempty"`
  15371. ClrType string `json:"clr_type,omitempty"`
  15372. ClrWay string `json:"clr_way,omitempty"`
  15373. PsnSetlway string `json:"psn_setlway,omitempty"`
  15374. ClrOptins string `json:"clr_optins,omitempty"`
  15375. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15376. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15377. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15378. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15379. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15380. DedcStd float64 `json:"dedc_std,omitempty"`
  15381. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15382. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15383. HifpPay float64 `json:"hifp_pay,omitempty"`
  15384. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15385. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15386. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15387. HifesPay float64 `json:"hifes_pay,omitempty"`
  15388. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15389. HifobPay float64 `json:"hifob_pay,omitempty"`
  15390. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15391. MafPay float64 `json:"maf_pay,omitempty"`
  15392. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15393. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15394. PsnPay float64 `json:"psn_pay,omitempty"`
  15395. AcctPay float64 `json:"acct_pay,omitempty"`
  15396. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15397. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15398. Balc float64 `json:"balc,omitempty"`
  15399. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  15400. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  15401. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  15402. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  15403. Year string `json:"year,omitempty"`
  15404. DiseNo string `json:"dise_no,omitempty"`
  15405. DiseName string `json:"dise_name,omitempty"`
  15406. Invono string `json:"invono,omitempty"`
  15407. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  15408. ValiFlag string `json:"vali_flag,omitempty"`
  15409. Memo string `json:"memo,omitempty"`
  15410. Rid string `json:"rid"`
  15411. UpdtTime string `json:"updt_time,omitempty"`
  15412. CrterID string `json:"crter_id,omitempty"`
  15413. CrterName string `json:"crter_name,omitempty"`
  15414. CrteTime string `json:"crte_time,omitempty"`
  15415. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  15416. OpterID string `json:"opter_id,omitempty"`
  15417. OpterName string `json:"opter_name,omitempty"`
  15418. OptTime string `json:"opt_time,omitempty"`
  15419. OptinsNo string `json:"optins_no,omitempty"`
  15420. PoolareaNo string `json:"poolarea_no,omitempty"`
  15421. } `json:"result"`
  15422. } `json:"output"`
  15423. RefmsgTime string `json:"refmsg_time"`
  15424. RespondTime string `json:"respond_time"`
  15425. Signtype interface{} `json:"signtype"`
  15426. WarnInfo interface{} `json:"warn_info"`
  15427. }
  15428. type Result5267 struct {
  15429. ErrMsg string `json:"err_msg"`
  15430. InfRefmsgid string `json:"inf_refmsgid"`
  15431. Infcode int64 `json:"infcode"`
  15432. Output struct {
  15433. PageInfo struct {
  15434. Size int `json:"size"`
  15435. RecordCounts int `json:"record_counts"`
  15436. } `json:"pageinfo"`
  15437. Result []struct {
  15438. SetlID string `json:"setl_id"`
  15439. ClrOptins string `json:"clr_optins"`
  15440. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15441. MdtrtID string `json:"mdtrt_id"`
  15442. InitSetlID string `json:"init_setl_id,omitempty"`
  15443. PsnNo string `json:"psn_no"`
  15444. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15445. PsnName string `json:"psn_name"`
  15446. PsnCertType string `json:"psn_cert_type"`
  15447. Certno string `json:"certno"`
  15448. Gend string `json:"gend,omitempty"`
  15449. Naty string `json:"naty,omitempty"`
  15450. Brdy string `json:"brdy,omitempty"`
  15451. Age float64 `json:"age,omitempty"`
  15452. Insutype string `json:"insutype,omitempty"`
  15453. PsnType string `json:"psn_type"`
  15454. CvlservFlag string `json:"cvlserv_flag"`
  15455. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15456. SpPsnType string `json:"sp_psn_type,omitempty"`
  15457. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15458. ClctGrde string `json:"clct_grde,omitempty"`
  15459. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15460. NwbFlag string `json:"nwb_flag,omitempty"`
  15461. InsuAdmdvs string `json:"insu_admdvs"`
  15462. EmpNo string `json:"emp_no,omitempty"`
  15463. EmpName string `json:"emp_name,omitempty"`
  15464. EmpType string `json:"emp_type,omitempty"`
  15465. EconType string `json:"econ_type,omitempty"`
  15466. AfilIndu string `json:"afil_indu,omitempty"`
  15467. AfilRlts string `json:"afil_rlts,omitempty"`
  15468. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15469. PayLoc string `json:"pay_loc,omitempty"`
  15470. FixmedinsCode string `json:"fixmedins_code"`
  15471. FixmedinsName string `json:"fixmedins_name"`
  15472. HospLv string `json:"hosp_lv,omitempty"`
  15473. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15474. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15475. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15476. Begndate string `json:"begndate,omitempty"`
  15477. Enddate string `json:"enddate,omitempty"`
  15478. SetlTime string `json:"setl_time,omitempty"`
  15479. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15480. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15481. MedType string `json:"med_type"`
  15482. SetlType string `json:"setl_type,omitempty"`
  15483. ClrType string `json:"clr_type,omitempty"`
  15484. ClrWay string `json:"clr_way,omitempty"`
  15485. PsnSetlway string `json:"psn_setlway,omitempty"`
  15486. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15487. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15488. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15489. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15490. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15491. DedcStd float64 `json:"dedc_std,omitempty"`
  15492. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15493. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15494. HifpPay float64 `json:"hifp_pay,omitempty"`
  15495. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15496. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15497. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15498. HifesPay float64 `json:"hifes_pay,omitempty"`
  15499. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15500. HifobPay float64 `json:"hifob_pay,omitempty"`
  15501. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15502. MafPay float64 `json:"maf_pay,omitempty"`
  15503. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15504. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15505. PsnPay float64 `json:"psn_pay,omitempty"`
  15506. AcctPay float64 `json:"acct_pay,omitempty"`
  15507. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15508. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15509. Balc float64 `json:"balc,omitempty"`
  15510. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  15511. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  15512. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  15513. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  15514. Year string `json:"year,omitempty"`
  15515. DiseNo string `json:"dise_no,omitempty"`
  15516. DiseName string `json:"dise_name,omitempty"`
  15517. Invono string `json:"invono,omitempty"`
  15518. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  15519. Memo string `json:"memo,omitempty"`
  15520. UpdtTime string `json:"updt_time,omitempty"`
  15521. OpterID string `json:"opter_id,omitempty"`
  15522. OpterName string `json:"opter_name,omitempty"`
  15523. OptTime string `json:"opt_time,omitempty"`
  15524. OptinsNo string `json:"optins_no,omitempty"`
  15525. PoolareaNo string `json:"poolarea_no,omitempty"`
  15526. } `json:"result"`
  15527. } `json:"output"`
  15528. RefmsgTime string `json:"refmsg_time"`
  15529. RespondTime string `json:"respond_time"`
  15530. Signtype interface{} `json:"signtype"`
  15531. WarnInfo interface{} `json:"warn_info"`
  15532. }
  15533. // type Autogenerated struct {
  15534. // Output struct {
  15535. // Setlinfo struct {
  15536. // SetlTime string `json:"setl_time"`
  15537. // CvlservPay float64 `json:"cvlserv_pay"`
  15538. // Year string `json:"year"`
  15539. // MedType string `json:"med_type"`
  15540. // PsnPay float64 `json:"psn_pay"`
  15541. // OpterID string `json:"opter_id"`
  15542. // Begndate string `json:"begndate"`
  15543. // FlxempeFlag string `json:"flxempe_flag"`
  15544. // HifmiPay float64 `json:"hifmi_pay"`
  15545. // PsnNo string `json:"psn_no"`
  15546. // ActPayDedc float64 `json:"act_pay_dedc"`
  15547. // MedinsSetlID interface{} `json:"medins_setl_id"`
  15548. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15549. // ClrWay string `json:"clr_way"`
  15550. // OthPay float64 `json:"oth_pay"`
  15551. // Gend string `json:"gend"`
  15552. // MdtrtID string `json:"mdtrt_id"`
  15553. // AcctPay float64 `json:"acct_pay"`
  15554. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  15555. // Insutype string `json:"insutype"`
  15556. // Invono interface{} `json:"invono"`
  15557. // Enddate string `json:"enddate"`
  15558. // CashPayamt float64 `json:"cash_payamt"`
  15559. // PsnType string `json:"psn_type"`
  15560. // FixmedinsName string `json:"fixmedins_name"`
  15561. // HifpPay float64 `json:"hifp_pay"`
  15562. // NewFlag interface{} `json:"new_flag"`
  15563. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15564. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  15565. // PayLoc string `json:"pay_loc"`
  15566. // ClrType string `json:"clr_type"`
  15567. // RefdSetlFlag string `json:"refd_setl_flag"`
  15568. // CvlservFlag string `json:"cvlserv_flag"`
  15569. // EmpName string `json:"emp_name"`
  15570. // Brdy string `json:"brdy"`
  15571. // Naty string `json:"naty"`
  15572. // Certno string `json:"certno"`
  15573. // DiseCode string `json:"dise_code"`
  15574. // FixmedinsCode string `json:"fixmedins_code"`
  15575. // DedcHospLv string `json:"dedc_hosp_lv"`
  15576. // OpterName string `json:"opter_name"`
  15577. // Balc float64 `json:"balc"`
  15578. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15579. // PsnCertType string `json:"psn_cert_type"`
  15580. // HifobPay float64 `json:"hifob_pay"`
  15581. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  15582. // HifesPay float64 `json:"hifes_pay"`
  15583. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15584. // OptTime string `json:"opt_time"`
  15585. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15586. // SetlID string `json:"setl_id"`
  15587. // MafPay float64 `json:"maf_pay"`
  15588. // PsnName string `json:"psn_name"`
  15589. // InsuOptins interface{} `json:"insu_optins"`
  15590. // PrefFundPay interface{} `json:"pref_fund_pay"`
  15591. // ClrOptins string `json:"clr_optins"`
  15592. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15593. // DiseName string `json:"dise_name"`
  15594. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15595. // Age float64 `json:"age"`
  15596. // DtrtCertType string `json:"dtrt_cert_type"`
  15597. // HospLv string `json:"hosp_lv"`
  15598. // } `json:"setlinfo"`
  15599. // Setldetail []struct {
  15600. // FundPayType string `json:"fund_pay_type"`
  15601. // FundPayamt float64 `json:"fund_payamt"`
  15602. // SetlProcInfo interface{} `json:"setl_proc_info"`
  15603. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  15604. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  15605. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  15606. // PrefFundPay interface{} `json:"pref_fund_pay"`
  15607. // } `json:"setldetail"`
  15608. // } `json:"output"`
  15609. // Infcode int `json:"infcode"`
  15610. // WarnMsg interface{} `json:"warn_msg"`
  15611. // Cainfo interface{} `json:"cainfo"`
  15612. // ErrMsg interface{} `json:"err_msg"`
  15613. // RefmsgTime string `json:"refmsg_time"`
  15614. // Signtype interface{} `json:"signtype"`
  15615. // RespondTime string `json:"respond_time"`
  15616. // InfRefmsgid string `json:"inf_refmsgid"`
  15617. // }
  15618. type Result002 struct {
  15619. Cainfo interface{} `json:"cainfo"`
  15620. ErrMsg string `json:"err_msg"`
  15621. InfRefmsgid string `json:"inf_refmsgid"`
  15622. Infcode int64 `json:"infcode"`
  15623. Output struct {
  15624. RxFile string `json:"rx_file"`
  15625. SignDigest string `json:"sign_digest"`
  15626. SignCertSn string `json:"sign_cert_sn"`
  15627. SignCertDn string `json:"sign_cert_dn"`
  15628. } `json:"output"`
  15629. RefmsgTime string `json:"refmsg_time"`
  15630. RespondTime string `json:"respond_time"`
  15631. Signtype interface{} `json:"signtype"`
  15632. WarnMsg interface{} `json:"warn_msg"`
  15633. }
  15634. type Result003 struct {
  15635. Cainfo interface{} `json:"cainfo"`
  15636. ErrMsg string `json:"err_msg"`
  15637. InfRefmsgid string `json:"inf_refmsgid"`
  15638. Infcode int64 `json:"infcode"`
  15639. Output struct {
  15640. HiRxno string `json:"hi_rxno"`
  15641. RxStasCodg string `json:"rx_stas_codg"`
  15642. RxStasName string `json:"rx_stas_name"`
  15643. } `json:"output"`
  15644. RefmsgTime string `json:"refmsg_time"`
  15645. RespondTime string `json:"respond_time"`
  15646. Signtype interface{} `json:"signtype"`
  15647. WarnMsg interface{} `json:"warn_msg"`
  15648. }
  15649. type ResultEleven struct {
  15650. Cainfo string `json:"cainfo"`
  15651. ErrMsg string `json:"err_msg"`
  15652. InfRefmsgid string `json:"inf_refmsgid"`
  15653. Infcode int64 `json:"infcode"`
  15654. Output struct {
  15655. Setlinfo struct {
  15656. SetlTime string `json:"setl_time"`
  15657. CvlservPay float64 `json:"cvlserv_pay"`
  15658. Year string `json:"year"`
  15659. MedType string `json:"med_type"`
  15660. PsnPay float64 `json:"psn_pay"`
  15661. OpterID string `json:"opter_id"`
  15662. Begndate string `json:"begndate"`
  15663. FlxempeFlag string `json:"flxempe_flag"`
  15664. HifmiPay float64 `json:"hifmi_pay"`
  15665. PsnNo string `json:"psn_no"`
  15666. ActPayDedc float64 `json:"act_pay_dedc"`
  15667. MedinsSetlID interface{} `json:"medins_setl_id"`
  15668. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15669. ClrWay string `json:"clr_way"`
  15670. OthPay float64 `json:"oth_pay"`
  15671. Gend string `json:"gend"`
  15672. MdtrtID string `json:"mdtrt_id"`
  15673. AcctPay float64 `json:"acct_pay"`
  15674. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15675. Insutype string `json:"insutype"`
  15676. Invono interface{} `json:"invono"`
  15677. Enddate string `json:"enddate"`
  15678. CashPayamt float64 `json:"cash_payamt"`
  15679. PsnType string `json:"psn_type"`
  15680. FixmedinsName string `json:"fixmedins_name"`
  15681. HifpPay float64 `json:"hifp_pay"`
  15682. NewFlag interface{} `json:"new_flag"`
  15683. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15684. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15685. PayLoc string `json:"pay_loc"`
  15686. ClrType string `json:"clr_type"`
  15687. RefdSetlFlag string `json:"refd_setl_flag"`
  15688. CvlservFlag string `json:"cvlserv_flag"`
  15689. EmpName string `json:"emp_name"`
  15690. Brdy string `json:"brdy"`
  15691. Naty string `json:"naty"`
  15692. Certno string `json:"certno"`
  15693. DiseCode string `json:"dise_code"`
  15694. FixmedinsCode string `json:"fixmedins_code"`
  15695. DedcHospLv string `json:"dedc_hosp_lv"`
  15696. OpterName string `json:"opter_name"`
  15697. Balc float64 `json:"balc"`
  15698. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15699. PsnCertType string `json:"psn_cert_type"`
  15700. HifobPay float64 `json:"hifob_pay"`
  15701. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15702. HifesPay float64 `json:"hifes_pay"`
  15703. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15704. OptTime string `json:"opt_time"`
  15705. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15706. SetlID string `json:"setl_id"`
  15707. MafPay float64 `json:"maf_pay"`
  15708. PsnName string `json:"psn_name"`
  15709. InsuOptins interface{} `json:"insu_optins"`
  15710. PrefFundPay interface{} `json:"pref_fund_pay"`
  15711. ClrOptins string `json:"clr_optins"`
  15712. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15713. DiseName string `json:"dise_name"`
  15714. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15715. Age float64 `json:"age"`
  15716. DtrtCertType string `json:"dtrt_cert_type"`
  15717. HospLv string `json:"hosp_lv"`
  15718. PsnCashPay float64 `json:"psn_cash_pay"`
  15719. } `json:"setlinfo"`
  15720. } `json:"output"`
  15721. RefmsgTime string `json:"refmsg_time"`
  15722. RespondTime string `json:"respond_time"`
  15723. Signtype interface{} `json:"signtype"`
  15724. WarnMsg interface{} `json:"warn_msg"`
  15725. }
  15726. type ResultElevenah struct {
  15727. Cainfo string `json:"cainfo"`
  15728. ErrMsg string `json:"err_msg"`
  15729. InfRefmsgid string `json:"inf_refmsgid"`
  15730. Infcode int64 `json:"infcode"`
  15731. Output struct {
  15732. Setlinfo struct {
  15733. SetlTime int64 `json:"setl_time"`
  15734. CvlservPay float64 `json:"cvlserv_pay"`
  15735. Year string `json:"year"`
  15736. MedType string `json:"med_type"`
  15737. PsnPay float64 `json:"psn_pay"`
  15738. OpterID string `json:"opter_id"`
  15739. Begndate int64 `json:"begndate"`
  15740. FlxempeFlag string `json:"flxempe_flag"`
  15741. HifmiPay float64 `json:"hifmi_pay"`
  15742. PsnNo string `json:"psn_no"`
  15743. ActPayDedc float64 `json:"act_pay_dedc"`
  15744. MedinsSetlID interface{} `json:"medins_setl_id"`
  15745. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15746. ClrWay string `json:"clr_way"`
  15747. OthPay float64 `json:"oth_pay"`
  15748. Gend string `json:"gend"`
  15749. MdtrtID string `json:"mdtrt_id"`
  15750. AcctPay float64 `json:"acct_pay"`
  15751. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15752. Insutype string `json:"insutype"`
  15753. Invono interface{} `json:"invono"`
  15754. Enddate int64 `json:"enddate"`
  15755. CashPayamt float64 `json:"cash_payamt"`
  15756. PsnType string `json:"psn_type"`
  15757. FixmedinsName string `json:"fixmedins_name"`
  15758. HifpPay float64 `json:"hifp_pay"`
  15759. NewFlag interface{} `json:"new_flag"`
  15760. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15761. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15762. PayLoc string `json:"pay_loc"`
  15763. ClrType string `json:"clr_type"`
  15764. RefdSetlFlag string `json:"refd_setl_flag"`
  15765. CvlservFlag string `json:"cvlserv_flag"`
  15766. EmpName string `json:"emp_name"`
  15767. Brdy int64 `json:"brdy"`
  15768. Naty string `json:"naty"`
  15769. Certno string `json:"certno"`
  15770. DiseCode string `json:"dise_code"`
  15771. FixmedinsCode string `json:"fixmedins_code"`
  15772. DedcHospLv string `json:"dedc_hosp_lv"`
  15773. OpterName string `json:"opter_name"`
  15774. Balc float64 `json:"balc"`
  15775. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15776. PsnCertType string `json:"psn_cert_type"`
  15777. HifobPay float64 `json:"hifob_pay"`
  15778. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15779. HifesPay float64 `json:"hifes_pay"`
  15780. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15781. OptTime int64 `json:"opt_time"`
  15782. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15783. SetlID string `json:"setl_id"`
  15784. MafPay float64 `json:"maf_pay"`
  15785. PsnName string `json:"psn_name"`
  15786. InsuOptins interface{} `json:"insu_optins"`
  15787. PrefFundPay interface{} `json:"pref_fund_pay"`
  15788. ClrOptins string `json:"clr_optins"`
  15789. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15790. DiseName string `json:"dise_name"`
  15791. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15792. Age float64 `json:"age"`
  15793. DtrtCertType string `json:"dtrt_cert_type"`
  15794. HospLv string `json:"hosp_lv"`
  15795. PsnCashPay float64 `json:"psn_cash_pay"`
  15796. } `json:"setlinfo"`
  15797. } `json:"output"`
  15798. RefmsgTime string `json:"refmsg_time"`
  15799. RespondTime string `json:"respond_time"`
  15800. Signtype interface{} `json:"signtype"`
  15801. WarnMsg interface{} `json:"warn_msg"`
  15802. }
  15803. type ResultEleven10265 struct {
  15804. Cainfo string `json:"cainfo"`
  15805. ErrMsg string `json:"err_msg"`
  15806. InfRefmsgid string `json:"inf_refmsgid"`
  15807. Infcode string `json:"infcode"`
  15808. Output struct {
  15809. Setlinfo struct {
  15810. SetlTime string `json:"setl_time"`
  15811. CvlservPay float64 `json:"cvlserv_pay"`
  15812. Year string `json:"year"`
  15813. MedType string `json:"med_type"`
  15814. PsnPay float64 `json:"psn_pay"`
  15815. OpterID string `json:"opter_id"`
  15816. Begndate string `json:"begndate"`
  15817. FlxempeFlag string `json:"flxempe_flag"`
  15818. HifmiPay float64 `json:"hifmi_pay"`
  15819. PsnNo string `json:"psn_no"`
  15820. ActPayDedc float64 `json:"act_pay_dedc"`
  15821. MedinsSetlID interface{} `json:"medins_setl_id"`
  15822. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15823. ClrWay string `json:"clr_way"`
  15824. OthPay float64 `json:"oth_pay"`
  15825. Gend string `json:"gend"`
  15826. MdtrtID string `json:"mdtrt_id"`
  15827. AcctPay float64 `json:"acct_pay"`
  15828. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15829. Insutype string `json:"insutype"`
  15830. Invono interface{} `json:"invono"`
  15831. Enddate string `json:"enddate"`
  15832. CashPayamt float64 `json:"cash_payamt"`
  15833. PsnType string `json:"psn_type"`
  15834. FixmedinsName string `json:"fixmedins_name"`
  15835. HifpPay float64 `json:"hifp_pay"`
  15836. NewFlag interface{} `json:"new_flag"`
  15837. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15838. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15839. PayLoc string `json:"pay_loc"`
  15840. ClrType string `json:"clr_type"`
  15841. RefdSetlFlag string `json:"refd_setl_flag"`
  15842. CvlservFlag string `json:"cvlserv_flag"`
  15843. EmpName string `json:"emp_name"`
  15844. Brdy string `json:"brdy"`
  15845. Naty string `json:"naty"`
  15846. Certno string `json:"certno"`
  15847. DiseCode string `json:"dise_code"`
  15848. FixmedinsCode string `json:"fixmedins_code"`
  15849. DedcHospLv string `json:"dedc_hosp_lv"`
  15850. OpterName string `json:"opter_name"`
  15851. Balc float64 `json:"balc"`
  15852. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15853. PsnCertType string `json:"psn_cert_type"`
  15854. HifobPay float64 `json:"hifob_pay"`
  15855. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15856. HifesPay float64 `json:"hifes_pay"`
  15857. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15858. OptTime string `json:"opt_time"`
  15859. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15860. SetlID string `json:"setl_id"`
  15861. MafPay float64 `json:"maf_pay"`
  15862. PsnName string `json:"psn_name"`
  15863. InsuOptins interface{} `json:"insu_optins"`
  15864. PrefFundPay interface{} `json:"pref_fund_pay"`
  15865. ClrOptins string `json:"clr_optins"`
  15866. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15867. DiseName string `json:"dise_name"`
  15868. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15869. Age float64 `json:"age"`
  15870. DtrtCertType string `json:"dtrt_cert_type"`
  15871. HospLv string `json:"hosp_lv"`
  15872. PsnCashPay float64 `json:"psn_cash_pay"`
  15873. } `json:"setlinfo"`
  15874. } `json:"output"`
  15875. RefmsgTime string `json:"refmsg_time"`
  15876. RespondTime string `json:"respond_time"`
  15877. Signtype interface{} `json:"signtype"`
  15878. WarnMsg interface{} `json:"warn_msg"`
  15879. }
  15880. type ResultTwelve struct {
  15881. Cainfo string `json:"cainfo"`
  15882. ErrMsg string `json:"err_msg"`
  15883. InfRefmsgid string `json:"inf_refmsgid"`
  15884. Infcode int64 `json:"infcode"`
  15885. Output struct {
  15886. MdtrtId string `json:"mdtrt_id"`
  15887. ChrgBchno string `json:"chrg_bchno"`
  15888. PsnNo string `json:"psn_no"`
  15889. } `json:"output"`
  15890. RefmsgTime string `json:"refmsg_time"`
  15891. RespondTime string `json:"respond_time"`
  15892. Signtype interface{} `json:"signtype"`
  15893. WarnMsg interface{} `json:"warn_msg"`
  15894. }
  15895. type ResultThirteen struct {
  15896. ErrMsg string `json:"err_msg"`
  15897. InfRefmsgid string `json:"inf_refmsgid"`
  15898. Infcode int64 `json:"infcode"`
  15899. Output struct {
  15900. Result struct {
  15901. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  15902. } `json:"result"`
  15903. } `json:"output"`
  15904. RefmsgTime string `json:"refmsg_time"`
  15905. RespondTime string `json:"respond_time"`
  15906. Signtype interface{} `json:"signtype"`
  15907. WarnInfo interface{} `json:"warn_info"`
  15908. }
  15909. type ResultThirteen10265 struct {
  15910. ErrMsg string `json:"err_msg"`
  15911. InfRefmsgid string `json:"inf_refmsgid"`
  15912. Infcode string `json:"infcode"`
  15913. Output struct {
  15914. Result struct {
  15915. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  15916. } `json:"result"`
  15917. } `json:"output"`
  15918. RefmsgTime string `json:"refmsg_time"`
  15919. RespondTime string `json:"respond_time"`
  15920. Signtype interface{} `json:"signtype"`
  15921. WarnInfo interface{} `json:"warn_info"`
  15922. }
  15923. type ResultFourteen struct {
  15924. ErrMsg string `json:"err_msg"`
  15925. InfRefmsgid string `json:"inf_refmsgid"`
  15926. Infcode int64 `json:"infcode"`
  15927. Output struct {
  15928. } `json:"output"`
  15929. RefmsgTime string `json:"refmsg_time"`
  15930. RespondTime string `json:"respond_time"`
  15931. Signtype interface{} `json:"signtype"`
  15932. WarnInfo interface{} `json:"warn_info"`
  15933. }
  15934. type ResultCFYLJG001 struct {
  15935. ErrMsg string `json:"err_msg"`
  15936. InfRefmsgid string `json:"inf_refmsgid"`
  15937. Infcode int64 `json:"infcode"`
  15938. Output struct {
  15939. RxTraceCode string `json:"rx_trace_code"`
  15940. HiRxno string `json:"hi_rxno"`
  15941. } `json:"output"`
  15942. RefmsgTime string `json:"refmsg_time"`
  15943. RespondTime string `json:"respond_time"`
  15944. Signtype interface{} `json:"signtype"`
  15945. WarnInfo interface{} `json:"warn_info"`
  15946. }
  15947. type ResultCFYLJG007 struct {
  15948. ErrMsg string `json:"err_msg"`
  15949. InfRefmsgid string `json:"inf_refmsgid"`
  15950. Infcode int64 `json:"infcode"`
  15951. Output struct {
  15952. HiRxno string `json:"hi_rxno"`
  15953. RxStasName string `json:"rx_stas_name"`
  15954. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  15955. Seltdelts []interface{} `json:"seltdelts"`
  15956. RxUsedStasName string `json:"rx_used_stas_name"`
  15957. RxStasCodg string `json:"rx_stas_codg"`
  15958. } `json:"output"`
  15959. RefmsgTime string `json:"refmsg_time"`
  15960. RespondTime string `json:"respond_time"`
  15961. Signtype interface{} `json:"signtype"`
  15962. WarnInfo interface{} `json:"warn_info"`
  15963. }
  15964. type ResultCFYLJG002 struct {
  15965. ErrMsg string `json:"err_msg"`
  15966. InfRefmsgid string `json:"inf_refmsgid"`
  15967. Infcode int64 `json:"infcode"`
  15968. Output struct {
  15969. RxFile string `json:"rx_file"`
  15970. SignDigest string `json:"sign_digest"`
  15971. SignCertSn string `json:"sign_cert_sn"`
  15972. SignCertDn string `json:"sign_cert_dn"`
  15973. } `json:"output"`
  15974. RefmsgTime string `json:"refmsg_time"`
  15975. RespondTime string `json:"respond_time"`
  15976. Signtype interface{} `json:"signtype"`
  15977. WarnInfo interface{} `json:"warn_info"`
  15978. }
  15979. type ResultCFYLJG003 struct {
  15980. ErrMsg string `json:"err_msg"`
  15981. InfRefmsgid string `json:"inf_refmsgid"`
  15982. Infcode int64 `json:"infcode"`
  15983. Output struct {
  15984. HiRxno string `json:"hi_rxno"`
  15985. RxStasCodg string `json:"rx_stas_codg"`
  15986. RxStasName string `json:"rx_stas_name"`
  15987. } `json:"output"`
  15988. RefmsgTime string `json:"refmsg_time"`
  15989. RespondTime string `json:"respond_time"`
  15990. Signtype interface{} `json:"signtype"`
  15991. WarnInfo interface{} `json:"warn_info"`
  15992. }
  15993. type ResultCFYLJG004 struct {
  15994. ErrMsg string `json:"err_msg"`
  15995. InfRefmsgid string `json:"inf_refmsgid"`
  15996. Infcode int64 `json:"infcode"`
  15997. Output struct {
  15998. HiRxno string `json:"hi_rxno"`
  15999. RxStasCodg string `json:"rx_stas_codg"`
  16000. RxStasName string `json:"rx_stas_name"`
  16001. } `json:"output"`
  16002. RefmsgTime string `json:"refmsg_time"`
  16003. RespondTime string `json:"respond_time"`
  16004. Signtype interface{} `json:"signtype"`
  16005. WarnInfo interface{} `json:"warn_info"`
  16006. }
  16007. type ResultCFYLJG008 struct {
  16008. ErrMsg string `json:"err_msg"`
  16009. InfRefmsgid string `json:"inf_refmsgid"`
  16010. Infcode int64 `json:"infcode"`
  16011. Output struct {
  16012. PoolareaNo string `json:"poolareaNo"`
  16013. AdmdvsName string `json:"admdvsName"`
  16014. Count string `json:"count"`
  16015. } `json:"output"`
  16016. RefmsgTime string `json:"refmsg_time"`
  16017. RespondTime string `json:"respond_time"`
  16018. Signtype interface{} `json:"signtype"`
  16019. WarnInfo interface{} `json:"warn_info"`
  16020. }
  16021. type ResultCFYLJG005 struct {
  16022. ErrMsg string `json:"err_msg"`
  16023. InfRefmsgid string `json:"inf_refmsgid"`
  16024. Infcode int64 `json:"infcode"`
  16025. Output struct {
  16026. HiRxNo string `json:"hi_rxno"`
  16027. FixMedinsCode string `json:"fixmedins_code"`
  16028. FixMedinsName string `json:"fixmedins_name"`
  16029. RxStasCodg string `json:"rx_stas_codg"`
  16030. RxStasName string `json:"rx_stas_name"`
  16031. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  16032. RxUserdStasName string `json:"rx_userd_stas_name"`
  16033. PrscTime string `json:"prsc_time"`
  16034. RxDrugCnt float64 `json:"rx_drug_cnt"`
  16035. RxUsedWayCodg string `json:"rx_used_way_codg"`
  16036. RxUsedWayName string `json:"rx_used_way_name"`
  16037. RxFrquCodg string `json:"rx_frqu_codg"`
  16038. RxFrquName string `json:"rx_frqu_name"`
  16039. RxDosunt string `json:"rx_dosunt"`
  16040. RxDoscnt float64 `json:"rx_doscnt"`
  16041. RxDrordDscr string `json:"rx_drord_dscr"`
  16042. ValiDays int64 `json:"vali_days"`
  16043. ValiEndTime string `json:"vali_end_time"`
  16044. ReptFlag string `json:"rept_flag"`
  16045. MaxReptCnt int64 `json:"max_rept_cnt"`
  16046. ReptdCnt int64 `json:"reptd_cnt"`
  16047. MinInrvDays int64 `json:"min_inrv_days"`
  16048. RxTypeCode string `json:"rx_type_code"`
  16049. RxTypeName string `json:"rx_type_name"`
  16050. LongRxFlag string `json:"long_rx_flag"`
  16051. RxDetlList []struct {
  16052. MedListCodg string `json:"med_list_codg"`
  16053. MedinsListCodg string `json:"medins_list_codg"`
  16054. HospPrepFlag string `json:"hosp_prep_flag"`
  16055. RxItemTypeCode string `json:"rx_item_type_code"`
  16056. RxItemTypeName string `json:"rx_item_type_name"`
  16057. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  16058. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  16059. TcmHerbFoote string `json:"tcmherb_foote"`
  16060. MednTypeCode string `json:"medn_type_code"`
  16061. MednTypeName string `json:"medn_type_name"`
  16062. MainMedcFlag string `json:"main_medc_flag"`
  16063. UrgtFlag string `json:"urgt_flag"`
  16064. BasMednFlag string `json:"bas_medn_flag"`
  16065. ImpDrugFlag string `json:"imp_drug_flag"`
  16066. ProdBarc string `json:"prod_barc"`
  16067. DrugProdname string `json:"drug_prodname"`
  16068. GennameCodg string `json:"genname_codg"`
  16069. DrugGenname string `json:"drug_genname"`
  16070. DrugDosform string `json:"drug_dosform"`
  16071. DrugSpec string `json:"drug_spec"`
  16072. PrdrName string `json:"prdr_name"`
  16073. MedcWayCodg string `json:"medc_way_codg"`
  16074. MedcWayDscr string `json:"medc_way_dscr"`
  16075. MedcBegntime string `json:"medc_begntime"`
  16076. MedcEndtime string `json:"medc_endtime"`
  16077. MedcDays float64 `json:"medc_days"`
  16078. DrugPric float64 `json:"drug_pric"`
  16079. DrugSumamt float64 `json:"drug_sumamt"`
  16080. DrugCnt float64 `json:"drug_cnt"`
  16081. DrugDosunt string `json:"drug_dosunt"`
  16082. SinDoscnt float64 `json:"sin_doscnt"`
  16083. SinDosunt string `json:"sin_dosunt"`
  16084. UsedFrquCodg string `json:"used_frqu_codg"`
  16085. UsedFrquName string `json:"used_frqu_name"`
  16086. DrugTotlcnt string `json:"drug_totlcnt"`
  16087. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  16088. DiseCodg string `json:"dise_codg"`
  16089. HospApprFlag string `json:"hosp_appr_flag"`
  16090. } `json:"rx_detl_list"`
  16091. RxOtpinfo struct {
  16092. MedType string `json:"med_type"`
  16093. IptOtpNo string `json:"ipt_otp_no"`
  16094. OtpIptFlag string `json:"otp_ipt_flag"`
  16095. PatnName string `json:"patn_name"`
  16096. PatnAge float64 `json:"patn_age"`
  16097. PatnHgt float64 `json:"patn_hgt"`
  16098. PatnWt float64 `json:"patn_wt"`
  16099. Gend string `json:"gend"`
  16100. GesoVal float64 `json:"geso_val"`
  16101. NwbFlag string `json:"nwb_flag"`
  16102. NwbAge string `json:"nwb_age"`
  16103. SuckPrdFlag string `json:"suck_prd_flag"`
  16104. AlgsHis string `json:"algs_his"`
  16105. Insutype string `json:"insutype"`
  16106. PrscDeptName string `json:"prsc_dept_name"`
  16107. PrscDrName string `json:"prsc_dr_name"`
  16108. PharName string `json:"phar_name"`
  16109. PharChkTime string `json:"phar_chk_time"`
  16110. MdtrtTime string `json:"mdtrt_time"`
  16111. DiseCodg string `json:"dise_codg"`
  16112. DiseName string `json:"dise_name"`
  16113. SpDiseFlag string `json:"sp_dise_flag"`
  16114. MaindiagCode string `json:"maindiag_code"`
  16115. MaindiagName string `json:"maindiag_name"`
  16116. DiseCondDscr string `json:"dise_cond_dscr"`
  16117. FstdiagFlag string `json:"fstdiag_flag"`
  16118. } `json:"rx_otpinfo"`
  16119. RxDiseList []struct {
  16120. DiagType string `json:"diag_type"`
  16121. MaindiagFlag string `json:"maindiag_flag"`
  16122. DiagSrtNo string `json:"diag_srt_no"`
  16123. DiagCode string `json:"diag_code"`
  16124. DiagName string `json:"diag_name"`
  16125. DiagDept string `json:"diag_dept"`
  16126. DiagDrNo string `json:"diag_dr_no"`
  16127. DiagDrName string `json:"diag_dr_name"`
  16128. DiagTime string `json:"diag_time"`
  16129. TcmDiseCode string `json:"tcm_dise_code"`
  16130. TcmDiseName string `json:"tcm_dise_name"`
  16131. TcmSympCode string `json:"tcmsymp_code"`
  16132. TcmSymp string `json:"tcmsymp"`
  16133. } `json:"rx_dise_list"`
  16134. } `json:"output"`
  16135. RefmsgTime string `json:"refmsg_time"`
  16136. RespondTime string `json:"respond_time"`
  16137. Signtype interface{} `json:"signtype"`
  16138. WarnInfo interface{} `json:"warn_info"`
  16139. }
  16140. type ResultCFYLJG006 struct {
  16141. ErrMsg string `json:"err_msg"`
  16142. InfRefmsgid string `json:"inf_refmsgid"`
  16143. Infcode int64 `json:"infcode"`
  16144. Output struct {
  16145. HiRxNo string `json:"hi_rxno"`
  16146. PharCode string `json:"phar_code"`
  16147. PharName string `json:"phar_name"`
  16148. RxChkOpnn string `json:"rx_chk_opnn"`
  16149. RxChkTime string `json:"rx_chk_time"`
  16150. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  16151. RxChkStasName string `json:"rx_chk_stas_name"`
  16152. RxStasCodg string `json:"rx_stas_codg"`
  16153. RxStasName string `json:"rx_stas_name"`
  16154. } `json:"output"`
  16155. RefmsgTime string `json:"refmsg_time"`
  16156. RespondTime string `json:"respond_time"`
  16157. Signtype interface{} `json:"signtype"`
  16158. WarnInfo interface{} `json:"warn_info"`
  16159. }
  16160. type ResultFourteen10265 struct {
  16161. ErrMsg string `json:"err_msg"`
  16162. InfRefmsgid string `json:"inf_refmsgid"`
  16163. Infcode string `json:"infcode"`
  16164. Output struct {
  16165. } `json:"output"`
  16166. RefmsgTime string `json:"refmsg_time"`
  16167. RespondTime string `json:"respond_time"`
  16168. Signtype interface{} `json:"signtype"`
  16169. WarnInfo interface{} `json:"warn_info"`
  16170. }
  16171. type ResultSixteen struct {
  16172. Cainfo string `json:"cainfo"`
  16173. ErrMsg string `json:"err_msg"`
  16174. InfRefmsgid string `json:"inf_refmsgid"`
  16175. Infcode int64 `json:"infcode"`
  16176. Output struct {
  16177. Setlinfo struct {
  16178. MdtrtID string `json:"mdtrt_id"`
  16179. SetlID string `json:"setl_id"`
  16180. ClrOptins string `json:"clr_optins"`
  16181. SetlTime string `json:"setl_time"`
  16182. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16183. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16184. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16185. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16186. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16187. ActPayDedc float64 `json:"act_pay_dedc"`
  16188. HifpPay float64 `json:"hifp_pay"`
  16189. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16190. Lfpay float64 `json:"selfpay"`
  16191. CvlservPay float64 `json:"cvlserv_pay"`
  16192. HifesPay float64 `json:"hifes_pay"`
  16193. HifmiPay float64 `json:"hifmi_pay"`
  16194. HifobPay float64 `json:"hifob_pay"`
  16195. MafPay float64 `json:"maf_pay"`
  16196. OthPay float64 `json:"oth_pay"`
  16197. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16198. PsnPartAmt float64 `json:"psn_part_amt"`
  16199. AcctPay float64 `json:"acct_pay"`
  16200. Balc float64 `json:"balc"`
  16201. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16202. HospPartAmt float64 `json:"hosp_part_amt"`
  16203. MedinsSetlID string `json:"medins_setl_id"`
  16204. PdnCashPay string `json:"pdn_cash_pay"`
  16205. } `json:"setlinfo"`
  16206. } `json:"output"`
  16207. RefmsgTime string `json:"refmsg_time"`
  16208. RespondTime string `json:"respond_time"`
  16209. Signtype interface{} `json:"signtype"`
  16210. WarnMsg interface{} `json:"warn_msg"`
  16211. }
  16212. type ResultSixteen10265 struct {
  16213. Cainfo string `json:"cainfo"`
  16214. ErrMsg string `json:"err_msg"`
  16215. InfRefmsgid string `json:"inf_refmsgid"`
  16216. Infcode string `json:"infcode"`
  16217. Output struct {
  16218. Setlinfo struct {
  16219. MdtrtID string `json:"mdtrt_id"`
  16220. SetlID string `json:"setl_id"`
  16221. ClrOptins string `json:"clr_optins"`
  16222. SetlTime string `json:"setl_time"`
  16223. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16224. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16225. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16226. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16227. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16228. ActPayDedc float64 `json:"act_pay_dedc"`
  16229. HifpPay float64 `json:"hifp_pay"`
  16230. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16231. Lfpay float64 `json:"selfpay"`
  16232. CvlservPay float64 `json:"cvlserv_pay"`
  16233. HifesPay float64 `json:"hifes_pay"`
  16234. HifmiPay float64 `json:"hifmi_pay"`
  16235. HifobPay float64 `json:"hifob_pay"`
  16236. MafPay float64 `json:"maf_pay"`
  16237. OthPay float64 `json:"oth_pay"`
  16238. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16239. PsnPartAmt float64 `json:"psn_part_amt"`
  16240. AcctPay float64 `json:"acct_pay"`
  16241. Balc float64 `json:"balc"`
  16242. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16243. HospPartAmt float64 `json:"hosp_part_amt"`
  16244. MedinsSetlID string `json:"medins_setl_id"`
  16245. PdnCashPay string `json:"pdn_cash_pay"`
  16246. } `json:"setlinfo"`
  16247. } `json:"output"`
  16248. RefmsgTime string `json:"refmsg_time"`
  16249. RespondTime string `json:"respond_time"`
  16250. Signtype interface{} `json:"signtype"`
  16251. WarnMsg interface{} `json:"warn_msg"`
  16252. }
  16253. type ResultSixteen10265Two struct {
  16254. Cainfo string `json:"cainfo"`
  16255. ErrMsg string `json:"err_msg"`
  16256. InfRefmsgid string `json:"inf_refmsgid"`
  16257. Infcode string `json:"infcode"`
  16258. Output struct {
  16259. Setlinfo interface{} `json:"setlinfo"`
  16260. } `json:"output"`
  16261. RefmsgTime string `json:"refmsg_time"`
  16262. RespondTime string `json:"respond_time"`
  16263. Signtype interface{} `json:"signtype"`
  16264. WarnMsg interface{} `json:"warn_msg"`
  16265. }
  16266. type ResultgzSixteen10265Two struct {
  16267. Cainfo string `json:"cainfo"`
  16268. ErrMsg string `json:"err_msg"`
  16269. InfRefmsgid string `json:"inf_refmsgid"`
  16270. Infcode int64 `json:"infcode"`
  16271. Output struct {
  16272. Setlinfo interface{} `json:"setlinfo"`
  16273. } `json:"output"`
  16274. RefmsgTime string `json:"refmsg_time"`
  16275. RespondTime string `json:"respond_time"`
  16276. Signtype interface{} `json:"signtype"`
  16277. WarnMsg interface{} `json:"warn_msg"`
  16278. }
  16279. type ResultSeventeen struct {
  16280. ErrMsg string `json:"err_msg"`
  16281. InfRefmsgid string `json:"inf_refmsgid"`
  16282. Infcode int64 `json:"infcode"`
  16283. Output struct {
  16284. SetlListId string `json:"setl_list_id"`
  16285. } `json:"output"`
  16286. RefmsgTime string `json:"refmsg_time"`
  16287. RespondTime string `json:"respond_time"`
  16288. Signtype string `json:"signtype"`
  16289. WarnInfo string `json:"warn_info"`
  16290. }
  16291. type ResultSeventeenOther struct {
  16292. ErrMsg string `json:"err_msg"`
  16293. InfRefmsgid string `json:"inf_refmsgid"`
  16294. Infcode string `json:"infcode"`
  16295. Output struct {
  16296. SetlListId string `json:"setl_list_id"`
  16297. } `json:"output"`
  16298. RefmsgTime string `json:"refmsg_time"`
  16299. RespondTime string `json:"respond_time"`
  16300. Signtype string `json:"signtype"`
  16301. WarnInfo string `json:"warn_info"`
  16302. }
  16303. type Result90991 struct {
  16304. ErrMsg string `json:"err_msg"`
  16305. InfRefmsgid string `json:"inf_refmsgid"`
  16306. Infcode int64 `json:"infcode"`
  16307. Output struct {
  16308. Result struct {
  16309. PsnNo string `json:"psn_no"`
  16310. CardStat string `json:"card_stat"`
  16311. Certno string `json:"certno"`
  16312. PsnName string `json:"psn_name"`
  16313. CheckStat string `json:"check_stat"`
  16314. SscnoCheckStat string `json:"sscno_check_stat"`
  16315. } `json:"result"`
  16316. } `json:"output"`
  16317. RefmsgTime string `json:"refmsg_time"`
  16318. RespondTime string `json:"respond_time"`
  16319. Signtype interface{} `json:"signtype"`
  16320. WarnInfo interface{} `json:"warn_info"`
  16321. }
  16322. type Result90100 struct {
  16323. ErrMsg string `json:"err_msg"`
  16324. InfRefmsgid string `json:"inf_refmsgid"`
  16325. Infcode int64 `json:"infcode"`
  16326. Output struct {
  16327. PoolareaNo string `json:"poolarea_no"`
  16328. PoolareaNoName string `json:"poolarea_no_name"`
  16329. Insutype string `json:"insutype"`
  16330. InsutypeName string `json:"insutype_name"`
  16331. ClctType string `json:"clct_type"`
  16332. ClctTypeName string `json:"clct_type_name"`
  16333. ClctFlag string `json:"clct_flag"`
  16334. ClctFlagName string `json:"clct_flag_name"`
  16335. AccrymBegn string `json:"accrym_begn"`
  16336. AccrymEnd string `json:"accrym_end"`
  16337. ClctTime string `json:"clct_time"`
  16338. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  16339. } `json:"output"`
  16340. RefmsgTime string `json:"refmsg_time"`
  16341. RespondTime string `json:"respond_time"`
  16342. Signtype interface{} `json:"signtype"`
  16343. WarnInfo interface{} `json:"warn_info"`
  16344. }
  16345. type Custom struct {
  16346. DetItemFeeSumamt string
  16347. Cut string
  16348. FeedetlSn string
  16349. Price string
  16350. MedListCodg string
  16351. Type int64
  16352. AdviceId int64
  16353. ProjectId int64
  16354. ItemId int64
  16355. }
  16356. type Result5301 struct {
  16357. ErrMsg string `json:"err_msg"`
  16358. InfRefmsgid string `json:"inf_refmsgid"`
  16359. Infcode int64 `json:"infcode"`
  16360. Output struct {
  16361. Result []struct {
  16362. OpspDiseCode string `json:"opsp_dise_code"`
  16363. OpspDiseName string `json:"opsp_dise_name"`
  16364. Begndate string `json:"begndate"`
  16365. Enddate string `json:"enddate"`
  16366. } `json:"feedetail"`
  16367. } `json:"output"`
  16368. RefmsgTime string `json:"refmsg_time"`
  16369. RespondTime string `json:"respond_time"`
  16370. Signtype interface{} `json:"signtype"`
  16371. WarnInfo interface{} `json:"warn_info"`
  16372. }
  16373. type Result5301For10265 struct {
  16374. ErrMsg string `json:"err_msg"`
  16375. InfRefmsgid string `json:"inf_refmsgid"`
  16376. Infcode string `json:"infcode"`
  16377. Output struct {
  16378. Result []struct {
  16379. OpspDiseCode string `json:"opsp_dise_code"`
  16380. OpspDiseName string `json:"opsp_dise_name"`
  16381. Begndate string `json:"begndate"`
  16382. Enddate string `json:"enddate"`
  16383. } `json:"feedetail"`
  16384. } `json:"output"`
  16385. RefmsgTime string `json:"refmsg_time"`
  16386. RespondTime string `json:"respond_time"`
  16387. Signtype interface{} `json:"signtype"`
  16388. WarnInfo interface{} `json:"warn_info"`
  16389. }
  16390. //获取个人信息----挂号-----上传就诊信息
  16391. func (c *HisApiController) GetRegisterInfo() {
  16392. id, _ := c.GetInt64("id")
  16393. record_time := c.GetString("record_time")
  16394. settlementValue, _ := c.GetInt64("settlement_value")
  16395. medical_insurance_card := c.GetString("medical_insurance_card")
  16396. name := c.GetString("name")
  16397. id_card_type, _ := c.GetInt64("id_card_type")
  16398. certificates, _ := c.GetInt64("certificates")
  16399. medical_care, _ := c.GetInt64("medical_care")
  16400. birthday := c.GetString("birthday")
  16401. id_card := c.GetString("id_card")
  16402. register_type, _ := c.GetInt64("register")
  16403. doctor, _ := c.GetInt64("doctor")
  16404. department, _ := c.GetInt64("department")
  16405. gender, _ := c.GetInt64("sex")
  16406. registration_fee, _ := c.GetFloat("registration_fee")
  16407. medical_expenses, _ := c.GetFloat("medical_expenses")
  16408. social_type, _ := c.GetInt64("social_type")
  16409. admin_user_id, _ := c.GetInt64("admin_user_id")
  16410. insuplc_admdvs := c.GetString("insuplc_admdvs")
  16411. mdtrt_type := c.GetString("mdtrt_type")
  16412. if id_card_type == 5 {
  16413. id_card_type = 4
  16414. }
  16415. timeLayout := "2006-01-02"
  16416. loc, _ := time.LoadLocation("Local")
  16417. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  16418. birthUnix := birthdays.Unix()
  16419. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  16420. if err != nil {
  16421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  16422. return
  16423. }
  16424. recordDateTime := theTime.Unix()
  16425. adminInfo := c.GetAdminUserInfo()
  16426. var patient service.Patients
  16427. if id == 0 {
  16428. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  16429. } else {
  16430. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  16431. }
  16432. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16433. if patientPrescription.ID == 0 {
  16434. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16435. }
  16436. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  16437. if patient.ID == 0 {
  16438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  16439. return
  16440. }
  16441. if len(patient.IdCardNo) == 0 {
  16442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  16443. return
  16444. }
  16445. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  16446. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  16447. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  16448. //就诊结算未完成,不能进行二次挂号
  16449. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  16450. //if len(his) >= 1 {
  16451. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  16452. // if len(his) >= 1 && order.ID == 0 {
  16453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  16454. // return
  16455. // }
  16456. //}
  16457. //var register_log string
  16458. if config.IsOpen == 1 {
  16459. var res ResultTwo
  16460. var res10265 ResultTwo10265
  16461. var PsnNo string
  16462. var PsnCertType string
  16463. var Certno string
  16464. var PsnName string
  16465. var Gend string
  16466. var Naty string
  16467. var Brdy string
  16468. var Age float64
  16469. var infoStr string
  16470. var idetinfoStr string
  16471. var infocode int64
  16472. var verify_number string
  16473. fmt.Println(verify_number)
  16474. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" {
  16475. psn_info, _ := service.GetPsnByPatientId(id)
  16476. PsnNo = psn_info.PsnNo
  16477. PsnCertType = psn_info.PsnCertType
  16478. Certno = psn_info.Certno
  16479. PsnName = psn_info.PsnName
  16480. Gend = psn_info.Gend
  16481. Naty = psn_info.Naty
  16482. Brdy = psn_info.Brdy
  16483. Age = psn_info.Age
  16484. infoStr = psn_info.Insuinfo
  16485. idetinfoStr = psn_info.Idetinfo
  16486. infocode = 0
  16487. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16488. psn_info, _ := service.GetPsnByPatientId(id)
  16489. PsnNo = psn_info.PsnNo
  16490. PsnCertType = psn_info.PsnCertType
  16491. Certno = psn_info.Certno
  16492. PsnName = psn_info.PsnName
  16493. Gend = psn_info.Gend
  16494. Naty = psn_info.Naty
  16495. Brdy = psn_info.Brdy
  16496. Age = psn_info.Age
  16497. infoStr = psn_info.Insuinfo
  16498. idetinfoStr = psn_info.Idetinfo
  16499. infocode = 0
  16500. verify_number = psn_info.VerifyNumber
  16501. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16502. if id_card_type == 2 {
  16503. //请求内网数据
  16504. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  16505. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16506. "&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
  16507. resp, requestErr := http.Get(api)
  16508. if requestErr != nil {
  16509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16510. return
  16511. }
  16512. body, ioErr := ioutil.ReadAll(resp.Body)
  16513. if ioErr != nil {
  16514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16516. return
  16517. }
  16518. var respJSON map[string]interface{}
  16519. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16522. return
  16523. }
  16524. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16525. result_byte, _ := json.Marshal(respJSON)
  16526. result := string(result_byte)
  16527. var dat map[string]interface{}
  16528. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16529. fmt.Println(dat)
  16530. } else {
  16531. fmt.Println(err)
  16532. }
  16533. userJSONBytes, _ := json.Marshal(dat)
  16534. var res ResultTwo
  16535. var resTwo10265 ResultTwo10265
  16536. if miConfig.Code == "H15049901371" {
  16537. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  16538. utils.ErrorLog("解析失败:%v", err)
  16539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16540. return
  16541. }
  16542. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  16543. res.Infcode = Infcode
  16544. res.ErrMsg = resTwo10265.ErrMsg
  16545. res.Output = resTwo10265.Output
  16546. res.InfRefmsgid = resTwo10265.InfRefmsgid
  16547. res.RespondTime = resTwo10265.RespondTime
  16548. res.WarnInfo = resTwo10265.WarnInfo
  16549. } else {
  16550. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16551. utils.ErrorLog("解析失败:%v", err)
  16552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16553. return
  16554. }
  16555. }
  16556. //var insutypes []string
  16557. //var insutype string
  16558. //var is390 int = 0
  16559. //var is310 int = 0
  16560. //for _, item := range res.Output.Iinfo {
  16561. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16562. // insutypes = append(insutypes, item.Insutype)
  16563. // }
  16564. //}
  16565. //if len(insutypes) == 1 {
  16566. // insutype = insutypes[0]
  16567. //} else {
  16568. // for _, i := range insutypes {
  16569. // if i == "390" {
  16570. // is390 = 1
  16571. // }
  16572. //
  16573. // if i == "310" {
  16574. // is310 = 1
  16575. // }
  16576. // }
  16577. //}
  16578. //if is390 == 1 {
  16579. // insutype = "390"
  16580. //}
  16581. //if is310 == 1 {
  16582. // insutype = "310"
  16583. //}
  16584. //if len(insutypes) == 0 {
  16585. // insutype = "310"
  16586. //}
  16587. PsnNo = res.Output.Baseinfo.PsnNo
  16588. PsnCertType = res.Output.Baseinfo.PsnCertType
  16589. Certno = res.Output.Baseinfo.Certno
  16590. PsnName = res.Output.Baseinfo.PsnName
  16591. Gend = res.Output.Baseinfo.Gend
  16592. Naty = res.Output.Baseinfo.Naty
  16593. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16594. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16595. infoStr = string(Iinfos)
  16596. idetinfoStr = string(Idetinfos)
  16597. infocode = res.Infcode
  16598. //infocode = 0
  16599. //verify_number = psn_info.VerifyNumber
  16600. } else {
  16601. psn_info, _ := service.GetPsnByPatientId(id)
  16602. PsnNo = psn_info.PsnNo
  16603. PsnCertType = psn_info.PsnCertType
  16604. Certno = psn_info.Certno
  16605. PsnName = psn_info.PsnName
  16606. Gend = psn_info.Gend
  16607. Naty = psn_info.Naty
  16608. Brdy = psn_info.Brdy
  16609. Age = psn_info.Age
  16610. infoStr = psn_info.Insuinfo
  16611. idetinfoStr = psn_info.Idetinfo
  16612. infocode = 0
  16613. verify_number = psn_info.VerifyNumber
  16614. }
  16615. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16616. if id_card_type == 1 {
  16617. psn_info, _ := service.GetPsnByPatientId(id)
  16618. PsnNo = psn_info.PsnNo
  16619. PsnCertType = psn_info.PsnCertType
  16620. Certno = psn_info.Certno
  16621. PsnName = psn_info.PsnName
  16622. Gend = psn_info.Gend
  16623. Naty = psn_info.Naty
  16624. Brdy = psn_info.Brdy
  16625. Age = psn_info.Age
  16626. infoStr = psn_info.Insuinfo
  16627. idetinfoStr = psn_info.Idetinfo
  16628. infocode = 0
  16629. verify_number = psn_info.VerifyNumber
  16630. } else if id_card_type == 2 {
  16631. 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)
  16632. fmt.Println(errMsgLog)
  16633. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16634. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16635. utils.ErrorLog("解析失败:%v", err)
  16636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16637. return
  16638. }
  16639. PsnNo = res.Output.Baseinfo.PsnNo
  16640. PsnCertType = res.Output.Baseinfo.PsnCertType
  16641. Certno = res.Output.Baseinfo.Certno
  16642. PsnName = res.Output.Baseinfo.PsnName
  16643. Gend = res.Output.Baseinfo.Gend
  16644. Naty = res.Output.Baseinfo.Naty
  16645. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16646. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16647. infoStr = string(Iinfos)
  16648. idetinfoStr = string(Idetinfos)
  16649. infocode = res.Infcode
  16650. }
  16651. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16652. if id_card_type == 1 {
  16653. psn_info, _ := service.GetPsnByPatientId(id)
  16654. PsnNo = psn_info.PsnNo
  16655. PsnCertType = psn_info.PsnCertType
  16656. Certno = psn_info.Certno
  16657. PsnName = psn_info.PsnName
  16658. Gend = psn_info.Gend
  16659. Naty = psn_info.Naty
  16660. Brdy = psn_info.Brdy
  16661. Age = psn_info.Age
  16662. infoStr = psn_info.Insuinfo
  16663. idetinfoStr = psn_info.Idetinfo
  16664. infocode = 0
  16665. verify_number = psn_info.VerifyNumber
  16666. } else if id_card_type == 2 {
  16667. 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, "")
  16668. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16669. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16670. utils.ErrorLog("解析失败:%v", err)
  16671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16672. return
  16673. }
  16674. PsnNo = res.Output.Baseinfo.PsnNo
  16675. PsnCertType = res.Output.Baseinfo.PsnCertType
  16676. Certno = res.Output.Baseinfo.Certno
  16677. PsnName = res.Output.Baseinfo.PsnName
  16678. Gend = res.Output.Baseinfo.Gend
  16679. Naty = res.Output.Baseinfo.Naty
  16680. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16681. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16682. infoStr = string(Iinfos)
  16683. idetinfoStr = string(Idetinfos)
  16684. infocode = res.Infcode
  16685. } else {
  16686. psn_info, _ := service.GetPsnByPatientId(id)
  16687. PsnNo = psn_info.PsnNo
  16688. PsnCertType = psn_info.PsnCertType
  16689. Certno = psn_info.Certno
  16690. PsnName = psn_info.PsnName
  16691. Gend = psn_info.Gend
  16692. Naty = psn_info.Naty
  16693. Brdy = psn_info.Brdy
  16694. Age = psn_info.Age
  16695. infoStr = psn_info.Insuinfo
  16696. idetinfoStr = psn_info.Idetinfo
  16697. infocode = 0
  16698. verify_number = psn_info.VerifyNumber
  16699. }
  16700. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16701. psn_info, _ := service.GetPsnByPatientId(id)
  16702. PsnNo = psn_info.PsnNo
  16703. PsnCertType = psn_info.PsnCertType
  16704. Certno = psn_info.Certno
  16705. PsnName = psn_info.PsnName
  16706. Gend = psn_info.Gend
  16707. Naty = psn_info.Naty
  16708. Brdy = psn_info.Brdy
  16709. Age = psn_info.Age
  16710. infoStr = psn_info.Insuinfo
  16711. idetinfoStr = psn_info.Idetinfo
  16712. infocode = 0
  16713. verify_number = psn_info.VerifyNumber
  16714. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16715. if id_card_type == 1 {
  16716. psn_info, _ := service.GetPsnByPatientId(id)
  16717. PsnNo = psn_info.PsnNo
  16718. PsnCertType = psn_info.PsnCertType
  16719. Certno = psn_info.Certno
  16720. PsnName = psn_info.PsnName
  16721. Gend = psn_info.Gend
  16722. Naty = psn_info.Naty
  16723. Brdy = psn_info.Brdy
  16724. Age = psn_info.Age
  16725. infoStr = psn_info.Insuinfo
  16726. idetinfoStr = psn_info.Idetinfo
  16727. infocode = 0
  16728. verify_number = psn_info.VerifyNumber
  16729. } else if id_card_type == 2 {
  16730. 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)
  16731. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16732. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16733. utils.ErrorLog("解析失败:%v", err)
  16734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16735. return
  16736. }
  16737. PsnNo = res.Output.Baseinfo.PsnNo
  16738. PsnCertType = res.Output.Baseinfo.PsnCertType
  16739. Certno = res.Output.Baseinfo.Certno
  16740. PsnName = res.Output.Baseinfo.PsnName
  16741. Gend = res.Output.Baseinfo.Gend
  16742. Naty = res.Output.Baseinfo.Naty
  16743. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16744. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16745. infoStr = string(Iinfos)
  16746. idetinfoStr = string(Idetinfos)
  16747. infocode = res.Infcode
  16748. } else if id_card_type == 4 {
  16749. psn_info, _ := service.GetPsnByPatientId(id)
  16750. PsnNo = psn_info.PsnNo
  16751. PsnCertType = psn_info.PsnCertType
  16752. Certno = psn_info.Certno
  16753. PsnName = psn_info.PsnName
  16754. Gend = psn_info.Gend
  16755. Naty = psn_info.Naty
  16756. Brdy = psn_info.Brdy
  16757. Age = psn_info.Age
  16758. infoStr = psn_info.Insuinfo
  16759. idetinfoStr = psn_info.Idetinfo
  16760. infocode = 0
  16761. verify_number = psn_info.VerifyNumber
  16762. }
  16763. } else if miConfig.MdtrtareaAdmvs == "131023" {
  16764. var result string
  16765. var requestLog string
  16766. 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), "")
  16767. if id_card_type == 4 {
  16768. psn_info, _ := service.GetPsnByPatientId(id)
  16769. PsnNo = psn_info.PsnNo
  16770. PsnCertType = psn_info.PsnCertType
  16771. Certno = psn_info.Certno
  16772. PsnName = psn_info.PsnName
  16773. Gend = psn_info.Gend
  16774. Naty = psn_info.Naty
  16775. Brdy = psn_info.Brdy
  16776. Age = psn_info.Age
  16777. infoStr = psn_info.Insuinfo
  16778. idetinfoStr = psn_info.Idetinfo
  16779. infocode = 0
  16780. verify_number = psn_info.VerifyNumber
  16781. } else {
  16782. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16783. if miConfig.Code == "H15049901371" {
  16784. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16785. utils.ErrorLog("解析失败:%v", err)
  16786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16787. return
  16788. }
  16789. res.ErrMsg = res10265.ErrMsg
  16790. res.Output = res10265.Output
  16791. res.InfRefmsgid = res10265.InfRefmsgid
  16792. } else {
  16793. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16794. utils.ErrorLog("解析失败:%v", err)
  16795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16796. return
  16797. }
  16798. }
  16799. PsnNo = res.Output.Baseinfo.PsnNo
  16800. PsnCertType = res.Output.Baseinfo.PsnCertType
  16801. Certno = res.Output.Baseinfo.Certno
  16802. PsnName = res.Output.Baseinfo.PsnName
  16803. Gend = res.Output.Baseinfo.Gend
  16804. Naty = res.Output.Baseinfo.Naty
  16805. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16806. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16807. infoStr = string(Iinfos)
  16808. idetinfoStr = string(Idetinfos)
  16809. if miConfig.Code == "H15049901371" {
  16810. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  16811. } else {
  16812. infocode = res.Infcode
  16813. }
  16814. }
  16815. } else if miConfig.MdtrtareaAdmvs == "441799" {
  16816. psn_info, _ := service.GetPsnByPatientId(id)
  16817. PsnNo = psn_info.PsnNo
  16818. PsnCertType = psn_info.PsnCertType
  16819. Certno = psn_info.Certno
  16820. PsnName = psn_info.PsnName
  16821. Gend = psn_info.Gend
  16822. Naty = psn_info.Naty
  16823. Brdy = psn_info.Brdy
  16824. Age = psn_info.Age
  16825. infoStr = psn_info.Insuinfo
  16826. idetinfoStr = psn_info.Idetinfo
  16827. infocode = 0
  16828. verify_number = psn_info.VerifyNumber
  16829. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16830. psn_info, _ := service.GetPsnByPatientId(id)
  16831. PsnNo = psn_info.PsnNo
  16832. PsnCertType = psn_info.PsnCertType
  16833. Certno = psn_info.Certno
  16834. PsnName = psn_info.PsnName
  16835. Gend = psn_info.Gend
  16836. Naty = psn_info.Naty
  16837. Brdy = psn_info.Brdy
  16838. Age = psn_info.Age
  16839. infoStr = psn_info.Insuinfo
  16840. idetinfoStr = psn_info.Idetinfo
  16841. infocode = 0
  16842. verify_number = psn_info.VerifyNumber
  16843. } else {
  16844. var result string
  16845. var requestLog string
  16846. //if miConfig.UserOrgId == 10138 {
  16847. if id_card_type != 4 || id_card_type != 1 {
  16848. var insa string
  16849. if len(patient.InsuplcAdmdvs) > 0 {
  16850. insa = patient.InsuplcAdmdvs
  16851. } else {
  16852. insa = miConfig.InsuplcAdmdvs
  16853. }
  16854. //psn_info, _ := service.GetPsnByPatientId(id)
  16855. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  16856. 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)
  16857. }
  16858. //}
  16859. //else {
  16860. // var insa string
  16861. // if len(patient.InsuplcAdmdvs) > 0 {
  16862. // insa = patient.InsuplcAdmdvs
  16863. // } else {
  16864. // insa = miConfig.InsuplcAdmdvs
  16865. // }
  16866. // 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)
  16867. //}
  16868. if id_card_type == 4 || id_card_type == 1 {
  16869. psn_info, _ := service.GetPsnByPatientId(id)
  16870. PsnNo = psn_info.PsnNo
  16871. PsnCertType = psn_info.PsnCertType
  16872. Certno = psn_info.Certno
  16873. PsnName = psn_info.PsnName
  16874. Gend = psn_info.Gend
  16875. Naty = psn_info.Naty
  16876. Brdy = psn_info.Brdy
  16877. Age = psn_info.Age
  16878. infoStr = psn_info.Insuinfo
  16879. idetinfoStr = psn_info.Idetinfo
  16880. infocode = 0
  16881. verify_number = psn_info.VerifyNumber
  16882. } else {
  16883. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16884. if miConfig.Code == "H15049901371" {
  16885. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16886. utils.ErrorLog("解析失败:%v", err)
  16887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16888. return
  16889. }
  16890. res.ErrMsg = res10265.ErrMsg
  16891. res.Output = res10265.Output
  16892. res.InfRefmsgid = res10265.InfRefmsgid
  16893. } else {
  16894. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16895. utils.ErrorLog("解析失败:%v", err)
  16896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16897. return
  16898. }
  16899. }
  16900. PsnNo = res.Output.Baseinfo.PsnNo
  16901. PsnCertType = res.Output.Baseinfo.PsnCertType
  16902. Certno = res.Output.Baseinfo.Certno
  16903. PsnName = res.Output.Baseinfo.PsnName
  16904. Gend = res.Output.Baseinfo.Gend
  16905. Naty = res.Output.Baseinfo.Naty
  16906. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16907. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16908. infoStr = string(Iinfos)
  16909. idetinfoStr = string(Idetinfos)
  16910. if miConfig.Code == "H15049901371" {
  16911. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  16912. } else {
  16913. infocode = res.Infcode
  16914. }
  16915. }
  16916. }
  16917. if infocode == 0 {
  16918. his := models.VMHisPatient{
  16919. Name: name,
  16920. Gender: gender,
  16921. Birthday: birthUnix,
  16922. MedicalTreatmentType: medical_care,
  16923. IdType: certificates,
  16924. IdCardNo: id_card,
  16925. BalanceAccountsType: settlementValue,
  16926. SocialType: social_type,
  16927. MedicalInsuranceNumber: medical_insurance_card,
  16928. RegisterType: register_type,
  16929. RegisterCost: registration_fee,
  16930. TreatmentCost: medical_expenses,
  16931. Status: 1,
  16932. Ctime: time.Now().Unix(),
  16933. Mtime: time.Now().Unix(),
  16934. PsnNo: PsnNo,
  16935. PsnCertType: PsnCertType,
  16936. Certno: Certno,
  16937. PsnName: PsnName,
  16938. Gend: Gend,
  16939. Naty: Naty,
  16940. Brdy: Brdy,
  16941. Age: Age,
  16942. Iinfo: infoStr,
  16943. Idetinfo: idetinfoStr,
  16944. PatientId: patient.ID,
  16945. RecordDate: theTime.Unix(),
  16946. UserOrgId: adminInfo.CurrentOrgId,
  16947. AdminUserId: admin_user_id,
  16948. IsReturn: 1,
  16949. IdCardType: id_card_type,
  16950. Doctor: doctor,
  16951. Departments: department,
  16952. MdtrtGrpType: mdtrt_type,
  16953. }
  16954. timestamp := time.Now().Unix()
  16955. tempTime := time.Unix(timestamp, 0)
  16956. timeFormat := tempTime.Format("20060102150405")
  16957. chrgBchno := rand.Intn(100000) + 10000
  16958. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  16959. his.Number = ipt_otp_no
  16960. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  16961. department, _ := service.GetDepartMentDetail(department)
  16962. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  16963. IdCardNo := ""
  16964. if id_card_type == 1 {
  16965. // IdCardNo = medical_insurance_card
  16966. IdCardNo = patient.IdCardNo
  16967. } else {
  16968. IdCardNo = patient.IdCardNo
  16969. }
  16970. var rf []*ResultFive
  16971. json.Unmarshal([]byte(his.Iinfo), &rf)
  16972. var insutypes []*ResultFive
  16973. var insutype string
  16974. var insuplc_admdvs_temp string
  16975. var is390 int = 0
  16976. var is310 int = 0
  16977. for _, item := range rf {
  16978. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16979. insutypes = append(insutypes, item)
  16980. }
  16981. }
  16982. if len(insutypes) == 1 {
  16983. insutype = insutypes[0].Insutype
  16984. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16985. if insutype == "390" {
  16986. is390 = 1
  16987. }
  16988. if insutype == "310" {
  16989. is310 = 1
  16990. }
  16991. } else {
  16992. for _, i := range insutypes {
  16993. if i.Insutype == "390" {
  16994. is390 = 1
  16995. }
  16996. if i.Insutype == "310" {
  16997. is310 = 1
  16998. }
  16999. }
  17000. }
  17001. if is390 == 1 {
  17002. insutype = "390"
  17003. }
  17004. if is310 == 1 {
  17005. insutype = "310"
  17006. }
  17007. fmt.Println(social_type)
  17008. if social_type > 0 {
  17009. insutype = strconv.FormatInt(social_type, 10)
  17010. }
  17011. var infocode int64
  17012. var resThree ResultThree
  17013. var resThree10265 ResultThree10265
  17014. if len(insuplc_admdvs) == 0 {
  17015. psn_info, _ := service.GetPsnByPatientId(id)
  17016. //if len(psn_info.InsuplcAdmdvs) > 0 {
  17017. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17018. //}
  17019. } else {
  17020. insuplc_admdvs_temp = insuplc_admdvs
  17021. }
  17022. if miConfig.MdtrtareaAdmvs == "421300" {
  17023. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17024. psn_info, _ := service.GetPsnByPatientId(id)
  17025. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17026. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17027. "&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
  17028. resp, requestErr := http.Get(api)
  17029. if requestErr != nil {
  17030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17031. return
  17032. }
  17033. body, ioErr := ioutil.ReadAll(resp.Body)
  17034. if ioErr != nil {
  17035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17037. return
  17038. }
  17039. var respJSON map[string]interface{}
  17040. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17043. return
  17044. }
  17045. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17046. result, _ := json.Marshal(respJSON)
  17047. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17048. utils.ErrorLog("解析失败:%v", err)
  17049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17050. return
  17051. }
  17052. infocode = resThree.Infcode
  17053. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17054. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17055. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17056. // insuplc_admdvs_temp =
  17057. //}
  17058. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17059. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17060. //}
  17061. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17062. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17063. "&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
  17064. resp, requestErr := http.Get(api)
  17065. if requestErr != nil {
  17066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17067. return
  17068. }
  17069. body, ioErr := ioutil.ReadAll(resp.Body)
  17070. if ioErr != nil {
  17071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17073. return
  17074. }
  17075. var respJSON map[string]interface{}
  17076. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17079. return
  17080. }
  17081. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17082. result, _ := json.Marshal(respJSON)
  17083. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17084. utils.ErrorLog("解析失败:%v", err)
  17085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17086. return
  17087. }
  17088. infocode = resThree.Infcode
  17089. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17090. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17091. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17092. // insuplc_admdvs_temp =
  17093. //}
  17094. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17095. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17096. //}
  17097. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17098. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17099. "&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
  17100. resp, requestErr := http.Get(api)
  17101. if requestErr != nil {
  17102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17103. return
  17104. }
  17105. body, ioErr := ioutil.ReadAll(resp.Body)
  17106. if ioErr != nil {
  17107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17109. return
  17110. }
  17111. var respJSON map[string]interface{}
  17112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17115. return
  17116. }
  17117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17118. result, _ := json.Marshal(respJSON)
  17119. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17120. utils.ErrorLog("解析失败:%v", err)
  17121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17122. return
  17123. }
  17124. infocode = resThree.Infcode
  17125. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17126. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17127. psn_info, _ := service.GetPsnByPatientId(id)
  17128. var verify_number string
  17129. if id_card_type == 4 {
  17130. verify_number = psn_info.VerifyNumber
  17131. } else if id_card_type == 1 {
  17132. bas := strings.Split(psn_info.CardInfo, "|")
  17133. cardNumber := bas[2]
  17134. verify_number = cardNumber
  17135. }
  17136. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17137. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17138. "&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
  17139. resp, requestErr := http.Get(api)
  17140. if requestErr != nil {
  17141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17142. return
  17143. }
  17144. body, ioErr := ioutil.ReadAll(resp.Body)
  17145. if ioErr != nil {
  17146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17148. return
  17149. }
  17150. var respJSON map[string]interface{}
  17151. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17154. return
  17155. }
  17156. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17157. result, _ := json.Marshal(respJSON)
  17158. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17159. // utils.ErrorLog("解析失败:%v", err)
  17160. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17161. // return
  17162. //}
  17163. //infocode = resThree.Infcode
  17164. //result, _ := json.Marshal(respJSON)
  17165. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17166. utils.ErrorLog("解析失败:%v", err)
  17167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17168. return
  17169. }
  17170. resThree.ErrMsg = resThree10265.ErrMsg
  17171. resThree.Output = resThree10265.Output
  17172. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17173. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17174. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17175. psn_info, _ := service.GetPsnByPatientId(id)
  17176. his.PsnNo = psn_info.PsnNo
  17177. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17178. var cert_no string
  17179. if id_card_type == 3 {
  17180. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  17181. cert_no = IdCardNo
  17182. } else if id_card_type == 4 {
  17183. cert_no = IdCardNo
  17184. psn_info.VerifyNumber = psn_info.VerifyNumber
  17185. } else {
  17186. bas := strings.Split(psn_info.CardInfo, "|")
  17187. cert_no = bas[2]
  17188. }
  17189. var hisPrescription []*models.HisPrescription
  17190. for _, item := range rf {
  17191. if item.Insutype == insutype {
  17192. //insuplc_admdvs = item.InsuplcAdmdvs
  17193. his.InsuplcAdmdvs = insuplc_admdvs
  17194. }
  17195. }
  17196. his.Insutype = insutype
  17197. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  17198. fmt.Println(res3101)
  17199. fmt.Println(res3101.Infcode)
  17200. if res3101.Infcode == "0" {
  17201. fmt.Println("33333333")
  17202. if len(res3101.Output.Result) > 0 {
  17203. fmt.Println("222222")
  17204. for _, item := range res3101.Output.Result {
  17205. if len(res3101.ErrMsg) == 0 {
  17206. res3101.ErrMsg = item.VolaCont
  17207. } else {
  17208. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  17209. }
  17210. }
  17211. c.ServeSuccessJSON(map[string]interface{}{
  17212. "failed_code": -10,
  17213. "msg": res3101.ErrMsg,
  17214. })
  17215. return
  17216. } else {
  17217. fmt.Println("11111")
  17218. var api string
  17219. if miConfig.MdtrtareaAdmvs == "320921" {
  17220. ipt_otp_no = timeFormat
  17221. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17222. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17223. "&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
  17224. } else {
  17225. ipt_otp_no = timeFormat
  17226. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17227. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17228. "&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
  17229. }
  17230. resp, requestErr := http.Get(api)
  17231. if requestErr != nil {
  17232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17233. return
  17234. }
  17235. body, ioErr := ioutil.ReadAll(resp.Body)
  17236. if ioErr != nil {
  17237. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17239. return
  17240. }
  17241. var respJSON map[string]interface{}
  17242. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17245. return
  17246. }
  17247. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17248. result, _ := json.Marshal(respJSON)
  17249. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17250. utils.ErrorLog("解析失败:%v", err)
  17251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17252. return
  17253. }
  17254. resThree.ErrMsg = resThree10265.ErrMsg
  17255. resThree.Output = resThree10265.Output
  17256. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17257. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17258. }
  17259. } else if res3101.Infcode != "0" {
  17260. c.ServeSuccessJSON(map[string]interface{}{
  17261. "failed_code": -10,
  17262. "msg": res3101.ErrMsg,
  17263. })
  17264. return
  17265. }
  17266. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17267. psn_info, _ := service.GetPsnByPatientId(id)
  17268. var cert_no string
  17269. if id_card_type == 1 {
  17270. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  17271. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17272. } else if id_card_type == 4 {
  17273. cert_no = psn_info.VerifyNumber
  17274. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17275. } else {
  17276. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17277. cert_no = psn_info.VerifyNumber
  17278. }
  17279. 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)
  17280. saveLog(result, requestLog, "2201", "挂号")
  17281. if miConfig.Code == "H15049901371" {
  17282. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17283. utils.ErrorLog("解析失败:%v", err)
  17284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17285. return
  17286. }
  17287. resThree.ErrMsg = resThree10265.ErrMsg
  17288. resThree.Output = resThree10265.Output
  17289. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17290. } else {
  17291. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17292. utils.ErrorLog("解析失败:%v", err)
  17293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17294. return
  17295. }
  17296. }
  17297. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17298. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  17299. psn_info, _ := service.GetPsnByPatientId(id)
  17300. var result string
  17301. var requestLog string
  17302. if id_card_type == 1 {
  17303. bas := strings.Split(psn_info.CardInfo, "|")
  17304. basNumber := bas[2]
  17305. card_sn := bas[3]
  17306. 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)
  17307. saveLog(result, requestLog, "2201A", "挂号")
  17308. } else if id_card_type == 2 {
  17309. 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, "", "", "", "", "", "")
  17310. saveLog(result, requestLog, "2201A", "挂号")
  17311. } else {
  17312. 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)
  17313. saveLog(result, requestLog, "2201A", "挂号")
  17314. }
  17315. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17316. utils.ErrorLog("解析失败:%v", err)
  17317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17318. return
  17319. }
  17320. infocode = resThree.Infcode
  17321. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17322. psn_info, _ := service.GetPsnByPatientId(id)
  17323. his.PsnNo = psn_info.PsnNo
  17324. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17325. var cert_no string
  17326. if id_card_type == 1 {
  17327. bas := strings.Split(psn_info.CardInfo, "|")
  17328. cert_no = bas[2]
  17329. } else if id_card_type == 4 {
  17330. cert_no = IdCardNo
  17331. psn_info.VerifyNumber = psn_info.VerifyNumber
  17332. } else {
  17333. cert_no = IdCardNo
  17334. psn_info.VerifyNumber = cert_no
  17335. }
  17336. for _, item := range rf {
  17337. if item.Insutype == insutype {
  17338. his.InsuplcAdmdvs = insuplc_admdvs
  17339. }
  17340. }
  17341. his.Insutype = insutype
  17342. var api string
  17343. ipt_otp_no = timeFormat
  17344. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17345. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17346. "&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
  17347. resp, requestErr := http.Get(api)
  17348. if requestErr != nil {
  17349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17350. return
  17351. }
  17352. body, ioErr := ioutil.ReadAll(resp.Body)
  17353. if ioErr != nil {
  17354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17356. return
  17357. }
  17358. var respJSON map[string]interface{}
  17359. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17362. return
  17363. }
  17364. status := respJSON["data"].(map[string]interface{})["status"].(string)
  17365. if status == "0" {
  17366. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  17367. c.ServeSuccessJSON(map[string]interface{}{
  17368. "failed_code": -10,
  17369. "msg": err_msg,
  17370. })
  17371. return
  17372. }
  17373. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17374. result, _ := json.Marshal(respJSON)
  17375. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17376. utils.ErrorLog("解析失败:%v", err)
  17377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17378. return
  17379. }
  17380. infocode = resThree.Infcode
  17381. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17382. psn_info, _ := service.GetPsnByPatientId(id)
  17383. var result string
  17384. var requestLog string
  17385. if id_card_type == 1 {
  17386. bas := strings.Split(psn_info.CardInfo, "|")
  17387. basNumber := bas[2]
  17388. card_sn := bas[3]
  17389. 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)
  17390. saveLog(result, requestLog, "2201A", "挂号")
  17391. } else if id_card_type == 2 {
  17392. 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, "", "")
  17393. saveLog(result, requestLog, "2201A", "挂号")
  17394. } else {
  17395. 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, "", "")
  17396. saveLog(result, requestLog, "2201A", "挂号")
  17397. }
  17398. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17399. utils.ErrorLog("解析失败:%v", err)
  17400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17401. return
  17402. }
  17403. infocode = resThree.Infcode
  17404. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17405. psn_info, _ := service.GetPsnByPatientId(id)
  17406. 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)
  17407. saveLog(result, requestLog, "2201A", "挂号")
  17408. if miConfig.Code == "H15049901371" {
  17409. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17410. utils.ErrorLog("解析失败:%v", err)
  17411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17412. return
  17413. }
  17414. resThree.ErrMsg = resThree10265.ErrMsg
  17415. resThree.Output = resThree10265.Output
  17416. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17417. } else {
  17418. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17419. utils.ErrorLog("解析失败:%v", err)
  17420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17421. return
  17422. }
  17423. }
  17424. if miConfig.Code == "H15049901371" {
  17425. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17426. } else {
  17427. infocode = resThree.Infcode
  17428. }
  17429. } else {
  17430. psn_info, _ := service.GetPsnByPatientId(id)
  17431. if id_card_type == 4 || id_card_type == 1 {
  17432. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17433. }
  17434. var rf []*ResultFive
  17435. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  17436. var insutypes []*ResultFive
  17437. var insutype string
  17438. var is390 int = 0
  17439. var is310 int = 0
  17440. for _, item := range rf {
  17441. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17442. insutypes = append(insutypes, item)
  17443. }
  17444. }
  17445. if len(insutypes) == 1 {
  17446. insutype = insutypes[0].Insutype
  17447. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17448. } else {
  17449. for _, i := range insutypes {
  17450. if i.Insutype == "390" {
  17451. is390 = 1
  17452. }
  17453. if i.Insutype == "310" {
  17454. is310 = 1
  17455. }
  17456. }
  17457. }
  17458. if is390 == 1 {
  17459. insutype = "390"
  17460. }
  17461. if is310 == 1 {
  17462. insutype = "310"
  17463. }
  17464. fmt.Println(len(insutypes))
  17465. if len(insutypes) == 0 {
  17466. for index, item := range rf {
  17467. if index == 0 {
  17468. insutype = item.Insutype
  17469. insuplc_admdvs = item.InsuplcAdmdvs
  17470. }
  17471. }
  17472. fmt.Println(insutype)
  17473. fmt.Println(insuplc_admdvs)
  17474. }
  17475. if social_type > 0 {
  17476. insutype = strconv.FormatInt(social_type, 10)
  17477. }
  17478. fmt.Println("--------")
  17479. fmt.Println(psn_info)
  17480. fmt.Println(psn_info.PsnNo)
  17481. if miConfig.MdtrtareaAdmvs == "441202" {
  17482. var hisPrescription []*models.HisPrescription
  17483. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  17484. if res3101.Infcode == 0 {
  17485. fmt.Println("33333333")
  17486. if len(res3101.Output.Result) > 0 {
  17487. fmt.Println("222222")
  17488. for _, item := range res3101.Output.Result {
  17489. if len(res3101.ErrMsg) == 0 {
  17490. res3101.ErrMsg = item.VolaCont
  17491. } else {
  17492. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  17493. }
  17494. }
  17495. c.ServeSuccessJSON(map[string]interface{}{
  17496. "failed_code": -10,
  17497. "msg": res3101.ErrMsg,
  17498. })
  17499. return
  17500. } else {
  17501. hour := time.Now().Format("15")
  17502. min := time.Now().Format("04")
  17503. sec := time.Now().Format("05")
  17504. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  17505. fmt.Println(record_time_two)
  17506. 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)
  17507. saveLog(result, requestLog, "2201A", "挂号")
  17508. if miConfig.Code == "H15049901371" {
  17509. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17510. utils.ErrorLog("解析失败:%v", err)
  17511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17512. return
  17513. }
  17514. resThree.ErrMsg = resThree10265.ErrMsg
  17515. resThree.Output = resThree10265.Output
  17516. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17517. } else {
  17518. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17519. utils.ErrorLog("解析失败:%v", err)
  17520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17521. return
  17522. }
  17523. }
  17524. if miConfig.Code == "H15049901371" {
  17525. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17526. } else {
  17527. infocode = resThree.Infcode
  17528. }
  17529. }
  17530. } else if res3101.Infcode != 0 {
  17531. c.ServeSuccessJSON(map[string]interface{}{
  17532. "failed_code": -10,
  17533. "msg": res3101.ErrMsg,
  17534. })
  17535. return
  17536. }
  17537. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17538. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17539. psn_info, _ := service.GetPsnByPatientId(id)
  17540. var verify_number string
  17541. if id_card_type == 4 {
  17542. verify_number = psn_info.VerifyNumber
  17543. } else if id_card_type == 1 {
  17544. bas := strings.Split(psn_info.CardInfo, "|")
  17545. cardNumber := bas[2]
  17546. verify_number = cardNumber
  17547. } else {
  17548. verify_number = psn_info.Certno
  17549. }
  17550. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17551. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17552. "&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
  17553. resp, requestErr := http.Get(api)
  17554. if requestErr != nil {
  17555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17556. return
  17557. }
  17558. body, ioErr := ioutil.ReadAll(resp.Body)
  17559. if ioErr != nil {
  17560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17562. return
  17563. }
  17564. var respJSON map[string]interface{}
  17565. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17568. return
  17569. }
  17570. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17571. result, _ := json.Marshal(respJSON)
  17572. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17573. utils.ErrorLog("解析失败:%v", err)
  17574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17575. return
  17576. }
  17577. infocode = resThree.Infcode
  17578. } else {
  17579. hour := time.Now().Format("15")
  17580. min := time.Now().Format("04")
  17581. sec := time.Now().Format("05")
  17582. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  17583. if id_card_type == 1 {
  17584. for _, item := range rf {
  17585. if item.Insutype == strconv.FormatInt(social_type, 10) {
  17586. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  17587. insuplc_admdvs_temp = item.InsuplcAdmdvs
  17588. } else if strconv.FormatInt(social_type, 10) == "390" {
  17589. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17590. } else {
  17591. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17592. }
  17593. }
  17594. }
  17595. }
  17596. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  17597. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17598. }
  17599. if id_card_type == 1 {
  17600. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  17601. bas := strings.Split(psn_info.CardInfo, "|")
  17602. basNumber := bas[1]
  17603. IdCardNo = basNumber
  17604. }
  17605. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  17606. IdCardNo = psn_info.VerifyNumber
  17607. }
  17608. 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)
  17609. saveLog(result, requestLog, "2201A", "挂号")
  17610. if miConfig.Code == "H15049901371" {
  17611. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17612. utils.ErrorLog("解析失败:%v", err)
  17613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17614. return
  17615. }
  17616. resThree.ErrMsg = resThree10265.ErrMsg
  17617. resThree.Output = resThree10265.Output
  17618. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17619. } else {
  17620. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17621. utils.ErrorLog("解析失败:%v", err)
  17622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17623. return
  17624. }
  17625. }
  17626. if miConfig.Code == "H15049901371" {
  17627. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17628. } else {
  17629. infocode = resThree.Infcode
  17630. }
  17631. }
  17632. }
  17633. if infocode != 0 {
  17634. adminUser := c.GetAdminUserInfo()
  17635. errlog := &models.HisOrderError{
  17636. UserOrgId: adminUser.CurrentOrgId,
  17637. Ctime: time.Now().Unix(),
  17638. Mtime: time.Now().Unix(),
  17639. ErrMsg: resThree.ErrMsg,
  17640. Status: 1,
  17641. PatientId: id,
  17642. RecordTime: recordDateTime,
  17643. Stage: 2,
  17644. }
  17645. service.CreateErrMsgLog(errlog)
  17646. c.ServeSuccessJSON(map[string]interface{}{
  17647. "failed_code": -10,
  17648. "msg": resThree.ErrMsg,
  17649. })
  17650. return
  17651. }
  17652. his.Number = resThree.Output.Data.MdtrtID
  17653. his.PsnNo = resThree.Output.Data.PsnNo
  17654. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  17655. his.IdCardNo = patient.IdCardNo
  17656. his.PhoneNumber = patient.Phone
  17657. his.UserOrgId = adminInfo.CurrentOrgId
  17658. his.Insutype = insutype
  17659. his.Ctime = time.Now().Unix()
  17660. his.Mtime = time.Now().Unix()
  17661. his.InsuplcAdmdvs = insuplc_admdvs_temp
  17662. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  17663. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17664. }
  17665. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  17666. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17667. }
  17668. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  17669. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17670. }
  17671. his.Status = 1
  17672. his.MdtrtGrpType = mdtrt_type
  17673. service.UpdateHisPatientStatus(&his)
  17674. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  17675. c.ServeSuccessJSON(map[string]interface{}{
  17676. "his_info": his,
  17677. })
  17678. } else {
  17679. adminUser := c.GetAdminUserInfo()
  17680. errlog := &models.HisOrderError{
  17681. UserOrgId: adminUser.CurrentOrgId,
  17682. Ctime: time.Now().Unix(),
  17683. Mtime: time.Now().Unix(),
  17684. ErrMsg: res.ErrMsg,
  17685. Status: 1,
  17686. PatientId: id,
  17687. RecordTime: recordDateTime,
  17688. Stage: 1,
  17689. }
  17690. service.CreateErrMsgLog(errlog)
  17691. c.ServeSuccessJSON(map[string]interface{}{
  17692. "failed_code": -10,
  17693. "msg": res.ErrMsg,
  17694. })
  17695. return
  17696. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  17697. }
  17698. }
  17699. }
  17700. func (c *HisApiController) GetUploadInfo() {
  17701. id, _ := c.GetInt64("id")
  17702. record_time := c.GetString("record_time")
  17703. his_patient_id, _ := c.GetInt64("his_patient_id")
  17704. order_id, _ := c.GetInt64("order_id")
  17705. pay_way, _ := c.GetInt64("pay_way")
  17706. pay_ways := c.GetString("pay_ways")
  17707. oth_desc := c.GetString("oth_desc")
  17708. pay_price, _ := c.GetFloat("pay_price")
  17709. pay_card_no := c.GetString("pay_card_no")
  17710. discount_price, _ := c.GetFloat("discount_price")
  17711. preferential_price, _ := c.GetFloat("preferential_price")
  17712. reality_price, _ := c.GetFloat("reality_price")
  17713. found_price, _ := c.GetFloat("found_price")
  17714. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  17715. private_price, _ := c.GetFloat("private_price")
  17716. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  17717. admin_user_id, _ := c.GetInt64("admin_user_id")
  17718. fapiao_code := c.GetString("fapiao_code")
  17719. fapiao_number := c.GetString("fapiao_number")
  17720. diagnosis_id := c.GetString("diagnosis")
  17721. sick_type, _ := c.GetInt64("sick_type")
  17722. reg_type, _ := c.GetInt64("p_type")
  17723. begin_time := c.GetString("begin_time")
  17724. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  17725. cash_pay := c.GetString("cash_pay")
  17726. band_card_pay := c.GetString("band_card_pay")
  17727. wechat_pay := c.GetString("wechat_pay")
  17728. ali_pay := c.GetString("ali_pay")
  17729. jifen_pay := c.GetString("jifen_pay")
  17730. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  17731. fmt.Println(acct_used_flag)
  17732. id_str := c.GetString("ids")
  17733. ids_arr := strings.Split(id_str, ",")
  17734. timeLayout := "2006-01-02"
  17735. loc, _ := time.LoadLocation("Local")
  17736. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17737. if err != nil {
  17738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17739. return
  17740. }
  17741. recordDateTime := theTime.Unix()
  17742. adminUser := c.GetAdminUserInfo()
  17743. var tempOrder models.HisOrder
  17744. tempOrder, _ = service.GetHisOrderByID(order_id)
  17745. var prescriptions []*models.HisPrescription
  17746. var start_time int64
  17747. var end_time int64
  17748. //押金模块
  17749. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  17750. tmp_decimal := c.GetString("tmp_decimal")
  17751. var decimal float64 //本次使用的押金
  17752. var errmsg error
  17753. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  17754. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  17755. return
  17756. }
  17757. if len(tmp_decimal) > 0 {
  17758. if tmp_decimal[0] == 45 {
  17759. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  17760. return
  17761. }
  17762. }
  17763. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  17764. fmt.Println(errs)
  17765. decimal = tt
  17766. //if adminUser.CurrentOrgId == 10106{
  17767. // if len(fapiao_code) == 0{
  17768. // fapiao_code = "144072080589"
  17769. // }
  17770. // if len(fapiao_number) == 0{
  17771. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  17772. // if order.ID == 0{
  17773. // fapiao_number = "00001520"
  17774. // }else{
  17775. // //fapiao_code = "00001520"
  17776. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  17777. // var zero string
  17778. // if fpNumber >= 1000{
  17779. // zero = "0000" + strconv.Itoa(fpNumber)
  17780. // }else if fpNumber >= 10000{
  17781. // zero = "000" + strconv.Itoa(fpNumber)
  17782. // } else if fpNumber >= 100000{
  17783. // zero = "00" + strconv.Itoa(fpNumber)
  17784. // } else if fpNumber >= 1000000{
  17785. // zero = "0" + strconv.Itoa(fpNumber)
  17786. // }else {
  17787. // zero = strconv.Itoa(fpNumber)
  17788. // }
  17789. // fapiao_number = zero
  17790. // }
  17791. // }
  17792. //}
  17793. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17794. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  17795. var patientPrescription models.HisPrescriptionInfo
  17796. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  17797. if patientPrescription.ID == 0 {
  17798. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  17799. }
  17800. //if patientPrescription.Do
  17801. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17802. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  17803. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  17804. diagnosis_ids := strings.Split(diagnosis_id, ",")
  17805. var config []*models.HisXtDiagnoseConfig
  17806. for _, item := range diagnosis_ids {
  17807. id, _ := strconv.ParseInt(item, 10, 64)
  17808. diagnosisConfig, _ := service.FindDiagnoseById(id)
  17809. config = append(config, &diagnosisConfig)
  17810. }
  17811. sickConfig, _ := service.FindSickById(sick_type)
  17812. //if tempOrder.ID == 0 {
  17813. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  17814. //}
  17815. if tempOrder.ID == 0 {
  17816. var result string
  17817. var requestLog string
  17818. var res2 ResultSix
  17819. var res3 GZResultSix
  17820. var ressix10265 ResultSix10265
  17821. if miConfig.MdtrtareaAdmvs == "421300" {
  17822. data := make(map[string]interface{})
  17823. client := &http.Client{}
  17824. data["psn_no"] = his.PsnNo
  17825. data["mdtrt_id"] = his.Number
  17826. data["opter"] = roles.UserName
  17827. data["org_name"] = miConfig.OrgName
  17828. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17829. data["doctor_id"] = doctor_info.DoctorNumber
  17830. data["doctor_name"] = doctor_info.UserName
  17831. data["department"] = department.Name
  17832. data["fixmedins_code"] = miConfig.Code
  17833. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17834. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17835. data["secret_key"] = miConfig.SecretKey
  17836. data["sick_code"] = sickConfig.CountryCode
  17837. data["sick_name"] = sickConfig.ClassName
  17838. data["dept"] = strconv.FormatInt(department.ID, 10)
  17839. data["config"] = config
  17840. data["begin_time"] = begin_time
  17841. bytesData, _ := json.Marshal(data)
  17842. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  17843. resp, _ := client.Do(req)
  17844. defer resp.Body.Close()
  17845. body, ioErr := ioutil.ReadAll(resp.Body)
  17846. if ioErr != nil {
  17847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17849. return
  17850. }
  17851. var respJSON map[string]interface{}
  17852. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17855. return
  17856. }
  17857. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17858. userJSONBytes, _ := json.Marshal(respJSON)
  17859. fmt.Println("log")
  17860. fmt.Println(string(userJSONBytes))
  17861. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17862. utils.ErrorLog("解析失败:%v", err)
  17863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17864. return
  17865. }
  17866. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17867. data := make(map[string]interface{})
  17868. client := &http.Client{}
  17869. data["psn_no"] = his.PsnNo
  17870. data["mdtrt_id"] = his.Number
  17871. data["opter"] = roles.UserName
  17872. data["org_name"] = miConfig.OrgName
  17873. if reg_type == 11 && his.Insutype == "390" {
  17874. data["med_type"] = "110104"
  17875. } else {
  17876. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17877. }
  17878. data["doctor_id"] = doctor_info.DoctorNumber
  17879. data["doctor_name"] = doctor_info.UserName
  17880. data["department"] = department.Name
  17881. data["fixmedins_code"] = miConfig.Code
  17882. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17883. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17884. data["secret_key"] = miConfig.SecretKey
  17885. data["sick_code"] = sickConfig.CountryCode
  17886. data["sick_name"] = sickConfig.ClassName
  17887. data["dept"] = strconv.FormatInt(department.ID, 10)
  17888. data["config"] = config
  17889. data["begin_time"] = begin_time
  17890. bytesData, _ := json.Marshal(data)
  17891. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  17892. resp, _ := client.Do(req)
  17893. defer resp.Body.Close()
  17894. body, ioErr := ioutil.ReadAll(resp.Body)
  17895. if ioErr != nil {
  17896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17898. return
  17899. }
  17900. var respJSON map[string]interface{}
  17901. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17904. return
  17905. }
  17906. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17907. userJSONBytes, _ := json.Marshal(respJSON)
  17908. fmt.Println("log")
  17909. fmt.Println(string(userJSONBytes))
  17910. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17911. utils.ErrorLog("解析失败:%v", err)
  17912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17913. return
  17914. }
  17915. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17916. data := make(map[string]interface{})
  17917. client := &http.Client{}
  17918. data["psn_no"] = his.PsnNo
  17919. data["mdtrt_id"] = his.Number
  17920. data["opter"] = roles.UserName
  17921. data["org_name"] = miConfig.OrgName
  17922. if reg_type == 11 && his.Insutype == "390" {
  17923. data["med_type"] = "110104"
  17924. } else {
  17925. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17926. }
  17927. data["doctor_id"] = doctor_info.DoctorNumber
  17928. data["doctor_name"] = doctor_info.UserName
  17929. data["department"] = department.Name
  17930. data["fixmedins_code"] = miConfig.Code
  17931. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17932. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17933. data["secret_key"] = miConfig.SecretKey
  17934. data["sick_code"] = sickConfig.CountryCode
  17935. data["sick_name"] = sickConfig.ClassName
  17936. data["dept"] = strconv.FormatInt(department.ID, 10)
  17937. data["config"] = config
  17938. data["begin_time"] = begin_time
  17939. bytesData, _ := json.Marshal(data)
  17940. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  17941. resp, _ := client.Do(req)
  17942. defer resp.Body.Close()
  17943. body, ioErr := ioutil.ReadAll(resp.Body)
  17944. if ioErr != nil {
  17945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17947. return
  17948. }
  17949. var respJSON map[string]interface{}
  17950. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17953. return
  17954. }
  17955. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17956. userJSONBytes, _ := json.Marshal(respJSON)
  17957. fmt.Println("log")
  17958. fmt.Println(string(userJSONBytes))
  17959. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17960. utils.ErrorLog("解析失败:%v", err)
  17961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17962. return
  17963. }
  17964. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17965. data := make(map[string]interface{})
  17966. client := &http.Client{}
  17967. data["psn_no"] = his.PsnNo
  17968. data["mdtrt_id"] = his.Number
  17969. data["doctor"] = roles.UserName
  17970. data["department"] = department.Name
  17971. data["org_name"] = miConfig.OrgName
  17972. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17973. data["doctor_id"] = doctor_info.DoctorNumber
  17974. data["new_doctor_name"] = doctor_info.UserName
  17975. data["fixmedins_code"] = miConfig.Code
  17976. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17977. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17978. data["secret_key"] = miConfig.SecretKey
  17979. data["sick_code"] = sickConfig.CountryCode
  17980. data["sick_name"] = sickConfig.ClassName
  17981. data["url"] = miConfig.Url
  17982. data["ak"] = miConfig.AccessKey
  17983. data["begin_time"] = begin_time
  17984. data["cainfo"] = miConfig.Cainfo
  17985. data["dept"] = strconv.FormatInt(department.ID, 10)
  17986. data["config"] = config
  17987. bytesData, _ := json.Marshal(data)
  17988. var req *http.Request
  17989. if miConfig.MdtrtareaAdmvs == "320921" {
  17990. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  17991. //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 +
  17992. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  17993. } else {
  17994. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  17995. }
  17996. resp, _ := client.Do(req)
  17997. defer resp.Body.Close()
  17998. body, ioErr := ioutil.ReadAll(resp.Body)
  17999. if ioErr != nil {
  18000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18002. return
  18003. }
  18004. var respJSON map[string]interface{}
  18005. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18008. return
  18009. }
  18010. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18011. userJSONBytes, _ := json.Marshal(respJSON)
  18012. fmt.Println("log")
  18013. fmt.Println(string(userJSONBytes))
  18014. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18015. utils.ErrorLog("解析失败:%v", err)
  18016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18017. return
  18018. }
  18019. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18020. res2.Output = ressix10265.Output
  18021. res2.ErrMsg = ressix10265.ErrMsg
  18022. res2.Cainfo = ressix10265.Cainfo
  18023. res2.WarnMsg = ressix10265.WarnMsg
  18024. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18025. res2.Infcode = infocode
  18026. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18027. data := make(map[string]interface{})
  18028. client := &http.Client{}
  18029. data["psn_no"] = his.PsnNo
  18030. data["mdtrt_id"] = his.Number
  18031. data["doctor"] = roles.UserName
  18032. data["department"] = department.Name
  18033. data["org_name"] = miConfig.OrgName
  18034. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18035. data["doctor_id"] = doctor_info.DoctorNumber
  18036. data["new_doctor_name"] = doctor_info.UserName
  18037. data["fixmedins_code"] = miConfig.Code
  18038. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18039. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18040. data["secret_key"] = miConfig.SecretKey
  18041. data["sick_code"] = sickConfig.CountryCode
  18042. data["sick_name"] = sickConfig.ClassName
  18043. data["url"] = miConfig.Url
  18044. data["ak"] = miConfig.AccessKey
  18045. data["begin_time"] = begin_time
  18046. data["cainfo"] = miConfig.Cainfo
  18047. data["dept"] = strconv.FormatInt(department.ID, 10)
  18048. data["config"] = config
  18049. bytesData, _ := json.Marshal(data)
  18050. var req *http.Request
  18051. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  18052. resp, _ := client.Do(req)
  18053. defer resp.Body.Close()
  18054. body, ioErr := ioutil.ReadAll(resp.Body)
  18055. if ioErr != nil {
  18056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18058. return
  18059. }
  18060. var respJSON map[string]interface{}
  18061. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18064. return
  18065. }
  18066. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18067. userJSONBytes, _ := json.Marshal(respJSON)
  18068. fmt.Println("log")
  18069. fmt.Println(string(userJSONBytes))
  18070. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18071. utils.ErrorLog("解析失败:%v", err)
  18072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18073. return
  18074. }
  18075. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18076. res2.Output = ressix10265.Output
  18077. res2.ErrMsg = ressix10265.ErrMsg
  18078. res2.Cainfo = ressix10265.Cainfo
  18079. res2.WarnMsg = ressix10265.WarnMsg
  18080. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18081. res2.Infcode = infocode
  18082. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18083. 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)
  18084. saveLog(result, requestLog, "2203", "上传就诊信息")
  18085. var respJSON2 map[string]interface{}
  18086. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18089. return
  18090. }
  18091. userJSONBytes2, _ := json.Marshal(respJSON2)
  18092. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18093. utils.ErrorLog("解析失败:%v", err)
  18094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18095. return
  18096. }
  18097. 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)
  18098. fmt.Println(result2)
  18099. fmt.Println(src_request)
  18100. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18101. data := make(map[string]interface{})
  18102. client := &http.Client{}
  18103. data["psn_no"] = his.PsnNo
  18104. data["mdtrt_id"] = his.Number
  18105. data["doctor"] = roles.UserName
  18106. data["department"] = department.Name
  18107. data["org_name"] = miConfig.OrgName
  18108. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18109. data["doctor_id"] = doctor_info.DoctorNumber
  18110. data["new_doctor_name"] = doctor_info.UserName
  18111. data["fixmedins_code"] = miConfig.Code
  18112. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18113. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18114. data["secret_key"] = miConfig.SecretKey
  18115. data["sick_code"] = sickConfig.CountryCode
  18116. data["sick_name"] = sickConfig.ClassName
  18117. data["url"] = miConfig.Url
  18118. data["ak"] = miConfig.AccessKey
  18119. data["begin_time"] = begin_time
  18120. data["cainfo"] = miConfig.Cainfo
  18121. data["dept"] = strconv.FormatInt(department.ID, 10)
  18122. data["config"] = config
  18123. bytesData, _ := json.Marshal(data)
  18124. var req *http.Request
  18125. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  18126. resp, _ := client.Do(req)
  18127. defer resp.Body.Close()
  18128. body, ioErr := ioutil.ReadAll(resp.Body)
  18129. if ioErr != nil {
  18130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18132. return
  18133. }
  18134. var respJSON map[string]interface{}
  18135. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18138. return
  18139. }
  18140. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18141. userJSONBytes, _ := json.Marshal(respJSON)
  18142. fmt.Println("log")
  18143. fmt.Println(string(userJSONBytes))
  18144. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18145. utils.ErrorLog("解析失败:%v", err)
  18146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18147. return
  18148. }
  18149. } else {
  18150. if miConfig.MdtrtareaAdmvs == "440781" { //
  18151. 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)
  18152. } else {
  18153. if miConfig.Code == "H15049901371" {
  18154. //赤峰地区国家医保医疗类别
  18155. //职工透析:医疗类别选特殊情况门诊990502
  18156. //居民定额血透门慢: 医疗类别选门诊慢病140104
  18157. var med_type string
  18158. if his.Insutype == "390" {
  18159. if reg_type == 14 {
  18160. med_type = "9933"
  18161. } else if reg_type == 11 {
  18162. med_type = "11"
  18163. }
  18164. } else if his.Insutype == "310" {
  18165. if reg_type == 14 {
  18166. med_type = "990502"
  18167. } else if reg_type == 11 {
  18168. med_type = "11"
  18169. }
  18170. }
  18171. 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)
  18172. } else {
  18173. 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)
  18174. }
  18175. }
  18176. saveLog(result, requestLog, "2203", "上传就诊信息")
  18177. var respJSON2 map[string]interface{}
  18178. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18181. return
  18182. }
  18183. userJSONBytes2, _ := json.Marshal(respJSON2)
  18184. if miConfig.Code == "H15049901371" {
  18185. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  18186. utils.ErrorLog("解析失败:%v", err)
  18187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18188. return
  18189. }
  18190. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18191. res2.Output = ressix10265.Output
  18192. res2.ErrMsg = ressix10265.ErrMsg
  18193. res2.Cainfo = ressix10265.Cainfo
  18194. res2.WarnMsg = ressix10265.WarnMsg
  18195. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18196. res2.Infcode = infocode
  18197. } else {
  18198. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  18199. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  18200. utils.ErrorLog("解析失败:%v", err)
  18201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18202. return
  18203. }
  18204. res2.Infcode = res3.Infcode
  18205. } else {
  18206. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18207. utils.ErrorLog("解析失败:%v", err)
  18208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18209. return
  18210. }
  18211. }
  18212. }
  18213. }
  18214. if res2.Infcode != 0 {
  18215. adminUser := c.GetAdminUserInfo()
  18216. errlog := &models.HisOrderError{
  18217. UserOrgId: adminUser.CurrentOrgId,
  18218. Ctime: time.Now().Unix(),
  18219. Mtime: time.Now().Unix(),
  18220. ErrMsg: res2.ErrMsg,
  18221. Status: 1,
  18222. PatientId: id,
  18223. RecordTime: recordDateTime,
  18224. Stage: 3,
  18225. }
  18226. service.CreateErrMsgLog(errlog)
  18227. c.ServeSuccessJSON(map[string]interface{}{
  18228. "failed_code": -10,
  18229. "msg": res2.ErrMsg,
  18230. })
  18231. return
  18232. } else {
  18233. his.Diagnosis = diagnosis_id
  18234. his.SickType = sickConfig.ID
  18235. //var p_type int64
  18236. //if reg_type == 1111 || reg_type == 1112 {
  18237. // p_type = 11
  18238. //
  18239. //}
  18240. his.PType = fmt.Sprintf("%d", reg_type)
  18241. service.UpdateHisPatientThree(&his)
  18242. data := make(map[string]interface{})
  18243. if settle_accounts_type == 1 { //日结
  18244. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  18245. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  18246. } else {
  18247. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  18248. }
  18249. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  18250. data["pre"] = prescriptions
  18251. } else { //月结
  18252. start_time_str := c.GetString("start_time")
  18253. end_time_str := c.GetString("end_time")
  18254. timeLayout := "2006-01-02"
  18255. loc, _ := time.LoadLocation("Local")
  18256. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  18257. if err != nil {
  18258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18259. return
  18260. }
  18261. recordStartTime := theStartTime.Unix()
  18262. start_time = recordStartTime
  18263. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  18264. if err != nil {
  18265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18266. return
  18267. }
  18268. recordEndTime := theEndTime.Unix()
  18269. end_time = recordEndTime
  18270. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  18271. data["pre"] = prescriptions
  18272. }
  18273. timestamp := time.Now().Unix()
  18274. tempTime := time.Unix(timestamp, 0)
  18275. timeFormat := tempTime.Format("20060102150405")
  18276. chrgBchno := rand.Intn(100000) + 10000
  18277. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  18278. strconv.FormatInt(his.PatientId, 10)
  18279. client := &http.Client{}
  18280. data["psn_no"] = his.PsnNo
  18281. data["mdtrt_id"] = his.Number
  18282. data["chrg_bchno"] = chrg_bchno
  18283. data["org_name"] = miConfig.OrgName
  18284. data["doctor"] = doctor_info.UserName
  18285. data["doctor_id"] = doctor_info.DoctorNumber
  18286. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  18287. data["fixmedins_code"] = miConfig.Code
  18288. data["dept_code"] = department.Number
  18289. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18290. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18291. data["secret_key"] = miConfig.SecretKey
  18292. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  18293. data["url"] = miConfig.Url
  18294. data["ak"] = miConfig.AccessKey
  18295. data["new_doctor_name"] = patientPrescription.Doctor
  18296. data["diag_code"] = sickConfig.CountryCode
  18297. data["cainfo"] = miConfig.Cainfo
  18298. data["opter"] = roles.UserName
  18299. var ids []int64
  18300. for _, item := range prescriptions {
  18301. ids = append(ids, item.ID)
  18302. }
  18303. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  18304. if config.IsOpen == 1 { //对接了医保,走医保流程
  18305. var res ResultFour
  18306. var resFour10265 ResultFour10265
  18307. if miConfig.MdtrtareaAdmvs == "421300" {
  18308. bytesData, _ := json.Marshal(data)
  18309. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  18310. resp, _ := client.Do(req)
  18311. defer resp.Body.Close()
  18312. body, ioErr := ioutil.ReadAll(resp.Body)
  18313. if ioErr != nil {
  18314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18316. return
  18317. }
  18318. var respJSON map[string]interface{}
  18319. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18322. return
  18323. }
  18324. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18325. userJSONBytes, _ := json.Marshal(respJSON)
  18326. fmt.Println("log")
  18327. fmt.Println(string(userJSONBytes))
  18328. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18329. utils.ErrorLog("解析失败:%v", err)
  18330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18331. return
  18332. }
  18333. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18334. bytesData, _ := json.Marshal(data)
  18335. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  18336. resp, _ := client.Do(req)
  18337. defer resp.Body.Close()
  18338. body, ioErr := ioutil.ReadAll(resp.Body)
  18339. if ioErr != nil {
  18340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18342. return
  18343. }
  18344. var respJSON map[string]interface{}
  18345. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18348. return
  18349. }
  18350. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18351. userJSONBytes, _ := json.Marshal(respJSON)
  18352. fmt.Println("log")
  18353. fmt.Println(string(userJSONBytes))
  18354. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18355. utils.ErrorLog("解析失败:%v", err)
  18356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18357. return
  18358. }
  18359. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18360. bytesData, _ := json.Marshal(data)
  18361. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  18362. resp, _ := client.Do(req)
  18363. defer resp.Body.Close()
  18364. body, ioErr := ioutil.ReadAll(resp.Body)
  18365. if ioErr != nil {
  18366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18368. return
  18369. }
  18370. var respJSON map[string]interface{}
  18371. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18374. return
  18375. }
  18376. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18377. userJSONBytes, _ := json.Marshal(respJSON)
  18378. fmt.Println("log")
  18379. fmt.Println(string(userJSONBytes))
  18380. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18381. utils.ErrorLog("解析失败:%v", err)
  18382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18383. return
  18384. }
  18385. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18386. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  18387. if result3101.Infcode == "0" {
  18388. if len(result3101.Output.Result) > 0 {
  18389. var errMsgs []string
  18390. for _, item := range result3101.Output.Result {
  18391. errMsgs = append(errMsgs, item.VolaCont)
  18392. }
  18393. c.ServeSuccessJSON(map[string]interface{}{
  18394. "failed_code": -10,
  18395. "msg": errMsgs,
  18396. })
  18397. return
  18398. }
  18399. }
  18400. bytesData, _ := json.Marshal(data)
  18401. var req *http.Request
  18402. if miConfig.MdtrtareaAdmvs == "320921" {
  18403. data["diag_code"] = sickConfig.CountryCode
  18404. fmt.Println(data)
  18405. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  18406. } else {
  18407. data["diag_code"] = sickConfig.CountryCode
  18408. fmt.Println(data)
  18409. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  18410. }
  18411. resp, _ := client.Do(req)
  18412. defer resp.Body.Close()
  18413. body, ioErr := ioutil.ReadAll(resp.Body)
  18414. if ioErr != nil {
  18415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18417. return
  18418. }
  18419. var respJSON map[string]interface{}
  18420. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18423. return
  18424. }
  18425. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18426. userJSONBytes, _ := json.Marshal(respJSON)
  18427. fmt.Println("log")
  18428. fmt.Println(string(userJSONBytes))
  18429. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18430. utils.ErrorLog("解析失败:%v", err)
  18431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18432. return
  18433. }
  18434. res.InfRefmsgid = resFour10265.InfRefmsgid
  18435. res.Output = resFour10265.Output
  18436. res.ErrMsg = resFour10265.ErrMsg
  18437. res.Cainfo = resFour10265.Cainfo
  18438. res.WarnMsg = resFour10265.WarnMsg
  18439. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18440. res.Infcode = infocode
  18441. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18442. var pagesize int = 2
  18443. var start int = 1
  18444. var stop int
  18445. var pagecount int
  18446. var curpage int
  18447. var isSuccess bool = true
  18448. data["doctor_id"] = doctor_info.DoctorNumber
  18449. //总页数,向上取整,注意除之前要先转换类型为float64
  18450. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  18451. for curpage = 1; curpage <= pagecount; curpage++ {
  18452. if curpage == 1 {
  18453. start = 1
  18454. } else {
  18455. start = (curpage-1)*pagesize + 1
  18456. }
  18457. stop = curpage * pagesize
  18458. if stop > len(prescriptions) {
  18459. stop = len(prescriptions)
  18460. }
  18461. //var requestLog string
  18462. data["pre"] = prescriptions[start-1 : stop]
  18463. fmt.Println(data["pre"])
  18464. bytesData, _ := json.Marshal(data)
  18465. var req *http.Request
  18466. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  18467. resp, _ := client.Do(req)
  18468. defer resp.Body.Close()
  18469. body, ioErr := ioutil.ReadAll(resp.Body)
  18470. if ioErr != nil {
  18471. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18473. return
  18474. }
  18475. var respJSON map[string]interface{}
  18476. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18477. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18479. return
  18480. }
  18481. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18482. userJSONBytes, _ := json.Marshal(respJSON)
  18483. fmt.Println("log")
  18484. fmt.Println(string(userJSONBytes))
  18485. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18486. utils.ErrorLog("解析失败:%v", err)
  18487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18488. return
  18489. }
  18490. res.InfRefmsgid = resFour10265.InfRefmsgid
  18491. res.Output = resFour10265.Output
  18492. res.ErrMsg = resFour10265.ErrMsg
  18493. res.Cainfo = resFour10265.Cainfo
  18494. res.WarnMsg = resFour10265.WarnMsg
  18495. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18496. res.Infcode = infocode
  18497. if infocode == 0 {
  18498. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  18499. } else {
  18500. isSuccess = false
  18501. errlog := &models.HisOrderError{
  18502. UserOrgId: adminUser.CurrentOrgId,
  18503. Ctime: time.Now().Unix(),
  18504. Mtime: time.Now().Unix(),
  18505. Number: chrg_bchno,
  18506. ErrMsg: "",
  18507. Status: 1,
  18508. PatientId: id,
  18509. RecordTime: recordDateTime,
  18510. Stage: 4,
  18511. }
  18512. service.CreateErrMsgLog(errlog)
  18513. c.ServeSuccessJSON(map[string]interface{}{
  18514. "failed_code": -10,
  18515. "msg": res.ErrMsg,
  18516. })
  18517. return
  18518. }
  18519. }
  18520. if isSuccess {
  18521. res.Infcode = 0
  18522. }
  18523. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18524. 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)
  18525. var dat map[string]interface{}
  18526. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18527. fmt.Println(dat)
  18528. } else {
  18529. fmt.Println(err)
  18530. }
  18531. saveLog(result, request_log, "2204", "上传费用明细")
  18532. userJSONBytes, _ := json.Marshal(dat)
  18533. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18534. utils.ErrorLog("解析失败:%v", err)
  18535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18536. return
  18537. }
  18538. res.InfRefmsgid = resFour10265.InfRefmsgid
  18539. res.Output = resFour10265.Output
  18540. res.ErrMsg = resFour10265.ErrMsg
  18541. res.Cainfo = resFour10265.Cainfo
  18542. res.WarnMsg = resFour10265.WarnMsg
  18543. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18544. res.Infcode = infocode
  18545. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18546. bytesData, _ := json.Marshal(data)
  18547. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  18548. resp, _ := client.Do(req)
  18549. defer resp.Body.Close()
  18550. body, ioErr := ioutil.ReadAll(resp.Body)
  18551. if ioErr != nil {
  18552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18554. return
  18555. }
  18556. var respJSON map[string]interface{}
  18557. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18560. return
  18561. }
  18562. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18563. userJSONBytes, _ := json.Marshal(respJSON)
  18564. fmt.Println("log")
  18565. fmt.Println(string(userJSONBytes))
  18566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18567. utils.ErrorLog("解析失败:%v", err)
  18568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18569. return
  18570. }
  18571. } else {
  18572. if miConfig.Code == "H15049901371" {
  18573. 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)
  18574. var dat map[string]interface{}
  18575. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18576. fmt.Println(dat)
  18577. } else {
  18578. fmt.Println(err)
  18579. }
  18580. saveLog(result, request_log, "2204", "上传费用明细")
  18581. userJSONBytes, _ := json.Marshal(dat)
  18582. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18583. utils.ErrorLog("解析失败:%v", err)
  18584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18585. return
  18586. }
  18587. res.InfRefmsgid = resFour10265.InfRefmsgid
  18588. res.Output = resFour10265.Output
  18589. res.ErrMsg = resFour10265.ErrMsg
  18590. res.Cainfo = resFour10265.Cainfo
  18591. res.WarnMsg = resFour10265.WarnMsg
  18592. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18593. res.Infcode = infocode
  18594. } else {
  18595. 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)
  18596. var dat map[string]interface{}
  18597. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18598. fmt.Println(dat)
  18599. } else {
  18600. fmt.Println(err)
  18601. }
  18602. saveLog(result, request_log, "2204", "上传费用明细")
  18603. userJSONBytes, _ := json.Marshal(dat)
  18604. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18605. utils.ErrorLog("解析失败:%v", err)
  18606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18607. return
  18608. }
  18609. }
  18610. }
  18611. if res.Infcode == 0 {
  18612. order := &models.HisOrder{
  18613. UserOrgId: adminUser.CurrentOrgId,
  18614. HisPatientId: his.ID,
  18615. PatientId: his.PatientId,
  18616. SettleAccountsDate: recordDateTime,
  18617. MdtrtId: his.Number,
  18618. PsnNo: his.PsnNo,
  18619. MedType: strconv.FormatInt(reg_type, 10),
  18620. Ctime: time.Now().Unix(),
  18621. Mtime: time.Now().Unix(),
  18622. Status: 1,
  18623. Number: chrg_bchno,
  18624. Infcode: res.Infcode,
  18625. WarnMsg: res.WarnMsg,
  18626. Cainfo: res.Cainfo,
  18627. ErrMsg: res.ErrMsg,
  18628. RespondTime: res.RefmsgTime,
  18629. InfRefmsgid: res.InfRefmsgid,
  18630. OrderStatus: 1,
  18631. PayWay: pay_way,
  18632. PayWays: pay_ways,
  18633. OthDesc: oth_desc,
  18634. PayPrice: pay_price,
  18635. PayCardNo: pay_card_no,
  18636. DiscountPrice: discount_price,
  18637. PreferentialPrice: preferential_price,
  18638. RealityPrice: reality_price,
  18639. FoundPrice: found_price,
  18640. MedicalInsurancePrice: medical_insurance_price,
  18641. PrivatePrice: private_price,
  18642. IsMedicineInsurance: 1,
  18643. SettleType: settle_accounts_type,
  18644. SettleStartTime: start_time,
  18645. SettleEndTime: end_time,
  18646. Creator: roles.AdminUserId,
  18647. Modify: roles.AdminUserId,
  18648. FaPiaoNumber: fapiao_number,
  18649. FaPiaoCode: fapiao_code,
  18650. PType: 2,
  18651. Diagnosis: diagnosis_id,
  18652. CashPay: cash_pay,
  18653. WechatPay: wechat_pay,
  18654. AliPay: ali_pay,
  18655. JifenPay: jifen_pay,
  18656. BandCardPay: band_card_pay,
  18657. }
  18658. err = service.CreateOrder(order)
  18659. if err != nil {
  18660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  18661. return
  18662. }
  18663. for _, item := range res.Output.Result {
  18664. temp := strings.Split(item.FeedetlSn, "-")
  18665. var advice_id int64 = 0
  18666. var project_id int64 = 0
  18667. var types int64 = 0
  18668. id, _ := strconv.ParseInt(temp[2], 10, 64)
  18669. types, _ = strconv.ParseInt(temp[1], 10, 64)
  18670. if temp[1] == "1" {
  18671. advice_id = id
  18672. project_id = 0
  18673. } else if temp[1] == "2" {
  18674. advice_id = 0
  18675. project_id = id
  18676. }
  18677. if item.MedChrgitmType == "9" {
  18678. item.MedChrgitmType = "09"
  18679. }
  18680. info := &models.HisOrderInfo{
  18681. OrderNumber: order.Number,
  18682. FeedetlSn: item.FeedetlSn,
  18683. UploadDate: time.Now().Unix(),
  18684. AdviceId: advice_id,
  18685. DetItemFeeSumamt: item.DetItemFeeSumamt,
  18686. Cnt: item.Cnt,
  18687. Pric: float64(item.Pric),
  18688. PatientId: his.PatientId,
  18689. PricUplmtAmt: item.PricUplmtAmt,
  18690. SelfpayProp: item.SelfpayProp,
  18691. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  18692. OverlmtAmt: item.OverlmtAmt,
  18693. PreselfpayAmt: item.PreselfpayAmt,
  18694. BasMednFlag: item.BasMednFlag,
  18695. MedChrgitmType: item.MedChrgitmType,
  18696. HiNegoDrugFlag: item.HiNegoDrugFlag,
  18697. Status: 1,
  18698. Memo: item.Memo,
  18699. Mtime: time.Now().Unix(),
  18700. InscpScpAmt: item.InscpScpAmt,
  18701. DrtReimFlag: item.DrtReimFlag,
  18702. Ctime: time.Now().Unix(),
  18703. ListSpItemFlag: item.ListSpItemFlag,
  18704. ChldMedcFlag: item.ChldMedcFlag,
  18705. LmtUsedFlag: item.LmtUsedFlag,
  18706. ChrgitmLv: item.ChrgitmLv,
  18707. UserOrgId: adminUser.CurrentOrgId,
  18708. HisPatientId: his.ID,
  18709. OrderId: order.ID,
  18710. ProjectId: project_id,
  18711. Type: types,
  18712. }
  18713. service.CreateOrderInfo(info)
  18714. }
  18715. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  18716. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  18717. var total float64
  18718. for _, item := range prescriptions {
  18719. if item.Type == 1 { //药品
  18720. for _, subItem := range item.HisDoctorAdviceInfo {
  18721. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  18722. total_one := price * subItem.PrescribingNumber
  18723. total = total + total_one
  18724. }
  18725. }
  18726. if item.Type == 2 { //项目
  18727. for _, subItem := range item.HisPrescriptionProject {
  18728. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  18729. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  18730. total_one := price * cnt
  18731. total = total + total_one
  18732. }
  18733. }
  18734. }
  18735. allTotal := fmt.Sprintf("%.2f", total)
  18736. //if adminUser.CurrentOrgId == 9919 {
  18737. //
  18738. // allTotal = fmt.Sprintf("%.2f", total)
  18739. //
  18740. //} else {
  18741. //
  18742. // allTotal = fmt.Sprintf("%.2f", total)
  18743. //
  18744. //}
  18745. if res.Infcode == 0 {
  18746. var rf []*ResultFive
  18747. json.Unmarshal([]byte(his.Iinfo), &rf)
  18748. chrg_bchno := chrg_bchno
  18749. cert_no := his.Certno
  18750. var insutypes []string
  18751. var insutype string
  18752. var is390 int = 0
  18753. var is310 int = 0
  18754. for _, item := range rf {
  18755. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18756. insutypes = append(insutypes, item.Insutype)
  18757. }
  18758. }
  18759. if len(insutypes) == 1 {
  18760. insutype = insutypes[0]
  18761. } else {
  18762. for _, i := range insutypes {
  18763. if i == "390" {
  18764. is390 = 1
  18765. }
  18766. if i == "310" {
  18767. is310 = 1
  18768. }
  18769. }
  18770. }
  18771. if is390 == 1 {
  18772. insutype = "390"
  18773. }
  18774. if is310 == 1 {
  18775. insutype = "310"
  18776. }
  18777. if len(insutypes) == 0 {
  18778. insutype = "310"
  18779. }
  18780. if len(insutypes) == 2 {
  18781. insutype = strconv.FormatInt(his.SocialType, 10)
  18782. }
  18783. insutype = strconv.FormatInt(his.SocialType, 10)
  18784. //insutype = "390"
  18785. if his.IdCardType == 1 {
  18786. // cert_no = his.MedicalInsuranceNumber
  18787. cert_no = his.Certno
  18788. } else {
  18789. cert_no = his.Certno
  18790. }
  18791. var res ResultSeven
  18792. var resSeven10265 ResultSeven10265
  18793. var gzresSeven10265Two GZResultSeven10265Two
  18794. var src_resquest string
  18795. var result2 string
  18796. if miConfig.MdtrtareaAdmvs == "421300" {
  18797. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18798. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18799. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18800. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18801. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18802. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18803. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18804. resp, requestErr := http.Get(api)
  18805. if requestErr != nil {
  18806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18807. return
  18808. }
  18809. body, ioErr := ioutil.ReadAll(resp.Body)
  18810. if ioErr != nil {
  18811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18813. return
  18814. }
  18815. var respJSON map[string]interface{}
  18816. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18819. return
  18820. }
  18821. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18822. result, _ := json.Marshal(respJSON)
  18823. if miConfig.Code == "H15049901371" {
  18824. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18825. utils.ErrorLog("解析失败:%v", err)
  18826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18827. return
  18828. }
  18829. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18830. res.Output = resSeven10265.Output
  18831. res.ErrMsg = resSeven10265.ErrMsg
  18832. res.Cainfo = resSeven10265.Cainfo
  18833. res.WarnMsg = resSeven10265.WarnMsg
  18834. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18835. res.Infcode = infocode
  18836. } else {
  18837. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18838. utils.ErrorLog("解析失败:%v", err)
  18839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18840. return
  18841. }
  18842. }
  18843. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18844. if reg_type == 11 && his.Insutype == "390" {
  18845. reg_type = 110104
  18846. }
  18847. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18848. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18849. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18850. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18851. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18852. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18853. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18854. resp, requestErr := http.Get(api)
  18855. if requestErr != nil {
  18856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18857. return
  18858. }
  18859. body, ioErr := ioutil.ReadAll(resp.Body)
  18860. if ioErr != nil {
  18861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18863. return
  18864. }
  18865. var respJSON map[string]interface{}
  18866. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18869. return
  18870. }
  18871. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18872. result, _ := json.Marshal(respJSON)
  18873. if miConfig.Code == "H15049901371" {
  18874. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18875. utils.ErrorLog("解析失败:%v", err)
  18876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18877. return
  18878. }
  18879. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18880. res.Output = resSeven10265.Output
  18881. res.ErrMsg = resSeven10265.ErrMsg
  18882. res.Cainfo = resSeven10265.Cainfo
  18883. res.WarnMsg = resSeven10265.WarnMsg
  18884. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18885. res.Infcode = infocode
  18886. } else {
  18887. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18888. utils.ErrorLog("解析失败:%v", err)
  18889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18890. return
  18891. }
  18892. }
  18893. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18894. if reg_type == 11 && his.Insutype == "390" {
  18895. reg_type = 110104
  18896. }
  18897. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18898. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18899. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18900. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18901. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18902. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18903. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18904. resp, requestErr := http.Get(api)
  18905. if requestErr != nil {
  18906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18907. return
  18908. }
  18909. body, ioErr := ioutil.ReadAll(resp.Body)
  18910. if ioErr != nil {
  18911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18913. return
  18914. }
  18915. var respJSON map[string]interface{}
  18916. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18919. return
  18920. }
  18921. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18922. result, _ := json.Marshal(respJSON)
  18923. if miConfig.Code == "H15049901371" {
  18924. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18925. utils.ErrorLog("解析失败:%v", err)
  18926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18927. return
  18928. }
  18929. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18930. res.Output = resSeven10265.Output
  18931. res.ErrMsg = resSeven10265.ErrMsg
  18932. res.Cainfo = resSeven10265.Cainfo
  18933. res.WarnMsg = resSeven10265.WarnMsg
  18934. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18935. res.Infcode = infocode
  18936. } else {
  18937. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18938. utils.ErrorLog("解析失败:%v", err)
  18939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18940. return
  18941. }
  18942. }
  18943. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18944. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  18945. if result3101.Infcode == "0" {
  18946. if len(result3101.Output.Result) > 0 {
  18947. var errMsgs []string
  18948. for _, item := range result3101.Output.Result {
  18949. errMsgs = append(errMsgs, item.VolaCont)
  18950. }
  18951. c.ServeSuccessJSON(map[string]interface{}{
  18952. "failed_code": -10,
  18953. "msg": errMsgs,
  18954. })
  18955. return
  18956. } else {
  18957. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18958. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  18959. bas := strings.Split(psn_info.CardInfo, "|")
  18960. if his.IdCardType == 1 {
  18961. cert_no = bas[2]
  18962. } else if his.IdCardType == 3 {
  18963. cert_no = his.Certno
  18964. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  18965. } else if his.IdCardType == 4 {
  18966. cert_no = his.Certno
  18967. psn_info.VerifyNumber = psn_info.VerifyNumber
  18968. }
  18969. var api string
  18970. if miConfig.MdtrtareaAdmvs == "320921" {
  18971. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18972. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18973. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18974. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18975. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18976. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18977. "&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
  18978. } else {
  18979. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18980. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18981. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18982. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18983. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18984. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18985. "&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
  18986. }
  18987. resp, requestErr := http.Get(api)
  18988. if requestErr != nil {
  18989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18990. return
  18991. }
  18992. body, ioErr := ioutil.ReadAll(resp.Body)
  18993. if ioErr != nil {
  18994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18996. return
  18997. }
  18998. var respJSON map[string]interface{}
  18999. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19002. return
  19003. }
  19004. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19005. result, _ := json.Marshal(respJSON)
  19006. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19007. utils.ErrorLog("解析失败:%v", err)
  19008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19009. return
  19010. }
  19011. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19012. res.Output = resSeven10265.Output
  19013. res.ErrMsg = resSeven10265.ErrMsg
  19014. res.Cainfo = resSeven10265.Cainfo
  19015. res.WarnMsg = resSeven10265.WarnMsg
  19016. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19017. res.Infcode = infocode
  19018. }
  19019. }
  19020. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19021. psn_info, _ := service.GetPsnByPatientId(id)
  19022. var verify_number string
  19023. if psn_info.IdCardType == 4 {
  19024. verify_number = psn_info.VerifyNumber
  19025. } else if psn_info.IdCardType == 1 {
  19026. bas := strings.Split(psn_info.CardInfo, "|")
  19027. cardNumber := bas[2]
  19028. verify_number = cardNumber
  19029. } else {
  19030. psn_info.IdCardType = 2
  19031. verify_number = psn_info.Certno
  19032. }
  19033. var api string
  19034. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19035. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19036. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19037. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19038. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19039. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19040. "&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
  19041. resp, requestErr := http.Get(api)
  19042. if requestErr != nil {
  19043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19044. return
  19045. }
  19046. body, ioErr := ioutil.ReadAll(resp.Body)
  19047. if ioErr != nil {
  19048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19050. return
  19051. }
  19052. var respJSON map[string]interface{}
  19053. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19056. return
  19057. }
  19058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19059. result, _ := json.Marshal(respJSON)
  19060. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19061. utils.ErrorLog("解析失败:%v", err)
  19062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19063. return
  19064. }
  19065. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19066. res.Output = resSeven10265.Output
  19067. res.ErrMsg = resSeven10265.ErrMsg
  19068. res.Cainfo = resSeven10265.Cainfo
  19069. res.WarnMsg = resSeven10265.WarnMsg
  19070. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19071. res.Infcode = infocode
  19072. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19073. var cert_no string
  19074. if his.IdCardType == 4 {
  19075. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19076. cert_no = psn_info.VerifyNumber
  19077. 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)
  19078. } else if his.IdCardType == 1 {
  19079. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19080. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19081. 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)
  19082. }
  19083. //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)
  19084. var dat map[string]interface{}
  19085. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19086. fmt.Println(dat)
  19087. } else {
  19088. fmt.Println(err)
  19089. }
  19090. saveLog(result2, src_resquest, "2207", "结算")
  19091. userJSONBytes, _ := json.Marshal(dat)
  19092. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19093. utils.ErrorLog("解析失败:%v", err)
  19094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19095. return
  19096. }
  19097. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19098. res.Output = resSeven10265.Output
  19099. res.ErrMsg = resSeven10265.ErrMsg
  19100. res.Cainfo = resSeven10265.Cainfo
  19101. res.WarnMsg = resSeven10265.WarnMsg
  19102. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19103. res.Infcode = infocode
  19104. } else if miConfig.MdtrtareaAdmvs == "450721" {
  19105. res2 := c.GetoleInfo()
  19106. if res2.Infcode == 0 {
  19107. var result string
  19108. var request_log string
  19109. var result_log string
  19110. if res2.Output.MdtrtCertType == "02" {
  19111. 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)
  19112. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19113. } else if res2.Output.MdtrtCertType == "01" {
  19114. 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)
  19115. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19116. } else {
  19117. 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)
  19118. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19119. }
  19120. var dat map[string]interface{}
  19121. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19122. fmt.Println(dat)
  19123. } else {
  19124. fmt.Println(err)
  19125. }
  19126. userJSONBytes, _ := json.Marshal(dat)
  19127. var res5 ResultTwo
  19128. //var resTwo10265 ResultTwo10265
  19129. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  19130. utils.ErrorLog("解析失败:%v", err)
  19131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19132. return
  19133. }
  19134. if res5.Infcode == -1 {
  19135. c.ServeSuccessJSON(map[string]interface{}{
  19136. "failed_code": -10,
  19137. "msg": res5.ErrMsg,
  19138. })
  19139. return
  19140. }
  19141. var insutypes []string
  19142. var insutype string
  19143. var is390 int = 0
  19144. var is310 int = 0
  19145. for _, item := range res5.Output.Iinfo {
  19146. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19147. insutypes = append(insutypes, item.Insutype)
  19148. }
  19149. }
  19150. if len(insutypes) == 1 {
  19151. insutype = insutypes[0]
  19152. } else {
  19153. for _, i := range insutypes {
  19154. if i == "390" {
  19155. is390 = 1
  19156. }
  19157. if i == "310" {
  19158. is310 = 1
  19159. }
  19160. }
  19161. }
  19162. if is390 == 1 {
  19163. insutype = "390"
  19164. }
  19165. if is310 == 1 {
  19166. insutype = "310"
  19167. }
  19168. if len(insutypes) == 0 {
  19169. insutype = "310"
  19170. }
  19171. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  19172. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  19173. infoStr := string(Iinfos)
  19174. idetinfoStr := string(Idetinfos)
  19175. psn := &models.HisPsn{
  19176. PsnNo: res5.Output.Baseinfo.PsnNo,
  19177. PatientId: id,
  19178. Certno: res5.Output.Baseinfo.Certno,
  19179. Gend: res5.Output.Baseinfo.Gend,
  19180. Naty: res5.Output.Baseinfo.Naty,
  19181. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  19182. PsnName: res5.Output.Baseinfo.PsnName,
  19183. Idetinfo: idetinfoStr,
  19184. Insuinfo: infoStr,
  19185. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  19186. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19187. VerifyNumber: res2.Output.EcToken,
  19188. }
  19189. if res2.Output.MdtrtCertType == "01" {
  19190. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19191. psn.VerifyNumber = res2.Output.EcToken
  19192. } else if res2.Output.MdtrtCertType == "02" {
  19193. psn.VerifyNumber = res2.Output.CardNo
  19194. } else {
  19195. psn.VerifyNumber = res2.Output.MdtrtCertNo
  19196. }
  19197. service.CreateHisPsn(psn)
  19198. if res2.Output.MdtrtCertType == "01" {
  19199. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19200. token := res2.Output.EcToken
  19201. 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)
  19202. } else if res2.Output.MdtrtCertType == "02" {
  19203. 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)
  19204. } else {
  19205. 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)
  19206. }
  19207. var dat2 map[string]interface{}
  19208. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  19209. fmt.Println(dat2)
  19210. } else {
  19211. fmt.Println(err)
  19212. }
  19213. userJSONBytes3, _ := json.Marshal(dat2)
  19214. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  19215. utils.ErrorLog("解析失败:%v", err)
  19216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19217. return
  19218. }
  19219. saveLog(result2, src_resquest, "2207", "结算")
  19220. } else {
  19221. c.ServeSuccessJSON(map[string]interface{}{
  19222. "failed_code": -10,
  19223. "msg": res2.ErrMsg,
  19224. })
  19225. return
  19226. }
  19227. } else {
  19228. if miConfig.Code == "H15049901371" {
  19229. //赤峰地区国家医保医疗类别
  19230. //职工透析:医疗类别选特殊情况门诊990502
  19231. //居民定额血透门慢: 医疗类别选门诊慢病140104
  19232. var med_type string
  19233. if his.Insutype == "390" {
  19234. if reg_type == 14 {
  19235. med_type = "9933"
  19236. } else if reg_type == 11 {
  19237. med_type = "11"
  19238. }
  19239. } else if his.Insutype == "310" {
  19240. if reg_type == 14 {
  19241. med_type = "990502"
  19242. } else if reg_type == 11 {
  19243. med_type = "11"
  19244. }
  19245. }
  19246. 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)
  19247. } else {
  19248. if his.IdCardType == 4 {
  19249. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19250. var token string
  19251. token = psn_info.VerifyNumber
  19252. 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)
  19253. } else {
  19254. if his.IdCardType == 1 {
  19255. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19256. bas := strings.Split(psn_info.CardInfo, "|")
  19257. basNumber := bas[2]
  19258. cert_no = basNumber
  19259. }
  19260. 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)
  19261. }
  19262. }
  19263. //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)
  19264. var dat map[string]interface{}
  19265. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19266. fmt.Println(dat)
  19267. } else {
  19268. fmt.Println(err)
  19269. }
  19270. saveLog(result2, src_resquest, "2207", "结算")
  19271. userJSONBytes, _ := json.Marshal(dat)
  19272. if miConfig.Code == "H15049901371" {
  19273. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19274. utils.ErrorLog("解析失败:%v", err)
  19275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19276. return
  19277. }
  19278. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19279. res.Output = resSeven10265.Output
  19280. res.ErrMsg = resSeven10265.ErrMsg
  19281. res.Cainfo = resSeven10265.Cainfo
  19282. res.WarnMsg = resSeven10265.WarnMsg
  19283. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19284. res.Infcode = infocode
  19285. } else {
  19286. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  19287. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  19288. utils.ErrorLog("解析失败:%v", err)
  19289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19290. return
  19291. }
  19292. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  19293. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  19294. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  19295. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19296. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  19297. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  19298. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  19299. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  19300. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  19301. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19302. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19303. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19304. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19305. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19306. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  19307. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  19308. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  19309. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  19310. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  19311. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  19312. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  19313. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  19314. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  19315. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  19316. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  19317. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  19318. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  19319. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  19320. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  19321. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  19322. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  19323. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  19324. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  19325. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  19326. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  19327. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  19328. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  19329. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  19330. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19331. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  19332. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  19333. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  19334. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  19335. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  19336. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  19337. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  19338. res.ErrMsg = gzresSeven10265Two.ErrMsg
  19339. res.Cainfo = gzresSeven10265Two.Cainfo
  19340. res.WarnMsg = gzresSeven10265Two.WarnMsg
  19341. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  19342. //res.Infcode = infocode
  19343. } else {
  19344. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19345. utils.ErrorLog("解析失败:%v", err)
  19346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19347. return
  19348. }
  19349. }
  19350. }
  19351. }
  19352. if res.Infcode == -1 {
  19353. errlog := &models.HisOrderError{
  19354. UserOrgId: adminUser.CurrentOrgId,
  19355. Ctime: time.Now().Unix(),
  19356. Mtime: time.Now().Unix(),
  19357. Number: chrg_bchno,
  19358. ErrMsg: res.ErrMsg,
  19359. Status: 1,
  19360. PatientId: id,
  19361. RecordTime: recordDateTime,
  19362. Stage: 6,
  19363. }
  19364. service.CreateErrMsgLog(errlog)
  19365. c.ServeSuccessJSON(map[string]interface{}{
  19366. "failed_code": -10,
  19367. "msg": res.ErrMsg,
  19368. })
  19369. return
  19370. } else {
  19371. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  19372. order.OrderStatus = 2
  19373. order.Status = 1
  19374. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  19375. order.SetlId = res.Output.Setlinfo.SetlID
  19376. order.PsnNo = res.Output.Setlinfo.PsnNo
  19377. order.PsnName = res.Output.Setlinfo.PsnName
  19378. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  19379. order.Certno = res.Output.Setlinfo.Certno
  19380. order.Gend = res.Output.Setlinfo.Gend
  19381. order.Naty = res.Output.Setlinfo.Naty
  19382. order.Age = res.Output.Setlinfo.Age
  19383. order.Insutype = res.Output.Setlinfo.Insutype
  19384. order.PsnType = res.Output.Setlinfo.PsnType
  19385. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  19386. order.SetlTime = res.Output.Setlinfo.SetlTime
  19387. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  19388. if res.Output.Setlinfo.MedType == "140101" {
  19389. order.MedType = "14"
  19390. } else {
  19391. if res.Output.Setlinfo.MedType == "110104" {
  19392. order.MedType = "11"
  19393. } else {
  19394. order.MedType = res.Output.Setlinfo.MedType
  19395. }
  19396. }
  19397. if reg_type == 1112 {
  19398. order.MedType = "1112"
  19399. }
  19400. if reg_type == 1111 {
  19401. order.MedType = "1111"
  19402. }
  19403. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  19404. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  19405. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  19406. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  19407. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  19408. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  19409. order.HifpPay = res.Output.Setlinfo.HifpPay
  19410. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  19411. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  19412. order.HifesPay = res.Output.Setlinfo.HifesPay
  19413. order.HifobPay = res.Output.Setlinfo.HifobPay
  19414. order.MafPay = res.Output.Setlinfo.MafPay
  19415. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  19416. order.OthPay = res.Output.Setlinfo.OthPay
  19417. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  19418. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  19419. order.AcctPay = res.Output.Setlinfo.AcctPay
  19420. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  19421. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  19422. order.Balc = res.Output.Setlinfo.Balc
  19423. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  19424. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  19425. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  19426. order.ClrType = res.Output.Setlinfo.ClrType
  19427. order.ClrWay = res.Output.Setlinfo.ClrWay
  19428. order.Creator = order.Creator
  19429. order.Modify = roles.AdminUserId
  19430. order.RequestLog = src_resquest
  19431. order.FaPiaoNumber = fapiao_number
  19432. order.FaPiaoCode = fapiao_code
  19433. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  19434. //detailStr := string(setlDetail)
  19435. //order.SetlDetail = detailStr
  19436. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  19437. err = service.UpDateOrder(order)
  19438. if err == nil {
  19439. //判断是否使用了押金
  19440. if dec_way == "true" {
  19441. tmpstring := strconv.FormatInt(order.ID, 10)
  19442. order.Decimal = decimal
  19443. service.UpDateOrder(order)
  19444. //扣押金
  19445. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  19446. if errmsg != nil {
  19447. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  19448. return
  19449. }
  19450. }
  19451. c.ServeSuccessJSON(map[string]interface{}{
  19452. "msg": "结算成功",
  19453. })
  19454. } else {
  19455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  19456. return
  19457. }
  19458. }
  19459. } else {
  19460. adminUser := c.GetAdminUserInfo()
  19461. errlog := &models.HisOrderError{
  19462. UserOrgId: adminUser.CurrentOrgId,
  19463. Ctime: time.Now().Unix(),
  19464. Mtime: time.Now().Unix(),
  19465. ErrMsg: res.ErrMsg,
  19466. Status: 1,
  19467. PatientId: id,
  19468. RecordTime: recordDateTime,
  19469. Stage: 4,
  19470. }
  19471. service.CreateErrMsgLog(errlog)
  19472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  19473. return
  19474. }
  19475. } else {
  19476. adminUser := c.GetAdminUserInfo()
  19477. errlog := &models.HisOrderError{
  19478. UserOrgId: adminUser.CurrentOrgId,
  19479. Ctime: time.Now().Unix(),
  19480. Mtime: time.Now().Unix(),
  19481. ErrMsg: res.ErrMsg,
  19482. Status: 1,
  19483. PatientId: id,
  19484. RecordTime: recordDateTime,
  19485. Stage: 4,
  19486. }
  19487. service.CreateErrMsgLog(errlog)
  19488. c.ServeSuccessJSON(map[string]interface{}{
  19489. "failed_code": -10,
  19490. "msg": res.ErrMsg,
  19491. })
  19492. return
  19493. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  19494. //return
  19495. }
  19496. }
  19497. }
  19498. } else if tempOrder.ID > 0 {
  19499. if tempOrder.IsPre == 1 {
  19500. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  19501. var rf []*ResultFive
  19502. json.Unmarshal([]byte(his.Iinfo), &rf)
  19503. chrg_bchno := tempOrder.Number
  19504. cert_no := his.Certno
  19505. var insutypes []string
  19506. var insutype string
  19507. var is390 int = 0
  19508. var is310 int = 0
  19509. for _, item := range rf {
  19510. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19511. insutypes = append(insutypes, item.Insutype)
  19512. }
  19513. }
  19514. if len(insutypes) == 1 {
  19515. insutype = insutypes[0]
  19516. } else {
  19517. for _, i := range insutypes {
  19518. if i == "390" {
  19519. is390 = 1
  19520. }
  19521. if i == "310" {
  19522. is310 = 1
  19523. }
  19524. }
  19525. }
  19526. if is390 == 1 {
  19527. insutype = "390"
  19528. }
  19529. if is310 == 1 {
  19530. insutype = "310"
  19531. }
  19532. if len(insutypes) == 0 {
  19533. insutype = "310"
  19534. }
  19535. if len(insutypes) == 2 {
  19536. insutype = strconv.FormatInt(his.SocialType, 10)
  19537. }
  19538. //insutype = "390"
  19539. if his.IdCardType == 1 {
  19540. // cert_no = his.MedicalInsuranceNumber
  19541. cert_no = his.Certno
  19542. } else {
  19543. cert_no = his.Certno
  19544. }
  19545. var res ResultSeven
  19546. var ahres ResultSevenAH
  19547. var resSeven10265 ResultSeven10265
  19548. var gzresSeven10265Two GZResultSeven10265Two
  19549. var src_resquest string
  19550. var result2 string
  19551. if miConfig.MdtrtareaAdmvs == "450721" {
  19552. res2 := c.GetoleInfo()
  19553. if res2.Infcode == 0 {
  19554. var result string
  19555. var request_log string
  19556. var result_log string
  19557. if res2.Output.MdtrtCertType == "02" {
  19558. 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)
  19559. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19560. } else if res2.Output.MdtrtCertType == "01" {
  19561. 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)
  19562. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19563. } else {
  19564. 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)
  19565. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19566. }
  19567. var dat map[string]interface{}
  19568. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19569. fmt.Println(dat)
  19570. } else {
  19571. fmt.Println(err)
  19572. }
  19573. userJSONBytes, _ := json.Marshal(dat)
  19574. var res5 ResultTwo
  19575. //var resTwo10265 ResultTwo10265
  19576. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  19577. utils.ErrorLog("解析失败:%v", err)
  19578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19579. return
  19580. }
  19581. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  19582. if res5.Infcode == -1 {
  19583. c.ServeSuccessJSON(map[string]interface{}{
  19584. "failed_code": -10,
  19585. "msg": res5.ErrMsg,
  19586. })
  19587. return
  19588. }
  19589. var insutypes []string
  19590. var insutype string
  19591. var is390 int = 0
  19592. var is310 int = 0
  19593. for _, item := range res5.Output.Iinfo {
  19594. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19595. insutypes = append(insutypes, item.Insutype)
  19596. }
  19597. }
  19598. if len(insutypes) == 1 {
  19599. insutype = insutypes[0]
  19600. } else {
  19601. for _, i := range insutypes {
  19602. if i == "390" {
  19603. is390 = 1
  19604. }
  19605. if i == "310" {
  19606. is310 = 1
  19607. }
  19608. }
  19609. }
  19610. if is390 == 1 {
  19611. insutype = "390"
  19612. }
  19613. if is310 == 1 {
  19614. insutype = "310"
  19615. }
  19616. if len(insutypes) == 0 {
  19617. insutype = "310"
  19618. }
  19619. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  19620. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  19621. infoStr := string(Iinfos)
  19622. idetinfoStr := string(Idetinfos)
  19623. psn := &models.HisPsn{
  19624. PsnNo: res5.Output.Baseinfo.PsnNo,
  19625. PatientId: id,
  19626. Certno: res5.Output.Baseinfo.Certno,
  19627. Gend: res5.Output.Baseinfo.Gend,
  19628. Naty: res5.Output.Baseinfo.Naty,
  19629. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  19630. PsnName: res5.Output.Baseinfo.PsnName,
  19631. Idetinfo: idetinfoStr,
  19632. Insuinfo: infoStr,
  19633. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  19634. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19635. VerifyNumber: res2.Output.EcToken,
  19636. }
  19637. service.CreateHisPsn(psn)
  19638. if res2.Output.MdtrtCertType == "01" {
  19639. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19640. token := res2.Output.EcToken
  19641. 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)
  19642. } else if res2.Output.MdtrtCertType == "02" {
  19643. 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)
  19644. } else {
  19645. 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)
  19646. }
  19647. var dat2 map[string]interface{}
  19648. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  19649. fmt.Println(dat2)
  19650. } else {
  19651. fmt.Println(err)
  19652. }
  19653. userJSONBytes3, _ := json.Marshal(dat2)
  19654. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  19655. utils.ErrorLog("解析失败:%v", err)
  19656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19657. return
  19658. }
  19659. saveLog(result2, src_resquest, "2207", "结算")
  19660. } else {
  19661. c.ServeSuccessJSON(map[string]interface{}{
  19662. "failed_code": -10,
  19663. "msg": res2.ErrMsg,
  19664. })
  19665. return
  19666. }
  19667. } else if miConfig.MdtrtareaAdmvs == "421300" {
  19668. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19669. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19670. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19671. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19672. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19673. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19674. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19675. resp, requestErr := http.Get(api)
  19676. if requestErr != nil {
  19677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19678. return
  19679. }
  19680. body, ioErr := ioutil.ReadAll(resp.Body)
  19681. if ioErr != nil {
  19682. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19684. return
  19685. }
  19686. var respJSON map[string]interface{}
  19687. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19690. return
  19691. }
  19692. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19693. result, _ := json.Marshal(respJSON)
  19694. fmt.Println("log")
  19695. fmt.Println(string(result))
  19696. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19697. utils.ErrorLog("解析失败:%v", err)
  19698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19699. return
  19700. }
  19701. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19702. if reg_type == 11 && his.Insutype == "390" {
  19703. reg_type = 110104
  19704. }
  19705. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19706. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19707. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19708. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19709. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19710. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19711. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19712. resp, requestErr := http.Get(api)
  19713. if requestErr != nil {
  19714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19715. return
  19716. }
  19717. body, ioErr := ioutil.ReadAll(resp.Body)
  19718. if ioErr != nil {
  19719. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19721. return
  19722. }
  19723. var respJSON map[string]interface{}
  19724. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19727. return
  19728. }
  19729. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19730. result, _ := json.Marshal(respJSON)
  19731. fmt.Println("log")
  19732. fmt.Println(string(result))
  19733. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19734. utils.ErrorLog("解析失败:%v", err)
  19735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19736. return
  19737. }
  19738. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19739. if reg_type == 11 && his.Insutype == "390" {
  19740. reg_type = 110104
  19741. }
  19742. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19743. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19744. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19745. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19746. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19747. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19748. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19749. resp, requestErr := http.Get(api)
  19750. if requestErr != nil {
  19751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19752. return
  19753. }
  19754. body, ioErr := ioutil.ReadAll(resp.Body)
  19755. if ioErr != nil {
  19756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19758. return
  19759. }
  19760. var respJSON map[string]interface{}
  19761. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19764. return
  19765. }
  19766. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19767. result, _ := json.Marshal(respJSON)
  19768. fmt.Println("log")
  19769. fmt.Println(string(result))
  19770. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19771. utils.ErrorLog("解析失败:%v", err)
  19772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19773. return
  19774. }
  19775. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19776. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  19777. if result3101.Infcode == "0" {
  19778. if len(result3101.Output.Result) > 0 {
  19779. var errMsgs []string
  19780. for _, item := range result3101.Output.Result {
  19781. errMsgs = append(errMsgs, item.VolaCont)
  19782. }
  19783. c.ServeSuccessJSON(map[string]interface{}{
  19784. "failed_code": -10,
  19785. "msg": errMsgs,
  19786. })
  19787. return
  19788. } else {
  19789. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19790. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19791. bas := strings.Split(psn_info.CardInfo, "|")
  19792. if his.IdCardType == 1 {
  19793. cert_no = bas[2]
  19794. } else if his.IdCardType == 3 {
  19795. cert_no = his.Certno
  19796. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19797. } else if his.IdCardType == 4 {
  19798. cert_no = his.Certno
  19799. psn_info.VerifyNumber = psn_info.VerifyNumber
  19800. }
  19801. //江苏地区国家医保医疗类别
  19802. //职工透析:医疗类别选特殊情况门诊9933
  19803. //居民血透门慢: 医疗类别选门诊慢病1402
  19804. //var med_type string
  19805. //if his.Insutype == "310" {
  19806. // if reg_type == 14 {
  19807. // med_type = "9933"
  19808. // } else if reg_type == 11 {
  19809. // med_type = "11"
  19810. //
  19811. // }
  19812. //} else if his.Insutype == "390" {
  19813. // if reg_type == 14 {
  19814. // med_type = "1402"
  19815. // } else if reg_type == 11 {
  19816. // med_type = "11"
  19817. // }
  19818. //}
  19819. var api string
  19820. if miConfig.MdtrtareaAdmvs == "320921" {
  19821. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19822. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19823. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19824. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19825. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19826. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19827. "&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
  19828. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19829. } else {
  19830. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19831. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19832. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19833. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19834. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19835. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19836. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19837. "&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
  19838. }
  19839. resp, requestErr := http.Get(api)
  19840. if requestErr != nil {
  19841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19842. return
  19843. }
  19844. body, ioErr := ioutil.ReadAll(resp.Body)
  19845. if ioErr != nil {
  19846. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19848. return
  19849. }
  19850. var respJSON map[string]interface{}
  19851. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19854. return
  19855. }
  19856. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19857. result, _ := json.Marshal(respJSON)
  19858. fmt.Println("log")
  19859. fmt.Println(string(result))
  19860. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19861. utils.ErrorLog("解析失败:%v", err)
  19862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19863. return
  19864. }
  19865. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19866. res.Output = resSeven10265.Output
  19867. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19868. res.ErrMsg = resSeven10265.ErrMsg
  19869. res.Cainfo = resSeven10265.Cainfo
  19870. res.WarnMsg = resSeven10265.WarnMsg
  19871. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19872. res.Infcode = infocode
  19873. }
  19874. }
  19875. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19876. psn_info, _ := service.GetPsnByPatientId(id)
  19877. var verify_number string
  19878. if psn_info.IdCardType == 4 {
  19879. verify_number = psn_info.VerifyNumber
  19880. } else if psn_info.IdCardType == 1 {
  19881. bas := strings.Split(psn_info.CardInfo, "|")
  19882. cardNumber := bas[2]
  19883. verify_number = cardNumber
  19884. } else {
  19885. verify_number = psn_info.Certno
  19886. psn_info.IdCardType = 2
  19887. }
  19888. var api string
  19889. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19890. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19891. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19892. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19893. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  19894. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19895. "&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
  19896. resp, requestErr := http.Get(api)
  19897. if requestErr != nil {
  19898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19899. return
  19900. }
  19901. body, ioErr := ioutil.ReadAll(resp.Body)
  19902. if ioErr != nil {
  19903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19905. return
  19906. }
  19907. var respJSON map[string]interface{}
  19908. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19911. return
  19912. }
  19913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19914. result, _ := json.Marshal(respJSON)
  19915. fmt.Println("log")
  19916. fmt.Println(string(result))
  19917. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19918. utils.ErrorLog("解析失败:%v", err)
  19919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19920. return
  19921. }
  19922. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19923. res.Output = resSeven10265.Output
  19924. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19925. res.ErrMsg = resSeven10265.ErrMsg
  19926. res.Cainfo = resSeven10265.Cainfo
  19927. res.WarnMsg = resSeven10265.WarnMsg
  19928. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19929. res.Infcode = infocode
  19930. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19931. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19932. var cert_no string
  19933. if his.IdCardType == 1 {
  19934. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19935. } else {
  19936. cert_no = psn_info.VerifyNumber
  19937. }
  19938. 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)
  19939. var dat map[string]interface{}
  19940. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19941. fmt.Println(dat)
  19942. } else {
  19943. fmt.Println(err)
  19944. }
  19945. saveLog(result2, src_resquest, "2207", "结算")
  19946. userJSONBytes, _ := json.Marshal(dat)
  19947. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19948. utils.ErrorLog("解析失败:%v", err)
  19949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19950. return
  19951. }
  19952. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19953. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19954. var cert_no string
  19955. var card_sn string
  19956. if his.IdCardType == 1 {
  19957. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19958. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19959. bas := strings.Split(psn_info.CardInfo, "|")
  19960. card_sn = bas[3]
  19961. } else if his.IdCardType == 2 {
  19962. cert_no = his.IdCardNo
  19963. } else {
  19964. cert_no = psn_info.VerifyNumber
  19965. }
  19966. var rf []*ResultFive
  19967. json.Unmarshal([]byte(his.Iinfo), &rf)
  19968. var psn_type string
  19969. for _, item := range rf {
  19970. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  19971. psn_type = item.PsnType
  19972. }
  19973. }
  19974. 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)
  19975. var dat map[string]interface{}
  19976. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19977. fmt.Println(dat)
  19978. } else {
  19979. fmt.Println(err)
  19980. }
  19981. saveLog(result2, src_resquest, "2207", "结算")
  19982. userJSONBytes, _ := json.Marshal(dat)
  19983. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19984. utils.ErrorLog("解析失败:%v", err)
  19985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19986. return
  19987. }
  19988. } else if miConfig.MdtrtareaAdmvs == "341203" {
  19989. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19990. if his.IdCardType == 1 {
  19991. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19992. bas := strings.Split(psn_info.CardInfo, "|")
  19993. cert_no = bas[2]
  19994. } else if his.IdCardType == 3 {
  19995. cert_no = his.Certno
  19996. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19997. } else if his.IdCardType == 4 {
  19998. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19999. cert_no = his.Certno
  20000. psn_info.VerifyNumber = psn_info.VerifyNumber
  20001. } else {
  20002. cert_no = his.Certno
  20003. psn_info.VerifyNumber = his.Certno
  20004. }
  20005. var api string
  20006. var med_type string
  20007. if his.Insutype == "390" {
  20008. if reg_type == 992102 {
  20009. med_type = "992102"
  20010. }
  20011. if reg_type == 140104 {
  20012. med_type = "140104"
  20013. }
  20014. if reg_type == 14 {
  20015. med_type = "14"
  20016. }
  20017. } else if his.Insutype == "310" {
  20018. if reg_type == 992102 {
  20019. med_type = "992102"
  20020. }
  20021. if reg_type == 14 {
  20022. med_type = "14"
  20023. }
  20024. }
  20025. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20026. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20027. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20028. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20029. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20030. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20031. "&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
  20032. resp, requestErr := http.Get(api)
  20033. if requestErr != nil {
  20034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20035. return
  20036. }
  20037. body, ioErr := ioutil.ReadAll(resp.Body)
  20038. if ioErr != nil {
  20039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20041. return
  20042. }
  20043. var respJSON map[string]interface{}
  20044. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20047. return
  20048. }
  20049. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20050. if status == "0" {
  20051. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20052. c.ServeSuccessJSON(map[string]interface{}{
  20053. "failed_code": -10,
  20054. "msg": err_msg,
  20055. })
  20056. return
  20057. }
  20058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20059. result, _ := json.Marshal(respJSON)
  20060. fmt.Println("log")
  20061. fmt.Println(string(result))
  20062. if err := json.Unmarshal(result, &ahres); err != nil {
  20063. utils.ErrorLog("解析失败:%v", err)
  20064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20065. return
  20066. }
  20067. res.InfRefmsgid = ahres.InfRefmsgid
  20068. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  20069. // 创建对应的Time类型
  20070. t := time.UnixMilli(timestamp)
  20071. // 格式化成指定的日期字符串
  20072. str := t.Format("2006-01-02 15:04:05")
  20073. res.Output.Setlinfo.SetlTime = str
  20074. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  20075. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  20076. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20077. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  20078. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  20079. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  20080. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20081. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  20082. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  20083. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  20084. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  20085. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  20086. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20087. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  20088. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  20089. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  20090. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  20091. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  20092. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  20093. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20094. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  20095. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  20096. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  20097. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  20098. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  20099. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  20100. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  20101. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  20102. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  20103. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  20104. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  20105. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  20106. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  20107. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  20108. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  20109. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  20110. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  20111. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  20112. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  20113. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  20114. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  20115. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  20116. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  20117. res.Output.Setldetail = ahres.Output.Setldetail
  20118. res.ErrMsg = ahres.ErrMsg
  20119. res.Cainfo = ahres.Cainfo
  20120. res.WarnMsg = ahres.WarnMsg
  20121. res.Infcode = ahres.Infcode
  20122. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20123. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20124. var cert_no string
  20125. if his.IdCardType == 1 {
  20126. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20127. } else if his.IdCardType == 2 {
  20128. cert_no = his.IdCardNo
  20129. } else {
  20130. cert_no = psn_info.VerifyNumber
  20131. }
  20132. 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, "")
  20133. var dat map[string]interface{}
  20134. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20135. fmt.Println(dat)
  20136. } else {
  20137. fmt.Println(err)
  20138. }
  20139. saveLog(result2, src_resquest, "2207", "结算")
  20140. userJSONBytes, _ := json.Marshal(dat)
  20141. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20142. utils.ErrorLog("解析失败:%v", err)
  20143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20144. return
  20145. }
  20146. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20147. psn_info, _ := service.GetPsnByPatientId(id)
  20148. var verify_number string
  20149. if psn_info.IdCardType == 4 {
  20150. verify_number = psn_info.VerifyNumber
  20151. } else if psn_info.IdCardType == 1 {
  20152. bas := strings.Split(psn_info.CardInfo, "|")
  20153. cardNumber := bas[2]
  20154. verify_number = cardNumber
  20155. } else {
  20156. verify_number = psn_info.Certno
  20157. psn_info.IdCardType = 2
  20158. }
  20159. var api string
  20160. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20161. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20162. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20163. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20164. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  20165. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20166. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  20167. resp, requestErr := http.Get(api)
  20168. if requestErr != nil {
  20169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20170. return
  20171. }
  20172. body, ioErr := ioutil.ReadAll(resp.Body)
  20173. if ioErr != nil {
  20174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20176. return
  20177. }
  20178. var respJSON map[string]interface{}
  20179. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20182. return
  20183. }
  20184. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20185. result, _ := json.Marshal(respJSON)
  20186. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20187. utils.ErrorLog("解析失败:%v", err)
  20188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20189. return
  20190. }
  20191. } else {
  20192. var src_resquest string
  20193. if miConfig.Code == "H15049901371" {
  20194. //赤峰地区国家医保医疗类别
  20195. //职工透析:医疗类别选特殊情况门诊990502
  20196. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20197. var med_type string
  20198. if his.Insutype == "390" {
  20199. if reg_type == 14 {
  20200. med_type = "9933"
  20201. } else if reg_type == 11 {
  20202. med_type = "11"
  20203. }
  20204. } else if his.Insutype == "310" {
  20205. if reg_type == 14 {
  20206. med_type = "990502"
  20207. } else if reg_type == 11 {
  20208. med_type = "11"
  20209. }
  20210. }
  20211. 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)
  20212. } else {
  20213. if his.IdCardType == 4 {
  20214. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20215. token := psn_info.VerifyNumber
  20216. 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)
  20217. } else {
  20218. 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)
  20219. }
  20220. }
  20221. var dat map[string]interface{}
  20222. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20223. fmt.Println(dat)
  20224. } else {
  20225. fmt.Println(err)
  20226. }
  20227. saveLog(result2, src_resquest, "2207", "结算")
  20228. userJSONBytes, _ := json.Marshal(dat)
  20229. if miConfig.Code == "H15049901371" {
  20230. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20231. utils.ErrorLog("解析失败:%v", err)
  20232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20233. return
  20234. }
  20235. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20236. res.Output = resSeven10265.Output
  20237. res.ErrMsg = resSeven10265.ErrMsg
  20238. res.Cainfo = resSeven10265.Cainfo
  20239. res.WarnMsg = resSeven10265.WarnMsg
  20240. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20241. res.Infcode = infocode
  20242. } else {
  20243. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  20244. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  20245. utils.ErrorLog("解析失败:%v", err)
  20246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20247. return
  20248. }
  20249. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  20250. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  20251. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  20252. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20253. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  20254. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  20255. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  20256. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20257. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  20258. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20259. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20260. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20261. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20262. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20263. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  20264. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  20265. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  20266. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  20267. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  20268. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  20269. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20270. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  20271. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  20272. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  20273. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  20274. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  20275. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  20276. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  20277. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  20278. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  20279. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  20280. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  20281. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  20282. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  20283. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  20284. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  20285. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  20286. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  20287. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20288. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  20289. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  20290. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  20291. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  20292. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  20293. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  20294. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  20295. res.ErrMsg = gzresSeven10265Two.ErrMsg
  20296. res.Cainfo = gzresSeven10265Two.Cainfo
  20297. res.WarnMsg = gzresSeven10265Two.WarnMsg
  20298. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  20299. //res.Infcode = infocode
  20300. } else {
  20301. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20302. utils.ErrorLog("解析失败:%v", err)
  20303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20304. return
  20305. }
  20306. }
  20307. }
  20308. }
  20309. if res.Infcode != 0 {
  20310. errlog := &models.HisOrderError{
  20311. UserOrgId: adminUser.CurrentOrgId,
  20312. Ctime: time.Now().Unix(),
  20313. Mtime: time.Now().Unix(),
  20314. Number: chrg_bchno,
  20315. ErrMsg: res.ErrMsg,
  20316. Status: 1,
  20317. PatientId: id,
  20318. RecordTime: recordDateTime,
  20319. Stage: 6,
  20320. }
  20321. service.CreateErrMsgLog(errlog)
  20322. c.ServeSuccessJSON(map[string]interface{}{
  20323. "failed_code": -10,
  20324. "msg": res.ErrMsg,
  20325. })
  20326. return
  20327. } else {
  20328. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  20329. order.OrderStatus = 2
  20330. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  20331. order.SetlId = res.Output.Setlinfo.SetlID
  20332. order.PsnNo = res.Output.Setlinfo.PsnNo
  20333. order.PsnName = res.Output.Setlinfo.PsnName
  20334. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  20335. order.Certno = res.Output.Setlinfo.Certno
  20336. order.Gend = res.Output.Setlinfo.Gend
  20337. order.Naty = res.Output.Setlinfo.Naty
  20338. order.Age = res.Output.Setlinfo.Age
  20339. order.Insutype = res.Output.Setlinfo.Insutype
  20340. order.PsnType = res.Output.Setlinfo.PsnType
  20341. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  20342. order.SetlTime = res.Output.Setlinfo.SetlTime
  20343. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  20344. order.PayWays = pay_ways
  20345. order.AcctUsedFlag = acct_used_flag
  20346. order.WechatPay = wechat_pay
  20347. order.AliPay = ali_pay
  20348. order.JifenPay = jifen_pay
  20349. order.BandCardPay = band_card_pay
  20350. order.CashPay = cash_pay
  20351. order.OthDesc = oth_desc
  20352. //order.MedType = res.Output.Setlinfo.MedType
  20353. if reg_type == 1112 {
  20354. order.MedType = "1112"
  20355. }
  20356. if reg_type == 1111 {
  20357. order.MedType = "1111"
  20358. }
  20359. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  20360. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  20361. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  20362. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  20363. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  20364. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  20365. order.HifpPay = res.Output.Setlinfo.HifpPay
  20366. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  20367. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  20368. order.HifesPay = res.Output.Setlinfo.HifesPay
  20369. order.HifobPay = res.Output.Setlinfo.HifobPay
  20370. order.MafPay = res.Output.Setlinfo.MafPay
  20371. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  20372. order.OthPay = res.Output.Setlinfo.OthPay
  20373. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  20374. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  20375. order.AcctPay = res.Output.Setlinfo.AcctPay
  20376. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  20377. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  20378. order.Balc = res.Output.Setlinfo.Balc
  20379. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  20380. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  20381. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  20382. order.ClrWay = res.Output.Setlinfo.ClrWay
  20383. order.Creator = order.Creator
  20384. order.ClrType = res.Output.Setlinfo.ClrType
  20385. order.Modify = roles.AdminUserId
  20386. order.RequestLog = src_resquest
  20387. order.Diagnosis = diagnosis_id
  20388. order.FaPiaoNumber = fapiao_number
  20389. order.FaPiaoCode = fapiao_code
  20390. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  20391. detailStr := string(setlDetail)
  20392. order.SetlDetail = detailStr
  20393. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  20394. err = service.UpDateOrder(order)
  20395. if err == nil {
  20396. //判断是否使用了押金
  20397. if dec_way == "true" {
  20398. tmpstring := strconv.FormatInt(order.ID, 10)
  20399. //扣押金
  20400. order.Decimal = decimal
  20401. service.UpDateOrder(order)
  20402. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  20403. if errmsg != nil {
  20404. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  20405. return
  20406. }
  20407. }
  20408. c.ServeSuccessJSON(map[string]interface{}{
  20409. "msg": "结算成功",
  20410. })
  20411. } else {
  20412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  20413. return
  20414. }
  20415. }
  20416. }
  20417. }
  20418. }
  20419. // 上传明细-预结算-
  20420. func (c *HisApiController) GetPreUploadInfo() {
  20421. id, _ := c.GetInt64("id")
  20422. record_time := c.GetString("record_time")
  20423. his_patient_id, _ := c.GetInt64("his_patient_id")
  20424. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  20425. admin_user_id, _ := c.GetInt64("admin_user_id")
  20426. diagnosis_id := c.GetString("diagnosis")
  20427. sick_type, _ := c.GetInt64("sick_type")
  20428. reg_type, _ := c.GetInt64("p_type")
  20429. begin_time := c.GetString("begin_time")
  20430. acct_used_flag := c.GetString("acct_used_flag")
  20431. id_str := c.GetString("ids")
  20432. ids_arr := strings.Split(id_str, ",")
  20433. timeLayout := "2006-01-02"
  20434. loc, _ := time.LoadLocation("Local")
  20435. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  20436. if err != nil {
  20437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  20438. return
  20439. }
  20440. recordDateTime := theTime.Unix()
  20441. adminUser := c.GetAdminUserInfo()
  20442. diagnosis_ids := strings.Split(diagnosis_id, ",")
  20443. var config []*models.HisXtDiagnoseConfig
  20444. for _, item := range diagnosis_ids {
  20445. id, _ := strconv.ParseInt(item, 10, 64)
  20446. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20447. config = append(config, &diagnosisConfig)
  20448. }
  20449. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  20450. sickConfig, _ := service.FindSickById(sick_type)
  20451. var prescriptions []*models.HisPrescription
  20452. var start_time int64
  20453. var end_time int64
  20454. var isSuccess bool = true
  20455. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  20456. fmt.Println(his_patient_id)
  20457. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  20458. timestamp := time.Now().Unix()
  20459. tempTime := time.Unix(timestamp, 0)
  20460. timeFormat := tempTime.Format("20060102150405")
  20461. chrgBchno := rand.Intn(100000) + 10000
  20462. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  20463. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20464. var patientPrescription models.HisPrescriptionInfo
  20465. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  20466. if patientPrescription.ID == 0 {
  20467. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  20468. }
  20469. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20470. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  20471. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  20472. strconv.FormatInt(his.PatientId, 10)
  20473. var res2406 Result2406
  20474. //安徽单病种处理
  20475. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  20476. data := make(map[string]interface{})
  20477. client := &http.Client{}
  20478. data["psn_no"] = his.PsnNo
  20479. data["mdtrt_id"] = his.Number
  20480. data["operator"] = roles.UserName
  20481. data["cert_no"] = his.IdCardNo
  20482. data["org_name"] = miConfig.OrgName
  20483. data["psn_name"] = his.Name
  20484. data["ipt_otp_no"] = his.IptOtpNo
  20485. data["ipt_psn_sp_flag_type"] = "0901"
  20486. data["ipt_psn_sp_flag"] = "1"
  20487. data["fixmedins_code"] = miConfig.Code
  20488. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20489. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20490. data["url"] = miConfig.Url
  20491. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  20492. bytesData, _ := json.Marshal(data)
  20493. var req *http.Request
  20494. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  20495. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  20496. resp, _ := client.Do(req)
  20497. defer resp.Body.Close()
  20498. body, ioErr := ioutil.ReadAll(resp.Body)
  20499. if ioErr != nil {
  20500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20502. return
  20503. }
  20504. var respJSON map[string]interface{}
  20505. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20508. return
  20509. }
  20510. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20511. if status == "0" {
  20512. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20513. c.ServeSuccessJSON(map[string]interface{}{
  20514. "failed_code": -10,
  20515. "msg": err_msg,
  20516. })
  20517. return
  20518. }
  20519. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20520. userJSONBytes, _ := json.Marshal(respJSON)
  20521. fmt.Println("log")
  20522. fmt.Println(string(userJSONBytes))
  20523. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  20524. utils.ErrorLog("解析失败:%v", err)
  20525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20526. return
  20527. }
  20528. }
  20529. if res2406.Infcode != 0 {
  20530. adminUser := c.GetAdminUserInfo()
  20531. errlog := &models.HisOrderError{
  20532. UserOrgId: adminUser.CurrentOrgId,
  20533. Ctime: time.Now().Unix(),
  20534. Mtime: time.Now().Unix(),
  20535. ErrMsg: res2406.ErrMsg,
  20536. Status: 1,
  20537. PatientId: id,
  20538. RecordTime: recordDateTime,
  20539. Stage: 3,
  20540. }
  20541. service.CreateErrMsgLog(errlog)
  20542. c.ServeSuccessJSON(map[string]interface{}{
  20543. "failed_code": -10,
  20544. "msg": res2406.ErrMsg,
  20545. })
  20546. return
  20547. }
  20548. var res2 ResultSix
  20549. var res3 GZResultSix
  20550. var resSix10265 ResultSix10265
  20551. //var time_stamp string
  20552. if miConfig.MdtrtareaAdmvs == "421300" {
  20553. data := make(map[string]interface{})
  20554. client := &http.Client{}
  20555. data["psn_no"] = his.PsnNo
  20556. data["mdtrt_id"] = his.Number
  20557. data["department"] = department.Name
  20558. data["org_name"] = miConfig.OrgName
  20559. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20560. data["doctor_id"] = doctor_info.DoctorNumber
  20561. data["doctor_name"] = roles.UserName
  20562. data["fixmedins_code"] = miConfig.Code
  20563. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20564. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20565. data["secret_key"] = miConfig.SecretKey
  20566. data["sick_code"] = sickConfig.CountryCode
  20567. data["sick_name"] = sickConfig.ClassName
  20568. data["begin_time"] = begin_time
  20569. data["dept"] = strconv.FormatInt(department.ID, 10)
  20570. data["config"] = config
  20571. data["opter"] = roles.UserName
  20572. fmt.Println(data)
  20573. bytesData, _ := json.Marshal(data)
  20574. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  20575. resp, _ := client.Do(req)
  20576. defer resp.Body.Close()
  20577. body, ioErr := ioutil.ReadAll(resp.Body)
  20578. if ioErr != nil {
  20579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20581. return
  20582. }
  20583. var respJSON map[string]interface{}
  20584. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20587. return
  20588. }
  20589. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20590. userJSONBytes, _ := json.Marshal(respJSON)
  20591. fmt.Println("log")
  20592. fmt.Println(string(userJSONBytes))
  20593. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20594. utils.ErrorLog("解析失败:%v", err)
  20595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20596. return
  20597. }
  20598. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20599. data := make(map[string]interface{})
  20600. client := &http.Client{}
  20601. data["psn_no"] = his.PsnNo
  20602. data["mdtrt_id"] = his.Number
  20603. data["department"] = department.Name
  20604. data["org_name"] = miConfig.OrgName
  20605. if reg_type == 11 && his.Insutype == "390" {
  20606. data["med_type"] = "110104"
  20607. } else {
  20608. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20609. }
  20610. data["doctor_id"] = doctor_info.DoctorNumber
  20611. data["doctor_name"] = roles.UserName
  20612. data["fixmedins_code"] = miConfig.Code
  20613. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20614. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20615. data["secret_key"] = miConfig.SecretKey
  20616. data["sick_code"] = sickConfig.CountryCode
  20617. data["sick_name"] = sickConfig.ClassName
  20618. data["begin_time"] = begin_time
  20619. data["dept"] = strconv.FormatInt(department.ID, 10)
  20620. data["config"] = config
  20621. data["opter"] = roles.UserName
  20622. fmt.Println(data)
  20623. bytesData, _ := json.Marshal(data)
  20624. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  20625. resp, _ := client.Do(req)
  20626. defer resp.Body.Close()
  20627. body, ioErr := ioutil.ReadAll(resp.Body)
  20628. if ioErr != nil {
  20629. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20631. return
  20632. }
  20633. var respJSON map[string]interface{}
  20634. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20637. return
  20638. }
  20639. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20640. userJSONBytes, _ := json.Marshal(respJSON)
  20641. fmt.Println("log")
  20642. fmt.Println(string(userJSONBytes))
  20643. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20644. utils.ErrorLog("解析失败:%v", err)
  20645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20646. return
  20647. }
  20648. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20649. data := make(map[string]interface{})
  20650. client := &http.Client{}
  20651. data["psn_no"] = his.PsnNo
  20652. data["mdtrt_id"] = his.Number
  20653. data["department"] = department.Name
  20654. data["org_name"] = miConfig.OrgName
  20655. if reg_type == 11 && his.Insutype == "390" {
  20656. data["med_type"] = "110104"
  20657. } else {
  20658. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20659. }
  20660. data["doctor_id"] = doctor_info.DoctorNumber
  20661. data["doctor_name"] = roles.UserName
  20662. data["fixmedins_code"] = miConfig.Code
  20663. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20664. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20665. data["secret_key"] = miConfig.SecretKey
  20666. data["sick_code"] = sickConfig.CountryCode
  20667. data["sick_name"] = sickConfig.ClassName
  20668. data["begin_time"] = begin_time
  20669. data["dept"] = strconv.FormatInt(department.ID, 10)
  20670. data["config"] = config
  20671. data["opter"] = roles.UserName
  20672. fmt.Println(data)
  20673. bytesData, _ := json.Marshal(data)
  20674. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  20675. resp, _ := client.Do(req)
  20676. defer resp.Body.Close()
  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(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. userJSONBytes, _ := json.Marshal(respJSON)
  20691. fmt.Println("log")
  20692. fmt.Println(string(userJSONBytes))
  20693. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20694. utils.ErrorLog("解析失败:%v", err)
  20695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20696. return
  20697. }
  20698. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20699. data := make(map[string]interface{})
  20700. client := &http.Client{}
  20701. data["psn_no"] = his.PsnNo
  20702. data["mdtrt_id"] = his.Number
  20703. data["doctor"] = roles.UserName
  20704. data["department"] = department.Name
  20705. data["org_name"] = miConfig.OrgName
  20706. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20707. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  20708. data["fixmedins_code"] = miConfig.Code
  20709. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20710. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20711. data["secret_key"] = miConfig.SecretKey
  20712. data["sick_code"] = sickConfig.CountryCode
  20713. data["sick_name"] = sickConfig.ClassName
  20714. data["begin_time"] = begin_time
  20715. data["dept"] = strconv.FormatInt(department.ID, 10)
  20716. data["config"] = config
  20717. data["url"] = miConfig.Url
  20718. data["ak"] = miConfig.AccessKey
  20719. data["cainfo"] = miConfig.Cainfo
  20720. bytesData, _ := json.Marshal(data)
  20721. var req *http.Request
  20722. if miConfig.MdtrtareaAdmvs == "320921" {
  20723. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  20724. } else {
  20725. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  20726. }
  20727. resp, _ := client.Do(req)
  20728. defer resp.Body.Close()
  20729. body, ioErr := ioutil.ReadAll(resp.Body)
  20730. if ioErr != nil {
  20731. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20733. return
  20734. }
  20735. var respJSON map[string]interface{}
  20736. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20739. return
  20740. }
  20741. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  20742. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  20743. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  20744. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20745. userJSONBytes, _ := json.Marshal(respJSON)
  20746. fmt.Println("log")
  20747. fmt.Println(string(userJSONBytes))
  20748. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  20749. utils.ErrorLog("解析失败:%v", err)
  20750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20751. return
  20752. }
  20753. res2.InfRefmsgid = resSix10265.InfRefmsgid
  20754. res2.Output = resSix10265.Output
  20755. res2.ErrMsg = resSix10265.ErrMsg
  20756. res2.Cainfo = resSix10265.Cainfo
  20757. res2.WarnMsg = resSix10265.WarnMsg
  20758. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  20759. res2.Infcode = infocode
  20760. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20761. data := make(map[string]interface{})
  20762. client := &http.Client{}
  20763. data["psn_no"] = his.PsnNo
  20764. data["mdtrt_id"] = his.Number
  20765. data["doctor"] = roles.UserName
  20766. data["department"] = department.Name
  20767. data["org_name"] = miConfig.OrgName
  20768. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20769. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  20770. data["fixmedins_code"] = miConfig.Code
  20771. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20772. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20773. data["secret_key"] = miConfig.SecretKey
  20774. data["sick_code"] = sickConfig.CountryCode
  20775. data["sick_name"] = sickConfig.ClassName
  20776. data["begin_time"] = begin_time
  20777. data["dept"] = strconv.FormatInt(department.ID, 10)
  20778. data["config"] = config
  20779. //data["url"] = miConfig.Url
  20780. //data["ak"] = miConfig.AccessKey
  20781. data["cainfo"] = miConfig.Cainfo
  20782. fmt.Println(data)
  20783. bytesData, _ := json.Marshal(data)
  20784. var req *http.Request
  20785. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  20786. resp, _ := client.Do(req)
  20787. defer resp.Body.Close()
  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(body), &respJSON); err != nil {
  20796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20798. return
  20799. }
  20800. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  20801. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  20802. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  20803. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20804. userJSONBytes, _ := json.Marshal(respJSON)
  20805. fmt.Println("log")
  20806. fmt.Println(string(userJSONBytes))
  20807. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  20808. utils.ErrorLog("解析失败:%v", err)
  20809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20810. return
  20811. }
  20812. res2.InfRefmsgid = resSix10265.InfRefmsgid
  20813. res2.Output = resSix10265.Output
  20814. res2.ErrMsg = resSix10265.ErrMsg
  20815. res2.Cainfo = resSix10265.Cainfo
  20816. res2.WarnMsg = resSix10265.WarnMsg
  20817. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  20818. res2.Infcode = infocode
  20819. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20820. 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)
  20821. saveLog(result, requestLog, "2203", "上传就诊信息")
  20822. var respJSON2 map[string]interface{}
  20823. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20826. return
  20827. }
  20828. userJSONBytes2, _ := json.Marshal(respJSON2)
  20829. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20830. utils.ErrorLog("解析失败:%v", err)
  20831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20832. return
  20833. }
  20834. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20835. var result string
  20836. var requestLog string
  20837. 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, "")
  20838. saveLog(result, requestLog, "2203", "上传就诊信息")
  20839. var respJSON2 map[string]interface{}
  20840. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20843. return
  20844. }
  20845. userJSONBytes2, _ := json.Marshal(respJSON2)
  20846. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20847. utils.ErrorLog("解析失败:%v", err)
  20848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20849. return
  20850. }
  20851. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20852. data := make(map[string]interface{})
  20853. client := &http.Client{}
  20854. data["psn_no"] = his.PsnNo
  20855. data["mdtrt_id"] = his.Number
  20856. data["operator"] = roles.UserName
  20857. data["department"] = department.Name
  20858. data["org_name"] = miConfig.OrgName
  20859. var med_type string
  20860. if his.Insutype == "390" {
  20861. if reg_type == 992102 {
  20862. med_type = "992102"
  20863. data["sick_code"] = "ZDZ940"
  20864. data["sick_name"] = "慢性肾衰竭"
  20865. }
  20866. if reg_type == 140104 {
  20867. med_type = "140104"
  20868. data["sick_code"] = sickConfig.CountryCode
  20869. data["sick_name"] = sickConfig.ClassName
  20870. }
  20871. if reg_type == 14 {
  20872. med_type = "140104"
  20873. data["sick_code"] = sickConfig.CountryCode
  20874. data["sick_name"] = sickConfig.ClassName
  20875. }
  20876. } else if his.Insutype == "310" {
  20877. if reg_type == 992102 {
  20878. med_type = "992102"
  20879. data["sick_code"] = "ZDZ940"
  20880. data["sick_name"] = "慢性肾衰竭"
  20881. }
  20882. if reg_type == 140104 {
  20883. med_type = "140104"
  20884. data["sick_code"] = sickConfig.CountryCode
  20885. data["sick_name"] = sickConfig.ClassName
  20886. }
  20887. if reg_type == 14 {
  20888. med_type = "14"
  20889. data["sick_code"] = sickConfig.CountryCode
  20890. data["sick_name"] = sickConfig.ClassName
  20891. }
  20892. }
  20893. data["med_type"] = med_type
  20894. data["doctor_number"] = doctor_info.DoctorNumber
  20895. data["doctor_name"] = doctor_info.UserName
  20896. data["fixmedins_code"] = miConfig.Code
  20897. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20898. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20899. data["secret_key"] = miConfig.SecretKey
  20900. data["begin_time"] = begin_time
  20901. data["dept"] = strconv.FormatInt(department.ID, 10)
  20902. data["config"] = config
  20903. data["url"] = miConfig.Url
  20904. data["ak"] = miConfig.AccessKey
  20905. data["cainfo"] = miConfig.Cainfo
  20906. bytesData, _ := json.Marshal(data)
  20907. var req *http.Request
  20908. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  20909. resp, _ := client.Do(req)
  20910. defer resp.Body.Close()
  20911. body, ioErr := ioutil.ReadAll(resp.Body)
  20912. if ioErr != nil {
  20913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20915. return
  20916. }
  20917. var respJSON map[string]interface{}
  20918. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20921. return
  20922. }
  20923. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20924. if status == "0" {
  20925. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20926. c.ServeSuccessJSON(map[string]interface{}{
  20927. "failed_code": -10,
  20928. "msg": err_msg,
  20929. })
  20930. return
  20931. }
  20932. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20933. userJSONBytes, _ := json.Marshal(respJSON)
  20934. fmt.Println("log")
  20935. fmt.Println(string(userJSONBytes))
  20936. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20937. utils.ErrorLog("解析失败:%v", err)
  20938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20939. return
  20940. }
  20941. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20942. var result string
  20943. var requestLog string
  20944. 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, "")
  20945. saveLog(result, requestLog, "2203", "上传就诊信息")
  20946. var respJSON2 map[string]interface{}
  20947. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20948. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20950. return
  20951. }
  20952. userJSONBytes2, _ := json.Marshal(respJSON2)
  20953. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20954. utils.ErrorLog("解析失败:%v", err)
  20955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20956. return
  20957. }
  20958. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20959. data := make(map[string]interface{})
  20960. client := &http.Client{}
  20961. data["psn_no"] = his.PsnNo
  20962. data["mdtrt_id"] = his.Number
  20963. data["doctor"] = roles.UserName
  20964. data["department"] = department.Name
  20965. data["org_name"] = miConfig.OrgName
  20966. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20967. data["doctor_id"] = doctor_info.DoctorNumber
  20968. data["fixmedins_code"] = miConfig.Code
  20969. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20970. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20971. data["secret_key"] = miConfig.SecretKey
  20972. data["sick_code"] = sickConfig.CountryCode
  20973. data["sick_name"] = sickConfig.ClassName
  20974. data["begin_time"] = begin_time
  20975. data["new_doctor_name"] = doctor_info.UserName
  20976. data["dept"] = strconv.FormatInt(department.ID, 10)
  20977. data["config"] = config
  20978. bytesData, _ := json.Marshal(data)
  20979. var req *http.Request
  20980. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  20981. resp, _ := client.Do(req)
  20982. defer resp.Body.Close()
  20983. body, ioErr := ioutil.ReadAll(resp.Body)
  20984. if ioErr != nil {
  20985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20987. return
  20988. }
  20989. var respJSON map[string]interface{}
  20990. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20993. return
  20994. }
  20995. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20996. userJSONBytes, _ := json.Marshal(respJSON)
  20997. fmt.Println("log")
  20998. fmt.Println(string(userJSONBytes))
  20999. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21000. utils.ErrorLog("解析失败:%v", err)
  21001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21002. return
  21003. }
  21004. } else {
  21005. var result string
  21006. var requestLog string
  21007. if miConfig.MdtrtareaAdmvs == "440781" { //
  21008. 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)
  21009. } else {
  21010. if miConfig.Code == "H15049901371" {
  21011. //赤峰地区国家医保医疗类别
  21012. //职工透析:医疗类别选特殊情况门诊990502
  21013. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21014. var med_type string
  21015. if his.Insutype == "390" {
  21016. if reg_type == 14 {
  21017. med_type = "9933"
  21018. } else if reg_type == 11 {
  21019. med_type = "11"
  21020. }
  21021. } else if his.Insutype == "310" {
  21022. if reg_type == 14 {
  21023. med_type = "990502"
  21024. } else if reg_type == 11 {
  21025. med_type = "11"
  21026. }
  21027. }
  21028. 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)
  21029. } else {
  21030. 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)
  21031. }
  21032. saveLog(result, requestLog, "2203", "上传就诊信息")
  21033. var respJSON2 map[string]interface{}
  21034. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21037. return
  21038. }
  21039. userJSONBytes2, _ := json.Marshal(respJSON2)
  21040. if miConfig.Code == "H15049901371" {
  21041. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  21042. utils.ErrorLog("解析失败:%v", err)
  21043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21044. return
  21045. }
  21046. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21047. res2.Output = resSix10265.Output
  21048. res2.ErrMsg = resSix10265.ErrMsg
  21049. res2.Cainfo = resSix10265.Cainfo
  21050. res2.WarnMsg = resSix10265.WarnMsg
  21051. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21052. res2.Infcode = infocode
  21053. } else {
  21054. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21055. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  21056. utils.ErrorLog("解析失败:%v", err)
  21057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21058. return
  21059. }
  21060. res2.Infcode = res3.Infcode
  21061. } else {
  21062. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21063. utils.ErrorLog("解析失败:%v", err)
  21064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21065. return
  21066. }
  21067. }
  21068. }
  21069. }
  21070. }
  21071. if res2.Infcode == -1 {
  21072. adminUser := c.GetAdminUserInfo()
  21073. errlog := &models.HisOrderError{
  21074. UserOrgId: adminUser.CurrentOrgId,
  21075. Ctime: time.Now().Unix(),
  21076. Mtime: time.Now().Unix(),
  21077. ErrMsg: res2.ErrMsg,
  21078. Status: 1,
  21079. PatientId: id,
  21080. RecordTime: recordDateTime,
  21081. Stage: 3,
  21082. }
  21083. service.CreateErrMsgLog(errlog)
  21084. c.ServeSuccessJSON(map[string]interface{}{
  21085. "failed_code": -10,
  21086. "msg": res2.ErrMsg,
  21087. })
  21088. return
  21089. }
  21090. if res2.Infcode != 0 {
  21091. adminUser := c.GetAdminUserInfo()
  21092. errlog := &models.HisOrderError{
  21093. UserOrgId: adminUser.CurrentOrgId,
  21094. Ctime: time.Now().Unix(),
  21095. Mtime: time.Now().Unix(),
  21096. ErrMsg: res2.ErrMsg,
  21097. Status: 1,
  21098. PatientId: id,
  21099. RecordTime: recordDateTime,
  21100. Stage: 3,
  21101. }
  21102. service.CreateErrMsgLog(errlog)
  21103. c.ServeSuccessJSON(map[string]interface{}{
  21104. "failed_code": -10,
  21105. "msg": res2.ErrMsg,
  21106. })
  21107. return
  21108. } else {
  21109. his.Diagnosis = diagnosis_id
  21110. his.SickType = sickConfig.ID
  21111. his.PType = fmt.Sprintf("%d", reg_type)
  21112. service.UpdateHisPatientThree(&his)
  21113. data := make(map[string]interface{})
  21114. if settle_accounts_type == 1 { //日结
  21115. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  21116. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  21117. } else {
  21118. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  21119. }
  21120. data["pre"] = prescriptions
  21121. } else { //月结
  21122. start_time_str := c.GetString("start_time")
  21123. end_time_str := c.GetString("end_time")
  21124. timeLayout := "2006-01-02"
  21125. loc, _ := time.LoadLocation("Local")
  21126. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  21127. if err != nil {
  21128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21129. return
  21130. }
  21131. recordStartTime := theStartTime.Unix()
  21132. start_time = recordStartTime
  21133. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  21134. if err != nil {
  21135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21136. return
  21137. }
  21138. recordEndTime := theEndTime.Unix()
  21139. end_time = recordEndTime
  21140. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  21141. data["pre"] = prescriptions
  21142. }
  21143. client := &http.Client{}
  21144. data["psn_no"] = his.PsnNo
  21145. data["mdtrt_id"] = his.Number
  21146. data["chrg_bchno"] = chrg_bchno
  21147. data["org_name"] = miConfig.OrgName
  21148. data["doctor"] = doctor_info.UserName
  21149. data["doctor_id"] = doctor_info.DoctorNumber
  21150. data["dept"] = department.Name
  21151. data["fixmedins_code"] = miConfig.Code
  21152. data["opter"] = roles.UserName
  21153. data["dept_code"] = department.Number
  21154. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21155. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21156. data["secret_key"] = miConfig.SecretKey
  21157. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  21158. data["url"] = miConfig.Url
  21159. data["ak"] = miConfig.AccessKey
  21160. data["new_doctor_name"] = patientPrescription.Doctor
  21161. if his.Insutype == "390" {
  21162. if reg_type == 992102 {
  21163. data["diag_code"] = "ZDZ940"
  21164. }
  21165. if reg_type == 140104 {
  21166. data["diag_code"] = sickConfig.CountryCode
  21167. }
  21168. if reg_type == 14 {
  21169. data["diag_code"] = sickConfig.CountryCode
  21170. }
  21171. } else if his.Insutype == "310" {
  21172. if reg_type == 992102 {
  21173. data["diag_code"] = "ZDZ940"
  21174. }
  21175. if reg_type == 14 {
  21176. data["diag_code"] = sickConfig.CountryCode
  21177. }
  21178. }
  21179. data["cainfo"] = miConfig.Cainfo
  21180. data["opter"] = roles.UserName
  21181. var ids []int64
  21182. for _, item := range prescriptions {
  21183. ids = append(ids, item.ID)
  21184. }
  21185. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  21186. if config.IsOpen == 1 { //对接了医保,走医保流程
  21187. var res ResultFour
  21188. var resFour10265 ResultFour10265
  21189. if miConfig.MdtrtareaAdmvs == "421300" {
  21190. bytesData, _ := json.Marshal(data)
  21191. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  21192. resp, _ := client.Do(req)
  21193. defer resp.Body.Close()
  21194. body, ioErr := ioutil.ReadAll(resp.Body)
  21195. if ioErr != nil {
  21196. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21198. return
  21199. }
  21200. var respJSON map[string]interface{}
  21201. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21204. return
  21205. }
  21206. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21207. userJSONBytes, _ := json.Marshal(respJSON)
  21208. fmt.Println("log")
  21209. fmt.Println(string(userJSONBytes))
  21210. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21211. utils.ErrorLog("解析失败:%v", err)
  21212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21213. return
  21214. }
  21215. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21216. bytesData, _ := json.Marshal(data)
  21217. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  21218. resp, _ := client.Do(req)
  21219. defer resp.Body.Close()
  21220. body, ioErr := ioutil.ReadAll(resp.Body)
  21221. if ioErr != nil {
  21222. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21224. return
  21225. }
  21226. var respJSON map[string]interface{}
  21227. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21230. return
  21231. }
  21232. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21233. userJSONBytes, _ := json.Marshal(respJSON)
  21234. fmt.Println("log")
  21235. fmt.Println(string(userJSONBytes))
  21236. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21237. utils.ErrorLog("解析失败:%v", err)
  21238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21239. return
  21240. }
  21241. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21242. bytesData, _ := json.Marshal(data)
  21243. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  21244. resp, _ := client.Do(req)
  21245. defer resp.Body.Close()
  21246. body, ioErr := ioutil.ReadAll(resp.Body)
  21247. if ioErr != nil {
  21248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21250. return
  21251. }
  21252. var respJSON map[string]interface{}
  21253. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21256. return
  21257. }
  21258. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21259. userJSONBytes, _ := json.Marshal(respJSON)
  21260. fmt.Println("log")
  21261. fmt.Println(string(userJSONBytes))
  21262. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21263. utils.ErrorLog("解析失败:%v", err)
  21264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21265. return
  21266. }
  21267. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21268. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  21269. if result3101.Infcode == "0" {
  21270. if len(result3101.Output.Result) > 0 {
  21271. var errMsgs []string
  21272. for _, item := range result3101.Output.Result {
  21273. errMsgs = append(errMsgs, item.VolaCont)
  21274. }
  21275. c.ServeSuccessJSON(map[string]interface{}{
  21276. "failed_code": -10,
  21277. "msg": errMsgs,
  21278. })
  21279. return
  21280. } else {
  21281. if miConfig.MdtrtareaAdmvs == "320921" {
  21282. data["doctor_id"] = "D320923012139"
  21283. } else {
  21284. data["doctor_id"] = "D371621008686"
  21285. }
  21286. bytesData, _ := json.Marshal(data)
  21287. var req *http.Request
  21288. if miConfig.MdtrtareaAdmvs == "320921" {
  21289. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21290. } else {
  21291. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21292. }
  21293. resp, _ := client.Do(req)
  21294. defer resp.Body.Close()
  21295. body, ioErr := ioutil.ReadAll(resp.Body)
  21296. if ioErr != nil {
  21297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21299. return
  21300. }
  21301. var respJSON map[string]interface{}
  21302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21305. return
  21306. }
  21307. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21308. userJSONBytes, _ := json.Marshal(respJSON)
  21309. fmt.Println("log")
  21310. fmt.Println(string(userJSONBytes))
  21311. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  21312. utils.ErrorLog("解析失败:%v", err)
  21313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21314. return
  21315. }
  21316. res.InfRefmsgid = resFour10265.InfRefmsgid
  21317. res.Output = resFour10265.Output
  21318. res.ErrMsg = resFour10265.ErrMsg
  21319. res.Cainfo = resFour10265.Cainfo
  21320. res.WarnMsg = resFour10265.WarnMsg
  21321. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  21322. res.Infcode = infocode
  21323. }
  21324. }
  21325. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21326. var pagesize int = 5
  21327. var start int = 1
  21328. var stop int
  21329. var pagecount int
  21330. var curpage int
  21331. data["doctor_id"] = doctor_info.DoctorNumber
  21332. var res2 ResultFour
  21333. //var result res.
  21334. //总页数,向上取整,注意除之前要先转换类型为float64
  21335. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  21336. for curpage = 1; curpage <= pagecount; curpage++ {
  21337. if curpage == 1 {
  21338. start = 1
  21339. } else {
  21340. start = (curpage-1)*pagesize + 1
  21341. }
  21342. stop = curpage * pagesize
  21343. if stop > len(prescriptions) {
  21344. stop = len(prescriptions)
  21345. }
  21346. //var requestLog string
  21347. data["pre"] = prescriptions[start-1 : stop]
  21348. fmt.Println(data["pre"])
  21349. bytesData, _ := json.Marshal(data)
  21350. var req *http.Request
  21351. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  21352. resp, _ := client.Do(req)
  21353. defer resp.Body.Close()
  21354. body, ioErr := ioutil.ReadAll(resp.Body)
  21355. if ioErr != nil {
  21356. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21358. return
  21359. }
  21360. var respJSON map[string]interface{}
  21361. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21362. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21364. return
  21365. }
  21366. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21367. userJSONBytes, _ := json.Marshal(respJSON)
  21368. fmt.Println("log")
  21369. fmt.Println(string(userJSONBytes))
  21370. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  21371. utils.ErrorLog("解析失败:%v", err)
  21372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21373. return
  21374. }
  21375. res.InfRefmsgid = resFour10265.InfRefmsgid
  21376. res.Output = resFour10265.Output
  21377. res.ErrMsg = resFour10265.ErrMsg
  21378. res.Cainfo = resFour10265.Cainfo
  21379. res.WarnMsg = resFour10265.WarnMsg
  21380. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  21381. res.Infcode = infocode
  21382. if infocode == 0 {
  21383. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  21384. } else {
  21385. isSuccess = false
  21386. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  21387. res.Infcode = -1
  21388. res.ErrMsg = resFour10265.ErrMsg
  21389. errlog := &models.HisOrderError{
  21390. UserOrgId: adminUser.CurrentOrgId,
  21391. Ctime: time.Now().Unix(),
  21392. Mtime: time.Now().Unix(),
  21393. Number: chrg_bchno,
  21394. ErrMsg: "",
  21395. Status: 1,
  21396. PatientId: id,
  21397. RecordTime: recordDateTime,
  21398. Stage: 4,
  21399. }
  21400. service.CreateErrMsgLog(errlog)
  21401. }
  21402. }
  21403. if isSuccess {
  21404. res.Infcode = 0
  21405. res.Output.Result = res2.Output.Result
  21406. } else {
  21407. order := &models.HisOrder{
  21408. UserOrgId: adminUser.CurrentOrgId,
  21409. HisPatientId: his.ID,
  21410. PatientId: his.PatientId,
  21411. SettleAccountsDate: recordDateTime,
  21412. Ctime: time.Now().Unix(),
  21413. Mtime: time.Now().Unix(),
  21414. MdtrtId: his.Number,
  21415. PsnNo: his.PsnNo,
  21416. MedType: strconv.FormatInt(reg_type, 10),
  21417. Status: 1,
  21418. Number: chrg_bchno,
  21419. Infcode: res.Infcode,
  21420. WarnMsg: res.WarnMsg,
  21421. Cainfo: res.Cainfo,
  21422. ErrMsg: res.ErrMsg,
  21423. RespondTime: res.RefmsgTime,
  21424. InfRefmsgid: res.InfRefmsgid,
  21425. OrderStatus: 1,
  21426. IsMedicineInsurance: 1,
  21427. SettleType: settle_accounts_type,
  21428. SettleStartTime: start_time,
  21429. SettleEndTime: end_time,
  21430. Creator: roles.AdminUserId,
  21431. Modify: roles.AdminUserId,
  21432. PType: 2,
  21433. Diagnosis: diagnosis_id,
  21434. }
  21435. err = service.CreateOrder(order)
  21436. if err != nil {
  21437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  21438. return
  21439. }
  21440. c.ServeSuccessJSON(map[string]interface{}{
  21441. "failed_code": -10,
  21442. "msg": res2.ErrMsg,
  21443. })
  21444. return
  21445. }
  21446. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21447. 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)
  21448. var dat map[string]interface{}
  21449. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21450. fmt.Println(dat)
  21451. } else {
  21452. fmt.Println(err)
  21453. }
  21454. saveLog(result, request_log, "2204", "上传费用明细")
  21455. userJSONBytes, _ := json.Marshal(dat)
  21456. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21457. utils.ErrorLog("解析失败:%v", err)
  21458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21459. return
  21460. }
  21461. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21462. 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, "", "")
  21463. var dat map[string]interface{}
  21464. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21465. fmt.Println(dat)
  21466. } else {
  21467. fmt.Println(err)
  21468. }
  21469. saveLog(result, request_log, "2204", "上传费用明细")
  21470. userJSONBytes, _ := json.Marshal(dat)
  21471. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21472. utils.ErrorLog("解析失败:%v", err)
  21473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21474. return
  21475. }
  21476. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21477. bytesData, _ := json.Marshal(data)
  21478. var req *http.Request
  21479. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  21480. resp, _ := client.Do(req)
  21481. defer resp.Body.Close()
  21482. body, ioErr := ioutil.ReadAll(resp.Body)
  21483. if ioErr != nil {
  21484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21486. return
  21487. }
  21488. var respJSON map[string]interface{}
  21489. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21492. return
  21493. }
  21494. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21495. if status == "0" {
  21496. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21497. c.ServeSuccessJSON(map[string]interface{}{
  21498. "failed_code": -10,
  21499. "msg": err_msg,
  21500. })
  21501. return
  21502. }
  21503. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21504. userJSONBytes, _ := json.Marshal(respJSON)
  21505. fmt.Println("log")
  21506. fmt.Println(string(userJSONBytes))
  21507. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21508. utils.ErrorLog("解析失败:%v", err)
  21509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21510. return
  21511. }
  21512. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21513. 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, "", "")
  21514. var dat map[string]interface{}
  21515. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21516. fmt.Println(dat)
  21517. } else {
  21518. fmt.Println(err)
  21519. }
  21520. saveLog(result, request_log, "2204", "上传费用明细")
  21521. userJSONBytes, _ := json.Marshal(dat)
  21522. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21523. utils.ErrorLog("解析失败:%v", err)
  21524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21525. return
  21526. }
  21527. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21528. bytesData, _ := json.Marshal(data)
  21529. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", 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. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21545. userJSONBytes, _ := json.Marshal(respJSON)
  21546. fmt.Println("log")
  21547. fmt.Println(string(userJSONBytes))
  21548. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21549. utils.ErrorLog("解析失败:%v", err)
  21550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21551. return
  21552. }
  21553. } else {
  21554. if miConfig.MdtrtareaAdmvs == "441202" {
  21555. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  21556. if result3101.Infcode == 0 {
  21557. if len(result3101.Output.Result) > 0 {
  21558. var errMsgs []string
  21559. for _, item := range result3101.Output.Result {
  21560. errMsgs = append(errMsgs, item.VolaCont)
  21561. }
  21562. c.ServeSuccessJSON(map[string]interface{}{
  21563. "failed_code": -10,
  21564. "msg": errMsgs,
  21565. })
  21566. return
  21567. } else {
  21568. 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)
  21569. var dat map[string]interface{}
  21570. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21571. fmt.Println(dat)
  21572. } else {
  21573. fmt.Println(err)
  21574. }
  21575. saveLog(result, request_log, "2204", "上传费用明细")
  21576. userJSONBytes, _ := json.Marshal(dat)
  21577. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21578. utils.ErrorLog("解析失败:%v", err)
  21579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21580. return
  21581. }
  21582. }
  21583. } else {
  21584. c.ServeSuccessJSON(map[string]interface{}{
  21585. "failed_code": -10,
  21586. "msg": result3101.ErrMsg,
  21587. })
  21588. return
  21589. }
  21590. } else {
  21591. if miConfig.Code == "H15049901371" {
  21592. 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)
  21593. var dat map[string]interface{}
  21594. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21595. fmt.Println(dat)
  21596. } else {
  21597. fmt.Println(err)
  21598. }
  21599. saveLog(result, request_log, "2204", "上传费用明细")
  21600. userJSONBytes, _ := json.Marshal(dat)
  21601. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  21602. utils.ErrorLog("解析失败:%v", err)
  21603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21604. return
  21605. }
  21606. res.InfRefmsgid = resFour10265.InfRefmsgid
  21607. res.Output = resFour10265.Output
  21608. res.ErrMsg = resFour10265.ErrMsg
  21609. res.Cainfo = resFour10265.Cainfo
  21610. res.WarnMsg = resFour10265.WarnMsg
  21611. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  21612. res.Infcode = infocode
  21613. } else {
  21614. 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)
  21615. var dat map[string]interface{}
  21616. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21617. fmt.Println(dat)
  21618. } else {
  21619. fmt.Println(err)
  21620. }
  21621. saveLog(result, request_log, "2204", "上传费用明细")
  21622. userJSONBytes, _ := json.Marshal(dat)
  21623. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21624. utils.ErrorLog("解析失败:%v", err)
  21625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21626. return
  21627. }
  21628. }
  21629. }
  21630. }
  21631. var total_two float64
  21632. if res.Infcode == 0 {
  21633. order := &models.HisOrder{
  21634. UserOrgId: adminUser.CurrentOrgId,
  21635. HisPatientId: his.ID,
  21636. PatientId: his.PatientId,
  21637. SettleAccountsDate: recordDateTime,
  21638. Ctime: time.Now().Unix(),
  21639. Mtime: time.Now().Unix(),
  21640. MdtrtId: his.Number,
  21641. PsnNo: his.PsnNo,
  21642. MedType: strconv.FormatInt(reg_type, 10),
  21643. Status: 1,
  21644. Number: chrg_bchno,
  21645. Infcode: res.Infcode,
  21646. WarnMsg: res.WarnMsg,
  21647. Cainfo: res.Cainfo,
  21648. ErrMsg: res.ErrMsg,
  21649. RespondTime: res.RefmsgTime,
  21650. InfRefmsgid: res.InfRefmsgid,
  21651. OrderStatus: 1,
  21652. IsMedicineInsurance: 1,
  21653. SettleType: settle_accounts_type,
  21654. SettleStartTime: start_time,
  21655. SettleEndTime: end_time,
  21656. Creator: roles.AdminUserId,
  21657. Modify: roles.AdminUserId,
  21658. PType: 2,
  21659. Diagnosis: diagnosis_id,
  21660. }
  21661. err = service.CreateOrder(order)
  21662. if err != nil {
  21663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  21664. return
  21665. }
  21666. for _, item := range res.Output.Result {
  21667. temp := strings.Split(item.FeedetlSn, "-")
  21668. var advice_id int64 = 0
  21669. var project_id int64 = 0
  21670. var types int64 = 0
  21671. id, _ := strconv.ParseInt(temp[2], 10, 64)
  21672. types, _ = strconv.ParseInt(temp[1], 10, 64)
  21673. if temp[1] == "1" {
  21674. advice_id = id
  21675. project_id = 0
  21676. } else if temp[1] == "2" {
  21677. advice_id = 0
  21678. project_id = id
  21679. }
  21680. total_two = total_two + item.DetItemFeeSumamt
  21681. info := &models.HisOrderInfo{
  21682. OrderNumber: order.Number,
  21683. FeedetlSn: item.FeedetlSn,
  21684. UploadDate: time.Now().Unix(),
  21685. AdviceId: advice_id,
  21686. DetItemFeeSumamt: item.DetItemFeeSumamt,
  21687. Cnt: item.Cnt,
  21688. Pric: float64(item.Pric),
  21689. PatientId: his.PatientId,
  21690. PricUplmtAmt: item.PricUplmtAmt,
  21691. SelfpayProp: item.SelfpayProp,
  21692. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  21693. OverlmtAmt: item.OverlmtAmt,
  21694. PreselfpayAmt: item.PreselfpayAmt,
  21695. BasMednFlag: item.BasMednFlag,
  21696. MedChrgitmType: item.MedChrgitmType,
  21697. HiNegoDrugFlag: item.HiNegoDrugFlag,
  21698. Status: 1,
  21699. Memo: item.Memo,
  21700. Mtime: time.Now().Unix(),
  21701. InscpScpAmt: item.InscpScpAmt,
  21702. DrtReimFlag: item.DrtReimFlag,
  21703. Ctime: time.Now().Unix(),
  21704. ListSpItemFlag: item.ListSpItemFlag,
  21705. ChldMedcFlag: item.ChldMedcFlag,
  21706. LmtUsedFlag: item.LmtUsedFlag,
  21707. ChrgitmLv: item.ChrgitmLv,
  21708. UserOrgId: adminUser.CurrentOrgId,
  21709. HisPatientId: his.ID,
  21710. OrderId: order.ID,
  21711. ProjectId: project_id,
  21712. Type: types,
  21713. }
  21714. service.CreateOrderInfo(info)
  21715. }
  21716. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  21717. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  21718. var total float64
  21719. for _, item := range prescriptions {
  21720. if item.Type == 1 { //药品
  21721. for _, subItem := range item.HisDoctorAdviceInfo {
  21722. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  21723. total_one := price * subItem.PrescribingNumber
  21724. fmt.Println("subItem")
  21725. fmt.Println(subItem.Price)
  21726. fmt.Println("price")
  21727. fmt.Println(price)
  21728. fmt.Println("total_one")
  21729. fmt.Println(total_one)
  21730. total = total + total_one
  21731. fmt.Println(total)
  21732. }
  21733. }
  21734. if item.Type == 2 { //项目
  21735. for _, subItem := range item.HisPrescriptionProject {
  21736. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  21737. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  21738. total_one := price * cnt
  21739. total = total + total_one
  21740. }
  21741. }
  21742. }
  21743. allTotal := fmt.Sprintf("%.2f", total)
  21744. if res.Infcode == 0 {
  21745. var rf []*ResultFive
  21746. json.Unmarshal([]byte(his.Iinfo), &rf)
  21747. chrg_bchno := chrg_bchno
  21748. cert_no := his.Certno
  21749. var insutypes []string
  21750. var insutype string
  21751. var is390 int = 0
  21752. var is310 int = 0
  21753. for _, item := range rf {
  21754. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21755. insutypes = append(insutypes, item.Insutype)
  21756. }
  21757. }
  21758. if len(insutypes) == 1 {
  21759. insutype = insutypes[0]
  21760. } else {
  21761. for _, i := range insutypes {
  21762. if i == "390" {
  21763. is390 = 1
  21764. }
  21765. if i == "310" {
  21766. is310 = 1
  21767. }
  21768. }
  21769. }
  21770. if is390 == 1 {
  21771. insutype = "390"
  21772. }
  21773. if is310 == 1 {
  21774. insutype = "310"
  21775. }
  21776. if len(insutypes) == 0 {
  21777. insutype = "390"
  21778. }
  21779. if len(insutypes) == 2 {
  21780. insutype = strconv.FormatInt(his.SocialType, 10)
  21781. }
  21782. //insutype = "390"
  21783. if his.IdCardType == 1 {
  21784. cert_no = his.MedicalInsuranceNumber
  21785. } else {
  21786. cert_no = his.Certno
  21787. }
  21788. var res ResultSeven
  21789. var ahres ResultSevenAH
  21790. var resSeven10265 ResultSeven10265
  21791. var resSeven10265Two ResultSeven10265Two
  21792. var gzresSeven10265Two GZResultSeven10265Two
  21793. if miConfig.MdtrtareaAdmvs == "421300" {
  21794. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  21795. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21796. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21797. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21798. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21799. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21800. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21801. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21802. resp, requestErr := http.Get(api)
  21803. if requestErr != nil {
  21804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21805. return
  21806. }
  21807. body, ioErr := ioutil.ReadAll(resp.Body)
  21808. if ioErr != nil {
  21809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21811. return
  21812. }
  21813. var respJSON map[string]interface{}
  21814. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21817. return
  21818. }
  21819. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21820. result, _ := json.Marshal(respJSON)
  21821. fmt.Println("log")
  21822. fmt.Println(string(result))
  21823. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21824. utils.ErrorLog("解析失败:%v", err)
  21825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21826. return
  21827. }
  21828. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21829. if reg_type == 11 && his.Insutype == "390" {
  21830. reg_type = 110104
  21831. }
  21832. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21833. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21834. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21835. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21836. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21837. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21838. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21839. resp, requestErr := http.Get(api)
  21840. if requestErr != nil {
  21841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21842. return
  21843. }
  21844. body, ioErr := ioutil.ReadAll(resp.Body)
  21845. if ioErr != nil {
  21846. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21848. return
  21849. }
  21850. var respJSON map[string]interface{}
  21851. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21854. return
  21855. }
  21856. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21857. result, _ := json.Marshal(respJSON)
  21858. fmt.Println("log")
  21859. fmt.Println(string(result))
  21860. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21861. utils.ErrorLog("解析失败:%v", err)
  21862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21863. return
  21864. }
  21865. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21866. if reg_type == 11 && his.Insutype == "390" {
  21867. reg_type = 110104
  21868. }
  21869. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21870. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21871. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21872. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21873. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21874. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21875. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21876. resp, requestErr := http.Get(api)
  21877. if requestErr != nil {
  21878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21879. return
  21880. }
  21881. body, ioErr := ioutil.ReadAll(resp.Body)
  21882. if ioErr != nil {
  21883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21885. return
  21886. }
  21887. var respJSON map[string]interface{}
  21888. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21891. return
  21892. }
  21893. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21894. result, _ := json.Marshal(respJSON)
  21895. fmt.Println("log")
  21896. fmt.Println(string(result))
  21897. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21898. utils.ErrorLog("解析失败:%v", err)
  21899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21900. return
  21901. }
  21902. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21903. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  21904. if result3101.Infcode == "0" {
  21905. if len(result3101.Output.Result) > 0 {
  21906. var errMsgs []string
  21907. for _, item := range result3101.Output.Result {
  21908. errMsgs = append(errMsgs, item.VolaCont)
  21909. }
  21910. c.ServeSuccessJSON(map[string]interface{}{
  21911. "failed_code": -10,
  21912. "msg": errMsgs,
  21913. })
  21914. return
  21915. } else {
  21916. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21917. if his.IdCardType != 4 {
  21918. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21919. bas := strings.Split(psn_info.CardInfo, "|")
  21920. if his.IdCardType == 1 {
  21921. cert_no = bas[2]
  21922. } else {
  21923. cert_no = bas[1]
  21924. }
  21925. } else {
  21926. cert_no = his.Certno
  21927. }
  21928. //江苏地区国家医保医疗类别
  21929. //职工透析:医疗类别选特殊情况门诊9933
  21930. //居民血透门慢: 医疗类别选门诊慢病1402
  21931. //var med_type string
  21932. //if his.Insutype == "310" {
  21933. // if reg_type == 14 {
  21934. // med_type = "9933"
  21935. // } else if reg_type == 11 {
  21936. // med_type = "11"
  21937. //
  21938. // }
  21939. //} else if his.Insutype == "390" {
  21940. // if reg_type == 14 {
  21941. // med_type = "1402"
  21942. // } else if reg_type == 11 {
  21943. // med_type = "11"
  21944. // }
  21945. //}
  21946. var api string
  21947. if miConfig.MdtrtareaAdmvs == "320921" {
  21948. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21949. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21950. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21951. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21952. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21953. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21954. "&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
  21955. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21956. } else {
  21957. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21958. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21959. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21960. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21961. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21962. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21963. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21964. "&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
  21965. }
  21966. resp, requestErr := http.Get(api)
  21967. if requestErr != nil {
  21968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21969. return
  21970. }
  21971. body, ioErr := ioutil.ReadAll(resp.Body)
  21972. if ioErr != nil {
  21973. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21975. return
  21976. }
  21977. var respJSON map[string]interface{}
  21978. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21981. return
  21982. }
  21983. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21984. result, _ := json.Marshal(respJSON)
  21985. fmt.Println("log")
  21986. fmt.Println(string(result))
  21987. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  21988. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  21989. utils.ErrorLog("解析失败:%v", err)
  21990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21991. return
  21992. }
  21993. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21994. res.Output = resSeven10265.Output
  21995. res.ErrMsg = resSeven10265.ErrMsg
  21996. res.Cainfo = resSeven10265.Cainfo
  21997. res.WarnMsg = resSeven10265.WarnMsg
  21998. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21999. res.Infcode = infocode
  22000. } else {
  22001. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  22002. utils.ErrorLog("解析失败:%v", err)
  22003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22004. return
  22005. }
  22006. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  22007. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  22008. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  22009. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  22010. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22011. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  22012. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  22013. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  22014. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  22015. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  22016. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  22017. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  22018. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  22019. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  22020. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22021. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  22022. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  22023. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  22024. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  22025. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  22026. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  22027. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22028. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  22029. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  22030. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  22031. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  22032. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  22033. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  22034. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  22035. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  22036. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  22037. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  22038. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  22039. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  22040. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  22041. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22042. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  22043. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  22044. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  22045. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  22046. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  22047. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  22048. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  22049. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  22050. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  22051. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  22052. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  22053. res.ErrMsg = resSeven10265Two.ErrMsg
  22054. res.Cainfo = resSeven10265Two.Cainfo
  22055. res.WarnMsg = resSeven10265Two.WarnMsg
  22056. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  22057. res.Infcode = infocode
  22058. }
  22059. }
  22060. }
  22061. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22062. psn_info, _ := service.GetPsnByPatientId(id)
  22063. var verify_number string
  22064. if psn_info.IdCardType == 4 {
  22065. verify_number = psn_info.VerifyNumber
  22066. } else if psn_info.IdCardType == 1 {
  22067. bas := strings.Split(psn_info.CardInfo, "|")
  22068. cardNumber := bas[2]
  22069. verify_number = cardNumber
  22070. } else {
  22071. psn_info.IdCardType = 2
  22072. verify_number = psn_info.Certno
  22073. }
  22074. var api string
  22075. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22076. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22077. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22078. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22079. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  22080. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22081. "&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
  22082. resp, requestErr := http.Get(api)
  22083. if requestErr != nil {
  22084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22085. return
  22086. }
  22087. body, ioErr := ioutil.ReadAll(resp.Body)
  22088. if ioErr != nil {
  22089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22091. return
  22092. }
  22093. var respJSON map[string]interface{}
  22094. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22097. return
  22098. }
  22099. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22100. result, _ := json.Marshal(respJSON)
  22101. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22102. utils.ErrorLog("解析失败:%v", err)
  22103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22104. return
  22105. }
  22106. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22107. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  22108. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  22109. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  22110. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  22111. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  22112. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  22113. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  22114. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  22115. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  22116. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  22117. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  22118. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  22119. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  22120. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  22121. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  22122. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  22123. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  22124. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  22125. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  22126. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22127. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  22128. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  22129. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  22130. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  22131. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  22132. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  22133. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  22134. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  22135. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  22136. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  22137. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  22138. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  22139. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  22140. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22141. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  22142. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  22143. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  22144. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  22145. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  22146. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  22147. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  22148. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  22149. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  22150. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  22151. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  22152. res.ErrMsg = resSeven10265.ErrMsg
  22153. res.Cainfo = resSeven10265.Cainfo
  22154. res.WarnMsg = resSeven10265.WarnMsg
  22155. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22156. res.Infcode = infocode
  22157. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22158. acct_used_flag := "1"
  22159. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  22160. var result string
  22161. var request_log string
  22162. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  22163. 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)
  22164. } else {
  22165. 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)
  22166. }
  22167. var dat map[string]interface{}
  22168. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22169. fmt.Println(dat)
  22170. } else {
  22171. fmt.Println(err)
  22172. }
  22173. saveLog(result, request_log, "2206", "预结算")
  22174. userJSONBytes, _ := json.Marshal(dat)
  22175. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22176. utils.ErrorLog("解析失败:%v", err)
  22177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22178. return
  22179. }
  22180. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22181. var result string
  22182. var request_log string
  22183. if his.IdCardType == 2 {
  22184. 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, "")
  22185. } else if his.IdCardType == 1 {
  22186. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22187. bas := strings.Split(psn_info.CardInfo, "|")
  22188. basNumber := bas[2]
  22189. card_sn := bas[3]
  22190. var rf []*ResultFive
  22191. json.Unmarshal([]byte(his.Iinfo), &rf)
  22192. var psn_type string
  22193. for _, item := range rf {
  22194. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  22195. psn_type = item.PsnType
  22196. }
  22197. }
  22198. 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)
  22199. } else {
  22200. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22201. 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, "")
  22202. }
  22203. var dat map[string]interface{}
  22204. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22205. fmt.Println(dat)
  22206. } else {
  22207. fmt.Println(err)
  22208. }
  22209. saveLog(result, request_log, "2206", "预结算")
  22210. userJSONBytes, _ := json.Marshal(dat)
  22211. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22212. utils.ErrorLog("解析失败:%v", err)
  22213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22214. return
  22215. }
  22216. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22217. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22218. if his.IdCardType == 4 {
  22219. psn_info.VerifyNumber = psn_info.VerifyNumber
  22220. cert_no = psn_info.Certno
  22221. } else if his.IdCardType == 2 {
  22222. cert_no = psn_info.Certno
  22223. psn_info.VerifyNumber = psn_info.Certno
  22224. } else {
  22225. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22226. bas := strings.Split(psn_info.CardInfo, "|")
  22227. if his.IdCardType == 1 {
  22228. cert_no = bas[2]
  22229. } else {
  22230. cert_no = bas[1]
  22231. }
  22232. }
  22233. var api string
  22234. var med_type string
  22235. if his.Insutype == "390" {
  22236. if reg_type == 992102 {
  22237. med_type = "992102"
  22238. }
  22239. if reg_type == 140104 {
  22240. med_type = "140104"
  22241. }
  22242. if reg_type == 14 {
  22243. med_type = "140104"
  22244. }
  22245. } else if his.Insutype == "310" {
  22246. if reg_type == 992102 {
  22247. med_type = "992102"
  22248. }
  22249. if reg_type == 14 {
  22250. med_type = "14"
  22251. }
  22252. }
  22253. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22254. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22255. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22256. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22257. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22258. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22259. "&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
  22260. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22261. resp, requestErr := http.Get(api)
  22262. if requestErr != nil {
  22263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22264. return
  22265. }
  22266. body, ioErr := ioutil.ReadAll(resp.Body)
  22267. if ioErr != nil {
  22268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22270. return
  22271. }
  22272. var respJSON map[string]interface{}
  22273. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22276. return
  22277. }
  22278. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22279. if status == "0" {
  22280. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22281. c.ServeSuccessJSON(map[string]interface{}{
  22282. "failed_code": -10,
  22283. "msg": err_msg,
  22284. })
  22285. return
  22286. }
  22287. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22288. result, _ := json.Marshal(respJSON)
  22289. fmt.Println("log")
  22290. fmt.Println(string(result))
  22291. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  22292. utils.ErrorLog("解析失败:%v", err)
  22293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22294. return
  22295. }
  22296. res.InfRefmsgid = ahres.InfRefmsgid
  22297. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  22298. // 创建对应的Time类型
  22299. t := time.UnixMilli(timestamp)
  22300. // 格式化成指定的日期字符串
  22301. str := t.Format("2006-01-02 15:04:05")
  22302. res.Output.Setlinfo.SetlTime = str
  22303. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  22304. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  22305. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  22306. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  22307. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  22308. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  22309. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  22310. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  22311. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  22312. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  22313. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  22314. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  22315. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  22316. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  22317. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  22318. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  22319. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  22320. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  22321. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  22322. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22323. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  22324. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  22325. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  22326. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  22327. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  22328. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  22329. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  22330. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  22331. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  22332. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  22333. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  22334. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  22335. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  22336. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  22337. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  22338. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  22339. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  22340. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  22341. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  22342. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  22343. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  22344. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  22345. //res.Output.Setldetail = ahres.Output.Setldetail
  22346. res.ErrMsg = ahres.ErrMsg
  22347. res.Cainfo = ahres.Cainfo
  22348. res.WarnMsg = ahres.WarnMsg
  22349. res.Infcode = ahres.Infcode
  22350. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22351. var result string
  22352. var request_log string
  22353. if his.IdCardType == 2 {
  22354. 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")
  22355. } else if his.IdCardType == 1 {
  22356. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22357. bas := strings.Split(psn_info.CardInfo, "|")
  22358. basNumber := bas[2]
  22359. card_sn := bas[3]
  22360. 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")
  22361. } else {
  22362. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22363. 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")
  22364. }
  22365. var dat map[string]interface{}
  22366. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22367. fmt.Println(dat)
  22368. } else {
  22369. fmt.Println(err)
  22370. }
  22371. saveLog(result, request_log, "2206", "预结算")
  22372. userJSONBytes, _ := json.Marshal(dat)
  22373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22374. utils.ErrorLog("解析失败:%v", err)
  22375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22376. return
  22377. }
  22378. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22379. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22380. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22381. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22382. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22383. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22384. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22385. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22386. resp, requestErr := http.Get(api)
  22387. if requestErr != nil {
  22388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22389. return
  22390. }
  22391. body, ioErr := ioutil.ReadAll(resp.Body)
  22392. if ioErr != nil {
  22393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22395. return
  22396. }
  22397. var respJSON map[string]interface{}
  22398. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22401. return
  22402. }
  22403. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22404. result, _ := json.Marshal(respJSON)
  22405. fmt.Println("log")
  22406. fmt.Println(string(result))
  22407. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22408. utils.ErrorLog("解析失败:%v", err)
  22409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22410. return
  22411. }
  22412. } else {
  22413. if miConfig.MdtrtareaAdmvs == "441202" {
  22414. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  22415. if result3101.Infcode == 0 {
  22416. if len(result3101.Output.Result) > 0 {
  22417. var errMsgs []string
  22418. for _, item := range result3101.Output.Result {
  22419. errMsgs = append(errMsgs, item.VolaCont)
  22420. }
  22421. c.ServeSuccessJSON(map[string]interface{}{
  22422. "failed_code": -10,
  22423. "msg": errMsgs,
  22424. })
  22425. return
  22426. } else {
  22427. var result string
  22428. var request_log string
  22429. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22430. allTotal = fmt.Sprintf("%.2f", total_two)
  22431. if his.IdCardType == 4 {
  22432. 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)
  22433. } else {
  22434. 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)
  22435. }
  22436. var dat map[string]interface{}
  22437. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22438. fmt.Println(dat)
  22439. } else {
  22440. fmt.Println(err)
  22441. }
  22442. saveLog(result, request_log, "2206", "预结算")
  22443. //userJSONBytes, _ := json.Marshal(dat)
  22444. //
  22445. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22446. // utils.ErrorLog("解析失败:%v", err)
  22447. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22448. // return
  22449. //}
  22450. userJSONBytes, _ := json.Marshal(dat)
  22451. if miConfig.Code == "H15049901371" {
  22452. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  22453. utils.ErrorLog("解析失败:%v", err)
  22454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22455. return
  22456. }
  22457. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22458. res.Output = resSeven10265.Output
  22459. res.ErrMsg = resSeven10265.ErrMsg
  22460. res.Cainfo = resSeven10265.Cainfo
  22461. res.WarnMsg = resSeven10265.WarnMsg
  22462. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22463. res.Infcode = infocode
  22464. } else {
  22465. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22466. utils.ErrorLog("解析失败:%v", err)
  22467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22468. return
  22469. }
  22470. }
  22471. }
  22472. } else {
  22473. c.ServeSuccessJSON(map[string]interface{}{
  22474. "failed_code": -10,
  22475. "msg": result3101.ErrMsg,
  22476. })
  22477. return
  22478. }
  22479. } else {
  22480. var result string
  22481. var request_log string
  22482. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22483. allTotal = fmt.Sprintf("%.2f", total_two)
  22484. if his.IdCardType == 4 {
  22485. 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)
  22486. } else {
  22487. 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)
  22488. }
  22489. var dat map[string]interface{}
  22490. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22491. fmt.Println(dat)
  22492. } else {
  22493. fmt.Println(err)
  22494. }
  22495. saveLog(result, request_log, "2206", "预结算")
  22496. //userJSONBytes, _ := json.Marshal(dat)
  22497. //
  22498. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22499. // utils.ErrorLog("解析失败:%v", err)
  22500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22501. // return
  22502. //}
  22503. userJSONBytes, _ := json.Marshal(dat)
  22504. if miConfig.Code == "H15049901371" {
  22505. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  22506. utils.ErrorLog("解析失败:%v", err)
  22507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22508. return
  22509. }
  22510. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22511. res.Output = resSeven10265.Output
  22512. res.ErrMsg = resSeven10265.ErrMsg
  22513. res.Cainfo = resSeven10265.Cainfo
  22514. res.WarnMsg = resSeven10265.WarnMsg
  22515. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22516. res.Infcode = infocode
  22517. } else {
  22518. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  22519. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  22520. utils.ErrorLog("解析失败:%v", err)
  22521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22522. return
  22523. }
  22524. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  22525. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  22526. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  22527. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  22528. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  22529. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  22530. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  22531. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  22532. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  22533. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22534. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22535. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22536. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22537. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  22538. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  22539. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  22540. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  22541. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  22542. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  22543. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  22544. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22545. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  22546. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  22547. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  22548. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  22549. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  22550. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  22551. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  22552. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  22553. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  22554. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  22555. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  22556. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  22557. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  22558. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22559. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  22560. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  22561. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  22562. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22563. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  22564. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  22565. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  22566. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  22567. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  22568. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  22569. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  22570. res.ErrMsg = gzresSeven10265Two.ErrMsg
  22571. res.Cainfo = gzresSeven10265Two.Cainfo
  22572. res.WarnMsg = gzresSeven10265Two.WarnMsg
  22573. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  22574. //res.Infcode = infocode
  22575. } else {
  22576. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22577. utils.ErrorLog("解析失败:%v", err)
  22578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22579. return
  22580. }
  22581. }
  22582. }
  22583. }
  22584. }
  22585. utils.ErrorLog("解析失败:%v", res.Infcode)
  22586. if res.Infcode == -1 {
  22587. errlog := &models.HisOrderError{
  22588. UserOrgId: adminUser.CurrentOrgId,
  22589. Ctime: time.Now().Unix(),
  22590. Mtime: time.Now().Unix(),
  22591. Number: chrg_bchno,
  22592. ErrMsg: res.ErrMsg,
  22593. Status: 1,
  22594. PatientId: id,
  22595. RecordTime: recordDateTime,
  22596. Stage: 20,
  22597. }
  22598. service.CreateErrMsgLog(errlog)
  22599. c.ServeSuccessJSON(map[string]interface{}{
  22600. "failed_code": -10,
  22601. "msg": res.ErrMsg,
  22602. })
  22603. return
  22604. }
  22605. if res.Infcode != 0 {
  22606. errlog := &models.HisOrderError{
  22607. UserOrgId: adminUser.CurrentOrgId,
  22608. Ctime: time.Now().Unix(),
  22609. Mtime: time.Now().Unix(),
  22610. Number: chrg_bchno,
  22611. ErrMsg: res.ErrMsg,
  22612. Status: 1,
  22613. PatientId: id,
  22614. RecordTime: recordDateTime,
  22615. Stage: 20,
  22616. }
  22617. service.CreateErrMsgLog(errlog)
  22618. c.ServeSuccessJSON(map[string]interface{}{
  22619. "failed_code": -10,
  22620. "msg": res.ErrMsg,
  22621. })
  22622. return
  22623. } else {
  22624. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  22625. order.OrderStatus = 1
  22626. order.IsPre = 1
  22627. order.Status = 1
  22628. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  22629. order.SetlId = res.Output.Setlinfo.SetlID
  22630. order.PsnNo = res.Output.Setlinfo.PsnNo
  22631. order.PsnName = res.Output.Setlinfo.PsnName
  22632. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  22633. order.Certno = res.Output.Setlinfo.Certno
  22634. order.Gend = res.Output.Setlinfo.Gend
  22635. order.Naty = res.Output.Setlinfo.Naty
  22636. order.Age = res.Output.Setlinfo.Age
  22637. order.Insutype = res.Output.Setlinfo.Insutype
  22638. order.PsnType = res.Output.Setlinfo.PsnType
  22639. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  22640. order.SetlTime = res.Output.Setlinfo.SetlTime
  22641. order.AcctUsedFlag = acct_used_flag
  22642. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  22643. if res.Output.Setlinfo.MedType == "140101" {
  22644. order.MedType = "14"
  22645. } else {
  22646. if res.Output.Setlinfo.MedType == "110104" {
  22647. order.MedType = "11"
  22648. } else {
  22649. order.MedType = res.Output.Setlinfo.MedType
  22650. }
  22651. }
  22652. if res.Output.Setlinfo.MedType == "992102" {
  22653. order.MedType = "992102"
  22654. }
  22655. if res.Output.Setlinfo.MedType == "140104" {
  22656. order.MedType = "140104"
  22657. }
  22658. if res.Output.Setlinfo.MedType == "14" {
  22659. order.MedType = "14"
  22660. }
  22661. if reg_type == 1112 {
  22662. order.MedType = "1112"
  22663. }
  22664. if reg_type == 1111 {
  22665. order.MedType = "1111"
  22666. }
  22667. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  22668. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  22669. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  22670. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  22671. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  22672. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  22673. order.HifpPay = res.Output.Setlinfo.HifpPay
  22674. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  22675. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  22676. order.HifesPay = res.Output.Setlinfo.HifesPay
  22677. order.HifobPay = res.Output.Setlinfo.HifobPay
  22678. order.MafPay = res.Output.Setlinfo.MafPay
  22679. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  22680. order.OthPay = res.Output.Setlinfo.OthPay
  22681. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  22682. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  22683. order.AcctPay = res.Output.Setlinfo.AcctPay
  22684. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  22685. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  22686. order.Balc = res.Output.Setlinfo.Balc
  22687. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  22688. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  22689. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  22690. order.ClrWay = res.Output.Setlinfo.ClrWay
  22691. order.Creator = order.Creator
  22692. order.Modify = roles.AdminUserId
  22693. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  22694. //detailStr := string(setlDetail)
  22695. //order.SetlDetail = detailStr
  22696. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  22697. err = service.UpDateOrder(order)
  22698. if err == nil {
  22699. c.ServeSuccessJSON(map[string]interface{}{
  22700. "msg": "预结算成功",
  22701. })
  22702. } else {
  22703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  22704. return
  22705. }
  22706. }
  22707. } else {
  22708. adminUser := c.GetAdminUserInfo()
  22709. errlog := &models.HisOrderError{
  22710. UserOrgId: adminUser.CurrentOrgId,
  22711. Ctime: time.Now().Unix(),
  22712. Mtime: time.Now().Unix(),
  22713. ErrMsg: res.ErrMsg,
  22714. Status: 1,
  22715. PatientId: id,
  22716. RecordTime: recordDateTime,
  22717. Stage: 4,
  22718. }
  22719. service.CreateErrMsgLog(errlog)
  22720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  22721. return
  22722. }
  22723. } else {
  22724. if miConfig.MdtrtareaAdmvs == "150499" {
  22725. order := &models.HisOrder{
  22726. UserOrgId: adminUser.CurrentOrgId,
  22727. HisPatientId: his.ID,
  22728. PatientId: his.PatientId,
  22729. SettleAccountsDate: recordDateTime,
  22730. Ctime: time.Now().Unix(),
  22731. Mtime: time.Now().Unix(),
  22732. MdtrtId: his.Number,
  22733. PsnNo: his.PsnNo,
  22734. MedType: strconv.FormatInt(reg_type, 10),
  22735. Status: 1,
  22736. Number: chrg_bchno,
  22737. Infcode: res.Infcode,
  22738. WarnMsg: res.WarnMsg,
  22739. Cainfo: res.Cainfo,
  22740. ErrMsg: res.ErrMsg,
  22741. RespondTime: res.RefmsgTime,
  22742. InfRefmsgid: res.InfRefmsgid,
  22743. OrderStatus: 1,
  22744. IsMedicineInsurance: 1,
  22745. SettleType: settle_accounts_type,
  22746. SettleStartTime: start_time,
  22747. SettleEndTime: end_time,
  22748. Creator: roles.AdminUserId,
  22749. Modify: roles.AdminUserId,
  22750. PType: 2,
  22751. Diagnosis: diagnosis_id,
  22752. }
  22753. err = service.CreateOrder(order)
  22754. if err != nil {
  22755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22756. return
  22757. }
  22758. }
  22759. adminUser := c.GetAdminUserInfo()
  22760. errlog := &models.HisOrderError{
  22761. UserOrgId: adminUser.CurrentOrgId,
  22762. Ctime: time.Now().Unix(),
  22763. Mtime: time.Now().Unix(),
  22764. ErrMsg: res.ErrMsg,
  22765. Status: 1,
  22766. PatientId: id,
  22767. RecordTime: recordDateTime,
  22768. Stage: 4,
  22769. }
  22770. service.CreateErrMsgLog(errlog)
  22771. c.ServeSuccessJSON(map[string]interface{}{
  22772. "failed_code": -10,
  22773. "msg": res.ErrMsg,
  22774. })
  22775. return
  22776. }
  22777. }
  22778. }
  22779. }
  22780. // 退款
  22781. func (c *HisApiController) Refund() {
  22782. order_id, _ := c.GetInt64("order_id")
  22783. admin_user_id, _ := c.GetInt64("admin_user_id")
  22784. adminUser := c.GetAdminUserInfo()
  22785. var order models.HisOrder
  22786. order, _ = service.GetHisOrderByID(order_id)
  22787. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  22788. if order.ID == 0 {
  22789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22790. return
  22791. }
  22792. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  22793. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  22794. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  22795. if config.IsOpen == 1 { //对接了医保,走医保流程
  22796. var res ResultSixteen
  22797. var ahres ResultSevenAH
  22798. var resSixteen10265 ResultSixteen10265
  22799. var resSixteen10265Two ResultSixteen10265Two
  22800. var gz ResultgzSixteen10265Two
  22801. var src_resquest string
  22802. var result string
  22803. if miConfig.MdtrtareaAdmvs == "421300" {
  22804. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  22805. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22806. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22807. resp3, requestErr3 := http.Get(api3)
  22808. if requestErr3 != nil {
  22809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22810. return
  22811. }
  22812. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22813. if ioErr3 != nil {
  22814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22816. return
  22817. }
  22818. var respJSON3 map[string]interface{}
  22819. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22822. return
  22823. }
  22824. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22825. userJSONBytes3, _ := json.Marshal(respJSON3)
  22826. fmt.Println("log")
  22827. fmt.Println(string(userJSONBytes3))
  22828. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22829. utils.ErrorLog("解析失败:%v", err)
  22830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22831. return
  22832. }
  22833. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22834. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  22835. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22836. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22837. resp3, requestErr3 := http.Get(api3)
  22838. if requestErr3 != nil {
  22839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22840. return
  22841. }
  22842. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22843. if ioErr3 != nil {
  22844. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22846. return
  22847. }
  22848. var respJSON3 map[string]interface{}
  22849. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22852. return
  22853. }
  22854. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22855. userJSONBytes3, _ := json.Marshal(respJSON3)
  22856. fmt.Println("log")
  22857. fmt.Println(string(userJSONBytes3))
  22858. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22859. utils.ErrorLog("解析失败:%v", err)
  22860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22861. return
  22862. }
  22863. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22864. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  22865. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22866. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22867. resp3, requestErr3 := http.Get(api3)
  22868. if requestErr3 != nil {
  22869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22870. return
  22871. }
  22872. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22873. if ioErr3 != nil {
  22874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22876. return
  22877. }
  22878. var respJSON3 map[string]interface{}
  22879. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22882. return
  22883. }
  22884. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22885. userJSONBytes3, _ := json.Marshal(respJSON3)
  22886. fmt.Println("log")
  22887. fmt.Println(string(userJSONBytes3))
  22888. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22889. utils.ErrorLog("解析失败:%v", err)
  22890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22891. return
  22892. }
  22893. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22894. var api3 string
  22895. if miConfig.MdtrtareaAdmvs == "320921" {
  22896. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  22897. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22898. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22899. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22900. } else {
  22901. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22902. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  22903. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22904. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22905. }
  22906. resp3, requestErr3 := http.Get(api3)
  22907. if requestErr3 != nil {
  22908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22909. return
  22910. }
  22911. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22912. if ioErr3 != nil {
  22913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22915. return
  22916. }
  22917. var respJSON3 map[string]interface{}
  22918. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22921. return
  22922. }
  22923. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22924. userJSONBytes3, _ := json.Marshal(respJSON3)
  22925. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  22926. utils.ErrorLog("解析失败:%v", err)
  22927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22928. return
  22929. }
  22930. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  22931. res.Output = resSixteen10265.Output
  22932. res.ErrMsg = resSixteen10265.ErrMsg
  22933. res.Cainfo = resSixteen10265.Cainfo
  22934. res.WarnMsg = resSixteen10265.WarnMsg
  22935. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  22936. res.Infcode = infocode
  22937. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22938. var api3 string
  22939. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  22940. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22941. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22942. resp3, requestErr3 := http.Get(api3)
  22943. if requestErr3 != nil {
  22944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22945. return
  22946. }
  22947. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22948. if ioErr3 != nil {
  22949. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22951. return
  22952. }
  22953. var respJSON3 map[string]interface{}
  22954. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22957. return
  22958. }
  22959. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22960. userJSONBytes3, _ := json.Marshal(respJSON3)
  22961. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  22962. utils.ErrorLog("解析失败:%v", err)
  22963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22964. return
  22965. }
  22966. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  22967. res.Output = resSixteen10265.Output
  22968. res.ErrMsg = resSixteen10265.ErrMsg
  22969. res.Cainfo = resSixteen10265.Cainfo
  22970. res.WarnMsg = resSixteen10265.WarnMsg
  22971. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  22972. res.Infcode = infocode
  22973. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22974. 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)
  22975. var dat map[string]interface{}
  22976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22977. fmt.Println(dat)
  22978. } else {
  22979. fmt.Println(err)
  22980. }
  22981. saveLog(result, src_resquest, "2208", "退费")
  22982. userJSONBytes, _ := json.Marshal(dat)
  22983. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22984. utils.ErrorLog("解析失败:%v", err)
  22985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22986. return
  22987. }
  22988. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22989. 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, "")
  22990. var dat map[string]interface{}
  22991. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22992. fmt.Println(dat)
  22993. } else {
  22994. fmt.Println(err)
  22995. }
  22996. saveLog(result, src_resquest, "2208", "退费")
  22997. userJSONBytes, _ := json.Marshal(dat)
  22998. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22999. utils.ErrorLog("解析失败:%v", err)
  23000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23001. return
  23002. }
  23003. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23004. var api3 string
  23005. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  23006. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23007. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23008. resp3, requestErr3 := http.Get(api3)
  23009. if requestErr3 != nil {
  23010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23011. return
  23012. }
  23013. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23014. if ioErr3 != nil {
  23015. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23017. return
  23018. }
  23019. var respJSON3 map[string]interface{}
  23020. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23023. return
  23024. }
  23025. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23026. if status == "0" {
  23027. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23028. c.ServeSuccessJSON(map[string]interface{}{
  23029. "failed_code": -10,
  23030. "msg": err_msg,
  23031. })
  23032. return
  23033. }
  23034. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23035. userJSONBytes3, _ := json.Marshal(respJSON3)
  23036. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23037. // utils.ErrorLog("解析失败:%v", err)
  23038. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23039. // return
  23040. //}
  23041. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  23042. utils.ErrorLog("解析失败:%v", err)
  23043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23044. return
  23045. }
  23046. res.InfRefmsgid = ahres.InfRefmsgid
  23047. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  23048. // 创建对应的Time类型
  23049. t := time.UnixMilli(timestamp)
  23050. // 格式化成指定的日期字符串
  23051. str := t.Format("2006-01-02 15:04:05")
  23052. res.Output.Setlinfo.SetlTime = str
  23053. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  23054. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  23055. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23056. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  23057. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  23058. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  23059. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23060. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  23061. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  23062. //
  23063. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  23064. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  23065. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  23066. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23067. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  23068. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  23069. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  23070. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  23071. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  23072. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  23073. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23074. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  23075. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  23076. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  23077. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  23078. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  23079. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  23080. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  23081. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  23082. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  23083. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  23084. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  23085. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  23086. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  23087. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  23088. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  23089. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  23090. //res.Output.Setldetail = ahres.Output.Setldetail
  23091. res.ErrMsg = ahres.ErrMsg
  23092. res.Cainfo = ahres.Cainfo
  23093. res.WarnMsg = ahres.WarnMsg
  23094. res.Infcode = ahres.Infcode
  23095. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23096. 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, "")
  23097. var dat map[string]interface{}
  23098. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23099. fmt.Println(dat)
  23100. } else {
  23101. fmt.Println(err)
  23102. }
  23103. saveLog(result, src_resquest, "2208", "退费")
  23104. userJSONBytes, _ := json.Marshal(dat)
  23105. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23106. utils.ErrorLog("解析失败:%v", err)
  23107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23108. return
  23109. }
  23110. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23111. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  23112. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23113. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23114. resp3, requestErr3 := http.Get(api3)
  23115. if requestErr3 != nil {
  23116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23117. return
  23118. }
  23119. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23120. if ioErr3 != nil {
  23121. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23123. return
  23124. }
  23125. var respJSON3 map[string]interface{}
  23126. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23129. return
  23130. }
  23131. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23132. userJSONBytes3, _ := json.Marshal(respJSON3)
  23133. fmt.Println("log")
  23134. fmt.Println(string(userJSONBytes3))
  23135. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23136. utils.ErrorLog("解析失败:%v", err)
  23137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23138. return
  23139. }
  23140. } else {
  23141. if miConfig.Code == "H15049901371" {
  23142. 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)
  23143. var dat map[string]interface{}
  23144. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23145. fmt.Println(dat)
  23146. } else {
  23147. fmt.Println(err)
  23148. }
  23149. saveLog(result, src_resquest, "2208", "退费")
  23150. userJSONBytes, _ := json.Marshal(dat)
  23151. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  23152. utils.ErrorLog("解析失败:%v", err)
  23153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23154. return
  23155. }
  23156. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23157. res.Output = resSixteen10265.Output
  23158. res.ErrMsg = resSixteen10265.ErrMsg
  23159. res.Cainfo = resSixteen10265.Cainfo
  23160. res.WarnMsg = resSixteen10265.WarnMsg
  23161. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23162. res.Infcode = infocode
  23163. } else {
  23164. 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)
  23165. var dat map[string]interface{}
  23166. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23167. fmt.Println(dat)
  23168. } else {
  23169. fmt.Println(err)
  23170. }
  23171. saveLog(result, src_resquest, "2208", "退费")
  23172. userJSONBytes, _ := json.Marshal(dat)
  23173. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23174. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  23175. utils.ErrorLog("解析失败:%v", err)
  23176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23177. return
  23178. }
  23179. res.Infcode = gz.Infcode
  23180. } else {
  23181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23182. utils.ErrorLog("解析失败:%v", err)
  23183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23184. return
  23185. }
  23186. }
  23187. }
  23188. }
  23189. if res.Infcode == 0 {
  23190. var res2 ResultSix
  23191. var resSix10265 ResultSix10265
  23192. if miConfig.MdtrtareaAdmvs == "421300" {
  23193. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  23194. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23195. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23196. resp3, requestErr3 := http.Get(api3)
  23197. if requestErr3 != nil {
  23198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23199. return
  23200. }
  23201. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23202. if ioErr3 != nil {
  23203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23205. return
  23206. }
  23207. var respJSON3 map[string]interface{}
  23208. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23211. return
  23212. }
  23213. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23214. userJSONBytes3, _ := json.Marshal(respJSON3)
  23215. fmt.Println("log")
  23216. fmt.Println(string(userJSONBytes3))
  23217. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23218. utils.ErrorLog("解析失败:%v", err)
  23219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23220. return
  23221. }
  23222. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23223. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  23224. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23225. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23226. resp3, requestErr3 := http.Get(api3)
  23227. if requestErr3 != nil {
  23228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23229. return
  23230. }
  23231. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23232. if ioErr3 != nil {
  23233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23235. return
  23236. }
  23237. var respJSON3 map[string]interface{}
  23238. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23241. return
  23242. }
  23243. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23244. userJSONBytes3, _ := json.Marshal(respJSON3)
  23245. fmt.Println("log")
  23246. fmt.Println(string(userJSONBytes3))
  23247. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23248. utils.ErrorLog("解析失败:%v", err)
  23249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23250. return
  23251. }
  23252. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23253. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  23254. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23255. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23256. resp3, requestErr3 := http.Get(api3)
  23257. if requestErr3 != nil {
  23258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23259. return
  23260. }
  23261. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23262. if ioErr3 != nil {
  23263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23265. return
  23266. }
  23267. var respJSON3 map[string]interface{}
  23268. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23271. return
  23272. }
  23273. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23274. userJSONBytes3, _ := json.Marshal(respJSON3)
  23275. fmt.Println("log")
  23276. fmt.Println(string(userJSONBytes3))
  23277. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23278. utils.ErrorLog("解析失败:%v", err)
  23279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23280. return
  23281. }
  23282. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23283. var api3 string
  23284. if miConfig.MdtrtareaAdmvs == "320921" {
  23285. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  23286. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23287. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23288. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23289. } else {
  23290. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23291. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  23292. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23293. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23294. }
  23295. resp3, requestErr3 := http.Get(api3)
  23296. if requestErr3 != nil {
  23297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23298. return
  23299. }
  23300. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23301. if ioErr3 != nil {
  23302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23304. return
  23305. }
  23306. var respJSON3 map[string]interface{}
  23307. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23310. return
  23311. }
  23312. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23313. userJSONBytes3, _ := json.Marshal(respJSON3)
  23314. fmt.Println("log")
  23315. fmt.Println(string(userJSONBytes3))
  23316. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23317. utils.ErrorLog("解析失败:%v", err)
  23318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23319. return
  23320. }
  23321. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23322. res2.Output = resSix10265.Output
  23323. res2.ErrMsg = resSix10265.ErrMsg
  23324. res2.Cainfo = resSix10265.Cainfo
  23325. res2.WarnMsg = resSix10265.WarnMsg
  23326. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23327. res2.Infcode = infocode
  23328. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23329. var api3 string
  23330. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  23331. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23332. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23333. resp3, requestErr3 := http.Get(api3)
  23334. if requestErr3 != nil {
  23335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23336. return
  23337. }
  23338. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23339. if ioErr3 != nil {
  23340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23342. return
  23343. }
  23344. var respJSON3 map[string]interface{}
  23345. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23348. return
  23349. }
  23350. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23351. userJSONBytes3, _ := json.Marshal(respJSON3)
  23352. fmt.Println("log")
  23353. fmt.Println(string(userJSONBytes3))
  23354. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23355. utils.ErrorLog("解析失败:%v", err)
  23356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23357. return
  23358. }
  23359. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23360. res2.Output = resSix10265.Output
  23361. res2.ErrMsg = resSix10265.ErrMsg
  23362. res2.Cainfo = resSix10265.Cainfo
  23363. res2.WarnMsg = resSix10265.WarnMsg
  23364. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23365. res2.Infcode = infocode
  23366. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23367. 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)
  23368. var dat map[string]interface{}
  23369. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23370. fmt.Println(dat)
  23371. } else {
  23372. fmt.Println(err)
  23373. }
  23374. saveLog(result2, src_request, "2205", "撤销明细")
  23375. userJSONBytes, _ := json.Marshal(dat)
  23376. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23377. utils.ErrorLog("解析失败:%v", err)
  23378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23379. return
  23380. }
  23381. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23382. 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, "")
  23383. var dat map[string]interface{}
  23384. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23385. fmt.Println(dat)
  23386. } else {
  23387. fmt.Println(err)
  23388. }
  23389. saveLog(result2, src_request, "2205", "撤销明细")
  23390. userJSONBytes, _ := json.Marshal(dat)
  23391. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23392. utils.ErrorLog("解析失败:%v", err)
  23393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23394. return
  23395. }
  23396. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23397. var api3 string
  23398. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  23399. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23400. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23401. resp3, requestErr3 := http.Get(api3)
  23402. if requestErr3 != nil {
  23403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23404. return
  23405. }
  23406. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23407. if ioErr3 != nil {
  23408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23410. return
  23411. }
  23412. var respJSON3 map[string]interface{}
  23413. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23416. return
  23417. }
  23418. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23419. if status == "0" {
  23420. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23421. c.ServeSuccessJSON(map[string]interface{}{
  23422. "failed_code": -10,
  23423. "msg": err_msg,
  23424. })
  23425. return
  23426. }
  23427. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23428. userJSONBytes3, _ := json.Marshal(respJSON3)
  23429. fmt.Println("log")
  23430. fmt.Println(string(userJSONBytes3))
  23431. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23432. utils.ErrorLog("解析失败:%v", err)
  23433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23434. return
  23435. }
  23436. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23437. 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, "")
  23438. var dat map[string]interface{}
  23439. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23440. fmt.Println(dat)
  23441. } else {
  23442. fmt.Println(err)
  23443. }
  23444. saveLog(result2, src_request, "2205", "撤销明细")
  23445. userJSONBytes, _ := json.Marshal(dat)
  23446. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23447. utils.ErrorLog("解析失败:%v", err)
  23448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23449. return
  23450. }
  23451. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23452. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  23453. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23454. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23455. resp3, requestErr3 := http.Get(api3)
  23456. if requestErr3 != nil {
  23457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23458. return
  23459. }
  23460. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23461. if ioErr3 != nil {
  23462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23464. return
  23465. }
  23466. var respJSON3 map[string]interface{}
  23467. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23470. return
  23471. }
  23472. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23473. userJSONBytes3, _ := json.Marshal(respJSON3)
  23474. fmt.Println("log")
  23475. fmt.Println(string(userJSONBytes3))
  23476. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23477. utils.ErrorLog("解析失败:%v", err)
  23478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23479. return
  23480. }
  23481. } else {
  23482. if miConfig.Code == "H15049901371" {
  23483. 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)
  23484. var dat map[string]interface{}
  23485. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23486. fmt.Println(dat)
  23487. } else {
  23488. fmt.Println(err)
  23489. }
  23490. saveLog(result2, src_request, "2205", "撤销明细")
  23491. userJSONBytes, _ := json.Marshal(dat)
  23492. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  23493. utils.ErrorLog("解析失败:%v", err)
  23494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23495. return
  23496. }
  23497. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23498. res2.Output = resSix10265.Output
  23499. res2.ErrMsg = resSix10265.ErrMsg
  23500. res2.Cainfo = resSix10265.Cainfo
  23501. res2.WarnMsg = resSix10265.WarnMsg
  23502. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23503. res2.Infcode = infocode
  23504. } else {
  23505. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23506. res2.Infcode = 0
  23507. } else {
  23508. 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)
  23509. var dat map[string]interface{}
  23510. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23511. fmt.Println(dat)
  23512. } else {
  23513. fmt.Println(err)
  23514. }
  23515. saveLog(result2, src_request, "2205", "撤销明细")
  23516. userJSONBytes, _ := json.Marshal(dat)
  23517. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23518. utils.ErrorLog("解析失败:%v", err)
  23519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23520. return
  23521. }
  23522. }
  23523. }
  23524. }
  23525. if res2.Infcode == -1 {
  23526. c.ServeSuccessJSON(map[string]interface{}{
  23527. "failed_code": -10,
  23528. "msg": res2.ErrMsg,
  23529. })
  23530. return
  23531. }
  23532. if res2.Infcode == 0 {
  23533. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  23534. if err == nil {
  23535. //当押金不为零时产生退费记录
  23536. if order.Decimal != 0 {
  23537. tmp := strconv.FormatInt(order.ID, 10)
  23538. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  23539. if err != nil {
  23540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23541. return
  23542. }
  23543. }
  23544. c.ServeSuccessJSON(map[string]interface{}{
  23545. "msg": "退费成功",
  23546. })
  23547. } else {
  23548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23549. return
  23550. }
  23551. } else {
  23552. c.ServeSuccessJSON(map[string]interface{}{
  23553. "failed_code": -10,
  23554. "msg": res2.ErrMsg,
  23555. })
  23556. }
  23557. } else {
  23558. c.ServeSuccessJSON(map[string]interface{}{
  23559. "failed_code": -10,
  23560. "msg": res.ErrMsg,
  23561. })
  23562. }
  23563. }
  23564. }
  23565. func (c *HisApiController) RefundNumber() {
  23566. record_time := c.GetString("record_time")
  23567. //patient_id, _ := c.GetInt64("patient_id")
  23568. admin_user_id, _ := c.GetInt64("admin_user_id")
  23569. his_patient_id, _ := c.GetInt64("id")
  23570. timeLayout := "2006-01-02"
  23571. loc, _ := time.LoadLocation("Local")
  23572. adminUser := c.GetAdminUserInfo()
  23573. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23574. fmt.Println(err)
  23575. if err != nil {
  23576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23577. return
  23578. }
  23579. recordDateTime := theTime.Unix()
  23580. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  23581. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  23582. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  23583. //order, _ := service.GetHisOrderByID(order_id)
  23584. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23585. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23586. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23587. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  23588. if count > 0 {
  23589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  23590. return
  23591. }
  23592. if config.IsOpen == 1 { //对接了医保,走医保流程
  23593. var res2 ResultSix
  23594. var res3 GZResultSix
  23595. var resSix10265 ResultSix10265
  23596. if miConfig.MdtrtareaAdmvs == "421300" {
  23597. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  23598. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23599. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23600. resp3, requestErr3 := http.Get(api3)
  23601. if requestErr3 != nil {
  23602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23603. return
  23604. }
  23605. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23606. if ioErr3 != nil {
  23607. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23609. return
  23610. }
  23611. var respJSON3 map[string]interface{}
  23612. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23613. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23615. return
  23616. }
  23617. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23618. userJSONBytes3, _ := json.Marshal(respJSON3)
  23619. fmt.Println("log")
  23620. fmt.Println(string(userJSONBytes3))
  23621. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23622. utils.ErrorLog("解析失败:%v", err)
  23623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23624. return
  23625. }
  23626. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23627. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  23628. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23629. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23630. resp3, requestErr3 := http.Get(api3)
  23631. if requestErr3 != nil {
  23632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23633. return
  23634. }
  23635. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23636. if ioErr3 != nil {
  23637. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23639. return
  23640. }
  23641. var respJSON3 map[string]interface{}
  23642. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23645. return
  23646. }
  23647. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23648. userJSONBytes3, _ := json.Marshal(respJSON3)
  23649. fmt.Println("log")
  23650. fmt.Println(string(userJSONBytes3))
  23651. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23652. utils.ErrorLog("解析失败:%v", err)
  23653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23654. return
  23655. }
  23656. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23657. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  23658. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23659. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23660. resp3, requestErr3 := http.Get(api3)
  23661. if requestErr3 != nil {
  23662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23663. return
  23664. }
  23665. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23666. if ioErr3 != nil {
  23667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23669. return
  23670. }
  23671. var respJSON3 map[string]interface{}
  23672. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23675. return
  23676. }
  23677. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23678. userJSONBytes3, _ := json.Marshal(respJSON3)
  23679. fmt.Println("log")
  23680. fmt.Println(string(userJSONBytes3))
  23681. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23682. utils.ErrorLog("解析失败:%v", err)
  23683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23684. return
  23685. }
  23686. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23687. var api3 string
  23688. if miConfig.MdtrtareaAdmvs == "320921" {
  23689. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  23690. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23691. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23692. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23693. } else {
  23694. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23695. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  23696. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23697. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23698. }
  23699. resp3, requestErr3 := http.Get(api3)
  23700. if requestErr3 != nil {
  23701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23702. return
  23703. }
  23704. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23705. if ioErr3 != nil {
  23706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23708. return
  23709. }
  23710. var respJSON3 map[string]interface{}
  23711. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23714. return
  23715. }
  23716. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23717. userJSONBytes3, _ := json.Marshal(respJSON3)
  23718. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23719. utils.ErrorLog("解析失败:%v", err)
  23720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23721. return
  23722. }
  23723. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23724. res2.Output = resSix10265.Output
  23725. res2.ErrMsg = resSix10265.ErrMsg
  23726. res2.Cainfo = resSix10265.Cainfo
  23727. res2.WarnMsg = resSix10265.WarnMsg
  23728. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23729. res2.Infcode = infocode
  23730. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23731. var api3 string
  23732. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  23733. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23734. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23735. resp3, requestErr3 := http.Get(api3)
  23736. if requestErr3 != nil {
  23737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23738. return
  23739. }
  23740. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23741. if ioErr3 != nil {
  23742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23744. return
  23745. }
  23746. var respJSON3 map[string]interface{}
  23747. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23750. return
  23751. }
  23752. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23753. userJSONBytes3, _ := json.Marshal(respJSON3)
  23754. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23755. utils.ErrorLog("解析失败:%v", err)
  23756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23757. return
  23758. }
  23759. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23760. res2.Output = resSix10265.Output
  23761. res2.ErrMsg = resSix10265.ErrMsg
  23762. res2.Cainfo = resSix10265.Cainfo
  23763. res2.WarnMsg = resSix10265.WarnMsg
  23764. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23765. res2.Infcode = infocode
  23766. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23767. 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)
  23768. var dat map[string]interface{}
  23769. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23770. fmt.Println(dat)
  23771. } else {
  23772. fmt.Println(err)
  23773. }
  23774. saveLog(result, request, "2202", "退号")
  23775. userJSONBytes, _ := json.Marshal(dat)
  23776. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23777. utils.ErrorLog("解析失败:%v", err)
  23778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23779. return
  23780. }
  23781. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23782. 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, "")
  23783. var dat map[string]interface{}
  23784. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23785. fmt.Println(dat)
  23786. } else {
  23787. fmt.Println(err)
  23788. }
  23789. saveLog(result, request, "2202", "退号")
  23790. userJSONBytes, _ := json.Marshal(dat)
  23791. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23792. utils.ErrorLog("解析失败:%v", err)
  23793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23794. return
  23795. }
  23796. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23797. var api3 string
  23798. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  23799. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23800. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23801. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23802. resp3, requestErr3 := http.Get(api3)
  23803. if requestErr3 != nil {
  23804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23805. return
  23806. }
  23807. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23808. if ioErr3 != nil {
  23809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23811. return
  23812. }
  23813. var respJSON3 map[string]interface{}
  23814. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23817. return
  23818. }
  23819. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23820. if status == "0" {
  23821. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23822. c.ServeSuccessJSON(map[string]interface{}{
  23823. "failed_code": -10,
  23824. "msg": err_msg,
  23825. })
  23826. return
  23827. }
  23828. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23829. userJSONBytes3, _ := json.Marshal(respJSON3)
  23830. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23831. utils.ErrorLog("解析失败:%v", err)
  23832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23833. return
  23834. }
  23835. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  23836. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23837. 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, "")
  23838. var dat map[string]interface{}
  23839. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23840. fmt.Println(dat)
  23841. } else {
  23842. fmt.Println(err)
  23843. }
  23844. saveLog(result, request, "2202", "退号")
  23845. userJSONBytes, _ := json.Marshal(dat)
  23846. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23847. utils.ErrorLog("解析失败:%v", err)
  23848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23849. return
  23850. }
  23851. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23852. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  23853. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23854. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  23855. resp3, requestErr3 := http.Get(api3)
  23856. if requestErr3 != nil {
  23857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23858. return
  23859. }
  23860. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23861. if ioErr3 != nil {
  23862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23864. return
  23865. }
  23866. var respJSON3 map[string]interface{}
  23867. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23870. return
  23871. }
  23872. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23873. userJSONBytes3, _ := json.Marshal(respJSON3)
  23874. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23875. utils.ErrorLog("解析失败:%v", err)
  23876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23877. return
  23878. }
  23879. } else {
  23880. var api3 string
  23881. if miConfig.Code == "H15049901371" {
  23882. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  23883. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23884. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23885. } else {
  23886. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  23887. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23888. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  23889. }
  23890. resp3, requestErr3 := http.Get(api3)
  23891. if requestErr3 != nil {
  23892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23893. return
  23894. }
  23895. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23896. if ioErr3 != nil {
  23897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23899. return
  23900. }
  23901. var respJSON3 map[string]interface{}
  23902. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23905. return
  23906. }
  23907. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23908. userJSONBytes3, _ := json.Marshal(respJSON3)
  23909. if miConfig.Code == "H15049901371" {
  23910. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23911. utils.ErrorLog("解析失败:%v", err)
  23912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23913. return
  23914. }
  23915. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23916. res2.Output = resSix10265.Output
  23917. res2.ErrMsg = resSix10265.ErrMsg
  23918. res2.Cainfo = resSix10265.Cainfo
  23919. res2.WarnMsg = resSix10265.WarnMsg
  23920. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23921. res2.Infcode = infocode
  23922. } else {
  23923. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23924. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  23925. utils.ErrorLog("解析失败:%v", err)
  23926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23927. return
  23928. }
  23929. res2.Infcode = res3.Infcode
  23930. } else {
  23931. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23932. utils.ErrorLog("解析失败:%v", err)
  23933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23934. return
  23935. }
  23936. }
  23937. }
  23938. }
  23939. if res2.Infcode == -1 {
  23940. utils.ErrorLog("解析失败:%v", res2.Infcode)
  23941. c.ServeSuccessJSON(map[string]interface{}{
  23942. "failed_code": -10,
  23943. "msg": res2.ErrMsg,
  23944. })
  23945. return
  23946. }
  23947. if res2.Infcode == 0 {
  23948. if err == nil {
  23949. c.ServeSuccessJSON(map[string]interface{}{
  23950. "msg": "退号成功",
  23951. })
  23952. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  23953. } else {
  23954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23955. return
  23956. }
  23957. }
  23958. } else {
  23959. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  23960. //if err == nil {
  23961. // c.ServeSuccessJSON(map[string]interface{}{
  23962. // "msg": "退费成功",
  23963. // })
  23964. //} else {
  23965. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23966. // return
  23967. //}
  23968. }
  23969. }
  23970. func (c *HisApiController) RefundDetail() {
  23971. order_id, _ := c.GetInt64("order_id")
  23972. admin_user_id, _ := c.GetInt64("admin_user_id")
  23973. //his_patient_id, _ := c.GetInt64("his_patient_id")
  23974. number := c.GetString("number")
  23975. record_time := c.GetString("record_time")
  23976. patient_id, _ := c.GetInt64("patient_id")
  23977. //med_type, _ := c.GetInt64("med_type")
  23978. timeLayout := "2006-01-02"
  23979. loc, _ := time.LoadLocation("Local")
  23980. adminUser := c.GetAdminUserInfo()
  23981. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23982. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23983. fmt.Println(err)
  23984. if err != nil {
  23985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23986. return
  23987. }
  23988. recordDateTime := theTime.Unix()
  23989. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  23990. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  23991. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23992. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23993. var order models.HisOrder
  23994. order, _ = service.GetHisOrderByID(order_id)
  23995. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  23996. if config.IsOpen == 1 { //对接了医保,走医保流程
  23997. var res2 ResultSix
  23998. if miConfig.MdtrtareaAdmvs == "421300" {
  23999. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24000. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24001. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24002. resp3, requestErr3 := http.Get(api3)
  24003. if requestErr3 != nil {
  24004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24005. return
  24006. }
  24007. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24008. if ioErr3 != nil {
  24009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24011. return
  24012. }
  24013. var respJSON3 map[string]interface{}
  24014. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24017. return
  24018. }
  24019. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24020. userJSONBytes3, _ := json.Marshal(respJSON3)
  24021. fmt.Println("log")
  24022. fmt.Println(string(userJSONBytes3))
  24023. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24024. utils.ErrorLog("解析失败:%v", err)
  24025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24026. return
  24027. }
  24028. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24029. if err == nil {
  24030. c.ServeSuccessJSON(map[string]interface{}{
  24031. "msg": "撤销明细成功",
  24032. })
  24033. return
  24034. } else {
  24035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24036. return
  24037. }
  24038. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24039. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24040. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24041. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24042. resp3, requestErr3 := http.Get(api3)
  24043. if requestErr3 != nil {
  24044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24045. return
  24046. }
  24047. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24048. if ioErr3 != nil {
  24049. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24051. return
  24052. }
  24053. var respJSON3 map[string]interface{}
  24054. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24055. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24057. return
  24058. }
  24059. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24060. userJSONBytes3, _ := json.Marshal(respJSON3)
  24061. fmt.Println("log")
  24062. fmt.Println(string(userJSONBytes3))
  24063. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24064. utils.ErrorLog("解析失败:%v", err)
  24065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24066. return
  24067. }
  24068. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24069. if err == nil {
  24070. c.ServeSuccessJSON(map[string]interface{}{
  24071. "msg": "撤销明细成功",
  24072. })
  24073. return
  24074. } else {
  24075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24076. return
  24077. }
  24078. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24079. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24080. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24081. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24082. resp3, requestErr3 := http.Get(api3)
  24083. if requestErr3 != nil {
  24084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24085. return
  24086. }
  24087. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24088. if ioErr3 != nil {
  24089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24091. return
  24092. }
  24093. var respJSON3 map[string]interface{}
  24094. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24097. return
  24098. }
  24099. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24100. userJSONBytes3, _ := json.Marshal(respJSON3)
  24101. fmt.Println("log")
  24102. fmt.Println(string(userJSONBytes3))
  24103. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24104. utils.ErrorLog("解析失败:%v", err)
  24105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24106. return
  24107. }
  24108. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24109. if err == nil {
  24110. c.ServeSuccessJSON(map[string]interface{}{
  24111. "msg": "撤销明细成功",
  24112. })
  24113. return
  24114. } else {
  24115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24116. return
  24117. }
  24118. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24119. var resSix10265 ResultSix10265
  24120. var api3 string
  24121. if miConfig.MdtrtareaAdmvs == "320921" {
  24122. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24123. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24124. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24125. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24126. } else {
  24127. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24128. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24129. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24130. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24131. }
  24132. resp3, requestErr3 := http.Get(api3)
  24133. utils.ErrorLog("接口: %v", requestErr3)
  24134. if requestErr3 != nil {
  24135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24136. return
  24137. }
  24138. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24139. if ioErr3 != nil {
  24140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24142. return
  24143. }
  24144. var respJSON3 map[string]interface{}
  24145. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24148. return
  24149. }
  24150. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24151. userJSONBytes3, _ := json.Marshal(respJSON3)
  24152. fmt.Println("log")
  24153. fmt.Println(string(userJSONBytes3))
  24154. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24155. utils.ErrorLog("解析失败:%v", err)
  24156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24157. return
  24158. }
  24159. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24160. res2.Output = resSix10265.Output
  24161. res2.ErrMsg = resSix10265.ErrMsg
  24162. res2.Cainfo = resSix10265.Cainfo
  24163. res2.WarnMsg = resSix10265.WarnMsg
  24164. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24165. res2.Infcode = infocode
  24166. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24167. if err == nil {
  24168. c.ServeSuccessJSON(map[string]interface{}{
  24169. "msg": "撤销明细成功",
  24170. })
  24171. return
  24172. } else {
  24173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24174. return
  24175. }
  24176. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24177. var api3 string
  24178. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  24179. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24180. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24181. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24182. resp3, requestErr3 := http.Get(api3)
  24183. utils.ErrorLog("接口: %v", requestErr3)
  24184. if requestErr3 != nil {
  24185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24186. return
  24187. }
  24188. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24189. if ioErr3 != nil {
  24190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24192. return
  24193. }
  24194. var respJSON3 map[string]interface{}
  24195. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24198. return
  24199. }
  24200. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24201. if status == "0" {
  24202. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24203. c.ServeSuccessJSON(map[string]interface{}{
  24204. "failed_code": -10,
  24205. "msg": err_msg,
  24206. })
  24207. return
  24208. }
  24209. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24210. userJSONBytes3, _ := json.Marshal(respJSON3)
  24211. fmt.Println("log")
  24212. fmt.Println(string(userJSONBytes3))
  24213. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24214. utils.ErrorLog("解析失败:%v", err)
  24215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24216. return
  24217. }
  24218. fmt.Println(res2.Infcode)
  24219. if res2.Infcode == -1 {
  24220. c.ServeSuccessJSON(map[string]interface{}{
  24221. "failed_code": -10,
  24222. "msg": res2.ErrMsg,
  24223. })
  24224. return
  24225. }
  24226. if res2.Infcode == 0 {
  24227. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24228. if err == nil {
  24229. c.ServeSuccessJSON(map[string]interface{}{
  24230. "msg": "撤销明细成功",
  24231. })
  24232. return
  24233. } else {
  24234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24235. return
  24236. }
  24237. } else {
  24238. c.ServeSuccessJSON(map[string]interface{}{
  24239. "failed_code": -10,
  24240. "msg": res2.ErrMsg,
  24241. })
  24242. }
  24243. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24244. if err == nil {
  24245. c.ServeSuccessJSON(map[string]interface{}{
  24246. "msg": "撤销明细成功",
  24247. })
  24248. return
  24249. } else {
  24250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24251. return
  24252. }
  24253. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24254. var resSix10265 ResultSix10265
  24255. var api3 string
  24256. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  24257. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24258. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24259. resp3, requestErr3 := http.Get(api3)
  24260. if requestErr3 != nil {
  24261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24262. return
  24263. }
  24264. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24265. if ioErr3 != nil {
  24266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24268. return
  24269. }
  24270. var respJSON3 map[string]interface{}
  24271. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24274. return
  24275. }
  24276. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24277. userJSONBytes3, _ := json.Marshal(respJSON3)
  24278. fmt.Println("log")
  24279. fmt.Println(string(userJSONBytes3))
  24280. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24281. utils.ErrorLog("解析失败:%v", err)
  24282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24283. return
  24284. }
  24285. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24286. res2.Output = resSix10265.Output
  24287. res2.ErrMsg = resSix10265.ErrMsg
  24288. res2.Cainfo = resSix10265.Cainfo
  24289. res2.WarnMsg = resSix10265.WarnMsg
  24290. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24291. res2.Infcode = infocode
  24292. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24293. if err == nil {
  24294. c.ServeSuccessJSON(map[string]interface{}{
  24295. "msg": "撤销明细成功",
  24296. })
  24297. return
  24298. } else {
  24299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24300. return
  24301. }
  24302. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24303. 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)
  24304. var dat map[string]interface{}
  24305. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24306. fmt.Println(dat)
  24307. } else {
  24308. fmt.Println(err)
  24309. }
  24310. saveLog(result2, src_request, "2205", "撤销明细")
  24311. userJSONBytes, _ := json.Marshal(dat)
  24312. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24313. utils.ErrorLog("解析失败:%v", err)
  24314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24315. return
  24316. }
  24317. if res2.Infcode == 0 {
  24318. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24319. if err == nil {
  24320. c.ServeSuccessJSON(map[string]interface{}{
  24321. "msg": "撤销明细成功",
  24322. })
  24323. return
  24324. } else {
  24325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24326. return
  24327. }
  24328. } else {
  24329. c.ServeSuccessJSON(map[string]interface{}{
  24330. "failed_code": -10,
  24331. "msg": res2.ErrMsg,
  24332. })
  24333. }
  24334. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24335. 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, "")
  24336. var dat map[string]interface{}
  24337. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24338. fmt.Println(dat)
  24339. } else {
  24340. fmt.Println(err)
  24341. }
  24342. saveLog(result2, src_request, "2205", "撤销明细")
  24343. userJSONBytes, _ := json.Marshal(dat)
  24344. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24345. utils.ErrorLog("解析失败:%v", err)
  24346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24347. return
  24348. }
  24349. if res2.Infcode == 0 {
  24350. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24351. if err == nil {
  24352. c.ServeSuccessJSON(map[string]interface{}{
  24353. "msg": "撤销明细成功",
  24354. })
  24355. return
  24356. } else {
  24357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24358. return
  24359. }
  24360. } else {
  24361. c.ServeSuccessJSON(map[string]interface{}{
  24362. "failed_code": -10,
  24363. "msg": res2.ErrMsg,
  24364. })
  24365. }
  24366. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24367. 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, "")
  24368. var dat map[string]interface{}
  24369. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24370. fmt.Println(dat)
  24371. } else {
  24372. fmt.Println(err)
  24373. }
  24374. saveLog(result2, src_request, "2205", "撤销明细")
  24375. userJSONBytes, _ := json.Marshal(dat)
  24376. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24377. utils.ErrorLog("解析失败:%v", err)
  24378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24379. return
  24380. }
  24381. if res2.Infcode == 0 {
  24382. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24383. if err == nil {
  24384. c.ServeSuccessJSON(map[string]interface{}{
  24385. "msg": "撤销明细成功",
  24386. })
  24387. return
  24388. } else {
  24389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24390. return
  24391. }
  24392. } else {
  24393. c.ServeSuccessJSON(map[string]interface{}{
  24394. "failed_code": -10,
  24395. "msg": res2.ErrMsg,
  24396. })
  24397. }
  24398. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24399. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  24400. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24401. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24402. resp2, requestErr2 := http.Get(api2)
  24403. if requestErr2 != nil {
  24404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24405. return
  24406. }
  24407. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  24408. if ioErr2 != nil {
  24409. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  24410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24411. return
  24412. }
  24413. var respJSON2 map[string]interface{}
  24414. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  24415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24417. return
  24418. }
  24419. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24420. userJSONBytes3, _ := json.Marshal(respJSON2)
  24421. fmt.Println("log")
  24422. fmt.Println(string(userJSONBytes3))
  24423. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24424. utils.ErrorLog("解析失败:%v", err)
  24425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24426. return
  24427. }
  24428. if res2.Infcode == 0 {
  24429. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24430. if err == nil {
  24431. c.ServeSuccessJSON(map[string]interface{}{
  24432. "msg": "撤销明细成功",
  24433. })
  24434. return
  24435. } else {
  24436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24437. return
  24438. }
  24439. } else {
  24440. c.ServeSuccessJSON(map[string]interface{}{
  24441. "failed_code": -10,
  24442. "msg": res2.ErrMsg,
  24443. })
  24444. }
  24445. } else {
  24446. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  24447. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24448. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24449. resp2, requestErr2 := http.Get(api2)
  24450. if requestErr2 != nil {
  24451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24452. return
  24453. }
  24454. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  24455. if ioErr2 != nil {
  24456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  24457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24458. return
  24459. }
  24460. var respJSON2 map[string]interface{}
  24461. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  24462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24464. return
  24465. }
  24466. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24467. if err == nil {
  24468. c.ServeSuccessJSON(map[string]interface{}{
  24469. "msg": "撤销明细成功",
  24470. })
  24471. return
  24472. } else {
  24473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24474. return
  24475. }
  24476. }
  24477. } else {
  24478. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24479. if err == nil {
  24480. c.ServeSuccessJSON(map[string]interface{}{
  24481. "msg": "退费成功",
  24482. })
  24483. } else {
  24484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24485. return
  24486. }
  24487. }
  24488. }
  24489. // 对账
  24490. func (c *HisApiController) GetCheckAccount() {
  24491. start_time := c.GetString("start_time")
  24492. end_time := c.GetString("end_time")
  24493. insutype := c.GetString("insutype")
  24494. clr_type := c.GetString("clr_type")
  24495. clr_org := c.GetString("clr_optins")
  24496. admin_user_id, _ := c.GetInt64("admin_user_id")
  24497. adminUser := c.GetAdminUserInfo()
  24498. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24499. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24500. if len(clr_org) == 0 {
  24501. clr_org = miConfig.InsuplcAdmdvs
  24502. }
  24503. timeLayout := "2006-01-02"
  24504. loc, _ := time.LoadLocation("Local")
  24505. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  24506. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  24507. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  24508. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  24509. fixmedins_setl_cnt := int64(len(orders))
  24510. var medfee_sumamt float64
  24511. var acct_pay float64
  24512. var fund_pay_sumamt float64
  24513. for _, item := range orders {
  24514. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  24515. acct_pay = acct_pay + item.AcctPay
  24516. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  24517. }
  24518. var user_name string
  24519. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24520. if role.ID == 0 {
  24521. user_name = "xxx"
  24522. } else {
  24523. user_name = role.UserName
  24524. }
  24525. var res ResultEight
  24526. var res10188 ResultEightFor10188
  24527. if config.IsOpen == 1 {
  24528. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24529. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  24530. "insutype=" + insutype +
  24531. "&clr_type=" + clr_type +
  24532. "&setl_optins=" + clr_org +
  24533. "&stmt_begndate=" + start_time +
  24534. "&stm_enddate=" + end_time +
  24535. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24536. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24537. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24538. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24539. "&fixmedins_code=" + miConfig.Code +
  24540. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24541. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24542. "&secret_key=" + miConfig.SecretKey +
  24543. "&org_name=" + miConfig.OrgName +
  24544. "&doctor=" + user_name +
  24545. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24546. fmt.Println(api)
  24547. resp, requestErr := http.Get(api)
  24548. if requestErr != nil {
  24549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24550. return
  24551. }
  24552. body, ioErr := ioutil.ReadAll(resp.Body)
  24553. fmt.Println(body)
  24554. if ioErr != nil {
  24555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24557. return
  24558. }
  24559. var respJSON map[string]interface{}
  24560. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24563. return
  24564. }
  24565. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24566. userJSONBytes, _ := json.Marshal(respJSON)
  24567. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24568. utils.ErrorLog("解析失败:%v", err)
  24569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24570. return
  24571. }
  24572. res.InfRefmsgid = res10188.InfRefmsgid
  24573. res.Output = res10188.Output
  24574. res.ErrMsg = res10188.ErrMsg
  24575. res.Cainfo = res10188.Cainfo
  24576. res.WarnMsg = res10188.WarnMsg
  24577. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  24578. res.Infcode = infocode
  24579. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24580. if clr_type != "9903" {
  24581. clr_type = "99" // 就诊 ID(来自2201接口返回)
  24582. }
  24583. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  24584. "insutype=" + insutype +
  24585. "&clr_type=" + clr_type +
  24586. "&setl_optins=" + clr_org +
  24587. "&stmt_begndate=" + start_time +
  24588. "&stm_enddate=" + end_time +
  24589. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24590. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24591. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24592. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24593. "&fixmedins_code=" + miConfig.Code +
  24594. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24595. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24596. "&secret_key=" + miConfig.SecretKey +
  24597. "&org_name=" + miConfig.OrgName +
  24598. "&doctor=" + user_name
  24599. resp, requestErr := http.Get(api)
  24600. if requestErr != nil {
  24601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24602. return
  24603. }
  24604. body, ioErr := ioutil.ReadAll(resp.Body)
  24605. if ioErr != nil {
  24606. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24608. return
  24609. }
  24610. var respJSON map[string]interface{}
  24611. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24612. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24614. return
  24615. }
  24616. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24617. result, _ := json.Marshal(respJSON)
  24618. fmt.Println("log")
  24619. fmt.Println(string(result))
  24620. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  24621. utils.ErrorLog("解析失败:%v", err)
  24622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24623. return
  24624. }
  24625. res.InfRefmsgid = res10188.InfRefmsgid
  24626. res.Output = res10188.Output
  24627. res.ErrMsg = res10188.ErrMsg
  24628. res.Cainfo = res10188.Cainfo
  24629. res.WarnMsg = res10188.WarnMsg
  24630. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  24631. res.Infcode = infocode
  24632. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24633. var baseParams models.BaseParams
  24634. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24635. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24636. baseParams.SecretKey = miConfig.SecretKey
  24637. baseParams.OrgName = miConfig.OrgName
  24638. baseParams.FixmedinsCode = miConfig.Code
  24639. baseParams.EncKey = miConfig.EncKey
  24640. baseParams.AppSecret = miConfig.AppSecret
  24641. baseParams.SignKey = miConfig.SignKey
  24642. baseParams.AppID = miConfig.Code
  24643. baseParams.Doctor = role.UserName
  24644. baseParams.RequestUrl = miConfig.Url
  24645. businessParams := models.BusinessParams{
  24646. Insutype: insutype,
  24647. ClrType: clr_type,
  24648. SetlOptins: clr_org,
  24649. StmtBegndate: start_time,
  24650. StmtEnddate: end_time,
  24651. MedfeeSumamt: medfee_sumamt,
  24652. FundPaySumamt: fund_pay_sumamt,
  24653. AcctPay: acct_pay,
  24654. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24655. }
  24656. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  24657. fmt.Println(requestLog)
  24658. fmt.Println(result)
  24659. fmt.Println(err_msg)
  24660. var dat map[string]interface{}
  24661. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24662. fmt.Println(dat)
  24663. } else {
  24664. fmt.Println(err)
  24665. }
  24666. userJSONBytes, _ := json.Marshal(dat)
  24667. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24668. utils.ErrorLog("解析失败:%v", err)
  24669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24670. return
  24671. }
  24672. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24673. var baseParams models.BaseParams
  24674. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24675. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24676. baseParams.SecretKey = miConfig.SecretKey
  24677. baseParams.OrgName = miConfig.OrgName
  24678. baseParams.FixmedinsCode = miConfig.Code
  24679. baseParams.EncKey = miConfig.EncKey
  24680. baseParams.AppSecret = miConfig.AppSecret
  24681. baseParams.SignKey = miConfig.SignKey
  24682. baseParams.AppID = miConfig.Code
  24683. baseParams.Doctor = role.UserName
  24684. baseParams.RequestUrl = miConfig.Url
  24685. baseParams.AccessKey = miConfig.AccessKey
  24686. businessParams := models.BusinessParams{
  24687. Insutype: insutype,
  24688. ClrType: clr_type,
  24689. SetlOptins: "430822",
  24690. StmtBegndate: start_time,
  24691. StmtEnddate: end_time,
  24692. MedfeeSumamt: medfee_sumamt,
  24693. FundPaySumamt: fund_pay_sumamt,
  24694. AcctPay: acct_pay,
  24695. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24696. }
  24697. 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)
  24698. fmt.Println(requestLog)
  24699. fmt.Println(result)
  24700. var dat map[string]interface{}
  24701. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24702. fmt.Println(dat)
  24703. } else {
  24704. fmt.Println(err)
  24705. }
  24706. userJSONBytes, _ := json.Marshal(dat)
  24707. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24708. utils.ErrorLog("解析失败:%v", err)
  24709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24710. return
  24711. }
  24712. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24713. var baseParams models.BaseParams
  24714. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24715. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24716. baseParams.SecretKey = miConfig.SecretKey
  24717. baseParams.OrgName = miConfig.OrgName
  24718. baseParams.FixmedinsCode = miConfig.Code
  24719. baseParams.EncKey = miConfig.EncKey
  24720. baseParams.AppSecret = miConfig.AppSecret
  24721. baseParams.SignKey = miConfig.SignKey
  24722. baseParams.AppID = miConfig.Code
  24723. baseParams.Doctor = role.UserName
  24724. baseParams.RequestUrl = miConfig.Url
  24725. businessParams := models.BusinessParams{
  24726. Insutype: insutype,
  24727. ClrType: clr_type,
  24728. SetlOptins: clr_org,
  24729. StmtBegndate: start_time,
  24730. StmtEnddate: end_time,
  24731. MedfeeSumamt: medfee_sumamt,
  24732. FundPaySumamt: fund_pay_sumamt,
  24733. AcctPay: acct_pay,
  24734. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24735. }
  24736. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  24737. fmt.Println(requestLog)
  24738. fmt.Println(result)
  24739. fmt.Println(err_msg)
  24740. var dat map[string]interface{}
  24741. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24742. fmt.Println(dat)
  24743. } else {
  24744. fmt.Println(err)
  24745. }
  24746. userJSONBytes, _ := json.Marshal(dat)
  24747. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24748. utils.ErrorLog("解析失败:%v", err)
  24749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24750. return
  24751. }
  24752. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24753. if len(clr_type) == 0 {
  24754. clr_type = "11"
  24755. }
  24756. api := miConfig.Url + "gdyb/ten?" +
  24757. "insutype=" + insutype +
  24758. "&clr_type=" + clr_type +
  24759. "&setl_optins=" + clr_org +
  24760. "&stmt_begndate=" + start_time +
  24761. "&stm_enddate=" + end_time +
  24762. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24763. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24764. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24765. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  24766. "&fixmedins_code=" + miConfig.Code +
  24767. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24768. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24769. "&secret_key=" + miConfig.SecretKey +
  24770. "&org_name=" + miConfig.OrgName +
  24771. "&doctor=" + user_name
  24772. fmt.Println(api)
  24773. resp, requestErr := http.Get(api)
  24774. if requestErr != nil {
  24775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24776. return
  24777. }
  24778. body, ioErr := ioutil.ReadAll(resp.Body)
  24779. fmt.Println(body)
  24780. if ioErr != nil {
  24781. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24783. return
  24784. }
  24785. var respJSON map[string]interface{}
  24786. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24789. return
  24790. }
  24791. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24792. userJSONBytes, _ := json.Marshal(respJSON)
  24793. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24794. utils.ErrorLog("解析失败:%v", err)
  24795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24796. return
  24797. }
  24798. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24799. var baseParams models.BaseParams
  24800. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24801. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24802. baseParams.SecretKey = miConfig.SecretKey
  24803. baseParams.OrgName = miConfig.OrgName
  24804. baseParams.FixmedinsCode = miConfig.Code
  24805. baseParams.EncKey = miConfig.EncKey
  24806. baseParams.AppSecret = miConfig.AppSecret
  24807. baseParams.SignKey = miConfig.SignKey
  24808. baseParams.AppID = miConfig.Code
  24809. baseParams.Doctor = role.UserName
  24810. baseParams.RequestUrl = miConfig.Url
  24811. if clr_type == "9903" {
  24812. clr_type = "9901"
  24813. }
  24814. businessParams := models.BusinessParams{
  24815. Insutype: insutype,
  24816. ClrType: clr_type,
  24817. SetlOptins: "360302",
  24818. StmtBegndate: start_time,
  24819. StmtEnddate: end_time,
  24820. MedfeeSumamt: 0,
  24821. FundPaySumamt: 0,
  24822. AcctPay: 0,
  24823. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24824. }
  24825. 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))
  24826. fmt.Println(requestLog)
  24827. fmt.Println(result)
  24828. var dat map[string]interface{}
  24829. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24830. fmt.Println(dat)
  24831. } else {
  24832. fmt.Println(err)
  24833. }
  24834. userJSONBytes, _ := json.Marshal(dat)
  24835. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24836. utils.ErrorLog("解析失败:%v", err)
  24837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24838. return
  24839. }
  24840. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24841. var api string
  24842. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  24843. "&clr_type=" + clr_type +
  24844. "&setl_optins=" + clr_org +
  24845. "&stmt_begndate=" + start_time +
  24846. "&stm_enddate=" + end_time +
  24847. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24848. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24849. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24850. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24851. "&fixmedins_code=" + miConfig.Code +
  24852. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24853. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24854. "&secret_key=" + miConfig.SecretKey +
  24855. "&org_name=" + miConfig.OrgName +
  24856. "&doctor=" + user_name + "&url=" + miConfig.Url
  24857. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24858. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24859. resp, requestErr := http.Get(api)
  24860. if requestErr != nil {
  24861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24862. return
  24863. }
  24864. body, ioErr := ioutil.ReadAll(resp.Body)
  24865. if ioErr != nil {
  24866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24868. return
  24869. }
  24870. var respJSON map[string]interface{}
  24871. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24874. return
  24875. }
  24876. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24877. if status == "0" {
  24878. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24879. c.ServeSuccessJSON(map[string]interface{}{
  24880. "failed_code": -10,
  24881. "msg": err_msg,
  24882. })
  24883. return
  24884. }
  24885. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24886. userJSONBytes, _ := json.Marshal(respJSON)
  24887. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24888. utils.ErrorLog("解析失败:%v", err)
  24889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24890. return
  24891. }
  24892. } else {
  24893. if len(clr_type) == 0 {
  24894. clr_type = "11"
  24895. }
  24896. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  24897. "insutype=" + insutype +
  24898. "&clr_type=" + clr_type +
  24899. "&setl_optins=" + clr_org +
  24900. "&stmt_begndate=" + start_time +
  24901. "&stm_enddate=" + end_time +
  24902. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24903. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24904. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24905. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  24906. "&fixmedins_code=" + miConfig.Code +
  24907. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24908. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24909. "&secret_key=" + miConfig.SecretKey +
  24910. "&org_name=" + miConfig.OrgName +
  24911. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24912. fmt.Println(api)
  24913. resp, requestErr := http.Get(api)
  24914. if requestErr != nil {
  24915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24916. return
  24917. }
  24918. body, ioErr := ioutil.ReadAll(resp.Body)
  24919. fmt.Println(body)
  24920. if ioErr != nil {
  24921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24923. return
  24924. }
  24925. var respJSON map[string]interface{}
  24926. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24929. return
  24930. }
  24931. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24932. userJSONBytes, _ := json.Marshal(respJSON)
  24933. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24934. utils.ErrorLog("解析失败:%v", err)
  24935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24936. return
  24937. }
  24938. }
  24939. if res.Infcode == 0 {
  24940. if res.Output.Stmtinfo.StmtRslt == "0" {
  24941. micc := &models.MedicalInsuranceCostCompare{
  24942. StartTime: startime.Unix(),
  24943. EndTime: endtime.Unix(),
  24944. Insutype: insutype,
  24945. CheckType: 1,
  24946. Num: fixmedins_setl_cnt,
  24947. Mtime: time.Now().Unix(),
  24948. Status: 1,
  24949. UserOrgId: adminUser.CurrentOrgId,
  24950. CostTotal: medfee_sumamt,
  24951. FuncTotal: fund_pay_sumamt,
  24952. PsnPay: acct_pay,
  24953. Creator: admin_user_id,
  24954. Ctime: time.Now().Unix(),
  24955. ClrType: clr_type,
  24956. }
  24957. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  24958. if err == nil {
  24959. c.ServeSuccessJSON(map[string]interface{}{
  24960. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  24961. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  24962. })
  24963. } else {
  24964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24965. }
  24966. } else {
  24967. c.ServeSuccessJSON(map[string]interface{}{
  24968. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  24969. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  24970. })
  24971. }
  24972. } else {
  24973. c.ServeSuccessJSON(map[string]interface{}{
  24974. "failed_code": -10,
  24975. "msg": res.ErrMsg,
  24976. })
  24977. }
  24978. }
  24979. }
  24980. func (c *HisApiController) Check310() {
  24981. adminUser := c.GetAdminUserInfo()
  24982. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24983. var user_name string
  24984. user_name = "高慧裕"
  24985. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  24986. "insutype=" + "310" +
  24987. "&clr_type=" + "" +
  24988. "&setl_optins=" + "441202" +
  24989. "&stmt_begndate=" + "2022-03-01" +
  24990. "&stm_enddate=" + "2022-03-31" +
  24991. "&medfee_sumamt=" + "194930.12" +
  24992. "&fund_pay_sumamt=" + "188741.46" +
  24993. "&acct_pay=" + "0" +
  24994. "&fixmedins_setl_cnt=" + "452" +
  24995. "&fixmedins_code=" + miConfig.Code +
  24996. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24997. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24998. "&secret_key=" + miConfig.SecretKey +
  24999. "&org_name=" + miConfig.OrgName +
  25000. "&doctor=" + user_name
  25001. fmt.Println(api)
  25002. resp, requestErr := http.Get(api)
  25003. if requestErr != nil {
  25004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25005. return
  25006. }
  25007. body, ioErr := ioutil.ReadAll(resp.Body)
  25008. fmt.Println(body)
  25009. if ioErr != nil {
  25010. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25012. return
  25013. }
  25014. var respJSON map[string]interface{}
  25015. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25018. return
  25019. }
  25020. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25021. userJSONBytes, _ := json.Marshal(respJSON)
  25022. var res ResultEight
  25023. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25024. utils.ErrorLog("解析失败:%v", err)
  25025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25026. return
  25027. }
  25028. }
  25029. func (c *HisApiController) Check390() {
  25030. adminUser := c.GetAdminUserInfo()
  25031. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25032. var user_name string
  25033. user_name = "高慧裕"
  25034. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25035. "insutype=" + "390" +
  25036. "&clr_type=" + "" +
  25037. "&setl_optins=" + "441202" +
  25038. "&stmt_begndate=" + "2022-03-01" +
  25039. "&stm_enddate=" + "2022-03-31" +
  25040. "&medfee_sumamt=" + "1068448.89" +
  25041. "&fund_pay_sumamt=" + "1014677.62" +
  25042. "&acct_pay=" + "0" +
  25043. "&fixmedins_setl_cnt=" + "1950" +
  25044. "&fixmedins_code=" + miConfig.Code +
  25045. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25046. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25047. "&secret_key=" + miConfig.SecretKey +
  25048. "&org_name=" + miConfig.OrgName +
  25049. "&doctor=" + user_name
  25050. fmt.Println(api)
  25051. resp, requestErr := http.Get(api)
  25052. if requestErr != nil {
  25053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25054. return
  25055. }
  25056. body, ioErr := ioutil.ReadAll(resp.Body)
  25057. fmt.Println(body)
  25058. if ioErr != nil {
  25059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25061. return
  25062. }
  25063. var respJSON map[string]interface{}
  25064. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25067. return
  25068. }
  25069. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25070. userJSONBytes, _ := json.Marshal(respJSON)
  25071. var res ResultEight
  25072. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25073. utils.ErrorLog("解析失败:%v", err)
  25074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25075. return
  25076. }
  25077. }
  25078. // 对账明细
  25079. func (c *HisApiController) GetCheckDetailAccount() {
  25080. start_time := c.GetString("start_time")
  25081. end_time := c.GetString("end_time")
  25082. admin_user_id, _ := c.GetInt64("admin_user_id")
  25083. adminUser := c.GetAdminUserInfo()
  25084. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25085. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25086. timeLayout := "2006-01-02"
  25087. loc, _ := time.LoadLocation("Local")
  25088. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  25089. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  25090. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  25091. rand.Seed(time.Now().UnixNano())
  25092. num := rand.Intn(30000)
  25093. Mkdir(miConfig.OrgName)
  25094. file := strconv.FormatInt(int64(num), 10)
  25095. file_name := file + ".txt"
  25096. zip_name := file + ".zip"
  25097. zip_path := miConfig.OrgName + "/" + zip_name
  25098. file_path := miConfig.OrgName + "/" + file_name
  25099. decimal.DivisionPrecision = 2
  25100. var medfee_sumamt float64
  25101. var psn_cash_pay float64
  25102. var fund_pay_sumamt float64
  25103. fixmedins_setl_cnt := int64(len(orders))
  25104. for _, item := range orders {
  25105. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  25106. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  25107. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  25108. }
  25109. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  25110. defer f.Close()
  25111. if err != nil {
  25112. fmt.Println(err.Error())
  25113. } else {
  25114. for _, item := range orders {
  25115. var refd_setl_flag string
  25116. if item.OrderStatus == 2 {
  25117. refd_setl_flag = "0"
  25118. var str string
  25119. str = item.SetlId + " " +
  25120. item.MdtrtId + " " +
  25121. item.PsnNo + " " +
  25122. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  25123. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  25124. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  25125. _, err = f.Write([]byte(str))
  25126. }
  25127. if item.OrderStatus == 3 {
  25128. var str string
  25129. str = item.SetlId + " " +
  25130. item.MdtrtId + " " +
  25131. item.PsnNo + " " +
  25132. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  25133. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  25134. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  25135. _, err = f.Write([]byte(str))
  25136. var str2 string
  25137. str2 = item.SetlId + " " +
  25138. item.MdtrtId + " " +
  25139. item.PsnNo + " " +
  25140. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  25141. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  25142. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  25143. _, err = f.Write([]byte(str2))
  25144. }
  25145. }
  25146. }
  25147. Zip(file_path, zip_path)
  25148. fmt.Println(ReadFile(zip_path))
  25149. fmt.Println(string(ReadFile(zip_path)))
  25150. if config.IsOpen == 1 {
  25151. var user_name string
  25152. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25153. if role.ID == 0 {
  25154. user_name = "管理员"
  25155. } else {
  25156. user_name = role.UserName
  25157. }
  25158. baseParams := models.BaseParams{
  25159. SecretKey: miConfig.SecretKey,
  25160. FixmedinsCode: miConfig.Code,
  25161. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  25162. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  25163. OrgName: miConfig.OrgName,
  25164. Doctor: user_name,
  25165. }
  25166. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  25167. var dat map[string]interface{}
  25168. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25169. fmt.Println(dat)
  25170. } else {
  25171. fmt.Println(err)
  25172. }
  25173. userJSONBytes, _ := json.Marshal(dat)
  25174. var res ResultNine
  25175. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25176. utils.ErrorLog("解析失败:%v", err)
  25177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25178. return
  25179. }
  25180. if res.Infcode == 0 {
  25181. fileNo := res.Output.FileQuryNo
  25182. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  25183. "file_qury_no=" + fileNo +
  25184. "&setl_optins=" + "定点医保中心" +
  25185. "&stmt_begndate=" + start_time +
  25186. "&stm_enddate=" + end_time +
  25187. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25188. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25189. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  25190. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  25191. "&fixmedins_code=" + miConfig.Code +
  25192. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25193. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25194. "&secret_key=" + miConfig.SecretKey +
  25195. "&org_name=" + miConfig.OrgName +
  25196. "&doctor=" + user_name
  25197. resp, requestErr := http.Get(api)
  25198. if requestErr != nil {
  25199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25200. return
  25201. }
  25202. body, ioErr := ioutil.ReadAll(resp.Body)
  25203. if ioErr != nil {
  25204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25206. return
  25207. }
  25208. var respJSON map[string]interface{}
  25209. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25212. return
  25213. }
  25214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25215. userJSONBytes, _ := json.Marshal(respJSON)
  25216. var res ResultTen
  25217. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25218. utils.ErrorLog("解析失败:%v", err)
  25219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25220. return
  25221. }
  25222. if res.Infcode == 0 {
  25223. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  25224. micc := &models.MedicalInsuranceCostCompare{
  25225. StartTime: startime.Unix(),
  25226. EndTime: endtime.Unix(),
  25227. Insutype: "0",
  25228. CheckType: 2,
  25229. Num: fixmedins_setl_cnt,
  25230. Mtime: time.Now().Unix(),
  25231. Status: 1,
  25232. UserOrgId: adminUser.CurrentOrgId,
  25233. CostTotal: medfee_sumamt,
  25234. FuncTotal: fund_pay_sumamt,
  25235. PsnPay: psn_cash_pay,
  25236. Creator: admin_user_id,
  25237. Ctime: time.Now().Unix(),
  25238. }
  25239. service.CreateMedicalInsuranceCostCompareRecord(micc)
  25240. c.ServeSuccessJSON(map[string]interface{}{
  25241. "msg": "明细对账成功",
  25242. })
  25243. }
  25244. } else {
  25245. }
  25246. }
  25247. }
  25248. type CustomOrderInfo struct {
  25249. Name string
  25250. Spec string
  25251. Unit string
  25252. Count float64
  25253. Price float64
  25254. Total float64
  25255. }
  25256. func (c *HisApiController) GetBatchSettleAccounts() {
  25257. admin_user_id, _ := c.GetInt64("admin_user_id")
  25258. order_ids := c.GetString("order_ids")
  25259. order_ids_arr := strings.Split(order_ids, ",")
  25260. data3 := []map[string]interface{}{}
  25261. for _, item := range order_ids_arr {
  25262. id, _ := strconv.ParseInt(item, 10, 64)
  25263. order_id := id
  25264. adminUser := c.GetAdminUserInfo()
  25265. order, _ := service.GetHisOrderByID(order_id)
  25266. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25267. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  25268. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  25269. orderInfos = append(orderInfos, orderInfos_two...)
  25270. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  25271. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  25272. var diagnosis_ids []string
  25273. if his.ID > 0 {
  25274. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  25275. } else {
  25276. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  25277. }
  25278. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  25279. var dia_config []*models.HisXtDiagnoseConfig
  25280. var name string
  25281. for _, item := range diagnosis_ids {
  25282. id, _ := strconv.ParseInt(item, 10, 64)
  25283. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25284. dia_config = append(dia_config, &diagnosisConfig)
  25285. if len(name) == 0 {
  25286. name = diagnosisConfig.ClassName
  25287. }
  25288. //} else {
  25289. // name = name + "," + diagnosisConfig.ClassName
  25290. //}
  25291. }
  25292. var bedCostTotal float64 = 0 //床位总费
  25293. var bedCostSelfTotal float64 = 0 //床位自费
  25294. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  25295. var bedSelfTotal float64 = 0 //床位部分项目自费
  25296. var bedInscpTotal float64 = 0 //床位部分项目自费
  25297. var operationCostTotal float64 = 0 //手术费
  25298. var operationCostSelfTotal float64 = 0 //手术费
  25299. var operationCostPartSelfTotal float64 = 0 //手术费
  25300. var operationSelfTotal float64 = 0 //床位部分项目自费
  25301. var operationInscpTotal float64 = 0 //床位部分项目自费
  25302. var otherCostTotal float64 = 0 //其他费用
  25303. var otherCostSelfTotal float64 = 0 //其他费用
  25304. var otherCostPartSelfTotal float64 = 0 //其他费用
  25305. var otherSelfTotal float64 = 0 //床位部分项目自费
  25306. var otherInscpTotal float64 = 0 //床位部分项目自费
  25307. var materialCostTotal float64 = 0 //材料费
  25308. var materialCostSelfTotal float64 = 0 //材料费
  25309. var materialCostPartSelfTotal float64 = 0 //材料费
  25310. var materialSelfTotal float64 = 0 //床位部分项目自费
  25311. var materialInscpTotal float64 = 0 //床位部分项目自费
  25312. var westernMedicineCostTotal float64 = 0 //西药费
  25313. var westernMedicineCostSelfTotal float64 = 0 //西药费
  25314. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  25315. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  25316. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  25317. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  25318. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  25319. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  25320. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  25321. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  25322. var checkCostTotal float64 = 0 //检查费
  25323. var checkCostSelfTotal float64 = 0 //检查费
  25324. var checkCostPartSelfTotal float64 = 0 //检查费
  25325. var checkSelfTotal float64 = 0 //床位部分项目自费
  25326. var checkInscpTotal float64 = 0 //床位部分项目自费
  25327. var laboratoryCostTotal float64 = 0 //化验费
  25328. var laboratoryCostSelfTotal float64 = 0 //化验费
  25329. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  25330. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  25331. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  25332. var treatCostTotal float64 = 0 //治疗费用
  25333. var treatCostSelfTotal float64 = 0 //治疗费用
  25334. var treatCostPartSelfTotal float64 = 0 //治疗费用
  25335. var treatSelfTotal float64 = 0 //床位部分项目自费
  25336. var treatInscpTotal float64 = 0 //床位部分项目自费
  25337. decimal.DivisionPrecision = 2
  25338. for _, item := range orderInfos {
  25339. if item.MedChrgitmType == "01" { //床位费
  25340. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25341. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25342. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25343. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25344. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25345. }
  25346. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  25347. if item.MedChrgitmType == "03" { //检查费
  25348. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25349. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25350. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25351. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25352. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25353. }
  25354. } else {
  25355. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  25356. fmt.Println("------------")
  25357. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25358. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25359. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25360. }
  25361. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  25362. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25363. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25364. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25365. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25366. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25367. }
  25368. }
  25369. if item.MedChrgitmType == "04" { //化验费
  25370. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25371. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25372. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25373. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25374. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25375. }
  25376. if item.MedChrgitmType == "05" { //治疗费
  25377. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25378. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25379. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25380. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25381. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25382. }
  25383. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  25384. fmt.Println("------------")
  25385. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25386. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25387. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25388. }
  25389. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  25390. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25391. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25392. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25393. }
  25394. //if item.MedChrgitmType == "06" { //手术费
  25395. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25396. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25397. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25398. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25399. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25400. //
  25401. //}
  25402. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  25403. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25404. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25405. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25406. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25407. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25408. }
  25409. if item.MedChrgitmType == "09" { //西药费
  25410. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25411. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25412. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25413. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25414. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25415. }
  25416. if item.MedChrgitmType == "11" { //中成费
  25417. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25418. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25419. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25420. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25421. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25422. }
  25423. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  25424. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25425. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25426. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25427. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25428. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25429. }
  25430. }
  25431. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25432. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25433. var user_name string
  25434. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25435. if role.ID == 0 {
  25436. user_name = "管理员"
  25437. } else {
  25438. user_name = role.UserName
  25439. }
  25440. baseParams := models.BaseParams{
  25441. SecretKey: miConfig.SecretKey,
  25442. FixmedinsCode: miConfig.Code,
  25443. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  25444. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  25445. OrgName: miConfig.OrgName,
  25446. Doctor: user_name,
  25447. RequestUrl: miConfig.Url,
  25448. AccessKey: miConfig.AccessKey,
  25449. }
  25450. businessParams := models.BusinessParams{
  25451. PsnNo: order.PsnNo,
  25452. MdtrtId: order.MdtrtId,
  25453. SetlId: order.SetlId,
  25454. }
  25455. var res ResultEleven
  25456. var resEleven10265 ResultEleven10265
  25457. if config.IsOpen == 1 {
  25458. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  25459. result := service.Gdyb5203(baseParams, businessParams)
  25460. service.Gdyb5204(baseParams, businessParams)
  25461. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  25462. var dat map[string]interface{}
  25463. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25464. fmt.Println(dat)
  25465. } else {
  25466. fmt.Println(err)
  25467. }
  25468. userJSONBytes, _ := json.Marshal(dat)
  25469. if miConfig.Code == "H15049901371" {
  25470. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  25471. utils.ErrorLog("解析失败:%v", err)
  25472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25473. return
  25474. }
  25475. res.InfRefmsgid = resEleven10265.InfRefmsgid
  25476. res.Output = resEleven10265.Output
  25477. res.ErrMsg = resEleven10265.ErrMsg
  25478. res.Cainfo = resEleven10265.Cainfo
  25479. res.WarnMsg = resEleven10265.WarnMsg
  25480. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  25481. res.Infcode = infocode
  25482. } else {
  25483. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25484. utils.ErrorLog("解析失败:%v", err)
  25485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25486. return
  25487. }
  25488. }
  25489. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25490. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  25491. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  25492. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25493. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  25494. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25495. var doctor_name string
  25496. if roles.ID == 0 {
  25497. doctor_name = "管理员"
  25498. } else {
  25499. doctor_name = roles.UserName
  25500. }
  25501. yiliao_leibie := ""
  25502. switch order.MedType {
  25503. case "11":
  25504. yiliao_leibie = "普通门诊"
  25505. break
  25506. case "12":
  25507. yiliao_leibie = "门诊挂号"
  25508. break
  25509. case "13":
  25510. yiliao_leibie = "急诊"
  25511. break
  25512. case "14":
  25513. yiliao_leibie = "门诊特殊病"
  25514. break
  25515. case "15":
  25516. yiliao_leibie = "门诊统筹"
  25517. break
  25518. case "16":
  25519. yiliao_leibie = "门诊慢性病"
  25520. break
  25521. case "21":
  25522. yiliao_leibie = "普通住院"
  25523. break
  25524. }
  25525. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25526. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  25527. if res.Infcode == 0 {
  25528. data2 := map[string]interface{}{
  25529. "diagnosis": name,
  25530. "order_infos": orderInfos,
  25531. "number": order.MdtrtId,
  25532. "date": order.SettleAccountsDate,
  25533. "charge_admin": charge_admin,
  25534. "printor_admin": printor_admin,
  25535. "info": res.Output.Setlinfo,
  25536. "order": order,
  25537. "bedCostTotal": bedCostTotal,
  25538. "bedCostSelfTotal": bedCostSelfTotal,
  25539. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  25540. "bedSelfTotal": bedSelfTotal,
  25541. "bedInscpTotal": bedInscpTotal,
  25542. "operationCostTotal": operationCostTotal,
  25543. "operationCostSelfTotal": operationCostSelfTotal,
  25544. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  25545. "operationSelfTotal": operationSelfTotal,
  25546. "operationInscpTotal": operationInscpTotal,
  25547. "otherCostTotal": otherCostTotal,
  25548. "otherCostSelfTotal": otherCostSelfTotal,
  25549. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  25550. "otherSelfTotal": otherSelfTotal,
  25551. "otherInscpTotal": otherInscpTotal,
  25552. "materialCostTotal": materialCostTotal,
  25553. "materialCostSelfTotal": materialCostSelfTotal,
  25554. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  25555. "materialSelfTotal": materialSelfTotal,
  25556. "materialInscpTotal": materialInscpTotal,
  25557. "westernMedicineCostTotal": westernMedicineCostTotal,
  25558. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  25559. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  25560. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  25561. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  25562. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  25563. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  25564. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  25565. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  25566. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  25567. "checkCostTotal": checkCostTotal,
  25568. "checkCostSelfTotal": checkCostSelfTotal,
  25569. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  25570. "checkSelfTotal": checkSelfTotal,
  25571. "checkInscpTotal": checkInscpTotal,
  25572. "laboratoryCostTotal": laboratoryCostTotal,
  25573. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  25574. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  25575. "laboratorySelfTotal": laboratorySelfTotal,
  25576. "laboratoryInscpTotal": laboratoryInscpTotal,
  25577. "treatCostTotal": treatCostTotal,
  25578. "treatCostSelfTotal": treatCostSelfTotal,
  25579. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  25580. "treatSelfTotal": treatSelfTotal,
  25581. "treatInscpTotal": treatInscpTotal,
  25582. "doctor_info": doctor_info,
  25583. "doctor_code": adminRole_two.DoctorCode,
  25584. "doctor_name": doctor_name,
  25585. "health_card_no": order.PsnNo,
  25586. "department": departments.Name,
  25587. "yiliao_leibie": yiliao_leibie,
  25588. "after_money": order.AccountPrice,
  25589. "patient": patient,
  25590. "org_name": miConfig.OrgName,
  25591. "org_code": miConfig.Code,
  25592. "order_number": order.Number,
  25593. "his_hospital": his_hospital,
  25594. "his": his,
  25595. "dia_config": dia_config,
  25596. "psn_cash_pay": order.PsnCashPay,
  25597. //"check_order_info": cus_slice,
  25598. }
  25599. data3 = append(data3, data2)
  25600. }
  25601. }
  25602. }
  25603. c.ServeSuccessJSON(map[string]interface{}{
  25604. "infos": data3,
  25605. })
  25606. }
  25607. func (c *HisApiController) GetSettleAccounts() {
  25608. //id, _ := c.GetInt64("id")
  25609. //record_time := c.GetString("record_time")
  25610. order_id, _ := c.GetInt64("order_id")
  25611. admin_user_id, _ := c.GetInt64("admin_user_id")
  25612. //timeLayout := "2006-01-02"
  25613. //loc, _ := time.LoadLocation("Local")
  25614. //
  25615. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25616. //if err != nil {
  25617. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25618. // return
  25619. //}Hbyb5203
  25620. //recordDateTime := theTime.Unix()
  25621. adminUser := c.GetAdminUserInfo()
  25622. order, _ := service.GetHisOrderByID(order_id)
  25623. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25624. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  25625. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  25626. orderInfos = append(orderInfos, orderInfos_two...)
  25627. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  25628. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  25629. var diagnosis_ids []string
  25630. if his.ID > 0 {
  25631. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  25632. } else {
  25633. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  25634. }
  25635. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  25636. var dia_config []*models.HisXtDiagnoseConfig
  25637. var name string
  25638. for _, item := range diagnosis_ids {
  25639. id, _ := strconv.ParseInt(item, 10, 64)
  25640. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25641. dia_config = append(dia_config, &diagnosisConfig)
  25642. if len(name) == 0 {
  25643. name = diagnosisConfig.ClassName
  25644. } else {
  25645. name = name + "," + diagnosisConfig.ClassName
  25646. }
  25647. }
  25648. if patient.UserOrgId == 10215 {
  25649. name = "慢性肾功能不全(血透治疗)"
  25650. }
  25651. var bedCostTotal float64 = 0 //床位总费
  25652. var bedCostSelfTotal float64 = 0 //床位自费
  25653. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  25654. var bedSelfTotal float64 = 0 //床位部分项目自费
  25655. var bedInscpTotal float64 = 0 //床位部分项目自费
  25656. var operationCostTotal float64 = 0 //手术费
  25657. var operationCostSelfTotal float64 = 0 //手术费
  25658. var operationCostPartSelfTotal float64 = 0 //手术费
  25659. var operationSelfTotal float64 = 0 //床位部分项目自费
  25660. var operationInscpTotal float64 = 0 //床位部分项目自费
  25661. var otherCostTotal float64 = 0 //其他费用
  25662. var otherCostSelfTotal float64 = 0 //其他费用
  25663. var otherCostPartSelfTotal float64 = 0 //其他费用
  25664. var otherSelfTotal float64 = 0 //床位部分项目自费
  25665. var otherInscpTotal float64 = 0 //床位部分项目自费
  25666. var materialCostTotal float64 = 0 //材料费
  25667. var materialCostSelfTotal float64 = 0 //材料费
  25668. var materialCostPartSelfTotal float64 = 0 //材料费
  25669. var materialSelfTotal float64 = 0 //床位部分项目自费
  25670. var materialInscpTotal float64 = 0 //床位部分项目自费
  25671. var westernMedicineCostTotal float64 = 0 //西药费
  25672. var westernMedicineCostSelfTotal float64 = 0 //西药费
  25673. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  25674. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  25675. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  25676. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  25677. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  25678. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  25679. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  25680. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  25681. var checkCostTotal float64 = 0 //检查费
  25682. var checkCostSelfTotal float64 = 0 //检查费
  25683. var checkCostPartSelfTotal float64 = 0 //检查费
  25684. var checkSelfTotal float64 = 0 //床位部分项目自费
  25685. var checkInscpTotal float64 = 0 //床位部分项目自费
  25686. var laboratoryCostTotal float64 = 0 //化验费
  25687. var laboratoryCostSelfTotal float64 = 0 //化验费
  25688. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  25689. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  25690. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  25691. var treatCostTotal float64 = 0 //治疗费用
  25692. var treatCostSelfTotal float64 = 0 //治疗费用
  25693. var treatCostPartSelfTotal float64 = 0 //治疗费用
  25694. var treatSelfTotal float64 = 0 //床位部分项目自费
  25695. var treatInscpTotal float64 = 0 //床位部分项目自费
  25696. decimal.DivisionPrecision = 2
  25697. for _, item := range orderInfos {
  25698. if item.MedChrgitmType == "01" { //床位费
  25699. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25700. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25701. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25702. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25703. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25704. }
  25705. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  25706. if item.MedChrgitmType == "03" { //检查费
  25707. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25708. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25709. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25710. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25711. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25712. }
  25713. } else {
  25714. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  25715. fmt.Println("------------")
  25716. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25717. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25718. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25719. }
  25720. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  25721. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25722. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25723. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25724. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25725. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25726. }
  25727. }
  25728. if item.MedChrgitmType == "04" { //化验费
  25729. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25730. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25731. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25732. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25733. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25734. }
  25735. if item.MedChrgitmType == "05" { //治疗费
  25736. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25737. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25738. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25739. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25740. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25741. }
  25742. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  25743. fmt.Println("------------")
  25744. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25745. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25746. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25747. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25748. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25749. }
  25750. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  25751. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25752. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25753. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25754. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25755. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25756. }
  25757. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  25758. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25759. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25760. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25761. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25762. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25763. }
  25764. if item.MedChrgitmType == "09" { //西药费
  25765. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25766. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25767. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25768. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25769. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25770. }
  25771. if item.MedChrgitmType == "11" { //中成费
  25772. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25773. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25774. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25775. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25776. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25777. }
  25778. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  25779. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25780. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25781. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25782. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25783. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25784. }
  25785. }
  25786. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25787. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25788. var user_name string
  25789. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25790. if role.ID == 0 {
  25791. user_name = "管理员"
  25792. } else {
  25793. user_name = role.UserName
  25794. }
  25795. baseParams := models.BaseParams{
  25796. SecretKey: miConfig.SecretKey,
  25797. FixmedinsCode: miConfig.Code,
  25798. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  25799. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  25800. OrgName: miConfig.OrgName,
  25801. Doctor: user_name,
  25802. RequestUrl: miConfig.Url,
  25803. AccessKey: miConfig.AccessKey,
  25804. }
  25805. businessParams := models.BusinessParams{
  25806. PsnNo: order.PsnNo,
  25807. MdtrtId: order.MdtrtId,
  25808. SetlId: order.SetlId,
  25809. }
  25810. var res ResultEleven
  25811. var resah ResultElevenah
  25812. var resEleven10265 ResultEleven10265
  25813. if config.IsOpen == 1 {
  25814. if miConfig.MdtrtareaAdmvs == "421300" {
  25815. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25816. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25817. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25818. resp, requestErr := http.Get(api)
  25819. if requestErr != nil {
  25820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25821. return
  25822. }
  25823. body, ioErr := ioutil.ReadAll(resp.Body)
  25824. if ioErr != nil {
  25825. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25827. return
  25828. }
  25829. var respJSON map[string]interface{}
  25830. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25831. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25833. return
  25834. }
  25835. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25836. result, _ := json.Marshal(respJSON)
  25837. fmt.Println("log")
  25838. fmt.Println(string(result))
  25839. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25840. utils.ErrorLog("解析失败:%v", err)
  25841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25842. return
  25843. }
  25844. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25845. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25846. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25847. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25848. resp, requestErr := http.Get(api)
  25849. if requestErr != nil {
  25850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25851. return
  25852. }
  25853. body, ioErr := ioutil.ReadAll(resp.Body)
  25854. if ioErr != nil {
  25855. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25857. return
  25858. }
  25859. var respJSON map[string]interface{}
  25860. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25863. return
  25864. }
  25865. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25866. result, _ := json.Marshal(respJSON)
  25867. fmt.Println("log")
  25868. fmt.Println(string(result))
  25869. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25870. utils.ErrorLog("解析失败:%v", err)
  25871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25872. return
  25873. }
  25874. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25875. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25876. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25877. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  25878. resp, requestErr := http.Get(api)
  25879. if requestErr != nil {
  25880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25881. return
  25882. }
  25883. body, ioErr := ioutil.ReadAll(resp.Body)
  25884. if ioErr != nil {
  25885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25887. return
  25888. }
  25889. var respJSON map[string]interface{}
  25890. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25893. return
  25894. }
  25895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25896. result, _ := json.Marshal(respJSON)
  25897. fmt.Println("log")
  25898. fmt.Println(string(result))
  25899. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25900. utils.ErrorLog("解析失败:%v", err)
  25901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25902. return
  25903. }
  25904. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25905. var api string
  25906. if miConfig.MdtrtareaAdmvs == "320921" {
  25907. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25908. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25909. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25910. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25911. } else {
  25912. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25913. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25914. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25915. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25916. }
  25917. resp, requestErr := http.Get(api)
  25918. if requestErr != nil {
  25919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25920. return
  25921. }
  25922. body, ioErr := ioutil.ReadAll(resp.Body)
  25923. if ioErr != nil {
  25924. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25926. return
  25927. }
  25928. var respJSON map[string]interface{}
  25929. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25932. return
  25933. }
  25934. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25935. result, _ := json.Marshal(respJSON)
  25936. fmt.Println("log")
  25937. fmt.Println(string(result))
  25938. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  25939. utils.ErrorLog("解析失败:%v", err)
  25940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25941. return
  25942. }
  25943. res.InfRefmsgid = resEleven10265.InfRefmsgid
  25944. res.Output = resEleven10265.Output
  25945. res.ErrMsg = resEleven10265.ErrMsg
  25946. res.Cainfo = resEleven10265.Cainfo
  25947. res.WarnMsg = resEleven10265.WarnMsg
  25948. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  25949. res.Infcode = infocode
  25950. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25951. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  25952. saveLog(result, requestLog, "5203", "结算单")
  25953. var dat map[string]interface{}
  25954. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25955. fmt.Println(dat)
  25956. } else {
  25957. fmt.Println(err)
  25958. }
  25959. userJSONBytes, _ := json.Marshal(dat)
  25960. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25961. utils.ErrorLog("解析失败:%v", err)
  25962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25963. return
  25964. }
  25965. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25966. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  25967. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  25968. fmt.Println(result3)
  25969. fmt.Println(requestLog3)
  25970. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  25971. fmt.Println(result2)
  25972. fmt.Println(requestLog2)
  25973. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  25974. saveLog(result, requestLog, "5203", "结算单")
  25975. var dat map[string]interface{}
  25976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25977. fmt.Println(dat)
  25978. } else {
  25979. fmt.Println(err)
  25980. }
  25981. userJSONBytes, _ := json.Marshal(dat)
  25982. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25983. utils.ErrorLog("解析失败:%v", err)
  25984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25985. return
  25986. }
  25987. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25988. var api string
  25989. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25990. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25991. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25992. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25993. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25994. resp, requestErr := http.Get(api)
  25995. if requestErr != nil {
  25996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25997. return
  25998. }
  25999. body, ioErr := ioutil.ReadAll(resp.Body)
  26000. if ioErr != nil {
  26001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26003. return
  26004. }
  26005. var respJSON map[string]interface{}
  26006. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26009. return
  26010. }
  26011. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26012. if status == "0" {
  26013. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26014. c.ServeSuccessJSON(map[string]interface{}{
  26015. "failed_code": -10,
  26016. "msg": err_msg,
  26017. })
  26018. return
  26019. }
  26020. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26021. result, _ := json.Marshal(respJSON)
  26022. fmt.Println("log")
  26023. fmt.Println(string(result))
  26024. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  26025. utils.ErrorLog("解析失败:%v", err)
  26026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26027. return
  26028. }
  26029. res.InfRefmsgid = resah.InfRefmsgid
  26030. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  26031. // 创建对应的Time类型
  26032. t := time.UnixMilli(timestamp)
  26033. // 格式化成指定的日期字符串
  26034. str := t.Format("2006-01-02 15:04:05")
  26035. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  26036. // 创建对应的Time类型
  26037. t3 := time.UnixMilli(timestamp2)
  26038. // 格式化成指定的日期字符串
  26039. str2 := t3.Format("2006-01-02 15:04:05")
  26040. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  26041. // 创建对应的Time类型
  26042. t4 := time.UnixMilli(timestamp3)
  26043. // 格式化成指定的日期字符串
  26044. str3 := t4.Format("2006-01-02 15:04:05")
  26045. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  26046. // 创建对应的Time类型
  26047. t5 := time.UnixMilli(timestamp4)
  26048. // 格式化成指定的日期字符串
  26049. str5 := t5.Format("2006-01-02 15:04:05")
  26050. res.Output.Setlinfo.Brdy = str2
  26051. res.Output.Setlinfo.SetlTime = str
  26052. res.Output.Setlinfo.Begndate = str3
  26053. res.Output.Setlinfo.Enddate = str5
  26054. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  26055. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  26056. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  26057. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  26058. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  26059. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  26060. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  26061. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  26062. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  26063. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  26064. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  26065. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  26066. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26067. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  26068. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  26069. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  26070. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  26071. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  26072. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  26073. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  26074. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  26075. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  26076. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  26077. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  26078. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  26079. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26080. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  26081. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  26082. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  26083. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  26084. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  26085. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  26086. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  26087. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  26088. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  26089. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  26090. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  26091. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  26092. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  26093. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  26094. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  26095. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  26096. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  26097. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  26098. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  26099. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  26100. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  26101. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  26102. //res.Output.Setldetail = resah.Output.Setldetail
  26103. res.ErrMsg = resah.ErrMsg
  26104. res.Cainfo = resah.Cainfo
  26105. res.WarnMsg = resah.WarnMsg
  26106. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26107. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  26108. saveLog(result, requestLog, "5203", "结算单")
  26109. var dat map[string]interface{}
  26110. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26111. fmt.Println(dat)
  26112. } else {
  26113. fmt.Println(err)
  26114. }
  26115. userJSONBytes, _ := json.Marshal(dat)
  26116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26117. utils.ErrorLog("解析失败:%v", err)
  26118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26119. return
  26120. }
  26121. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26122. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26123. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26124. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26125. resp, requestErr := http.Get(api)
  26126. if requestErr != nil {
  26127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26128. return
  26129. }
  26130. body, ioErr := ioutil.ReadAll(resp.Body)
  26131. if ioErr != nil {
  26132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26134. return
  26135. }
  26136. var respJSON map[string]interface{}
  26137. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26140. return
  26141. }
  26142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26143. result, _ := json.Marshal(respJSON)
  26144. fmt.Println("log")
  26145. fmt.Println(string(result))
  26146. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  26147. utils.ErrorLog("解析失败:%v", err)
  26148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26149. return
  26150. }
  26151. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26152. res.Output = resEleven10265.Output
  26153. res.ErrMsg = resEleven10265.ErrMsg
  26154. res.Cainfo = resEleven10265.Cainfo
  26155. res.WarnMsg = resEleven10265.WarnMsg
  26156. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26157. res.Infcode = infocode
  26158. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26159. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26160. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26161. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26162. resp, requestErr := http.Get(api)
  26163. if requestErr != nil {
  26164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26165. return
  26166. }
  26167. body, ioErr := ioutil.ReadAll(resp.Body)
  26168. if ioErr != nil {
  26169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26171. return
  26172. }
  26173. var respJSON map[string]interface{}
  26174. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26177. return
  26178. }
  26179. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26180. result, _ := json.Marshal(respJSON)
  26181. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26182. utils.ErrorLog("解析失败:%v", err)
  26183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26184. return
  26185. }
  26186. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26187. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  26188. //return
  26189. } else {
  26190. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26191. if len(his.InsuplcAdmdvs) == 0 {
  26192. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  26193. } else {
  26194. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  26195. }
  26196. result := service.Gdyb5203(baseParams, businessParams)
  26197. //service.Gdyb5204(baseParams, businessParams)
  26198. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  26199. var dat map[string]interface{}
  26200. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26201. fmt.Println(dat)
  26202. } else {
  26203. fmt.Println(err)
  26204. }
  26205. userJSONBytes, _ := json.Marshal(dat)
  26206. if miConfig.Code == "H15049901371" {
  26207. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  26208. utils.ErrorLog("解析失败:%v", err)
  26209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26210. return
  26211. }
  26212. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26213. res.Output = resEleven10265.Output
  26214. res.ErrMsg = resEleven10265.ErrMsg
  26215. res.Cainfo = resEleven10265.Cainfo
  26216. res.WarnMsg = resEleven10265.WarnMsg
  26217. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26218. res.Infcode = infocode
  26219. } else {
  26220. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26221. utils.ErrorLog("解析失败:%v", err)
  26222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26223. return
  26224. }
  26225. }
  26226. }
  26227. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26228. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  26229. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  26230. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26231. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  26232. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26233. var doctor_name string
  26234. if roles.ID == 0 {
  26235. doctor_name = "管理员"
  26236. } else {
  26237. doctor_name = roles.UserName
  26238. }
  26239. yiliao_leibie := ""
  26240. switch order.MedType {
  26241. case "11":
  26242. yiliao_leibie = "普通门诊"
  26243. break
  26244. case "12":
  26245. yiliao_leibie = "门诊挂号"
  26246. break
  26247. case "13":
  26248. yiliao_leibie = "急诊"
  26249. break
  26250. case "14":
  26251. yiliao_leibie = "门诊特殊病"
  26252. break
  26253. case "15":
  26254. yiliao_leibie = "门诊统筹"
  26255. break
  26256. case "16":
  26257. yiliao_leibie = "门诊慢性病"
  26258. break
  26259. case "21":
  26260. yiliao_leibie = "普通住院"
  26261. break
  26262. }
  26263. //var rf []CustomFundPay
  26264. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  26265. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26266. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  26267. if res.Infcode == 0 {
  26268. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  26269. c.ServeSuccessJSON(map[string]interface{}{
  26270. "diagnosis": name,
  26271. "order_infos": orderInfos,
  26272. "number": order.MdtrtId,
  26273. "date": order.SettleAccountsDate,
  26274. "charge_admin": charge_admin,
  26275. "printor_admin": printor_admin,
  26276. "info": res.Output.Setlinfo,
  26277. "order": order,
  26278. "bedCostTotal": bedCostTotal,
  26279. "bedCostSelfTotal": bedCostSelfTotal,
  26280. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  26281. "bedSelfTotal": bedSelfTotal,
  26282. "bedInscpTotal": bedInscpTotal,
  26283. "operationCostTotal": operationCostTotal,
  26284. "operationCostSelfTotal": operationCostSelfTotal,
  26285. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  26286. "operationSelfTotal": operationSelfTotal,
  26287. "operationInscpTotal": operationInscpTotal,
  26288. "otherCostTotal": otherCostTotal,
  26289. "otherCostSelfTotal": otherCostSelfTotal,
  26290. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  26291. "otherSelfTotal": otherSelfTotal,
  26292. "otherInscpTotal": otherInscpTotal,
  26293. "materialCostTotal": materialCostTotal,
  26294. "materialCostSelfTotal": materialCostSelfTotal,
  26295. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  26296. "materialSelfTotal": materialSelfTotal,
  26297. "materialInscpTotal": materialInscpTotal,
  26298. "westernMedicineCostTotal": westernMedicineCostTotal,
  26299. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  26300. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  26301. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  26302. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  26303. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  26304. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  26305. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  26306. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  26307. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  26308. "checkCostTotal": checkCostTotal,
  26309. "checkCostSelfTotal": checkCostSelfTotal,
  26310. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  26311. "checkSelfTotal": checkSelfTotal,
  26312. "checkInscpTotal": checkInscpTotal,
  26313. "laboratoryCostTotal": laboratoryCostTotal,
  26314. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26315. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26316. "laboratorySelfTotal": laboratorySelfTotal,
  26317. "laboratoryInscpTotal": laboratoryInscpTotal,
  26318. "treatCostTotal": treatCostTotal,
  26319. "treatCostSelfTotal": treatCostSelfTotal,
  26320. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26321. "treatSelfTotal": treatSelfTotal,
  26322. "treatInscpTotal": treatInscpTotal,
  26323. "doctor_info": doctor_info,
  26324. "doctor_code": adminRole_two.DoctorCode,
  26325. "doctor_name": doctor_name,
  26326. "health_card_no": order.PsnNo,
  26327. "department": departments.Name,
  26328. "yiliao_leibie": yiliao_leibie,
  26329. "after_money": order.AccountPrice,
  26330. "patient": patient,
  26331. "org_name": miConfig.OrgName,
  26332. "org_code": miConfig.Code,
  26333. "order_number": order.Number,
  26334. "his_hospital": his_hospital,
  26335. "his": his,
  26336. "dia_config": dia_config,
  26337. "psn_cash_pay": order.PsnCashPay,
  26338. //"funds": rf,
  26339. //"check_order_info": cus_slice,
  26340. })
  26341. } else {
  26342. c.ServeSuccessJSON(map[string]interface{}{
  26343. "diagnosis": name,
  26344. "order_infos": orderInfos,
  26345. "number": order.MdtrtId,
  26346. "date": order.SettleAccountsDate,
  26347. "charge_admin": charge_admin,
  26348. "printor_admin": printor_admin,
  26349. "info": order,
  26350. "order": order,
  26351. "bedCostTotal": bedCostTotal,
  26352. "bedCostSelfTotal": bedCostSelfTotal,
  26353. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  26354. "bedSelfTotal": bedSelfTotal,
  26355. "bedInscpTotal": bedInscpTotal,
  26356. "operationCostTotal": operationCostTotal,
  26357. "operationCostSelfTotal": operationCostSelfTotal,
  26358. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  26359. "operationSelfTotal": operationSelfTotal,
  26360. "operationInscpTotal": operationInscpTotal,
  26361. "otherCostTotal": otherCostTotal,
  26362. "otherCostSelfTotal": otherCostSelfTotal,
  26363. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  26364. "otherSelfTotal": otherSelfTotal,
  26365. "otherInscpTotal": otherInscpTotal,
  26366. "materialCostTotal": materialCostTotal,
  26367. "materialCostSelfTotal": materialCostSelfTotal,
  26368. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  26369. "materialSelfTotal": materialSelfTotal,
  26370. "materialInscpTotal": materialInscpTotal,
  26371. "westernMedicineCostTotal": westernMedicineCostTotal,
  26372. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  26373. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  26374. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  26375. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  26376. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  26377. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  26378. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  26379. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  26380. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  26381. "checkCostTotal": checkCostTotal,
  26382. "checkCostSelfTotal": checkCostSelfTotal,
  26383. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  26384. "checkSelfTotal": checkSelfTotal,
  26385. "checkInscpTotal": checkInscpTotal,
  26386. "laboratoryCostTotal": laboratoryCostTotal,
  26387. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26388. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26389. "laboratorySelfTotal": laboratorySelfTotal,
  26390. "laboratoryInscpTotal": laboratoryInscpTotal,
  26391. "treatCostTotal": treatCostTotal,
  26392. "treatCostSelfTotal": treatCostSelfTotal,
  26393. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26394. "treatSelfTotal": treatSelfTotal,
  26395. "treatInscpTotal": treatInscpTotal,
  26396. "doctor_info": doctor_info,
  26397. "doctor_code": adminRole_two.DoctorCode,
  26398. "doctor_name": doctor_name,
  26399. "health_card_no": order.PsnNo,
  26400. "department": departments.Name,
  26401. "yiliao_leibie": yiliao_leibie,
  26402. "after_money": order.AccountPrice,
  26403. "patient": patient,
  26404. "org_name": miConfig.OrgName,
  26405. "org_code": miConfig.Code,
  26406. "order_number": order.Number,
  26407. "his_hospital": his_hospital,
  26408. "his": his,
  26409. "dia_config": dia_config,
  26410. "psn_cash_pay": order.PsnCashPay,
  26411. //"funds": rf,
  26412. //"check_order_info": cus_slice,
  26413. })
  26414. }
  26415. }
  26416. }
  26417. }
  26418. //func (c *HisApiController) CheckTreatment() {
  26419. // patient_id, _ := c.GetInt64("patient_id")
  26420. // id_card_no := c.GetString("id_card_no")
  26421. // insutype := c.GetString("insutype")
  26422. // med_type := c.GetString("med_type")
  26423. // admin_user_id, _ := c.GetInt64("admin_user_id")
  26424. //
  26425. // adminUser := c.GetAdminUserInfo()
  26426. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  26427. //
  26428. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26429. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26430. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26431. //
  26432. // if miConfig.MdtrtareaAdmvs == "421300" {
  26433. // var res ResultTwo
  26434. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  26435. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26436. // "&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)
  26437. // resp, requestErr := http.Get(api)
  26438. // if requestErr != nil {
  26439. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26440. // return
  26441. // }
  26442. //
  26443. // body, ioErr := ioutil.ReadAll(resp.Body)
  26444. // if ioErr != nil {
  26445. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26446. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26447. // return
  26448. // }
  26449. // var respJSON map[string]interface{}
  26450. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26451. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26453. // return
  26454. // }
  26455. //
  26456. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26457. // result, _ := json.Marshal(respJSON)
  26458. //
  26459. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  26460. // utils.ErrorLog("解析失败:%v", err)
  26461. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26462. // return
  26463. // }
  26464. //
  26465. // if res.Infcode == 0 {
  26466. //
  26467. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  26468. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26469. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  26470. // resp, requestErr := http.Get(api)
  26471. // if requestErr != nil {
  26472. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26473. // return
  26474. // }
  26475. //
  26476. // body, ioErr := ioutil.ReadAll(resp.Body)
  26477. // if ioErr != nil {
  26478. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26480. // return
  26481. // }
  26482. // var respJSON map[string]interface{}
  26483. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26484. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26486. // return
  26487. // }
  26488. // var res Result2001
  26489. //
  26490. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26491. // result2, _ := json.Marshal(respJSON)
  26492. //
  26493. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  26494. // utils.ErrorLog("解析失败:%v", err)
  26495. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26496. // return
  26497. // }
  26498. //
  26499. // if res.Infcode == 0 {
  26500. // c.ServeSuccessJSON(map[string]interface{}{
  26501. // "msg": res.Output.Trtinfo,
  26502. // })
  26503. // }
  26504. //
  26505. // } else {
  26506. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  26507. // return
  26508. // }
  26509. //
  26510. // } else {
  26511. //
  26512. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  26513. // var dat map[string]interface{}
  26514. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26515. // fmt.Println(dat)
  26516. // } else {
  26517. // fmt.Println(err)
  26518. // }
  26519. // userJSONBytes, _ := json.Marshal(dat)
  26520. // var res ResultTwo
  26521. // var res10265 ResultTwo10265
  26522. // if miConfig.Code == "H15049901371" {
  26523. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  26524. // utils.ErrorLog("解析失败:%v", err)
  26525. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26526. // return
  26527. // }
  26528. // res.ErrMsg = res10265.ErrMsg
  26529. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  26530. // res.Infcode = infocode
  26531. // res.Output = res10265.Output
  26532. // res.InfRefmsgid = res10265.InfRefmsgid
  26533. // } else {
  26534. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26535. // utils.ErrorLog("解析失败:%v", err)
  26536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26537. // return
  26538. // }
  26539. // }
  26540. //
  26541. // var user_name string
  26542. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  26543. // if role.ID == 0 {
  26544. // user_name = "xxx"
  26545. // } else {
  26546. // user_name = role.UserName
  26547. // }
  26548. //
  26549. // baseParams := models.BaseParams{
  26550. // SecretKey: miConfig.SecretKey,
  26551. // FixmedinsCode: miConfig.Code,
  26552. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26553. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26554. // OrgName: miConfig.OrgName,
  26555. // Doctor: user_name,
  26556. // }
  26557. //
  26558. // if config.IsOpen == 1 {
  26559. // if miConfig.Code == "H15049901371" {
  26560. // if med_type == "14" {
  26561. // if insutype == "390" {
  26562. // med_type = "9933"
  26563. // } else if insutype == "310" {
  26564. // med_type = "990502"
  26565. // }
  26566. // } else if med_type == "11" {
  26567. // med_type = "11"
  26568. // }
  26569. // }
  26570. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  26571. // var dat map[string]interface{}
  26572. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26573. // fmt.Println(dat)
  26574. // } else {
  26575. // fmt.Println(err)
  26576. // }
  26577. // var res Result2001
  26578. // var res10265 Result2001Org10265
  26579. // if miConfig.Code == "H15049901371" {
  26580. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  26581. // utils.ErrorLog("解析失败:%v", err)
  26582. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26583. // return
  26584. // }
  26585. // res.ErrMsg = res10265.ErrMsg
  26586. // res.Output = res10265.Output
  26587. // res.InfRefmsgid = res10265.InfRefmsgid
  26588. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  26589. // res.Infcode = infocode
  26590. // } else {
  26591. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  26592. // utils.ErrorLog("解析失败:%v", err)
  26593. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26594. // return
  26595. // }
  26596. // }
  26597. // if res.Infcode == 0 {
  26598. // c.ServeSuccessJSON(map[string]interface{}{
  26599. // "msg": res.Output.Trtinfo,
  26600. // })
  26601. // }
  26602. // }
  26603. // }
  26604. //}
  26605. //func (c *HisApiController) PutRecord() {
  26606. // id, _ := c.GetInt64("id")
  26607. // record_time := c.GetString("record_time")
  26608. // timeLayout := "2006-01-02"
  26609. // loc, _ := time.LoadLocation("Local")
  26610. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26611. // if err != nil {
  26612. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26613. // return
  26614. // }
  26615. // recordDateTime := theTime.Unix()
  26616. //
  26617. // adminInfo := c.GetAdminUserInfo()
  26618. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  26619. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26620. //
  26621. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  26622. //
  26623. // fmt.Println(miConfig.SecretKey)
  26624. //
  26625. // if patient == nil {
  26626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  26627. // return
  26628. // }
  26629. // if len(patient.IdCardNo) == 0 {
  26630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  26631. // return
  26632. // }
  26633. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  26634. // if config.IsOpen == 1 {
  26635. // 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
  26636. // resp, requestErr := http.Get(api)
  26637. // if requestErr != nil {
  26638. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26639. // return
  26640. // }
  26641. // defer resp.Body.Close()
  26642. // body, ioErr := ioutil.ReadAll(resp.Body)
  26643. // if ioErr != nil {
  26644. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26646. // return
  26647. // }
  26648. // var respJSON map[string]interface{}
  26649. //
  26650. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26651. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26652. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26653. // return
  26654. // }
  26655. //
  26656. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26657. // userJSONBytes, _ := json.Marshal(userJSON)
  26658. // var res ResultTwo
  26659. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26660. // utils.ErrorLog("解析失败:%v", err)
  26661. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26662. // return
  26663. // }
  26664. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  26665. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  26666. // infoStr := string(Iinfos)
  26667. // idetinfoStr := string(Idetinfos)
  26668. //
  26669. // if res.Infcode == 0 {
  26670. // his := models.VMHisPatient{
  26671. // Status: 1,
  26672. // Ctime: time.Now().Unix(),
  26673. // Mtime: time.Now().Unix(),
  26674. // PsnNo: res.Output.Baseinfo.PsnNo,
  26675. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  26676. // Certno: res.Output.Baseinfo.Certno,
  26677. // PsnName: res.Output.Baseinfo.PsnName,
  26678. // Gend: res.Output.Baseinfo.Gend,
  26679. // Naty: res.Output.Baseinfo.Naty,
  26680. // Brdy: res.Output.Baseinfo.Brdy,
  26681. // Age: res.Output.Baseinfo.Age,
  26682. // Iinfo: infoStr,
  26683. // Idetinfo: idetinfoStr,
  26684. // PatientId: patient.ID,
  26685. // RecordDate: theTime.Unix(),
  26686. // UserOrgId: adminInfo.CurrentOrgId,
  26687. // AdminUserId: adminInfo.AdminUser.Id,
  26688. // IsReturn: 1,
  26689. // }
  26690. //
  26691. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  26692. // //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")
  26693. // //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")
  26694. //
  26695. // //var dat map[string]interface{}
  26696. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26697. // // fmt.Println(dat)
  26698. // //} else {
  26699. // // fmt.Println(err)
  26700. // //}
  26701. //
  26702. // var dat2 map[string]interface{}
  26703. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26704. // fmt.Println(dat2)
  26705. // } else {
  26706. // fmt.Println(err)
  26707. // }
  26708. //
  26709. // } else {
  26710. // adminUser := c.GetAdminUserInfo()
  26711. // errlog := &models.HisOrderError{
  26712. // UserOrgId: adminUser.CurrentOrgId,
  26713. // Ctime: time.Now().Unix(),
  26714. // Mtime: time.Now().Unix(),
  26715. // ErrMsg: res.ErrMsg,
  26716. // Status: 1,
  26717. // PatientId: id,
  26718. // RecordTime: recordDateTime,
  26719. // Stage: 1,
  26720. // }
  26721. // service.CreateErrMsgLog(errlog)
  26722. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26723. // return
  26724. // }
  26725. // }
  26726. //
  26727. //}
  26728. //func (c *HisApiController) GetUploadDiag() {
  26729. // id, _ := c.GetInt64("id")
  26730. // record_time := c.GetString("record_time")
  26731. //
  26732. // diagnosis_id, _ := c.GetInt64("diagnosis")
  26733. // sick_type, _ := c.GetInt64("sick_type")
  26734. // reg_type, _ := c.GetInt64("reg_type")
  26735. //
  26736. // timeLayout := "2006-01-02"
  26737. // loc, _ := time.LoadLocation("Local")
  26738. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26739. // if err != nil {
  26740. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26741. // return
  26742. // }
  26743. //
  26744. // var patientPrescription models.HisPrescriptionInfo
  26745. // recordDateTime := theTime.Unix()
  26746. // adminInfo := c.GetAdminUserInfo()
  26747. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26748. //
  26749. // if patientPrescription.ID == 0 {
  26750. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26751. // }
  26752. //
  26753. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  26754. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  26755. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26756. // sickConfig, _ := service.FindSickById(sick_type)
  26757. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26758. //
  26759. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  26760. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  26761. // "&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 +
  26762. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  26763. // resp2, requestErr2 := http.Get(api2)
  26764. // if requestErr2 != nil {
  26765. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26766. // return
  26767. // }
  26768. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  26769. // if ioErr2 != nil {
  26770. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  26771. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26772. // return
  26773. // }
  26774. // var respJSON2 map[string]interface{}
  26775. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  26776. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26778. // return
  26779. // }
  26780. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26781. // userJSONBytes2, _ := json.Marshal(respJSON2)
  26782. //
  26783. // var res2 ResultSix
  26784. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26785. // utils.ErrorLog("解析失败:%v", err)
  26786. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26787. // return
  26788. // }
  26789. // if res2.Infcode != 0 {
  26790. // adminUser := c.GetAdminUserInfo()
  26791. // errlog := &models.HisOrderError{
  26792. // UserOrgId: adminUser.CurrentOrgId,
  26793. // Ctime: time.Now().Unix(),
  26794. // Mtime: time.Now().Unix(),
  26795. // ErrMsg: res2.ErrMsg,
  26796. // Status: 1,
  26797. // PatientId: id,
  26798. // RecordTime: recordDateTime,
  26799. // Stage: 3,
  26800. // }
  26801. // service.CreateErrMsgLog(errlog)
  26802. //
  26803. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  26804. // return
  26805. // }
  26806. //
  26807. // c.ServeSuccessJSON(map[string]interface{}{
  26808. // "msg": "上传成功",
  26809. // })
  26810. //
  26811. //}
  26812. type QueryResult struct {
  26813. ID int64
  26814. Name string
  26815. Code string
  26816. List_type_code string
  26817. }
  26818. func (c *HisApiController) GetCheckCode() {
  26819. ids_str := c.GetString("ids")
  26820. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  26821. ids_arr := strings.Split(ids_str, ",")
  26822. var queryResult []QueryResult
  26823. ids := make([]int64, 0)
  26824. for _, item := range ids_arr {
  26825. id, _ := strconv.ParseInt(item, 10, 64)
  26826. ids = append(ids, id)
  26827. }
  26828. if record_type == 1 {
  26829. drugs, _ := service.GetBatchDrugList(ids)
  26830. for _, item := range drugs {
  26831. result := QueryResult{
  26832. ID: item.ID,
  26833. Name: item.DrugName,
  26834. Code: item.MedicalInsuranceNumber,
  26835. List_type_code: "101",
  26836. }
  26837. queryResult = append(queryResult, result)
  26838. }
  26839. } else if record_type == 2 {
  26840. goods, _ := service.GetBatchGoodInformationList(ids)
  26841. fmt.Println(goods)
  26842. for _, item := range goods {
  26843. result := QueryResult{
  26844. ID: item.ID,
  26845. Name: item.GoodName,
  26846. Code: item.SocialSecurityDirectoryCode,
  26847. List_type_code: "301",
  26848. }
  26849. queryResult = append(queryResult, result)
  26850. }
  26851. } else if record_type == 3 {
  26852. projects, _ := service.GetBathchMyPorjecgList(ids)
  26853. for _, item := range projects {
  26854. result := QueryResult{
  26855. ID: item.ID,
  26856. Name: item.ProjectName,
  26857. Code: item.MedicalCode,
  26858. List_type_code: "201",
  26859. }
  26860. queryResult = append(queryResult, result)
  26861. }
  26862. }
  26863. admin_user_id, _ := c.GetInt64("admin_user_id")
  26864. adminUser := c.GetAdminUserInfo()
  26865. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26866. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26867. var user_name string
  26868. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26869. if role.ID == 0 {
  26870. user_name = "管理员"
  26871. } else {
  26872. user_name = role.UserName
  26873. }
  26874. baseParams := models.BaseParams{
  26875. SecretKey: miConfig.SecretKey,
  26876. FixmedinsCode: miConfig.Code,
  26877. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26878. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26879. OrgName: miConfig.OrgName,
  26880. Doctor: user_name,
  26881. }
  26882. var result string
  26883. if miConfig.MdtrtareaAdmvs == "430800" {
  26884. for _, item := range queryResult {
  26885. if record_type == 1 {
  26886. 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)
  26887. } else if record_type == 2 {
  26888. fmt.Println(item.Code)
  26889. 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)
  26890. } else if record_type == 3 {
  26891. 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)
  26892. }
  26893. var dat map[string]interface{}
  26894. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26895. fmt.Println(dat)
  26896. } else {
  26897. fmt.Println(err)
  26898. }
  26899. userJSONBytes, _ := json.Marshal(dat)
  26900. var res ResultSix
  26901. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26902. utils.ErrorLog("解析失败:%v", err)
  26903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26904. return
  26905. }
  26906. if res.Infcode == 0 {
  26907. if record_type == 1 {
  26908. service.UpdateBaseDrugById(item.ID)
  26909. } else if record_type == 2 {
  26910. service.UpdateGoodInformaitonByDetail(item.ID)
  26911. } else if record_type == 3 {
  26912. service.UpdateProjectById(item.ID)
  26913. }
  26914. c.ServeSuccessJSON(map[string]interface{}{
  26915. "failed_code": 0,
  26916. "msg": "目录对照成功",
  26917. })
  26918. } else {
  26919. c.ServeSuccessJSON(map[string]interface{}{
  26920. "failed_code": -10,
  26921. "msg": res.ErrMsg,
  26922. })
  26923. }
  26924. }
  26925. } else {
  26926. for _, item := range queryResult {
  26927. var result string
  26928. if record_type == 1 {
  26929. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  26930. } else if record_type == 2 {
  26931. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  26932. } else if record_type == 3 {
  26933. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  26934. }
  26935. var dat map[string]interface{}
  26936. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26937. fmt.Println(dat)
  26938. } else {
  26939. fmt.Println(err)
  26940. }
  26941. userJSONBytes, _ := json.Marshal(dat)
  26942. var res ResultSix
  26943. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26944. utils.ErrorLog("解析失败:%v", err)
  26945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26946. return
  26947. }
  26948. if res.Infcode == 0 {
  26949. if record_type == 1 {
  26950. service.UpdateBaseDrugById(item.ID)
  26951. } else if record_type == 2 {
  26952. service.UpdateGoodInformaitonByDetail(item.ID)
  26953. } else if record_type == 3 {
  26954. service.UpdateProjectById(item.ID)
  26955. }
  26956. c.ServeSuccessJSON(map[string]interface{}{
  26957. "failed_code": 0,
  26958. "msg": "目录对照成功",
  26959. })
  26960. } else {
  26961. c.ServeSuccessJSON(map[string]interface{}{
  26962. "failed_code": -10,
  26963. "msg": res.ErrMsg,
  26964. })
  26965. }
  26966. }
  26967. }
  26968. }
  26969. func (c *HisApiController) UnCheckCode() {
  26970. ids_str := c.GetString("ids")
  26971. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  26972. admin_user_id, _ := c.GetInt64("admin_user_id")
  26973. ids_arr := strings.Split(ids_str, ",")
  26974. var queryResult []QueryResult
  26975. ids := make([]int64, 0)
  26976. for _, item := range ids_arr {
  26977. id, _ := strconv.ParseInt(item, 10, 64)
  26978. ids = append(ids, id)
  26979. }
  26980. if record_type == 1 {
  26981. drugs, _ := service.GetBatchDrugList(ids)
  26982. for _, item := range drugs {
  26983. result := QueryResult{
  26984. ID: item.ID,
  26985. Name: item.DrugName,
  26986. Code: item.MedicalInsuranceNumber,
  26987. List_type_code: "101",
  26988. }
  26989. queryResult = append(queryResult, result)
  26990. }
  26991. } else if record_type == 2 {
  26992. goods, _ := service.GetBatchGoodInformationList(ids)
  26993. for _, item := range goods {
  26994. result := QueryResult{
  26995. ID: item.ID,
  26996. Name: item.GoodName,
  26997. Code: item.SocialSecurityDirectoryCode,
  26998. List_type_code: "301",
  26999. }
  27000. queryResult = append(queryResult, result)
  27001. }
  27002. } else if record_type == 3 {
  27003. projects, _ := service.GetBathchMyPorjecgList(ids)
  27004. for _, item := range projects {
  27005. result := QueryResult{
  27006. ID: item.ID,
  27007. Name: item.ProjectName,
  27008. Code: item.MedicalCode,
  27009. List_type_code: "201",
  27010. }
  27011. queryResult = append(queryResult, result)
  27012. }
  27013. }
  27014. adminUser := c.GetAdminUserInfo()
  27015. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27016. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27017. var user_name string
  27018. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27019. if role.ID == 0 {
  27020. user_name = "xxx"
  27021. } else {
  27022. user_name = role.UserName
  27023. }
  27024. baseParams := &models.BaseParams{
  27025. SecretKey: miConfig.SecretKey,
  27026. FixmedinsCode: miConfig.Code,
  27027. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27028. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27029. OrgName: miConfig.OrgName,
  27030. Doctor: user_name,
  27031. }
  27032. if config.IsOpen == 1 {
  27033. if miConfig.MdtrtareaAdmvs == "430800" {
  27034. for _, item := range queryResult {
  27035. var result string
  27036. if record_type == 1 {
  27037. 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)
  27038. } else if record_type == 2 {
  27039. fmt.Println(item.Code)
  27040. 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)
  27041. } else if record_type == 3 {
  27042. 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)
  27043. }
  27044. var dat map[string]interface{}
  27045. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27046. fmt.Println(dat)
  27047. } else {
  27048. fmt.Println(err)
  27049. }
  27050. userJSONBytes, _ := json.Marshal(dat)
  27051. var res ResultSix
  27052. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27053. utils.ErrorLog("解析失败:%v", err)
  27054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27055. return
  27056. }
  27057. if res.Infcode == 0 {
  27058. if record_type == 1 {
  27059. service.UpdateBaseDrugById(item.ID)
  27060. } else if record_type == 2 {
  27061. service.UpdateGoodInformaitonByDetail(item.ID)
  27062. } else if record_type == 3 {
  27063. service.UpdateProjectById(item.ID)
  27064. }
  27065. c.ServeSuccessJSON(map[string]interface{}{
  27066. "failed_code": 0,
  27067. "msg": "目录对照成功",
  27068. })
  27069. } else {
  27070. c.ServeSuccessJSON(map[string]interface{}{
  27071. "failed_code": -10,
  27072. "msg": res.ErrMsg,
  27073. })
  27074. }
  27075. }
  27076. } else {
  27077. for _, item := range queryResult {
  27078. var result string
  27079. if record_type == 1 {
  27080. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  27081. } else if record_type == 2 {
  27082. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  27083. } else if record_type == 3 {
  27084. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  27085. }
  27086. var dat2 map[string]interface{}
  27087. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  27088. fmt.Println(dat2)
  27089. } else {
  27090. fmt.Println(err)
  27091. }
  27092. userJSONBytes, _ := json.Marshal(dat2)
  27093. var res ResultSix
  27094. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27095. utils.ErrorLog("解析失败:%v", err)
  27096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27097. return
  27098. }
  27099. if res.Infcode == 0 {
  27100. if record_type == 1 {
  27101. service.UpdateDrugByIdDetail(item.ID)
  27102. } else if record_type == 2 {
  27103. service.UpdateGoodInfoById(item.ID)
  27104. } else if record_type == 3 {
  27105. service.UpdateMyProjectById(item.ID)
  27106. }
  27107. c.ServeSuccessJSON(map[string]interface{}{
  27108. "failed_code": 0,
  27109. "msg": "撤销目录对照成功",
  27110. })
  27111. } else {
  27112. c.ServeSuccessJSON(map[string]interface{}{
  27113. "failed_code": -10,
  27114. "msg": res.ErrMsg,
  27115. })
  27116. }
  27117. }
  27118. }
  27119. }
  27120. }
  27121. func (c *HisApiController) GetPatientInfo() {
  27122. id_card_no := c.GetString("id_card_no")
  27123. admin_user_id, _ := c.GetInt64("admin_user_id")
  27124. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  27125. if patient.ID == 0 {
  27126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  27127. return
  27128. }
  27129. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  27130. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  27131. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  27132. var res ResultTwo
  27133. var res10265 ResultTwo10265
  27134. if config.IsOpen == 1 {
  27135. if miConfig.MdtrtareaAdmvs == "150499" {
  27136. //请求内网数据
  27137. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  27138. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  27139. "&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
  27140. resp, requestErr := http.Get(api)
  27141. if requestErr != nil {
  27142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27143. return
  27144. }
  27145. body, ioErr := ioutil.ReadAll(resp.Body)
  27146. if ioErr != nil {
  27147. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27149. return
  27150. }
  27151. var respJSON map[string]interface{}
  27152. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27153. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27155. return
  27156. }
  27157. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27158. result_byte, _ := json.Marshal(respJSON)
  27159. result := string(result_byte)
  27160. var dat map[string]interface{}
  27161. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27162. fmt.Println(dat)
  27163. } else {
  27164. fmt.Println(err)
  27165. }
  27166. userJSONBytes, _ := json.Marshal(dat)
  27167. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27168. utils.ErrorLog("解析失败:%v", err)
  27169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27170. return
  27171. }
  27172. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27173. res.Infcode = Infcode
  27174. res.ErrMsg = res10265.ErrMsg
  27175. res.Output = res10265.Output
  27176. res.InfRefmsgid = res10265.InfRefmsgid
  27177. res.RespondTime = res10265.RespondTime
  27178. res.WarnInfo = res10265.WarnInfo
  27179. } else {
  27180. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  27181. var dat map[string]interface{}
  27182. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27183. fmt.Println(dat)
  27184. } else {
  27185. fmt.Println(err)
  27186. }
  27187. userJSONBytes, _ := json.Marshal(dat)
  27188. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27189. utils.ErrorLog("解析失败:%v", err)
  27190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27191. return
  27192. }
  27193. }
  27194. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27195. // utils.ErrorLog("解析失败:%v", err)
  27196. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27197. // return
  27198. //}
  27199. for index, item := range res.Output.Iinfo {
  27200. if item.PsnInsuStas == "2" {
  27201. fmt.Println("--------")
  27202. res.Output.Iinfo[index].Insutype = "300"
  27203. res.Output.Iinfo[index].PsnInsuStas = "1"
  27204. }
  27205. }
  27206. fmt.Println(res.Output.Iinfo)
  27207. if res.Infcode != 0 {
  27208. c.ServeSuccessJSON(map[string]interface{}{
  27209. "failed_code": -10,
  27210. "msg": res.ErrMsg,
  27211. })
  27212. } else {
  27213. c.ServeSuccessJSON(map[string]interface{}{
  27214. "failed_code": 0,
  27215. "info": res,
  27216. })
  27217. }
  27218. }
  27219. }
  27220. func (c *HisApiController) PsnPutOnRecord() {
  27221. record_type, _ := c.GetInt64("type")
  27222. patient_id, _ := c.GetInt64("patient_id")
  27223. admin_user_id, _ := c.GetInt64("admin_user_id")
  27224. start_time := c.GetString("start_time")
  27225. end_time := c.GetString("end_time")
  27226. adminUser := c.GetAdminUserInfo()
  27227. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27228. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27229. var patients []*models.Patients
  27230. if record_type == 1 { //全部备案
  27231. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  27232. patients = append(patients, patient...)
  27233. } else { //单个备案
  27234. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  27235. patients = append(patients, patient)
  27236. }
  27237. var user_name string
  27238. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27239. if role.ID == 0 {
  27240. user_name = "xxx"
  27241. } else {
  27242. user_name = role.UserName
  27243. }
  27244. if config.IsOpen == 1 {
  27245. for _, item := range patients {
  27246. 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
  27247. resp, requestErr := http.Get(api)
  27248. if requestErr != nil {
  27249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27250. return
  27251. }
  27252. defer resp.Body.Close()
  27253. body, ioErr := ioutil.ReadAll(resp.Body)
  27254. if ioErr != nil {
  27255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27257. return
  27258. }
  27259. var respJSON map[string]interface{}
  27260. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27263. return
  27264. }
  27265. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27266. userJSONBytes, _ := json.Marshal(userJSON)
  27267. var res ResultTwo
  27268. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27269. utils.ErrorLog("解析失败:%v", err)
  27270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27271. return
  27272. }
  27273. if res.Infcode == 0 {
  27274. 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)
  27275. var dat map[string]interface{}
  27276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27277. fmt.Println(dat)
  27278. } else {
  27279. fmt.Println(err)
  27280. }
  27281. userJSONBytes, _ := json.Marshal(dat)
  27282. var res2 ResultThirteen
  27283. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27284. utils.ErrorLog("解析失败:%v", err)
  27285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27286. return
  27287. }
  27288. if res2.Infcode == 0 {
  27289. psnResult := &models.GdybPsnRecord{
  27290. UserOrgId: adminUser.CurrentOrgId,
  27291. PatientId: item.ID,
  27292. PsnNo: res.Output.Baseinfo.PsnNo,
  27293. Ctime: time.Now().Unix(),
  27294. Mtime: time.Now().Unix(),
  27295. Status: 1,
  27296. IsCancel: 1,
  27297. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  27298. }
  27299. service.CreatePsnRecord(psnResult)
  27300. } else {
  27301. c.ServeSuccessJSON(map[string]interface{}{
  27302. "failed_code": -10,
  27303. "msg": res2.ErrMsg,
  27304. })
  27305. return
  27306. }
  27307. }
  27308. }
  27309. }
  27310. }
  27311. func (c *HisApiController) PsnUnPutOnRecord() {
  27312. id, _ := c.GetInt64("id")
  27313. //record_type, _ := c.GetInt64("type")
  27314. admin_user_id, _ := c.GetInt64("admin_user_id")
  27315. adminUser := c.GetAdminUserInfo()
  27316. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27317. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27318. var user_name string
  27319. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27320. if role.ID == 0 {
  27321. user_name = "xxx"
  27322. } else {
  27323. user_name = role.UserName
  27324. }
  27325. psn_record, _ := service.GetPsnRecordById(id)
  27326. if psn_record.ID == 0 {
  27327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  27328. return
  27329. }
  27330. if config.IsOpen == 1 {
  27331. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  27332. var dat map[string]interface{}
  27333. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27334. fmt.Println(dat)
  27335. } else {
  27336. fmt.Println(err)
  27337. }
  27338. userJSONBytes, _ := json.Marshal(dat)
  27339. var res ResultFourteen
  27340. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27341. utils.ErrorLog("解析失败:%v", err)
  27342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27343. return
  27344. }
  27345. if res.Infcode == 0 {
  27346. psn_record.IsCancel = 2
  27347. service.CreatePsnRecord(&psn_record)
  27348. } else {
  27349. c.ServeSuccessJSON(map[string]interface{}{
  27350. "failed_code": -10,
  27351. "msg": res.ErrMsg,
  27352. })
  27353. return
  27354. }
  27355. }
  27356. }
  27357. func (c *HisApiController) PsnPutNCDSOnRecord() {
  27358. patient_id, _ := c.GetInt64("patient_id")
  27359. insutype_two := c.GetString("insutype")
  27360. psn_no := c.GetString("psn_no")
  27361. doctor_id, _ := c.GetInt64("doctor_id")
  27362. sick_id, _ := c.GetInt64("sick_id")
  27363. department_id, _ := c.GetInt64("department_id")
  27364. start_time := c.GetString("start_time")
  27365. end_time := c.GetString("end_time")
  27366. check_time := c.GetString("check_time")
  27367. hospital_code := c.GetString("hospital_code")
  27368. hospital_name := c.GetString("hospital_name")
  27369. adminUser := c.GetAdminUserInfo()
  27370. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  27371. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27372. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27373. sick, _ := service.FindSickById(sick_id)
  27374. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  27375. if len(hospital_code) == 0 {
  27376. hospital_code = miConfig.Code
  27377. }
  27378. if len(hospital_name) == 0 {
  27379. hospital_name = miConfig.OrgName
  27380. }
  27381. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  27382. var res ResultTwo
  27383. var res10265 ResultTwo10265
  27384. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27385. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  27386. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  27387. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  27388. "&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
  27389. resp, requestErr := http.Get(api)
  27390. if requestErr != nil {
  27391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27392. return
  27393. }
  27394. body, ioErr := ioutil.ReadAll(resp.Body)
  27395. if ioErr != nil {
  27396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27398. return
  27399. }
  27400. var respJSON map[string]interface{}
  27401. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27404. return
  27405. }
  27406. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27407. result, _ := json.Marshal(respJSON)
  27408. fmt.Println("log")
  27409. fmt.Println(string(result))
  27410. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27411. utils.ErrorLog("解析失败:%v", err)
  27412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27413. return
  27414. }
  27415. res.ErrMsg = res10265.ErrMsg
  27416. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27417. res.Infcode = infocode
  27418. res.Output = res10265.Output
  27419. res.InfRefmsgid = res10265.InfRefmsgid
  27420. } else {
  27421. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  27422. if miConfig.Code == "H15049901371" {
  27423. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27424. utils.ErrorLog("解析失败:%v", err)
  27425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27426. return
  27427. }
  27428. res.ErrMsg = res10265.ErrMsg
  27429. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27430. res.Infcode = infocode
  27431. res.Output = res10265.Output
  27432. res.InfRefmsgid = res10265.InfRefmsgid
  27433. } else {
  27434. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27435. utils.ErrorLog("解析失败:%v", err)
  27436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27437. return
  27438. }
  27439. }
  27440. }
  27441. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27442. infoStr := string(Iinfos)
  27443. var rf []*ResultFive
  27444. json.Unmarshal([]byte(infoStr), &rf)
  27445. var insuplc_admdvs string
  27446. var insutype string
  27447. var is390 int = 0
  27448. var is310 int = 0
  27449. var insutypes []*ResultFive
  27450. for _, item := range rf {
  27451. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27452. insutypes = append(insutypes, item)
  27453. }
  27454. }
  27455. if len(insutypes) == 1 {
  27456. insutype = insutypes[0].Insutype
  27457. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  27458. } else {
  27459. for _, i := range insutypes {
  27460. if i.Insutype == "390" {
  27461. is390 = 1
  27462. }
  27463. if i.Insutype == "310" {
  27464. is310 = 1
  27465. }
  27466. }
  27467. }
  27468. if is390 == 1 {
  27469. insutype = "390"
  27470. }
  27471. if is310 == 1 {
  27472. insutype = "310"
  27473. }
  27474. if len(insutypes) == 2 {
  27475. insutype = insutype_two
  27476. }
  27477. if len(insutypes) == 0 {
  27478. insutype = "310"
  27479. }
  27480. insutype = insutype_two
  27481. fmt.Println(insutype)
  27482. for _, item := range rf {
  27483. fmt.Println(item.Insutype)
  27484. fmt.Println(insutype)
  27485. if item.Insutype == insutype {
  27486. fmt.Println(item.Insutype)
  27487. fmt.Println(insutype)
  27488. insuplc_admdvs = item.InsuplcAdmdvs
  27489. }
  27490. }
  27491. fmt.Println(insuplc_admdvs)
  27492. var res2 ResultThirteen
  27493. var res10265_2 ResultThirteen10265
  27494. if config.IsOpen == 1 {
  27495. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27496. } else {
  27497. if miConfig.MdtrtareaAdmvs == "150499" {
  27498. //
  27499. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  27500. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  27501. // "&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
  27502. //resp, requestErr := http.Get(api)
  27503. //if requestErr != nil {
  27504. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27505. // return
  27506. //}
  27507. //
  27508. //body, ioErr := ioutil.ReadAll(resp.Body)
  27509. //if ioErr != nil {
  27510. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27511. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27512. // return
  27513. //}
  27514. //var respJSON map[string]interface{}
  27515. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27516. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27518. // return
  27519. //}
  27520. //
  27521. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27522. //result, _ := json.Marshal(respJSON)
  27523. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  27524. // utils.ErrorLog("解析失败:%v", err)
  27525. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27526. // return
  27527. //}
  27528. //infocode = resThree.Infcode
  27529. //result, _ := json.Marshal(respJSON)
  27530. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  27531. // utils.ErrorLog("解析失败:%v", err)
  27532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27533. // return
  27534. //}
  27535. //
  27536. //resThree.ErrMsg = resThree10265.ErrMsg
  27537. //
  27538. //resThree.Output = resThree10265.Output
  27539. //
  27540. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  27541. //
  27542. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  27543. //
  27544. } else {
  27545. 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)
  27546. var dat map[string]interface{}
  27547. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27548. fmt.Println(dat)
  27549. } else {
  27550. fmt.Println(err)
  27551. }
  27552. userJSONBytes, _ := json.Marshal(dat)
  27553. if miConfig.Code == "H15049901371" {
  27554. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  27555. utils.ErrorLog("解析失败:%v", err)
  27556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27557. return
  27558. }
  27559. res2.ErrMsg = res10265_2.ErrMsg
  27560. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  27561. res2.Infcode = infocode
  27562. res2.Output = res10265_2.Output
  27563. res2.InfRefmsgid = res10265_2.InfRefmsgid
  27564. } else {
  27565. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27566. utils.ErrorLog("解析失败:%v", err)
  27567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27568. return
  27569. }
  27570. }
  27571. }
  27572. }
  27573. if res2.Infcode == 0 {
  27574. psnResult := &models.GdybPsnNcdsRecord{
  27575. UserOrgId: adminUser.CurrentOrgId,
  27576. PatientId: patient.ID,
  27577. PsnNo: psn_no,
  27578. DoctorId: doctor.AdminUserId,
  27579. DepartmentId: department_id,
  27580. SickType: sick_id,
  27581. Insutype: insutype,
  27582. Ctime: time.Now().Unix(),
  27583. Mtime: time.Now().Unix(),
  27584. Status: 1,
  27585. IsCancel: 1,
  27586. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  27587. }
  27588. service.CreatePsnNCDSRecord(psnResult)
  27589. c.ServeSuccessJSON(map[string]interface{}{
  27590. "failed_code": 0,
  27591. "msg": "备案成功",
  27592. "result": psnResult,
  27593. })
  27594. } else {
  27595. c.ServeSuccessJSON(map[string]interface{}{
  27596. "failed_code": -10,
  27597. "msg": res2.ErrMsg,
  27598. })
  27599. return
  27600. }
  27601. }
  27602. }
  27603. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  27604. id, _ := c.GetInt64("id")
  27605. admin_user_id, _ := c.GetInt64("admin_user_id")
  27606. adminUser := c.GetAdminUserInfo()
  27607. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27608. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27609. //config, _ := service.Ge(adminUser.CurrentOrgId)
  27610. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  27611. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27612. //var user_name string
  27613. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27614. //if role.ID == 0 {
  27615. // user_name = "xxx"
  27616. //} else {
  27617. // user_name = role.UserName
  27618. //}
  27619. psn_record, _ := service.GetPsnNCDSRecordById(id)
  27620. if psn_record.ID == 0 {
  27621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  27622. return
  27623. }
  27624. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  27625. var res ResultTwo
  27626. var res10265 ResultTwo10265
  27627. if miConfig.Code == "H15049901371" {
  27628. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27629. utils.ErrorLog("解析失败:%v", err)
  27630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27631. return
  27632. }
  27633. res.ErrMsg = res10265.ErrMsg
  27634. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27635. res.Infcode = infocode
  27636. res.Output = res10265.Output
  27637. res.InfRefmsgid = res10265.InfRefmsgid
  27638. } else {
  27639. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27640. utils.ErrorLog("解析失败:%v", err)
  27641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27642. return
  27643. }
  27644. }
  27645. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27646. infoStr := string(Iinfos)
  27647. var rf []*ResultFive
  27648. json.Unmarshal([]byte(infoStr), &rf)
  27649. var insuplc_admdvs string
  27650. var insutype string
  27651. var is390 int = 0
  27652. var is310 int = 0
  27653. var insutypes []*ResultFive
  27654. for _, item := range rf {
  27655. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27656. insutypes = append(insutypes, item)
  27657. }
  27658. }
  27659. if len(insutypes) == 1 {
  27660. insutype = insutypes[0].Insutype
  27661. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  27662. } else {
  27663. for _, i := range insutypes {
  27664. if i.Insutype == "390" {
  27665. is390 = 1
  27666. }
  27667. if i.Insutype == "310" {
  27668. is310 = 1
  27669. }
  27670. }
  27671. }
  27672. if is390 == 1 {
  27673. insutype = "390"
  27674. }
  27675. if is310 == 1 {
  27676. insutype = "310"
  27677. }
  27678. if len(insutypes) == 0 {
  27679. insutype = "310"
  27680. }
  27681. insutype = psn_record.Insutype
  27682. for _, item := range rf {
  27683. if item.Insutype == insutype {
  27684. insuplc_admdvs = item.InsuplcAdmdvs
  27685. }
  27686. }
  27687. if config.IsOpen == 1 {
  27688. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  27689. var dat map[string]interface{}
  27690. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27691. fmt.Println(dat)
  27692. } else {
  27693. fmt.Println(err)
  27694. }
  27695. userJSONBytes, _ := json.Marshal(dat)
  27696. var res ResultFourteen
  27697. var res10265 ResultFourteen10265
  27698. if miConfig.Code == "H15049901371" {
  27699. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27700. utils.ErrorLog("解析失败:%v", err)
  27701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27702. return
  27703. }
  27704. res.ErrMsg = res10265.ErrMsg
  27705. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27706. res.Infcode = infocode
  27707. res.Output = res10265.Output
  27708. res.InfRefmsgid = res10265.InfRefmsgid
  27709. } else {
  27710. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27711. utils.ErrorLog("解析失败:%v", err)
  27712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27713. return
  27714. }
  27715. }
  27716. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27717. // utils.ErrorLog("解析失败:%v", err)
  27718. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27719. // return
  27720. //}
  27721. if res.Infcode == 0 {
  27722. psn_record.IsCancel = 2
  27723. service.CreatePsnNCDSRecord(&psn_record)
  27724. c.ServeSuccessJSON(map[string]interface{}{
  27725. "failed_code": 0,
  27726. "msg": "撤销备案成功",
  27727. })
  27728. } else {
  27729. c.ServeSuccessJSON(map[string]interface{}{
  27730. "failed_code": -10,
  27731. "msg": res.ErrMsg,
  27732. })
  27733. return
  27734. }
  27735. }
  27736. }
  27737. func (c *HisApiController) TestTest() {
  27738. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  27739. fmt.Println(patient.Iinfo)
  27740. }
  27741. type CustomData struct {
  27742. MsgId string
  27743. PsnNo string
  27744. Info string
  27745. }
  27746. func (c *HisApiController) ReversalData() {
  27747. var customData []*CustomData
  27748. custom := &CustomData{
  27749. MsgId: "H44022900158202103301714472004",
  27750. PsnNo: "44020000001101329945",
  27751. Info: "2207",
  27752. }
  27753. customData = append(customData, custom)
  27754. custom1 := &CustomData{
  27755. MsgId: "H4402290015820210330172057803",
  27756. PsnNo: "44020000001101161813",
  27757. Info: "2207",
  27758. }
  27759. customData = append(customData, custom1)
  27760. custom2 := &CustomData{
  27761. MsgId: "H44022900158202103301705198813",
  27762. PsnNo: "44190000133097375417",
  27763. Info: "2207",
  27764. }
  27765. customData = append(customData, custom2)
  27766. custom3 := &CustomData{
  27767. MsgId: "H44022900158202103301715524756",
  27768. PsnNo: "44020000001100187221",
  27769. Info: "2207",
  27770. }
  27771. customData = append(customData, custom3)
  27772. custom4 := &CustomData{
  27773. MsgId: "H44022900158202103301730376224",
  27774. PsnNo: "44020000001101959155",
  27775. Info: "2207",
  27776. }
  27777. customData = append(customData, custom4)
  27778. custom5 := &CustomData{
  27779. MsgId: "H44022900158202103301748008725",
  27780. PsnNo: "44020000001104246641",
  27781. Info: "2207",
  27782. }
  27783. customData = append(customData, custom5)
  27784. custom6 := &CustomData{
  27785. MsgId: "H44022900158202103301718096755",
  27786. PsnNo: "44020000001102211860",
  27787. Info: "2207",
  27788. }
  27789. customData = append(customData, custom6)
  27790. custom7 := &CustomData{
  27791. MsgId: "H44022900158202103301736551640",
  27792. PsnNo: "44020000001102687718",
  27793. Info: "2207",
  27794. }
  27795. customData = append(customData, custom7)
  27796. custom8 := &CustomData{
  27797. MsgId: "H44022900158202103301743097676",
  27798. PsnNo: "44020000001102127785",
  27799. Info: "2207",
  27800. }
  27801. customData = append(customData, custom8)
  27802. custom9 := &CustomData{
  27803. MsgId: "H44022900158202103301712304203",
  27804. PsnNo: "44020000001101518097",
  27805. Info: "2207",
  27806. }
  27807. customData = append(customData, custom9)
  27808. custom10 := &CustomData{
  27809. MsgId: "H44022900158202103301738448785",
  27810. PsnNo: "44020000001100500813",
  27811. Info: "2207",
  27812. }
  27813. customData = append(customData, custom10)
  27814. custom11 := &CustomData{
  27815. MsgId: "H44022900158202103301732455843",
  27816. PsnNo: "44020000001102690557",
  27817. Info: "2207",
  27818. }
  27819. customData = append(customData, custom11)
  27820. custom12 := &CustomData{
  27821. MsgId: "H44022900158202103301745421708",
  27822. PsnNo: "44020000001102211928",
  27823. Info: "2207",
  27824. }
  27825. customData = append(customData, custom12)
  27826. custom1212 := &CustomData{
  27827. MsgId: "H440229001582021033017351627",
  27828. PsnNo: "44020000001102481733",
  27829. Info: "2207",
  27830. }
  27831. customData = append(customData, custom1212)
  27832. custom13 := &CustomData{
  27833. MsgId: "H44022900158202103301740327951",
  27834. PsnNo: "44020000001103174866",
  27835. Info: "2207",
  27836. }
  27837. customData = append(customData, custom13)
  27838. custom14 := &CustomData{
  27839. MsgId: "H4402290015820210330174922668",
  27840. PsnNo: "44020000001102927272",
  27841. Info: "2207",
  27842. }
  27843. customData = append(customData, custom14)
  27844. custom15 := &CustomData{
  27845. MsgId: "H44022900158202103301752362273",
  27846. PsnNo: "44020000001102942890",
  27847. Info: "2207",
  27848. }
  27849. customData = append(customData, custom15)
  27850. custom16 := &CustomData{
  27851. MsgId: "H44022900158202103301751082917",
  27852. PsnNo: "44020000001101662162",
  27853. Info: "2207",
  27854. }
  27855. customData = append(customData, custom16)
  27856. custom17 := &CustomData{
  27857. MsgId: "H44022900158202103301754147728",
  27858. PsnNo: "44020000000229014511",
  27859. Info: "2207",
  27860. }
  27861. customData = append(customData, custom17)
  27862. adminUser := c.GetAdminUserInfo()
  27863. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27864. for _, item := range customData {
  27865. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  27866. fmt.Println(result)
  27867. }
  27868. }
  27869. func (c *HisApiController) GetAllopatry() {
  27870. year := c.GetString("year")
  27871. month := c.GetString("month")
  27872. admin_user_id, _ := c.GetInt64("admin_user_id")
  27873. adminUser := c.GetAdminUserInfo()
  27874. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27875. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27876. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  27877. var dat map[string]interface{}
  27878. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27879. fmt.Println(dat)
  27880. } else {
  27881. fmt.Println(err)
  27882. }
  27883. userJSONBytes, _ := json.Marshal(dat)
  27884. var res models.Result9001
  27885. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27886. utils.ErrorLog("解析失败:%v", err)
  27887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27888. return
  27889. }
  27890. fmt.Println(res.Output.Signinoutb)
  27891. fmt.Println(res.Output.Signinoutb.SignNo)
  27892. fmt.Println(string(userJSONBytes))
  27893. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  27894. var dat3 map[string]interface{}
  27895. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  27896. fmt.Println(dat3)
  27897. } else {
  27898. fmt.Println(err)
  27899. }
  27900. userJSONBytes3, _ := json.Marshal(dat3)
  27901. var res3 models.Result3260
  27902. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  27903. utils.ErrorLog("解析失败:%v", err)
  27904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27905. return
  27906. }
  27907. var curpage int
  27908. var pagesize int = 100
  27909. var start int = 1
  27910. //var stop int
  27911. //pagecount := 10
  27912. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  27913. var res22 []models.Result3260
  27914. for curpage = 1; curpage <= pagecount; curpage++ {
  27915. if curpage == 1 {
  27916. start = 0
  27917. } else {
  27918. start = (curpage-1)*pagesize + 1
  27919. }
  27920. fmt.Println(start)
  27921. //stop = curpage * pagesize
  27922. //if stop > int(res3.Output.Totalrow) {
  27923. // stop =int(res3.Output.Totalrow)
  27924. //}
  27925. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  27926. var dat2 map[string]interface{}
  27927. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27928. fmt.Println(dat)
  27929. } else {
  27930. fmt.Println(err)
  27931. }
  27932. userJSONBytes2, _ := json.Marshal(dat2)
  27933. var res2 models.Result3260
  27934. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27935. utils.ErrorLog("解析失败:%v", err)
  27936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27937. return
  27938. }
  27939. if res2.Infcode == 0 {
  27940. res22 = append(res22, res2)
  27941. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  27942. //var dat2 map[string]interface{}
  27943. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  27944. // fmt.Println(dat)
  27945. //} else {
  27946. // fmt.Println(err)
  27947. //}
  27948. //c.ServeSuccessJSON(map[string]interface{}{
  27949. // "list": res2.Output.Data,
  27950. //})
  27951. //continue
  27952. }
  27953. }
  27954. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  27955. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  27956. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  27957. //var dat2 map[string]interface{}
  27958. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27959. // fmt.Println(dat)
  27960. //} else {
  27961. // fmt.Println(err)
  27962. //}
  27963. //userJSONBytes2, _ := json.Marshal(dat2)
  27964. //var res2 models.Result3260
  27965. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27966. // utils.ErrorLog("解析失败:%v", err)
  27967. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27968. // return
  27969. //}
  27970. //if res2.Infcode == 0 {
  27971. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  27972. // var dat2 map[string]interface{}
  27973. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  27974. // fmt.Println(dat)
  27975. // } else {
  27976. // fmt.Println(err)
  27977. // }
  27978. // c.ServeSuccessJSON(map[string]interface{}{
  27979. // "list": res2.Output.Data,
  27980. // })
  27981. //}
  27982. }
  27983. func (c *HisApiController) ComfirmAllopatry() {
  27984. year := c.GetString("year")
  27985. month := c.GetString("month")
  27986. admin_user_id, _ := c.GetInt64("admin_user_id")
  27987. adminUser := c.GetAdminUserInfo()
  27988. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27989. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27990. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  27991. var dat map[string]interface{}
  27992. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27993. fmt.Println(dat)
  27994. } else {
  27995. fmt.Println(err)
  27996. }
  27997. userJSONBytes, _ := json.Marshal(dat)
  27998. var res models.Result9001
  27999. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28000. utils.ErrorLog("解析失败:%v", err)
  28001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28002. return
  28003. }
  28004. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  28005. var dat2 map[string]interface{}
  28006. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28007. fmt.Println(dat)
  28008. } else {
  28009. fmt.Println(err)
  28010. }
  28011. userJSONBytes2, _ := json.Marshal(dat2)
  28012. var res2 models.Result3260
  28013. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28014. utils.ErrorLog("解析失败:%v", err)
  28015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28016. return
  28017. }
  28018. //if res2.Infcode == 0 {
  28019. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28020. // var dat map[string]interface{}
  28021. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28022. // fmt.Println(dat)
  28023. // } else {
  28024. // fmt.Println(err)
  28025. // }
  28026. // userJSONBytes, _ := json.Marshal(dat)
  28027. // var res3 models.Result3261
  28028. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  28029. // utils.ErrorLog("解析失败:%v", err)
  28030. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28031. // return
  28032. // }
  28033. //
  28034. // if res3.Infcode == 0 {
  28035. // record := &models.HisYidiClearRecord{
  28036. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28037. // Ctime: time.Now().Unix(),
  28038. // Mtime: time.Now().Unix(),
  28039. // Status: 1,
  28040. // MsgId: msgId,
  28041. // }
  28042. // service.SaveClearRecord(record)
  28043. // c.ServeSuccessJSON(map[string]interface{}{
  28044. // "msg": "提取成功",
  28045. // })
  28046. // }
  28047. //}
  28048. }
  28049. func (c *HisApiController) RefundAllopatry() {
  28050. year := c.GetString("year")
  28051. month := c.GetString("month")
  28052. //id, _ := c.GetInt64("id")
  28053. admin_user_id, _ := c.GetInt64("admin_user_id")
  28054. adminUser := c.GetAdminUserInfo()
  28055. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28056. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28057. //record, _ := service.GetClearRecordById(id)
  28058. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  28059. var dat map[string]interface{}
  28060. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28061. fmt.Println(dat)
  28062. } else {
  28063. fmt.Println(err)
  28064. }
  28065. userJSONBytes, _ := json.Marshal(dat)
  28066. var res models.Result9001
  28067. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28068. utils.ErrorLog("解析失败:%v", err)
  28069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28070. return
  28071. }
  28072. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  28073. var dat2 map[string]interface{}
  28074. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  28075. fmt.Println(dat)
  28076. } else {
  28077. fmt.Println(err)
  28078. }
  28079. userJSONBytes2, _ := json.Marshal(dat2)
  28080. var empty ResultFourteen
  28081. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  28082. utils.ErrorLog("解析失败:%v", err)
  28083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28084. return
  28085. }
  28086. if empty.Infcode == 0 {
  28087. c.ServeSuccessJSON(map[string]interface{}{
  28088. "msg": "撤销成功",
  28089. })
  28090. return
  28091. }
  28092. }
  28093. func (c *HisApiController) ReversalOtherData() {
  28094. var customData []*CustomData
  28095. custom := &CustomData{
  28096. MsgId: "H44022900158202103301714472004",
  28097. PsnNo: "44020000001101329945",
  28098. Info: "2208",
  28099. }
  28100. customData = append(customData, custom)
  28101. custom1 := &CustomData{
  28102. MsgId: "H4402290015820210330172057803",
  28103. PsnNo: "44020000001101161813",
  28104. Info: "2208",
  28105. }
  28106. customData = append(customData, custom1)
  28107. custom2 := &CustomData{
  28108. MsgId: "H44022900158202103301705198813",
  28109. PsnNo: "44190000133097375417",
  28110. Info: "2208",
  28111. }
  28112. customData = append(customData, custom2)
  28113. custom3 := &CustomData{
  28114. MsgId: "H44022900158202103301715524756",
  28115. PsnNo: "44020000001100187221",
  28116. Info: "2208",
  28117. }
  28118. customData = append(customData, custom3)
  28119. custom4 := &CustomData{
  28120. MsgId: "H44022900158202103301730376224",
  28121. PsnNo: "44020000001101959155",
  28122. Info: "2208",
  28123. }
  28124. customData = append(customData, custom4)
  28125. custom5 := &CustomData{
  28126. MsgId: "H44022900158202103301748008725",
  28127. PsnNo: "44020000001104246641",
  28128. Info: "2208",
  28129. }
  28130. customData = append(customData, custom5)
  28131. custom6 := &CustomData{
  28132. MsgId: "H44022900158202103301718096755",
  28133. PsnNo: "44020000001102211860",
  28134. Info: "2208",
  28135. }
  28136. customData = append(customData, custom6)
  28137. custom7 := &CustomData{
  28138. MsgId: "H44022900158202103301736551640",
  28139. PsnNo: "44020000001102687718",
  28140. Info: "2208",
  28141. }
  28142. customData = append(customData, custom7)
  28143. custom8 := &CustomData{
  28144. MsgId: "H44022900158202103301743097676",
  28145. PsnNo: "44020000001102127785",
  28146. Info: "2208",
  28147. }
  28148. customData = append(customData, custom8)
  28149. custom9 := &CustomData{
  28150. MsgId: "H44022900158202103301712304203",
  28151. PsnNo: "44020000001101518097",
  28152. Info: "2208",
  28153. }
  28154. customData = append(customData, custom9)
  28155. custom10 := &CustomData{
  28156. MsgId: "H44022900158202103301738448785",
  28157. PsnNo: "44020000001100500813",
  28158. Info: "2208",
  28159. }
  28160. customData = append(customData, custom10)
  28161. custom11 := &CustomData{
  28162. MsgId: "H44022900158202103301732455843",
  28163. PsnNo: "44020000001102690557",
  28164. Info: "2208",
  28165. }
  28166. customData = append(customData, custom11)
  28167. custom12 := &CustomData{
  28168. MsgId: "H44022900158202103301745421708",
  28169. PsnNo: "44020000001102211928",
  28170. Info: "2208",
  28171. }
  28172. customData = append(customData, custom12)
  28173. custom1212 := &CustomData{
  28174. MsgId: "H440229001582021033017351627",
  28175. PsnNo: "44020000001102481733",
  28176. Info: "2208",
  28177. }
  28178. customData = append(customData, custom1212)
  28179. custom13 := &CustomData{
  28180. MsgId: "H44022900158202103301740327951",
  28181. PsnNo: "44020000001103174866",
  28182. Info: "2208",
  28183. }
  28184. customData = append(customData, custom13)
  28185. custom14 := &CustomData{
  28186. MsgId: "H4402290015820210330174922668",
  28187. PsnNo: "44020000001102927272",
  28188. Info: "2208",
  28189. }
  28190. customData = append(customData, custom14)
  28191. custom15 := &CustomData{
  28192. MsgId: "H44022900158202103301752362273",
  28193. PsnNo: "44020000001102942890",
  28194. Info: "2208",
  28195. }
  28196. customData = append(customData, custom15)
  28197. custom16 := &CustomData{
  28198. MsgId: "H44022900158202103301751082917",
  28199. PsnNo: "44020000001101662162",
  28200. Info: "2208",
  28201. }
  28202. customData = append(customData, custom16)
  28203. custom17 := &CustomData{
  28204. MsgId: "H44022900158202103301754147728",
  28205. PsnNo: "44020000000229014511",
  28206. Info: "2208",
  28207. }
  28208. customData = append(customData, custom17)
  28209. adminUser := c.GetAdminUserInfo()
  28210. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28211. for _, item := range customData {
  28212. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  28213. fmt.Println(result)
  28214. }
  28215. }
  28216. func PathExists(path string) (bool, error) {
  28217. _, err := os.Stat(path)
  28218. if err == nil {
  28219. return true, nil
  28220. }
  28221. if os.IsNotExist(err) {
  28222. return false, nil
  28223. }
  28224. return false, err
  28225. }
  28226. // 创建文件夹
  28227. func Mkdir(dir string) {
  28228. // 创建文件夹
  28229. exist, err := PathExists(dir)
  28230. if err != nil {
  28231. fmt.Println(err.Error())
  28232. } else {
  28233. if exist {
  28234. fmt.Println(dir + "文件夹已存在!")
  28235. } else {
  28236. // 文件夹名称,权限
  28237. err := os.Mkdir(dir, os.ModePerm)
  28238. if err != nil {
  28239. fmt.Println(dir+"文件夹创建失败:", err.Error())
  28240. } else {
  28241. fmt.Println(dir + "文件夹创建成功!")
  28242. }
  28243. }
  28244. }
  28245. }
  28246. // 压缩文件
  28247. func Zip(srcFile string, destZip string) error {
  28248. zipfile, err := os.Create(destZip)
  28249. if err != nil {
  28250. return err
  28251. }
  28252. defer zipfile.Close()
  28253. archive := zip.NewWriter(zipfile)
  28254. defer archive.Close()
  28255. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  28256. if err != nil {
  28257. return err
  28258. }
  28259. header, err := zip.FileInfoHeader(info)
  28260. if err != nil {
  28261. return err
  28262. }
  28263. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  28264. // header.Name = path
  28265. if info.IsDir() {
  28266. header.Name += "/"
  28267. } else {
  28268. header.Method = zip.Deflate
  28269. }
  28270. writer, err := archive.CreateHeader(header)
  28271. if err != nil {
  28272. return err
  28273. }
  28274. if !info.IsDir() {
  28275. file, err := os.Open(path)
  28276. if err != nil {
  28277. return err
  28278. }
  28279. defer file.Close()
  28280. _, err = io.Copy(writer, file)
  28281. }
  28282. return err
  28283. })
  28284. return err
  28285. }
  28286. func ReadFile(filePath string) []byte {
  28287. f, err := os.Open(filePath)
  28288. if err != nil {
  28289. fmt.Println("read file fail", err)
  28290. return nil
  28291. }
  28292. defer f.Close()
  28293. fd, err := ioutil.ReadAll(f)
  28294. if err != nil {
  28295. fmt.Println("read to fd fail", err)
  28296. return nil
  28297. }
  28298. return fd
  28299. }
  28300. func saveLogq(result string, request string, infno string, desc string) {
  28301. dir := "日志"
  28302. utils.Mkdir(dir)
  28303. month := time.Unix(1557042972, 0).Format("1")
  28304. year := time.Now().Format("2006")
  28305. month = time.Now().Format("01")
  28306. day := time.Now().Format("02")
  28307. hour := time.Now().Format("15")
  28308. min := time.Now().Format("04")
  28309. sec := time.Now().Format("05")
  28310. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  28311. file := year + month + day + "_log"
  28312. file_name := file + ".txt"
  28313. file_path := "日志" + "/" + file_name
  28314. exist, _ := utils.PathExists(file_path)
  28315. if exist { //存在
  28316. fmt.Println("存在")
  28317. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  28318. if err != nil {
  28319. fmt.Println("read fail")
  28320. }
  28321. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  28322. n, _ := f.Seek(0, 2)
  28323. _, err = f.WriteAt([]byte(content), n)
  28324. } else { //不存在
  28325. fmt.Println("文件不存在,创建文件")
  28326. f, err := os.Create("日志" + "/" + file_name)
  28327. defer f.Close()
  28328. if err != nil {
  28329. } else {
  28330. _, err = f.Write([]byte("记录日志"))
  28331. }
  28332. }
  28333. }
  28334. func saveLog(result string, request string, infno string, desc string) {
  28335. org_id, _ := beego.AppConfig.Int64("org_id")
  28336. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28337. dir := miConfig.OrgName + "日志"
  28338. utils.Mkdir(dir)
  28339. month := time.Unix(1557042972, 0).Format("1")
  28340. year := time.Now().Format("2006")
  28341. month = time.Now().Format("01")
  28342. day := time.Now().Format("02")
  28343. hour := time.Now().Format("15")
  28344. min := time.Now().Format("04")
  28345. sec := time.Now().Format("05")
  28346. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  28347. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  28348. file_name := file + ".txt"
  28349. file_path := miConfig.OrgName + "日志" + "/" + file_name
  28350. exist, _ := utils.PathExists(file_path)
  28351. if exist { //存在
  28352. fmt.Println("存在")
  28353. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  28354. if err != nil {
  28355. fmt.Println("read fail")
  28356. }
  28357. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  28358. n, _ := f.Seek(0, 2)
  28359. _, err = f.WriteAt([]byte(content), n)
  28360. } else { //不存在
  28361. fmt.Println("文件不存在,创建文件")
  28362. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  28363. defer f.Close()
  28364. if err != nil {
  28365. } else {
  28366. _, err = f.Write([]byte("记录日志"))
  28367. }
  28368. }
  28369. }
  28370. type Charset string
  28371. const (
  28372. UTF8 = Charset("UTF-8")
  28373. GB18030 = Charset("GB18030")
  28374. )
  28375. func ConvertToString(src string, srcCode string, tagCode string) string {
  28376. srcCoder := mahonia.NewDecoder(srcCode)
  28377. srcResult := srcCoder.ConvertString(src)
  28378. tagCoder := mahonia.NewDecoder(tagCode)
  28379. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  28380. result := string(cdata)
  28381. return result
  28382. }
  28383. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  28384. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  28385. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28386. var token string
  28387. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28388. var api string
  28389. if miConfig.MdtrtareaAdmvs == "320921" {
  28390. 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 +
  28391. "&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
  28392. fmt.Println(api)
  28393. } else {
  28394. 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 +
  28395. "&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
  28396. }
  28397. resp, requestErr := http.Get(api)
  28398. if requestErr != nil {
  28399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28400. return ""
  28401. }
  28402. body, ioErr := ioutil.ReadAll(resp.Body)
  28403. if ioErr != nil {
  28404. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28406. return ""
  28407. }
  28408. var respJSON map[string]interface{}
  28409. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28412. return ""
  28413. }
  28414. var status string
  28415. status = respJSON["data"].(map[string]interface{})["status"].(string)
  28416. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  28417. var res ResultTwo //1101结果
  28418. var res10265 ResultTwo10265 //1101结果
  28419. if status == "0" { //读卡成功
  28420. var card_info string //卡信息
  28421. var busi_card_info string
  28422. token = respJSON["data"].(map[string]interface{})["token"].(string)
  28423. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  28424. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  28425. fmt.Println(card_info)
  28426. fmt.Println(busi_card_info)
  28427. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  28428. result, _ := json.Marshal(respJSON)
  28429. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28430. utils.ErrorLog("解析失败:%v", err)
  28431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28432. return ""
  28433. }
  28434. res.ErrMsg = res10265.ErrMsg
  28435. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28436. res.Infcode = infocode
  28437. res.Output = res10265.Output
  28438. res.InfRefmsgid = res10265.InfRefmsgid
  28439. if res.Infcode == 0 {
  28440. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  28441. if err == gorm.ErrRecordNotFound {
  28442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  28443. return ""
  28444. } else if err != nil {
  28445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28446. return ""
  28447. } else {
  28448. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28449. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28450. infoStr := string(Iinfos)
  28451. idetinfoStr := string(Idetinfos)
  28452. psn := &models.HisPsn{
  28453. PsnNo: res.Output.Baseinfo.PsnNo,
  28454. PatientId: patient.ID,
  28455. Certno: res.Output.Baseinfo.Certno,
  28456. Gend: res.Output.Baseinfo.Gend,
  28457. Naty: res.Output.Baseinfo.Naty,
  28458. PsnCertType: res.Output.Baseinfo.PsnCertType,
  28459. PsnName: res.Output.Baseinfo.PsnName,
  28460. Idetinfo: idetinfoStr,
  28461. Insuinfo: infoStr,
  28462. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28463. CardInfo: card_info,
  28464. VerifyNumber: token,
  28465. }
  28466. service.CreateHisPsn(psn)
  28467. return token
  28468. }
  28469. }
  28470. } else {
  28471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28472. return ""
  28473. }
  28474. } else { //读卡失败
  28475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28476. return ""
  28477. }
  28478. return token
  28479. }
  28480. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  28481. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  28482. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28483. var token string
  28484. var api string
  28485. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  28486. "&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
  28487. fmt.Println(api)
  28488. resp, requestErr := http.Get(api)
  28489. if requestErr != nil {
  28490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28491. return ""
  28492. }
  28493. body, ioErr := ioutil.ReadAll(resp.Body)
  28494. if ioErr != nil {
  28495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28497. return ""
  28498. }
  28499. var respJSON map[string]interface{}
  28500. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28503. return ""
  28504. }
  28505. var status string
  28506. status = respJSON["data"].(map[string]interface{})["status"].(string)
  28507. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  28508. var res ResultTwo //1101结果
  28509. if status == "1" { //读卡成功
  28510. var card_info string //卡信息
  28511. var busi_card_info string
  28512. token = respJSON["data"].(map[string]interface{})["token"].(string)
  28513. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  28514. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  28515. fmt.Println(card_info)
  28516. fmt.Println(busi_card_info)
  28517. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  28518. result, _ := json.Marshal(respJSON)
  28519. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28520. utils.ErrorLog("解析失败:%v", err)
  28521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28522. return ""
  28523. }
  28524. if res.Infcode == 0 {
  28525. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  28526. if err == gorm.ErrRecordNotFound {
  28527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  28528. return ""
  28529. } else if err != nil {
  28530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28531. return ""
  28532. } else {
  28533. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28534. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28535. infoStr := string(Iinfos)
  28536. idetinfoStr := string(Idetinfos)
  28537. psn := &models.HisPsn{
  28538. PsnNo: res.Output.Baseinfo.PsnNo,
  28539. PatientId: patient.ID,
  28540. Certno: res.Output.Baseinfo.Certno,
  28541. Gend: res.Output.Baseinfo.Gend,
  28542. Naty: res.Output.Baseinfo.Naty,
  28543. PsnCertType: res.Output.Baseinfo.PsnCertType,
  28544. PsnName: res.Output.Baseinfo.PsnName,
  28545. Idetinfo: idetinfoStr,
  28546. Insuinfo: infoStr,
  28547. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28548. CardInfo: card_info,
  28549. VerifyNumber: token,
  28550. }
  28551. service.CreateHisPsn(psn)
  28552. return token
  28553. }
  28554. }
  28555. } else {
  28556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28557. return ""
  28558. }
  28559. return token
  28560. }
  28561. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  28562. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  28563. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28564. var token string
  28565. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28566. var api string
  28567. if miConfig.MdtrtareaAdmvs == "320921" {
  28568. 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 +
  28569. "&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
  28570. fmt.Println(api)
  28571. } else {
  28572. 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 +
  28573. "&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
  28574. }
  28575. resp, requestErr := http.Get(api)
  28576. if requestErr != nil {
  28577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28578. return ""
  28579. }
  28580. body, ioErr := ioutil.ReadAll(resp.Body)
  28581. if ioErr != nil {
  28582. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28584. return ""
  28585. }
  28586. var respJSON map[string]interface{}
  28587. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28590. return ""
  28591. }
  28592. var status string
  28593. status = respJSON["data"].(map[string]interface{})["status"].(string)
  28594. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  28595. var res ResultTwo //1101结果
  28596. var res10265 ResultTwo10265 //1101结果
  28597. if status == "0" { //读卡成功
  28598. var card_info string //卡信息
  28599. var busi_card_info string
  28600. token = respJSON["data"].(map[string]interface{})["token"].(string)
  28601. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  28602. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  28603. fmt.Println(card_info)
  28604. fmt.Println(busi_card_info)
  28605. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  28606. result, _ := json.Marshal(respJSON)
  28607. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28608. utils.ErrorLog("解析失败:%v", err)
  28609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28610. return ""
  28611. }
  28612. res.ErrMsg = res10265.ErrMsg
  28613. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28614. res.Infcode = infocode
  28615. res.Output = res10265.Output
  28616. res.InfRefmsgid = res10265.InfRefmsgid
  28617. if res.Infcode == 0 {
  28618. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  28619. if err == gorm.ErrRecordNotFound {
  28620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  28621. return ""
  28622. } else if err != nil {
  28623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28624. return ""
  28625. } else {
  28626. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28627. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28628. infoStr := string(Iinfos)
  28629. idetinfoStr := string(Idetinfos)
  28630. psn := &models.HisPsn{
  28631. PsnNo: res.Output.Baseinfo.PsnNo,
  28632. PatientId: patient.ID,
  28633. Certno: res.Output.Baseinfo.Certno,
  28634. Gend: res.Output.Baseinfo.Gend,
  28635. Naty: res.Output.Baseinfo.Naty,
  28636. PsnCertType: res.Output.Baseinfo.PsnCertType,
  28637. PsnName: res.Output.Baseinfo.PsnName,
  28638. Idetinfo: idetinfoStr,
  28639. Insuinfo: infoStr,
  28640. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28641. CardInfo: card_info,
  28642. VerifyNumber: token,
  28643. }
  28644. service.CreateHisPsn(psn)
  28645. return token
  28646. }
  28647. }
  28648. } else {
  28649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28650. return ""
  28651. }
  28652. } else { //读卡失败
  28653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28654. return ""
  28655. }
  28656. return token
  28657. }
  28658. func DeleteExtraSpaceTwo(s string) string {
  28659. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  28660. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  28661. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  28662. reg, _ := regexp.Compile(regstr) //编译正则表达式
  28663. s2 := make([]byte, len(s1)) //定义字符数组切片
  28664. copy(s2, s1) //将字符串复制到切片
  28665. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  28666. for len(spc_index) > 0 { //找到适配项
  28667. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  28668. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  28669. }
  28670. return string(s2)
  28671. }
  28672. func Remove0000(s string) string {
  28673. str := make([]rune, 0, len(s))
  28674. for _, v := range []rune(s) {
  28675. if v == 0 {
  28676. continue
  28677. }
  28678. str = append(str, v)
  28679. }
  28680. return string(str)
  28681. }
  28682. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  28683. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  28684. readCard := DllDef.MustFindProc("EcQuery")
  28685. pCardInfo := make([]byte, 8192)
  28686. pBusiCardInfo := make([]byte, 8192)
  28687. data := make(map[string]interface{})
  28688. //pData := make(map[string]interface{})
  28689. inputData := make(map[string]interface{})
  28690. inputData["orgId"] = code
  28691. inputData["businessType"] = "01101"
  28692. inputData["operatorId"] = operator_id
  28693. inputData["operatorName"] = operator_name
  28694. inputData["officeId"] = "001"
  28695. inputData["officeName"] = "血透室"
  28696. //
  28697. data["data"] = inputData
  28698. data["transType"] = "ec.query"
  28699. data["orgId"] = code
  28700. bytesData, _ := json.Marshal(data)
  28701. pCardInfo = bytesData
  28702. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  28703. fmt.Println(ret2)
  28704. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  28705. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  28706. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  28707. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  28708. if ret2 != 0 {
  28709. return "", ""
  28710. }
  28711. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  28712. }
  28713. func DeleteExtraSpace(s string) string {
  28714. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  28715. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  28716. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  28717. reg, _ := regexp.Compile(regstr) //编译正则表达式
  28718. s2 := make([]byte, len(s1)) //定义字符数组切片
  28719. copy(s2, s1) //将字符串复制到切片
  28720. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  28721. for len(spc_index) > 0 { //找到适配项
  28722. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  28723. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  28724. }
  28725. return string(s2)
  28726. }
  28727. // 对账
  28728. func (c *HisApiController) Post3202() {
  28729. start_time := c.GetString("start_time")
  28730. end_time := c.GetString("end_time")
  28731. //insutype := c.GetString("insutype")
  28732. clr_type := c.GetString("clr_type")
  28733. clr_org := c.GetString("clr_optins")
  28734. admin_user_id, _ := c.GetInt64("admin_user_id")
  28735. adminUser := c.GetAdminUserInfo()
  28736. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28737. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28738. if len(clr_org) == 0 {
  28739. clr_org = miConfig.MdtrtareaAdmvs
  28740. }
  28741. timeLayout := "2006-01-02"
  28742. loc, _ := time.LoadLocation("Local")
  28743. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  28744. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28745. var orders []*models.HisOrder
  28746. if clr_org == "421300" {
  28747. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28748. } else {
  28749. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28750. }
  28751. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  28752. //fixmedins_setl_cnt := int64(len(orders))
  28753. var medfee_sumamt float64
  28754. var acct_pay float64
  28755. var fund_pay_sumamt float64
  28756. for _, item := range orders {
  28757. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  28758. acct_pay = acct_pay + item.AcctPay
  28759. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  28760. }
  28761. //var medfee_sumamt_two float64
  28762. //var acct_pay_two float64
  28763. //var fund_pay_sumamt_two float64
  28764. //for _, item := range orders_two {
  28765. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  28766. // acct_pay_two = acct_pay_two + item.AcctPay
  28767. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  28768. //}
  28769. //var user_name string
  28770. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28771. //if role.ID == 0 {
  28772. // user_name = "xxx"
  28773. //} else {
  28774. // user_name = role.UserName
  28775. //}
  28776. var res ResultSix
  28777. if config.IsOpen == 1 {
  28778. var bps []*models.BusinessParamsTwo
  28779. var bp models.BusinessParamsTwo
  28780. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  28781. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  28782. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  28783. bp.MedfeeSumamt = medfee_sumamt_str
  28784. bp.AcctPay = acct_pay_str
  28785. bp.FundPaySumamt = fund_pay_sumamt_str
  28786. bp.Insutype = ""
  28787. bp.StmtBegndate = start_time
  28788. bp.ClrType = clr_type
  28789. bp.SetlOptins = clr_org
  28790. bp.StmtEnddate = end_time
  28791. bps = append(bps, &bp)
  28792. data := make(map[string]interface{})
  28793. data["bps"] = bps
  28794. data["org_name"] = miConfig.OrgName
  28795. data["doctor"] = role.UserName
  28796. data["fixmedins_code"] = miConfig.Code
  28797. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28798. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28799. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28800. if miConfig.MdtrtareaAdmvs == "421300" {
  28801. client := &http.Client{}
  28802. bytesData, _ := json.Marshal(data)
  28803. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  28804. resp, _ := client.Do(req)
  28805. defer resp.Body.Close()
  28806. body, ioErr := ioutil.ReadAll(resp.Body)
  28807. if ioErr != nil {
  28808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28810. return
  28811. }
  28812. var respJSON map[string]interface{}
  28813. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28816. return
  28817. }
  28818. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28819. userJSONBytes, _ := json.Marshal(respJSON)
  28820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28821. utils.ErrorLog("解析失败:%v", err)
  28822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28823. return
  28824. }
  28825. }
  28826. if miConfig.MdtrtareaAdmvs == "420200" {
  28827. client := &http.Client{}
  28828. bytesData, _ := json.Marshal(data)
  28829. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  28830. resp, _ := client.Do(req)
  28831. defer resp.Body.Close()
  28832. body, ioErr := ioutil.ReadAll(resp.Body)
  28833. if ioErr != nil {
  28834. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28836. return
  28837. }
  28838. var respJSON map[string]interface{}
  28839. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28842. return
  28843. }
  28844. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28845. userJSONBytes, _ := json.Marshal(respJSON)
  28846. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28847. utils.ErrorLog("解析失败:%v", err)
  28848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28849. return
  28850. }
  28851. }
  28852. if miConfig.MdtrtareaAdmvs == "421182" {
  28853. client := &http.Client{}
  28854. bytesData, _ := json.Marshal(data)
  28855. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  28856. resp, _ := client.Do(req)
  28857. defer resp.Body.Close()
  28858. body, ioErr := ioutil.ReadAll(resp.Body)
  28859. if ioErr != nil {
  28860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28862. return
  28863. }
  28864. var respJSON map[string]interface{}
  28865. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28868. return
  28869. }
  28870. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28871. userJSONBytes, _ := json.Marshal(respJSON)
  28872. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28873. utils.ErrorLog("解析失败:%v", err)
  28874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28875. return
  28876. }
  28877. }
  28878. if res.Infcode == 0 {
  28879. c.ServeSuccessJSON(map[string]interface{}{
  28880. "msg": "发起成功",
  28881. })
  28882. } else {
  28883. c.ServeSuccessJSON(map[string]interface{}{
  28884. "failed_code": -10,
  28885. "msg": res.ErrMsg,
  28886. })
  28887. }
  28888. }
  28889. }
  28890. func (c *HisApiController) Post3202b() {
  28891. start_time := c.GetString("start_time")
  28892. end_time := c.GetString("end_time")
  28893. //insutype := c.GetString("insutype")
  28894. clr_type := c.GetString("clr_type")
  28895. clr_org := c.GetString("clr_optins")
  28896. admin_user_id, _ := c.GetInt64("admin_user_id")
  28897. adminUser := c.GetAdminUserInfo()
  28898. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28899. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28900. if len(clr_org) == 0 {
  28901. clr_org = miConfig.MdtrtareaAdmvs
  28902. }
  28903. timeLayout := "2006-01-02"
  28904. loc, _ := time.LoadLocation("Local")
  28905. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  28906. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28907. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28908. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  28909. //fixmedins_setl_cnt := int64(len(orders))
  28910. var medfee_sumamt float64
  28911. var acct_pay float64
  28912. var fund_pay_sumamt float64
  28913. for _, item := range orders {
  28914. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  28915. acct_pay = acct_pay + item.AcctPay
  28916. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  28917. }
  28918. //var medfee_sumamt_two float64
  28919. //var acct_pay_two float64
  28920. //var fund_pay_sumamt_two float64
  28921. //for _, item := range orders_two {
  28922. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  28923. // acct_pay_two = acct_pay_two + item.AcctPay
  28924. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  28925. //}
  28926. //var user_name string
  28927. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28928. //if role.ID == 0 {
  28929. // user_name = "xxx"
  28930. //} else {
  28931. // user_name = role.UserName
  28932. //}
  28933. var res ResultSix
  28934. if config.IsOpen == 1 {
  28935. var bps []*models.BusinessParamsTwo
  28936. var bp models.BusinessParamsTwo
  28937. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  28938. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  28939. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  28940. bp.MedfeeSumamt = medfee_sumamt_str
  28941. bp.AcctPay = acct_pay_str
  28942. bp.FundPaySumamt = fund_pay_sumamt_str
  28943. bp.Insutype = "390"
  28944. bp.StmtBegndate = start_time
  28945. bp.ClrType = clr_type
  28946. bp.SetlOptins = clr_org
  28947. bp.StmtEnddate = end_time
  28948. bps = append(bps, &bp)
  28949. data := make(map[string]interface{})
  28950. data["bps"] = bps
  28951. data["org_name"] = miConfig.OrgName
  28952. data["doctor"] = role.UserName
  28953. data["fixmedins_code"] = miConfig.Code
  28954. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28955. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28956. if miConfig.MdtrtareaAdmvs == "421300" {
  28957. client := &http.Client{}
  28958. bytesData, _ := json.Marshal(data)
  28959. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  28960. resp, _ := client.Do(req)
  28961. defer resp.Body.Close()
  28962. body, ioErr := ioutil.ReadAll(resp.Body)
  28963. if ioErr != nil {
  28964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28966. return
  28967. }
  28968. var respJSON map[string]interface{}
  28969. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28972. return
  28973. }
  28974. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28975. userJSONBytes, _ := json.Marshal(respJSON)
  28976. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28977. utils.ErrorLog("解析失败:%v", err)
  28978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28979. return
  28980. }
  28981. }
  28982. if miConfig.MdtrtareaAdmvs == "420200" {
  28983. client := &http.Client{}
  28984. bytesData, _ := json.Marshal(data)
  28985. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  28986. resp, _ := client.Do(req)
  28987. defer resp.Body.Close()
  28988. body, ioErr := ioutil.ReadAll(resp.Body)
  28989. if ioErr != nil {
  28990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28992. return
  28993. }
  28994. var respJSON map[string]interface{}
  28995. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28998. return
  28999. }
  29000. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29001. userJSONBytes, _ := json.Marshal(respJSON)
  29002. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29003. utils.ErrorLog("解析失败:%v", err)
  29004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29005. return
  29006. }
  29007. }
  29008. if miConfig.MdtrtareaAdmvs == "421182" {
  29009. client := &http.Client{}
  29010. bytesData, _ := json.Marshal(data)
  29011. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  29012. resp, _ := client.Do(req)
  29013. defer resp.Body.Close()
  29014. body, ioErr := ioutil.ReadAll(resp.Body)
  29015. if ioErr != nil {
  29016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29018. return
  29019. }
  29020. var respJSON map[string]interface{}
  29021. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29024. return
  29025. }
  29026. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29027. userJSONBytes, _ := json.Marshal(respJSON)
  29028. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29029. utils.ErrorLog("解析失败:%v", err)
  29030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29031. return
  29032. }
  29033. }
  29034. if res.Infcode == 0 {
  29035. c.ServeSuccessJSON(map[string]interface{}{
  29036. "msg": "发起成功",
  29037. })
  29038. } else {
  29039. c.ServeSuccessJSON(map[string]interface{}{
  29040. "failed_code": -10,
  29041. "msg": res.ErrMsg,
  29042. })
  29043. }
  29044. }
  29045. }
  29046. func (c *HisApiController) Post1608() {
  29047. start_time := c.GetString("start_time")
  29048. end_time := c.GetString("end_time")
  29049. admin_user_id, _ := c.GetInt64("admin_user_id")
  29050. adminUser := c.GetAdminUserInfo()
  29051. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29052. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29053. timeLayout := "2006-01-02"
  29054. loc, _ := time.LoadLocation("Local")
  29055. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29056. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29057. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29058. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  29059. fixmedins_setl_cnt := int64(len(orders))
  29060. var medfee_sumamt float64
  29061. var func_smamt float64
  29062. for _, item := range orders {
  29063. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29064. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  29065. }
  29066. times := strings.Split(start_time, "-")
  29067. time_tows := strings.Split(end_time, "-")
  29068. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29069. var res ResultSix
  29070. if config.IsOpen == 1 {
  29071. //var bps []*models.BusinessParamsTwo
  29072. //var bp models.BusinessParamsTwo
  29073. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29074. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  29075. data := make(map[string]interface{})
  29076. data["org_name"] = miConfig.OrgName
  29077. data["doctor"] = role.UserName
  29078. data["func_smamt"] = func_smamt_str
  29079. data["fixmedins_code"] = miConfig.Code
  29080. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29081. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29082. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  29083. data["medfee_sumamt"] = medfee_sumamt_str
  29084. data["start_time"] = times[0] + times[1] + times[2]
  29085. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  29086. if miConfig.MdtrtareaAdmvs == "421300" {
  29087. client := &http.Client{}
  29088. bytesData, _ := json.Marshal(data)
  29089. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  29090. resp, _ := client.Do(req)
  29091. defer resp.Body.Close()
  29092. body, ioErr := ioutil.ReadAll(resp.Body)
  29093. if ioErr != nil {
  29094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29096. return
  29097. }
  29098. var respJSON map[string]interface{}
  29099. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29102. return
  29103. }
  29104. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29105. userJSONBytes, _ := json.Marshal(respJSON)
  29106. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29107. utils.ErrorLog("解析失败:%v", err)
  29108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29109. return
  29110. }
  29111. }
  29112. if miConfig.MdtrtareaAdmvs == "420200" {
  29113. client := &http.Client{}
  29114. bytesData, _ := json.Marshal(data)
  29115. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  29116. resp, _ := client.Do(req)
  29117. defer resp.Body.Close()
  29118. body, ioErr := ioutil.ReadAll(resp.Body)
  29119. if ioErr != nil {
  29120. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29122. return
  29123. }
  29124. var respJSON map[string]interface{}
  29125. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29128. return
  29129. }
  29130. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29131. userJSONBytes, _ := json.Marshal(respJSON)
  29132. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29133. utils.ErrorLog("解析失败:%v", err)
  29134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29135. return
  29136. }
  29137. }
  29138. if miConfig.MdtrtareaAdmvs == "421182" {
  29139. client := &http.Client{}
  29140. bytesData, _ := json.Marshal(data)
  29141. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  29142. resp, _ := client.Do(req)
  29143. defer resp.Body.Close()
  29144. body, ioErr := ioutil.ReadAll(resp.Body)
  29145. if ioErr != nil {
  29146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29148. return
  29149. }
  29150. var respJSON map[string]interface{}
  29151. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29154. return
  29155. }
  29156. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29157. userJSONBytes, _ := json.Marshal(respJSON)
  29158. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29159. utils.ErrorLog("解析失败:%v", err)
  29160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29161. return
  29162. }
  29163. }
  29164. if res.Infcode == 0 {
  29165. c.ServeSuccessJSON(map[string]interface{}{
  29166. "msg": "发起成功",
  29167. })
  29168. } else {
  29169. c.ServeSuccessJSON(map[string]interface{}{
  29170. "failed_code": -10,
  29171. "msg": res.ErrMsg,
  29172. })
  29173. }
  29174. }
  29175. }
  29176. // 5.11.1.1【5262】结算信息按时间段查询
  29177. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  29178. admin_user_id, _ := c.GetInt64("admin_user_id")
  29179. adminUser := c.GetAdminUserInfo()
  29180. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29181. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29182. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29183. var res Result5262
  29184. if config.IsOpen == 1 {
  29185. if miConfig.MdtrtareaAdmvs == "421300" {
  29186. data := make(map[string]interface{})
  29187. data["bps"] = bp
  29188. data["org_name"] = miConfig.OrgName
  29189. data["doctor"] = role.UserName
  29190. data["fixmedins_code"] = miConfig.Code
  29191. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29192. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29193. data["page"] = strconv.FormatInt(page, 10)
  29194. data["limit"] = strconv.FormatInt(limit, 10)
  29195. fmt.Println(data)
  29196. client := &http.Client{}
  29197. bytesData, _ := json.Marshal(data)
  29198. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  29199. resp, _ := client.Do(req)
  29200. defer resp.Body.Close()
  29201. body, ioErr := ioutil.ReadAll(resp.Body)
  29202. if ioErr != nil {
  29203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29205. return
  29206. }
  29207. var respJSON map[string]interface{}
  29208. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29211. return
  29212. }
  29213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29214. userJSONBytes, _ := json.Marshal(respJSON)
  29215. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29216. utils.ErrorLog("解析失败:%v", err)
  29217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29218. return
  29219. }
  29220. }
  29221. if miConfig.MdtrtareaAdmvs == "420200" {
  29222. data := make(map[string]interface{})
  29223. data["bps"] = bp
  29224. data["org_name"] = miConfig.OrgName
  29225. data["doctor"] = role.UserName
  29226. data["fixmedins_code"] = miConfig.Code
  29227. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29228. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29229. data["page"] = strconv.FormatInt(page, 10)
  29230. data["limit"] = strconv.FormatInt(limit, 10)
  29231. fmt.Println(data)
  29232. client := &http.Client{}
  29233. bytesData, _ := json.Marshal(data)
  29234. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  29235. resp, _ := client.Do(req)
  29236. defer resp.Body.Close()
  29237. body, ioErr := ioutil.ReadAll(resp.Body)
  29238. if ioErr != nil {
  29239. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29241. return
  29242. }
  29243. var respJSON map[string]interface{}
  29244. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29247. return
  29248. }
  29249. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29250. userJSONBytes, _ := json.Marshal(respJSON)
  29251. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29252. utils.ErrorLog("解析失败:%v", err)
  29253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29254. return
  29255. }
  29256. }
  29257. if miConfig.MdtrtareaAdmvs == "421182" {
  29258. data := make(map[string]interface{})
  29259. data["bps"] = bp
  29260. data["org_name"] = miConfig.OrgName
  29261. data["doctor"] = role.UserName
  29262. data["fixmedins_code"] = miConfig.Code
  29263. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29264. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29265. data["page"] = strconv.FormatInt(page, 10)
  29266. data["limit"] = strconv.FormatInt(limit, 10)
  29267. fmt.Println(data)
  29268. client := &http.Client{}
  29269. bytesData, _ := json.Marshal(data)
  29270. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  29271. resp, _ := client.Do(req)
  29272. defer resp.Body.Close()
  29273. body, ioErr := ioutil.ReadAll(resp.Body)
  29274. if ioErr != nil {
  29275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29277. return
  29278. }
  29279. var respJSON map[string]interface{}
  29280. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29281. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29283. return
  29284. }
  29285. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29286. userJSONBytes, _ := json.Marshal(respJSON)
  29287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29288. utils.ErrorLog("解析失败:%v", err)
  29289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29290. return
  29291. }
  29292. }
  29293. if res.Infcode == 0 {
  29294. c.ServeSuccessJSON(map[string]interface{}{
  29295. "order": res.Output.Result,
  29296. "total": res.Output.PageInfo.RecordCounts,
  29297. })
  29298. } else {
  29299. c.ServeSuccessJSON(map[string]interface{}{
  29300. "failed_code": -10,
  29301. "msg": res.ErrMsg,
  29302. })
  29303. }
  29304. }
  29305. }
  29306. // 5.11.1.2【5267】异地结算信息时间段查询
  29307. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  29308. admin_user_id, _ := c.GetInt64("admin_user_id")
  29309. adminUser := c.GetAdminUserInfo()
  29310. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29311. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29312. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29313. var res Result5267
  29314. if config.IsOpen == 1 {
  29315. if miConfig.MdtrtareaAdmvs == "421300" {
  29316. data := make(map[string]interface{})
  29317. data["bps"] = bp
  29318. data["org_name"] = miConfig.OrgName
  29319. data["doctor"] = role.UserName
  29320. data["fixmedins_code"] = miConfig.Code
  29321. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29322. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29323. data["page"] = page
  29324. data["limit"] = limit
  29325. fmt.Println(data)
  29326. client := &http.Client{}
  29327. bytesData, _ := json.Marshal(data)
  29328. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  29329. resp, _ := client.Do(req)
  29330. defer resp.Body.Close()
  29331. body, ioErr := ioutil.ReadAll(resp.Body)
  29332. if ioErr != nil {
  29333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29335. return
  29336. }
  29337. var respJSON map[string]interface{}
  29338. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29341. return
  29342. }
  29343. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29344. userJSONBytes, _ := json.Marshal(respJSON)
  29345. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29346. utils.ErrorLog("解析失败:%v", err)
  29347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29348. return
  29349. }
  29350. }
  29351. if miConfig.MdtrtareaAdmvs == "420200" {
  29352. data := make(map[string]interface{})
  29353. data["bps"] = bp
  29354. data["org_name"] = miConfig.OrgName
  29355. data["doctor"] = role.UserName
  29356. data["fixmedins_code"] = miConfig.Code
  29357. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29358. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29359. data["page"] = page
  29360. data["limit"] = limit
  29361. fmt.Println(data)
  29362. client := &http.Client{}
  29363. bytesData, _ := json.Marshal(data)
  29364. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  29365. resp, _ := client.Do(req)
  29366. defer resp.Body.Close()
  29367. body, ioErr := ioutil.ReadAll(resp.Body)
  29368. if ioErr != nil {
  29369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29371. return
  29372. }
  29373. var respJSON map[string]interface{}
  29374. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29377. return
  29378. }
  29379. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29380. userJSONBytes, _ := json.Marshal(respJSON)
  29381. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29382. utils.ErrorLog("解析失败:%v", err)
  29383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29384. return
  29385. }
  29386. }
  29387. if miConfig.MdtrtareaAdmvs == "421182" {
  29388. data := make(map[string]interface{})
  29389. data["bps"] = bp
  29390. data["org_name"] = miConfig.OrgName
  29391. data["doctor"] = role.UserName
  29392. data["fixmedins_code"] = miConfig.Code
  29393. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29394. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29395. data["page"] = page
  29396. data["limit"] = limit
  29397. fmt.Println(data)
  29398. client := &http.Client{}
  29399. bytesData, _ := json.Marshal(data)
  29400. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  29401. resp, _ := client.Do(req)
  29402. defer resp.Body.Close()
  29403. body, ioErr := ioutil.ReadAll(resp.Body)
  29404. if ioErr != nil {
  29405. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29407. return
  29408. }
  29409. var respJSON map[string]interface{}
  29410. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29413. return
  29414. }
  29415. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29416. userJSONBytes, _ := json.Marshal(respJSON)
  29417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29418. utils.ErrorLog("解析失败:%v", err)
  29419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29420. return
  29421. }
  29422. }
  29423. if res.Infcode == 0 {
  29424. c.ServeSuccessJSON(map[string]interface{}{
  29425. "order": res.Output.Result,
  29426. "total": res.Output.PageInfo.RecordCounts,
  29427. })
  29428. } else {
  29429. c.ServeSuccessJSON(map[string]interface{}{
  29430. "failed_code": -10,
  29431. "msg": res.ErrMsg,
  29432. })
  29433. }
  29434. }
  29435. }
  29436. func (c *HisApiController) Post3501() {
  29437. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29438. data := make(map[string]interface{})
  29439. var struct3501s []models.Struct3501
  29440. var struct3501 models.Struct3501
  29441. struct3501.OrgName = miConfig.OrgName
  29442. struct3501.AccessKey = miConfig.AccessKey
  29443. struct3501.RequestUrl = miConfig.Url
  29444. struct3501.SecretKey = miConfig.SecretKey
  29445. struct3501.ManuDate = "2022-08-17"
  29446. struct3501.FixmedinsBchno = ""
  29447. struct3501.ManuLotnum = ""
  29448. struct3501.RxFlag = "0"
  29449. struct3501.ExpyEnd = "2022-08-17"
  29450. struct3501.Invdate = "2022-08-17"
  29451. struct3501.InvCnt = "20.25"
  29452. struct3501.Memo = ""
  29453. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29454. struct3501.FixmedinsHilistId = miConfig.Code
  29455. struct3501.FixmedinsHilistName = miConfig.OrgName
  29456. struct3501s = append(struct3501s, struct3501)
  29457. data["struct_3501s"] = struct3501s
  29458. client := &http.Client{}
  29459. bytesData, _ := json.Marshal(data)
  29460. var req *http.Request
  29461. if miConfig.MdtrtareaAdmvs == "320921" {
  29462. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29463. } else {
  29464. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29465. }
  29466. resp, _ := client.Do(req)
  29467. defer resp.Body.Close()
  29468. body, ioErr := ioutil.ReadAll(resp.Body)
  29469. if ioErr != nil {
  29470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29472. return
  29473. }
  29474. var respJSON map[string]interface{}
  29475. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29478. return
  29479. }
  29480. var res ResultSix
  29481. var resSix10265 ResultSix10265 //1101结果
  29482. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29483. result, _ := json.Marshal(respJSON)
  29484. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29485. utils.ErrorLog("解析失败:%v", err)
  29486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29487. return
  29488. }
  29489. res.InfRefmsgid = resSix10265.InfRefmsgid
  29490. res.Output = resSix10265.Output
  29491. res.ErrMsg = resSix10265.ErrMsg
  29492. res.Cainfo = resSix10265.Cainfo
  29493. res.WarnMsg = resSix10265.WarnMsg
  29494. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29495. res.Infcode = infocode
  29496. if infocode == 0 {
  29497. c.ServeSuccessJSON(map[string]interface{}{
  29498. "msg": "上传成功",
  29499. })
  29500. return
  29501. } else {
  29502. c.ServeSuccessJSON(map[string]interface{}{
  29503. "failed_code": -10,
  29504. "msg": res.ErrMsg,
  29505. })
  29506. return
  29507. }
  29508. }
  29509. func (c *HisApiController) Post3502() {
  29510. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29511. data := make(map[string]interface{})
  29512. var struct3502s []models.Struct3502
  29513. var struct3502 models.Struct3502
  29514. struct3502.OrgName = miConfig.OrgName
  29515. struct3502.AccessKey = miConfig.AccessKey
  29516. struct3502.RequestUrl = miConfig.Url
  29517. struct3502.SecretKey = miConfig.SecretKey
  29518. struct3502.ManuDate = "2022-08-15"
  29519. struct3502.FixmedinsBchno = ""
  29520. struct3502.ManuLotnum = ""
  29521. struct3502.RxFlag = "0"
  29522. struct3502.ExpyEnd = "2022-08-15"
  29523. struct3502.Invdate = "2022-08-15"
  29524. struct3502.InvCnt = "20.25"
  29525. struct3502.Memo = ""
  29526. struct3502.MedListCodg = "XB01ABD056B002020200517"
  29527. struct3502.FixmedinsHilistId = miConfig.Code
  29528. struct3502.FixmedinsHilistName = miConfig.OrgName
  29529. struct3502s = append(struct3502s, struct3502)
  29530. data["struct_3502s"] = struct3502s
  29531. client := &http.Client{}
  29532. bytesData, _ := json.Marshal(data)
  29533. var req *http.Request
  29534. if miConfig.MdtrtareaAdmvs == "320921" {
  29535. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29536. } else {
  29537. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29538. }
  29539. resp, _ := client.Do(req)
  29540. defer resp.Body.Close()
  29541. body, ioErr := ioutil.ReadAll(resp.Body)
  29542. if ioErr != nil {
  29543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29545. return
  29546. }
  29547. var respJSON map[string]interface{}
  29548. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29551. return
  29552. }
  29553. var res ResultSix
  29554. var resSix10265 ResultSix10265 //1101结果
  29555. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29556. result, _ := json.Marshal(respJSON)
  29557. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29558. utils.ErrorLog("解析失败:%v", err)
  29559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29560. return
  29561. }
  29562. res.InfRefmsgid = resSix10265.InfRefmsgid
  29563. res.Output = resSix10265.Output
  29564. res.ErrMsg = resSix10265.ErrMsg
  29565. res.Cainfo = resSix10265.Cainfo
  29566. res.WarnMsg = resSix10265.WarnMsg
  29567. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29568. res.Infcode = infocode
  29569. if infocode == 0 {
  29570. c.ServeSuccessJSON(map[string]interface{}{
  29571. "msg": "上传成功",
  29572. })
  29573. return
  29574. } else {
  29575. c.ServeSuccessJSON(map[string]interface{}{
  29576. "failed_code": -10,
  29577. "msg": res.ErrMsg,
  29578. })
  29579. return
  29580. }
  29581. }
  29582. func (c *HisApiController) Post3503() {
  29583. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29584. data := make(map[string]interface{})
  29585. var struct3501s []models.Struct3501
  29586. var struct3501 models.Struct3501
  29587. struct3501.OrgName = miConfig.OrgName
  29588. struct3501.AccessKey = miConfig.AccessKey
  29589. struct3501.RequestUrl = miConfig.Url
  29590. struct3501.SecretKey = miConfig.SecretKey
  29591. struct3501.ManuDate = "2022-08-15"
  29592. struct3501.FixmedinsBchno = ""
  29593. struct3501.ManuLotnum = ""
  29594. struct3501.RxFlag = "0"
  29595. struct3501.ExpyEnd = "2022-08-15"
  29596. struct3501.Invdate = "2022-08-15"
  29597. struct3501.InvCnt = "20.25"
  29598. struct3501.Memo = ""
  29599. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29600. struct3501.FixmedinsHilistId = miConfig.Code
  29601. struct3501.FixmedinsHilistName = miConfig.OrgName
  29602. struct3501s = append(struct3501s, struct3501)
  29603. data["struct_3501s"] = struct3501s
  29604. client := &http.Client{}
  29605. bytesData, _ := json.Marshal(data)
  29606. var req *http.Request
  29607. if miConfig.MdtrtareaAdmvs == "320921" {
  29608. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29609. } else {
  29610. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29611. }
  29612. resp, _ := client.Do(req)
  29613. defer resp.Body.Close()
  29614. body, ioErr := ioutil.ReadAll(resp.Body)
  29615. if ioErr != nil {
  29616. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29618. return
  29619. }
  29620. var respJSON map[string]interface{}
  29621. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29622. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29624. return
  29625. }
  29626. var res ResultSix
  29627. var resSix10265 ResultSix10265 //1101结果
  29628. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29629. result, _ := json.Marshal(respJSON)
  29630. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29631. utils.ErrorLog("解析失败:%v", err)
  29632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29633. return
  29634. }
  29635. res.InfRefmsgid = resSix10265.InfRefmsgid
  29636. res.Output = resSix10265.Output
  29637. res.ErrMsg = resSix10265.ErrMsg
  29638. res.Cainfo = resSix10265.Cainfo
  29639. res.WarnMsg = resSix10265.WarnMsg
  29640. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29641. res.Infcode = infocode
  29642. if infocode == 0 {
  29643. c.ServeSuccessJSON(map[string]interface{}{
  29644. "msg": "上传成功",
  29645. })
  29646. return
  29647. } else {
  29648. c.ServeSuccessJSON(map[string]interface{}{
  29649. "failed_code": -10,
  29650. "msg": res.ErrMsg,
  29651. })
  29652. return
  29653. }
  29654. }
  29655. func (c *HisApiController) Post3504() {
  29656. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29657. data := make(map[string]interface{})
  29658. var struct3501s []models.Struct3501
  29659. var struct3501 models.Struct3501
  29660. struct3501.OrgName = miConfig.OrgName
  29661. struct3501.AccessKey = miConfig.AccessKey
  29662. struct3501.RequestUrl = miConfig.Url
  29663. struct3501.SecretKey = miConfig.SecretKey
  29664. struct3501.ManuDate = "2022-08-15"
  29665. struct3501.FixmedinsBchno = ""
  29666. struct3501.ManuLotnum = ""
  29667. struct3501.RxFlag = "0"
  29668. struct3501.ExpyEnd = "2022-08-15"
  29669. struct3501.Invdate = "2022-08-15"
  29670. struct3501.InvCnt = "20.25"
  29671. struct3501.Memo = ""
  29672. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29673. struct3501.FixmedinsHilistId = miConfig.Code
  29674. struct3501.FixmedinsHilistName = miConfig.OrgName
  29675. struct3501s = append(struct3501s, struct3501)
  29676. data["struct_3501s"] = struct3501s
  29677. client := &http.Client{}
  29678. bytesData, _ := json.Marshal(data)
  29679. var req *http.Request
  29680. if miConfig.MdtrtareaAdmvs == "320921" {
  29681. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29682. } else {
  29683. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29684. }
  29685. resp, _ := client.Do(req)
  29686. defer resp.Body.Close()
  29687. body, ioErr := ioutil.ReadAll(resp.Body)
  29688. if ioErr != nil {
  29689. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29691. return
  29692. }
  29693. var respJSON map[string]interface{}
  29694. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29697. return
  29698. }
  29699. var res ResultSix
  29700. var resSix10265 ResultSix10265 //1101结果
  29701. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29702. result, _ := json.Marshal(respJSON)
  29703. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29704. utils.ErrorLog("解析失败:%v", err)
  29705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29706. return
  29707. }
  29708. res.InfRefmsgid = resSix10265.InfRefmsgid
  29709. res.Output = resSix10265.Output
  29710. res.ErrMsg = resSix10265.ErrMsg
  29711. res.Cainfo = resSix10265.Cainfo
  29712. res.WarnMsg = resSix10265.WarnMsg
  29713. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29714. res.Infcode = infocode
  29715. if infocode == 0 {
  29716. c.ServeSuccessJSON(map[string]interface{}{
  29717. "msg": "上传成功",
  29718. })
  29719. return
  29720. } else {
  29721. c.ServeSuccessJSON(map[string]interface{}{
  29722. "failed_code": -10,
  29723. "msg": res.ErrMsg,
  29724. })
  29725. return
  29726. }
  29727. }
  29728. func (c *HisApiController) Post3505() {
  29729. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29730. data := make(map[string]interface{})
  29731. var struct3501s []models.Struct3501
  29732. var struct3501 models.Struct3501
  29733. struct3501.OrgName = miConfig.OrgName
  29734. struct3501.AccessKey = miConfig.AccessKey
  29735. struct3501.RequestUrl = miConfig.Url
  29736. struct3501.SecretKey = miConfig.SecretKey
  29737. struct3501.ManuDate = "2022-08-15"
  29738. struct3501.FixmedinsBchno = ""
  29739. struct3501.ManuLotnum = ""
  29740. struct3501.RxFlag = "0"
  29741. struct3501.ExpyEnd = "2022-08-15"
  29742. struct3501.Invdate = "2022-08-15"
  29743. struct3501.InvCnt = "20.25"
  29744. struct3501.Memo = ""
  29745. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29746. struct3501.FixmedinsHilistId = miConfig.Code
  29747. struct3501.FixmedinsHilistName = miConfig.OrgName
  29748. struct3501s = append(struct3501s, struct3501)
  29749. data["struct_3501s"] = struct3501s
  29750. client := &http.Client{}
  29751. bytesData, _ := json.Marshal(data)
  29752. var req *http.Request
  29753. if miConfig.MdtrtareaAdmvs == "320921" {
  29754. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29755. } else {
  29756. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29757. }
  29758. resp, _ := client.Do(req)
  29759. defer resp.Body.Close()
  29760. body, ioErr := ioutil.ReadAll(resp.Body)
  29761. if ioErr != nil {
  29762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29764. return
  29765. }
  29766. var respJSON map[string]interface{}
  29767. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29770. return
  29771. }
  29772. var res ResultSix
  29773. var resSix10265 ResultSix10265 //1101结果
  29774. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29775. result, _ := json.Marshal(respJSON)
  29776. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29777. utils.ErrorLog("解析失败:%v", err)
  29778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29779. return
  29780. }
  29781. res.InfRefmsgid = resSix10265.InfRefmsgid
  29782. res.Output = resSix10265.Output
  29783. res.ErrMsg = resSix10265.ErrMsg
  29784. res.Cainfo = resSix10265.Cainfo
  29785. res.WarnMsg = resSix10265.WarnMsg
  29786. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29787. res.Infcode = infocode
  29788. if infocode == 0 {
  29789. c.ServeSuccessJSON(map[string]interface{}{
  29790. "msg": "上传成功",
  29791. })
  29792. return
  29793. } else {
  29794. c.ServeSuccessJSON(map[string]interface{}{
  29795. "failed_code": -10,
  29796. "msg": res.ErrMsg,
  29797. })
  29798. return
  29799. }
  29800. }
  29801. func (c *HisApiController) Post3506() {
  29802. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29803. data := make(map[string]interface{})
  29804. var struct3501s []models.Struct3501
  29805. var struct3501 models.Struct3501
  29806. struct3501.OrgName = miConfig.OrgName
  29807. struct3501.AccessKey = miConfig.AccessKey
  29808. struct3501.RequestUrl = miConfig.Url
  29809. struct3501.SecretKey = miConfig.SecretKey
  29810. struct3501.ManuDate = "2022-08-15"
  29811. struct3501.FixmedinsBchno = ""
  29812. struct3501.ManuLotnum = ""
  29813. struct3501.RxFlag = "0"
  29814. struct3501.ExpyEnd = "2022-08-15"
  29815. struct3501.Invdate = "2022-08-15"
  29816. struct3501.InvCnt = "20.25"
  29817. struct3501.Memo = ""
  29818. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29819. struct3501.FixmedinsHilistId = miConfig.Code
  29820. struct3501.FixmedinsHilistName = miConfig.OrgName
  29821. struct3501s = append(struct3501s, struct3501)
  29822. data["struct_3501s"] = struct3501s
  29823. client := &http.Client{}
  29824. bytesData, _ := json.Marshal(data)
  29825. var req *http.Request
  29826. if miConfig.MdtrtareaAdmvs == "320921" {
  29827. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29828. } else {
  29829. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29830. }
  29831. resp, _ := client.Do(req)
  29832. defer resp.Body.Close()
  29833. body, ioErr := ioutil.ReadAll(resp.Body)
  29834. if ioErr != nil {
  29835. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29837. return
  29838. }
  29839. var respJSON map[string]interface{}
  29840. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29843. return
  29844. }
  29845. var res ResultSix
  29846. var resSix10265 ResultSix10265 //1101结果
  29847. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29848. result, _ := json.Marshal(respJSON)
  29849. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29850. utils.ErrorLog("解析失败:%v", err)
  29851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29852. return
  29853. }
  29854. res.InfRefmsgid = resSix10265.InfRefmsgid
  29855. res.Output = resSix10265.Output
  29856. res.ErrMsg = resSix10265.ErrMsg
  29857. res.Cainfo = resSix10265.Cainfo
  29858. res.WarnMsg = resSix10265.WarnMsg
  29859. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29860. res.Infcode = infocode
  29861. if infocode == 0 {
  29862. c.ServeSuccessJSON(map[string]interface{}{
  29863. "msg": "上传成功",
  29864. })
  29865. return
  29866. } else {
  29867. c.ServeSuccessJSON(map[string]interface{}{
  29868. "failed_code": -10,
  29869. "msg": res.ErrMsg,
  29870. })
  29871. return
  29872. }
  29873. }
  29874. func (c *HisApiController) Post3507() {
  29875. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29876. data := make(map[string]interface{})
  29877. var struct3501s []models.Struct3501
  29878. var struct3501 models.Struct3501
  29879. struct3501.OrgName = miConfig.OrgName
  29880. struct3501.AccessKey = miConfig.AccessKey
  29881. struct3501.RequestUrl = miConfig.Url
  29882. struct3501.SecretKey = miConfig.SecretKey
  29883. struct3501.ManuDate = "2022-08-15"
  29884. struct3501.FixmedinsBchno = ""
  29885. struct3501.ManuLotnum = ""
  29886. struct3501.RxFlag = "0"
  29887. struct3501.ExpyEnd = "2022-08-15"
  29888. struct3501.Invdate = "2022-08-15"
  29889. struct3501.InvCnt = "20.25"
  29890. struct3501.Memo = ""
  29891. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29892. struct3501.FixmedinsHilistId = miConfig.Code
  29893. struct3501.FixmedinsHilistName = miConfig.OrgName
  29894. struct3501s = append(struct3501s, struct3501)
  29895. data["struct_3501s"] = struct3501s
  29896. client := &http.Client{}
  29897. bytesData, _ := json.Marshal(data)
  29898. var req *http.Request
  29899. if miConfig.MdtrtareaAdmvs == "320921" {
  29900. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29901. } else {
  29902. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29903. }
  29904. resp, _ := client.Do(req)
  29905. defer resp.Body.Close()
  29906. body, ioErr := ioutil.ReadAll(resp.Body)
  29907. if ioErr != nil {
  29908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29910. return
  29911. }
  29912. var respJSON map[string]interface{}
  29913. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29916. return
  29917. }
  29918. var res ResultSix
  29919. var resSix10265 ResultSix10265 //1101结果
  29920. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29921. result, _ := json.Marshal(respJSON)
  29922. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29923. utils.ErrorLog("解析失败:%v", err)
  29924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29925. return
  29926. }
  29927. res.InfRefmsgid = resSix10265.InfRefmsgid
  29928. res.Output = resSix10265.Output
  29929. res.ErrMsg = resSix10265.ErrMsg
  29930. res.Cainfo = resSix10265.Cainfo
  29931. res.WarnMsg = resSix10265.WarnMsg
  29932. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29933. res.Infcode = infocode
  29934. if infocode == 0 {
  29935. c.ServeSuccessJSON(map[string]interface{}{
  29936. "msg": "上传成功",
  29937. })
  29938. return
  29939. } else {
  29940. c.ServeSuccessJSON(map[string]interface{}{
  29941. "failed_code": -10,
  29942. "msg": res.ErrMsg,
  29943. })
  29944. return
  29945. }
  29946. }
  29947. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  29948. // WebSocket服务器地址
  29949. serverURL := "ws://127.0.0.1:8899"
  29950. // 解析WebSocket服务器地址
  29951. u, err := url.Parse(serverURL)
  29952. if err != nil {
  29953. }
  29954. // 建立WebSocket连接
  29955. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  29956. if err != nil {
  29957. }
  29958. defer conn.Close()
  29959. input2 := make(map[string]interface{})
  29960. input := make(map[string]interface{})
  29961. inputData := make(map[string]interface{})
  29962. inputData["orgId"] = code
  29963. inputData["businessType"] = "01101"
  29964. inputData["operatorId"] = operator_id
  29965. inputData["operatorName"] = operator_name
  29966. inputData["officeId"] = "001"
  29967. inputData["officeName"] = "血透室"
  29968. inputData["deviceType"] = ""
  29969. input["data"] = inputData
  29970. input["orgId"] = code
  29971. input["transType"] = "ec.query"
  29972. //if md == ""
  29973. if md[:4] == "4403" {
  29974. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29975. } else if md[:4] == "4401" {
  29976. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29977. } else {
  29978. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29979. }
  29980. input2["indata"] = input
  29981. fmt.Println(input2)
  29982. bytesData, _ := json.Marshal(input2)
  29983. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  29984. if err != nil {
  29985. fmt.Println(err)
  29986. }
  29987. // 接收消息
  29988. _, receivedMessage, err := conn.ReadMessage()
  29989. if err != nil {
  29990. fmt.Println(err)
  29991. }
  29992. return "", string(receivedMessage)
  29993. }
  29994. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  29995. // WebSocket服务器地址
  29996. serverURL := "ws://127.0.0.1:8899"
  29997. // 解析WebSocket服务器地址
  29998. u, err := url.Parse(serverURL)
  29999. if err != nil {
  30000. }
  30001. // 建立WebSocket连接
  30002. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30003. if err != nil {
  30004. }
  30005. defer conn.Close()
  30006. input2 := make(map[string]interface{})
  30007. input := make(map[string]interface{})
  30008. inputData := make(map[string]interface{})
  30009. inputData["orgId"] = code
  30010. inputData["businessType"] = "01103"
  30011. inputData["operatorId"] = operator_id
  30012. inputData["operatorName"] = operator_name
  30013. inputData["officeId"] = "001"
  30014. inputData["officeName"] = "血透室"
  30015. inputData["deviceType"] = ""
  30016. input["data"] = inputData
  30017. input["orgId"] = code
  30018. input["transType"] = "ec.query"
  30019. //if md ==
  30020. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  30021. input2["indata"] = input
  30022. fmt.Println(input2)
  30023. bytesData, _ := json.Marshal(input2)
  30024. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30025. if err != nil {
  30026. fmt.Println(err)
  30027. }
  30028. // 接收消息
  30029. _, receivedMessage, err := conn.ReadMessage()
  30030. if err != nil {
  30031. fmt.Println(err)
  30032. }
  30033. return "", string(receivedMessage)
  30034. }
  30035. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  30036. // WebSocket服务器地址
  30037. serverURL := "ws://127.0.0.1:8899"
  30038. // 解析WebSocket服务器地址
  30039. u, err := url.Parse(serverURL)
  30040. if err != nil {
  30041. }
  30042. // 建立WebSocket连接
  30043. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30044. if err != nil {
  30045. }
  30046. defer conn.Close()
  30047. input2 := make(map[string]interface{})
  30048. input := make(map[string]interface{})
  30049. inputData := make(map[string]interface{})
  30050. inputData["orgId"] = code
  30051. inputData["businessType"] = "01101"
  30052. inputData["operatorId"] = operator_id
  30053. inputData["operatorName"] = operator_name
  30054. inputData["officeId"] = "001"
  30055. inputData["officeName"] = "血透室"
  30056. inputData["deviceType"] = ""
  30057. input["data"] = inputData
  30058. input["orgId"] = code
  30059. input["transType"] = "ec.query"
  30060. //if md == ""
  30061. if md[:4] == "4403" {
  30062. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30063. } else if md[:4] == "4401" {
  30064. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30065. } else {
  30066. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30067. }
  30068. input2["indata"] = input
  30069. fmt.Println(input2)
  30070. bytesData, _ := json.Marshal(input2)
  30071. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30072. if err != nil {
  30073. fmt.Println(err)
  30074. }
  30075. // 接收消息
  30076. _, receivedMessage, err := conn.ReadMessage()
  30077. if err != nil {
  30078. fmt.Println(err)
  30079. }
  30080. return "", string(receivedMessage)
  30081. }
  30082. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  30083. // WebSocket服务器地址
  30084. serverURL := "ws://127.0.0.1:8899"
  30085. // 解析WebSocket服务器地址
  30086. u, err := url.Parse(serverURL)
  30087. if err != nil {
  30088. }
  30089. // 建立WebSocket连接
  30090. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30091. if err != nil {
  30092. }
  30093. defer conn.Close()
  30094. input2 := make(map[string]interface{})
  30095. input := make(map[string]interface{})
  30096. inputData := make(map[string]interface{})
  30097. inputData["orgId"] = code
  30098. inputData["businessType"] = "01301"
  30099. inputData["operatorId"] = operator_id
  30100. inputData["operatorName"] = operator_name
  30101. inputData["officeId"] = "001"
  30102. inputData["officeName"] = "血透室"
  30103. inputData["deviceType"] = ""
  30104. input["data"] = inputData
  30105. input["orgId"] = code
  30106. input["transType"] = "ec.query"
  30107. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30108. input2["indata"] = input
  30109. bytesData, _ := json.Marshal(input2)
  30110. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30111. if err != nil {
  30112. fmt.Println(err)
  30113. }
  30114. // 接收消息
  30115. _, receivedMessage, err := conn.ReadMessage()
  30116. if err != nil {
  30117. fmt.Println(err)
  30118. }
  30119. return "", string(receivedMessage)
  30120. }
  30121. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  30122. newArr = make([]string, 0)
  30123. for i := 0; i < len(arr); i++ {
  30124. repeat := false
  30125. for j := i + 1; j < len(arr); j++ {
  30126. if arr[i] == arr[j] {
  30127. repeat = true
  30128. break
  30129. }
  30130. }
  30131. if !repeat {
  30132. newArr = append(newArr, arr[i])
  30133. }
  30134. }
  30135. return
  30136. }
  30137. func getBirthdateAndAge(idNumber string) (string, int, error) {
  30138. if len(idNumber) != 18 {
  30139. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  30140. }
  30141. // 提取出生日期
  30142. year, err := strconv.Atoi(idNumber[6:10])
  30143. if err != nil {
  30144. return "", 0, err
  30145. }
  30146. month, err := strconv.Atoi(idNumber[10:12])
  30147. if err != nil {
  30148. return "", 0, err
  30149. }
  30150. day, err := strconv.Atoi(idNumber[12:14])
  30151. if err != nil {
  30152. return "", 0, err
  30153. }
  30154. // 格式化生日字符串
  30155. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  30156. birthdateFormatted := birthdate.Format("2006-01-02")
  30157. // 计算年龄
  30158. today := time.Now()
  30159. age := today.Year() - birthdate.Year()
  30160. if today.YearDay() < birthdate.YearDay() {
  30161. age--
  30162. }
  30163. return birthdateFormatted, age, nil
  30164. }