his_api_controller.go 918KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. //"github.com/tjfoc/gmsm/sm3"
  8. "math"
  9. //"crypto/x509/pkix"
  10. "encoding/json"
  11. "fmt"
  12. //"github.com/tjfoc/gmsm/sm2"
  13. //"github.com/tjfoc/gmsm/sm3"
  14. "gdyb/controllers"
  15. "gdyb/enums"
  16. "gdyb/models"
  17. "gdyb/service"
  18. "gdyb/utils"
  19. "github.com/astaxie/beego"
  20. "github.com/axgle/mahonia"
  21. "github.com/gorilla/websocket"
  22. "github.com/jinzhu/gorm"
  23. "github.com/shopspring/decimal"
  24. "io"
  25. "io/ioutil"
  26. //"math"
  27. "math/rand"
  28. "net/http"
  29. "net/url"
  30. "os"
  31. "path/filepath"
  32. "regexp"
  33. "strconv"
  34. "strings"
  35. "syscall"
  36. "time"
  37. "unsafe"
  38. )
  39. type HisApiController struct {
  40. controllers.BaseAuthAPIController
  41. }
  42. func HisManagerApiRegistRouters() {
  43. //挂号
  44. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  45. //上传就诊信息-上传明细-结算
  46. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  47. //查询
  48. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  49. //对总账
  50. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  51. //对明细
  52. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  53. //退费,退明细
  54. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  55. //退号
  56. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  57. //退明细
  58. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  59. //上传就诊信息-上传明细-预结算
  60. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  61. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  62. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  63. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  64. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  65. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  66. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  67. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  68. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  69. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  70. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  71. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  72. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  73. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  74. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  75. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  76. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  77. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  78. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  79. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  80. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  81. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  82. beego.Router("/api/check", &HisApiController{}, "get:Check")
  83. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  84. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  85. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  86. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  87. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  88. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  89. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  90. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  91. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  92. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  93. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  94. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  95. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  96. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  97. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  98. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  99. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  100. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  101. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  102. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  103. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  106. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  107. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  108. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  109. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  110. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  111. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  112. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  113. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  114. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  115. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  116. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  117. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  118. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  119. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  120. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  121. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  122. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  123. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  124. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  125. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  126. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  127. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  128. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  129. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  130. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  131. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  132. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  133. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  134. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  135. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  136. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  137. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  138. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  139. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  140. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  141. }
  142. func (c *HisApiController) Getquerydata() {
  143. query_type, _ := c.GetInt64("type")
  144. refd_setl_flag := c.GetString("refd_setl_flag")
  145. med_type := c.GetString("med_type")
  146. //admin_user_id,_ := c.GetInt64("admin_user_id")
  147. cert_no := c.GetString("cert_no")
  148. psn_no := c.GetString("psn_no")
  149. start_time := c.GetString("start_time")
  150. end_time := c.GetString("end_time")
  151. page, _ := c.GetInt64("page")
  152. limit, _ := c.GetInt64("limit")
  153. var bp models.BusinessParams5262
  154. bp.RefdSetlFlag = refd_setl_flag
  155. bp.MedType = med_type
  156. bp.Certno = cert_no
  157. bp.Psnno = psn_no
  158. bp.QBegntime = start_time
  159. bp.QEndtime = end_time
  160. if query_type == 1 { //本地
  161. Post5262(c, bp, page, limit)
  162. } else { //异地
  163. Post5267(c, bp, page, limit)
  164. }
  165. }
  166. func (c *HisApiController) Drugscheck() {
  167. admin_user_id, _ := c.GetInt64("admin_user_id")
  168. adminUser := c.GetAdminUserInfo()
  169. var queryResult []QueryResult
  170. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  171. for _, item := range drugs {
  172. result := QueryResult{
  173. ID: item.ID,
  174. Name: item.DrugName,
  175. Code: item.MedicalInsuranceNumber,
  176. List_type_code: "101",
  177. }
  178. queryResult = append(queryResult, result)
  179. }
  180. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  181. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  182. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  183. for _, item := range queryResult {
  184. 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)
  185. }
  186. }
  187. func (c *HisApiController) Goodcheck() {
  188. admin_user_id, _ := c.GetInt64("admin_user_id")
  189. adminUser := c.GetAdminUserInfo()
  190. var queryResult []QueryResult
  191. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  192. for _, item := range goods {
  193. result := QueryResult{
  194. ID: item.ID,
  195. Name: item.GoodName,
  196. Code: item.SocialSecurityDirectoryCode,
  197. List_type_code: "301",
  198. }
  199. queryResult = append(queryResult, result)
  200. }
  201. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  202. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  203. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  204. for _, item := range queryResult {
  205. 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)
  206. //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)
  207. }
  208. }
  209. func (c *HisApiController) Projectcheck() {
  210. admin_user_id, _ := c.GetInt64("admin_user_id")
  211. adminUser := c.GetAdminUserInfo()
  212. var queryResult []QueryResult
  213. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  214. for _, item := range projects {
  215. result := QueryResult{
  216. ID: item.ID,
  217. Name: item.ProjectName,
  218. Code: item.MedicalCode,
  219. List_type_code: "201",
  220. }
  221. queryResult = append(queryResult, result)
  222. }
  223. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  224. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  225. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  226. for _, item := range queryResult {
  227. 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)
  228. }
  229. }
  230. //func (c *HisApiController)CancleDia(){
  231. //
  232. // id, _ := c.GetInt64("id")
  233. // record_time := c.GetString("record_time")
  234. // his_patient_id, _ := c.GetInt64("his_patient_id")
  235. //
  236. // admin_user_id, _ := c.GetInt64("admin_user_id")
  237. //
  238. // diagnosis_id := c.GetString("diagnosis")
  239. // sick_type, _ := c.GetInt64("sick_type")
  240. // reg_type, _ := c.GetInt64("p_type")
  241. // begin_time := c.GetString("begin_time")
  242. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  243. //
  244. //
  245. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  246. //
  247. // fmt.Println(acct_used_flag)
  248. //
  249. //
  250. // timeLayout := "2006-01-02"
  251. // loc, _ := time.LoadLocation("Local")
  252. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  253. // if err != nil {
  254. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  255. // return
  256. // }
  257. // recordDateTime := theTime.Unix()
  258. // adminUser := c.GetAdminUserInfo()
  259. //
  260. //
  261. //
  262. //
  263. //
  264. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  265. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  266. // var patientPrescription models.HisPrescriptionInfo
  267. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  268. // if patientPrescription.ID == 0 {
  269. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  270. // }
  271. // //if patientPrescription.Do
  272. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  273. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  274. //
  275. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  276. //
  277. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  278. //
  279. // var config []*models.HisXtDiagnoseConfig
  280. // for _, item := range diagnosis_ids {
  281. // id, _ := strconv.ParseInt(item, 10, 64)
  282. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  283. // config = append(config, &diagnosisConfig)
  284. // }
  285. //
  286. // sickConfig, _ := service.FindSickById(sick_type)
  287. //
  288. //
  289. // data := make(map[string]interface{})
  290. // client := &http.Client{}
  291. // data["psn_no"] = his.PsnNo
  292. // data["mdtrt_id"] = his.Number
  293. // data["doctor"] = roles.UserName
  294. // data["department"] = department.Name
  295. // data["org_name"] = miConfig.OrgName
  296. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  297. // data["doctor_id"] = doctor_info.DoctorNumber
  298. // data["new_doctor_name"] = doctor_info.UserName
  299. // data["fixmedins_code"] = miConfig.Code
  300. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  301. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  302. // data["secret_key"] = miConfig.SecretKey
  303. // data["sick_code"] = sickConfig.CountryCode
  304. // data["sick_name"] = sickConfig.ClassName
  305. // data["url"] = miConfig.Url
  306. // data["ak"] = miConfig.AccessKey
  307. // data["begin_time"] = begin_time
  308. // data["cainfo"] = miConfig.Cainfo
  309. // data["is_vaild"] = "0"
  310. //
  311. // data["dept"] = strconv.FormatInt(department.ID, 10)
  312. // data["config"] = config
  313. // bytesData, _ := json.Marshal(data)
  314. //
  315. // var req *http.Request
  316. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  317. // resp, _ := client.Do(req)
  318. // defer resp.Body.Close()
  319. // body, ioErr := ioutil.ReadAll(resp.Body)
  320. // if ioErr != nil {
  321. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  322. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  323. // return
  324. // }
  325. // var respJSON map[string]interface{}
  326. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  327. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  328. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  329. // return
  330. // }
  331. //
  332. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  333. // userJSONBytes, _ := json.Marshal(respJSON)
  334. // fmt.Println("log")
  335. // fmt.Println(string(userJSONBytes))
  336. //
  337. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  338. // utils.ErrorLog("解析失败:%v", err)
  339. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  340. // return
  341. // }
  342. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  343. // res2.Output = ressix10265.Output
  344. // res2.ErrMsg = ressix10265.ErrMsg
  345. // res2.Cainfo = ressix10265.Cainfo
  346. // res2.WarnMsg = ressix10265.WarnMsg
  347. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  348. // res2.Infcode = infocode
  349. //
  350. //}
  351. func (c *HisApiController) Get4102() {
  352. order_id, _ := c.GetInt64("order_id")
  353. admin_user_id, _ := c.GetInt64("admin_user_id")
  354. stas_type := c.GetString("stas_type")
  355. order, _ := service.GetHisOrderByIDTwo(order_id)
  356. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  357. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  358. var pp models.PublicParams
  359. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  360. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  361. pp.FixmedinsName = miConfig.OrgName
  362. pp.FixmedinsCode = miConfig.Code
  363. pp.RequestUrl = miConfig.Url
  364. pp.Cainfo = miConfig.Cainfo
  365. pp.SecretKey = miConfig.SecretKey
  366. pp.AccessKey = miConfig.AccessKey
  367. pp.OpterName = curRoles.UserName
  368. if miConfig.MdtrtareaAdmvs == "350500" {
  369. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  370. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  371. saveLog(result, request, "4102", "清单确认")
  372. var dat map[string]interface{}
  373. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  374. fmt.Println(dat)
  375. } else {
  376. fmt.Println(err)
  377. }
  378. var empty ResultFourteen
  379. userJSONBytes, _ := json.Marshal(dat)
  380. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  381. utils.ErrorLog("解析失败:%v", err)
  382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  383. return
  384. }
  385. if empty.Infcode == 0 {
  386. c.ServeSuccessJSON(map[string]interface{}{
  387. "msg": "确认成功",
  388. })
  389. return
  390. }
  391. } else {
  392. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  393. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  394. saveLog(result, request, "4102", "清单确认")
  395. var dat map[string]interface{}
  396. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  397. fmt.Println(dat)
  398. } else {
  399. fmt.Println(err)
  400. }
  401. var empty ResultFourteen
  402. userJSONBytes, _ := json.Marshal(dat)
  403. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  404. utils.ErrorLog("解析失败:%v", err)
  405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  406. return
  407. }
  408. if empty.Infcode == 0 {
  409. c.ServeSuccessJSON(map[string]interface{}{
  410. "msg": "确认成功",
  411. })
  412. return
  413. }
  414. }
  415. }
  416. // 对账权限查询
  417. func (c *HisApiController) Get3260() {
  418. admin_user_id, _ := c.GetInt64("admin_user_id")
  419. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  420. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  421. var api string
  422. var res models.JSResult3260
  423. if miConfig.MdtrtareaAdmvs == "320921" {
  424. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  425. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  426. } else {
  427. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  428. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  429. }
  430. resp, requestErr := http.Get(api)
  431. if requestErr != nil {
  432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  433. return
  434. }
  435. body, ioErr := ioutil.ReadAll(resp.Body)
  436. if ioErr != nil {
  437. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  439. return
  440. }
  441. var respJSON map[string]interface{}
  442. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  445. return
  446. }
  447. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  448. result, _ := json.Marshal(respJSON)
  449. if err := json.Unmarshal([]byte(result), &res); err != nil {
  450. utils.ErrorLog("解析失败:%v", err)
  451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  452. return
  453. }
  454. if res.Infcode == "0" {
  455. c.ServeSuccessJSON(map[string]interface{}{
  456. "result": res.Output.Data,
  457. })
  458. } else {
  459. c.ServeSuccessJSON(map[string]interface{}{
  460. "failed_code": -10,
  461. "msg": res.ErrMsg,
  462. })
  463. return
  464. }
  465. }
  466. func (c *HisApiController) Get3261() {
  467. admin_user_id, _ := c.GetInt64("admin_user_id")
  468. //month := c.GetString("month")
  469. startTime := c.GetString("start_time")
  470. //endTime, _ := c.GetString("end_time")
  471. times := strings.Split(startTime, "-")
  472. stmt_mon := times[0] + times[1]
  473. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  474. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  475. var api string
  476. var res models.JSResult3261
  477. //var res10265 Result5301For10265
  478. if miConfig.MdtrtareaAdmvs == "320921" {
  479. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "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 + "&month=" + stmt_mon
  481. } else {
  482. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "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 + "&month=" + stmt_mon
  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. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  503. result, _ := json.Marshal(respJSON)
  504. if err := json.Unmarshal([]byte(result), &res); err != nil {
  505. utils.ErrorLog("解析失败:%v", err)
  506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  507. return
  508. }
  509. if res.Infcode == "0" {
  510. c.ServeSuccessJSON(map[string]interface{}{
  511. "result": res.Output,
  512. })
  513. } else {
  514. c.ServeSuccessJSON(map[string]interface{}{
  515. "failed_code": -10,
  516. "msg": res.ErrMsg,
  517. })
  518. return
  519. }
  520. }
  521. type TempFun struct {
  522. FundKey string
  523. FundCode string
  524. }
  525. func (c *HisApiController) Get3262() {
  526. admin_user_id, _ := c.GetInt64("admin_user_id")
  527. startTime := c.GetString("start_time")
  528. endTime := c.GetString("end_time")
  529. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  530. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  531. //timeLayout := "2006-01-02"
  532. //loc, _ := time.LoadLocation("Local")
  533. //var theStartTIme int64
  534. //if len(startTime) > 0 {
  535. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  536. // if err != nil {
  537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  538. // return
  539. // }
  540. // theStartTIme = theTime.Unix()
  541. //}
  542. //var theEndtTIme int64
  543. //if len(endTime) > 0 {
  544. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  545. // if err != nil {
  546. // utils.ErrorLog(err.Error())
  547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  548. // return
  549. // }
  550. // theEndtTIme = theTime.Unix()
  551. //}
  552. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  553. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  554. for _, team := range datas {
  555. fmt.Println(team.PsnTime)
  556. for _, team_two := range datas_two {
  557. fmt.Println(team_two.PsnTime)
  558. if team.FundKey == team_two.FundKey {
  559. fmt.Println(team_two.PsnTime)
  560. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  561. fmt.Println(team.PsnTime)
  562. }
  563. }
  564. }
  565. fmt.Println("1111")
  566. fmt.Println(datas)
  567. fmt.Println("1111")
  568. var twos []models.FixMonRecDetailFileInTwo
  569. for _, team := range datas {
  570. var two models.FixMonRecDetailFileInTwo
  571. two.MedType = team.MedType
  572. two.Insutype = team.Insutype
  573. two.PsnType = team.PsnType
  574. two.MedType = team.MedType
  575. two.FixBlngAdmdvs = "999999"
  576. two.InsuAdmdvs = "555555"
  577. two.PsnTime = team.PsnTime
  578. two.PsnCnt = team.PsnCnt
  579. two.FundKey = team.FundKey
  580. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  581. fps, _ := strconv.ParseFloat(team.Fund, 64)
  582. ia, _ := strconv.ParseFloat(team.Amt, 64)
  583. two.MedfeeSumAmt = ms
  584. two.InscpAmt = ia
  585. two.FundPaySumAmt = fps
  586. twos = append(twos, two)
  587. }
  588. //startTime := c.GetString("start_time")
  589. //endTime, _ := c.GetString("end_time")
  590. times := strings.Split(startTime, "-")
  591. stmt_mon := times[0] + times[1]
  592. var funs []models.FundDetail
  593. for _, item := range datas {
  594. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  595. funs = append(funs, fun...)
  596. }
  597. var funInfos []models.Fund
  598. for _, item := range funs {
  599. var rf []models.FundInfo
  600. json.Unmarshal([]byte(item.SetlDetail), &rf)
  601. for _, subitem := range rf {
  602. var fund models.Fund
  603. fund.FundCode = subitem.FundPayType
  604. fund.FundName = subitem.FundPayTypeName
  605. fund.FundAmt = subitem.FundPayAmt
  606. fund.FundKey = item.FundKey
  607. fund.InsuAdmdvs = "555555"
  608. fund.FixBlngAdmdvs = "999999"
  609. funInfos = append(funInfos, fund)
  610. }
  611. }
  612. var tempFuns []TempFun
  613. for _, funInfo := range funInfos {
  614. var tempFun TempFun
  615. tempFun.FundKey = funInfo.FundKey
  616. tempFun.FundCode = funInfo.FundCode
  617. tempFuns = append(tempFuns, tempFun)
  618. }
  619. tempFuns = RemoveRepeatedFunElement(tempFuns)
  620. fmt.Println(tempFuns)
  621. var funInfosTwo []models.Fund
  622. decimal.DivisionPrecision = 2
  623. for _, item := range tempFuns {
  624. var fund models.Fund
  625. for _, subItem := range funInfos {
  626. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  627. fund.FundKey = subItem.FundKey
  628. fund.InsuAdmdvs = subItem.InsuAdmdvs
  629. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  630. fund.FundName = subItem.FundName
  631. fund.FundCode = subItem.FundCode
  632. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  633. }
  634. }
  635. funInfosTwo = append(funInfosTwo, fund)
  636. }
  637. fmt.Println("funInfosTwo")
  638. fmt.Println(funInfosTwo)
  639. var upld_btch string
  640. var empty models.JSResultEmpty
  641. data := make(map[string]interface{})
  642. data["org_name"] = miConfig.OrgName
  643. data["doctor"] = curRoles.UserName
  644. data["doctor_name"] = curRoles.UserName
  645. data["fixmedins_code"] = miConfig.Code
  646. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  647. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  648. data["secret_key"] = miConfig.SecretKey
  649. data["url"] = miConfig.Url
  650. data["ak"] = miConfig.AccessKey
  651. data["cainfo"] = miConfig.Cainfo
  652. data["datas"] = twos
  653. data["fund"] = funInfosTwo
  654. fmt.Println(twos)
  655. month := time.Unix(1557042972, 0).Format("1")
  656. year := time.Now().Format("2006")
  657. month = time.Now().Format("01")
  658. day := time.Now().Format("02")
  659. hour := time.Now().Format("15")
  660. min := time.Now().Format("04")
  661. sec := time.Now().Format("05")
  662. fix_fill_date := year + month + day + hour + min + sec
  663. data["fix_fill_dept"] = miConfig.OrgName
  664. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  665. data["fix_fill_psn"] = curRoles.UserName
  666. data["fix_fill_date"] = fix_fill_date
  667. data["stmt_loc"] = "2"
  668. data["setl_mon"] = stmt_mon
  669. upld_btch = "0"
  670. data["upld_btch"] = upld_btch
  671. //fmt.Println(data)
  672. client := &http.Client{}
  673. bytesData, _ := json.Marshal(data)
  674. var req *http.Request
  675. if miConfig.MdtrtareaAdmvs == "320921" {
  676. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  677. } else {
  678. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  679. }
  680. resp, _ := client.Do(req)
  681. defer resp.Body.Close()
  682. body, ioErr := ioutil.ReadAll(resp.Body)
  683. if ioErr != nil {
  684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  686. }
  687. var respJSON map[string]interface{}
  688. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  691. }
  692. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  693. //fmt.Println(respJSON)
  694. result, _ := json.Marshal(respJSON)
  695. //fmt.Println(result)
  696. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  697. utils.ErrorLog("解析失败:%v", err)
  698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  699. }
  700. if empty.Infcode != "0" {
  701. c.ServeSuccessJSON(map[string]interface{}{
  702. "failed_code": -10,
  703. "msg": empty.ErrMsg,
  704. })
  705. return
  706. } else {
  707. c.ServeSuccessJSON(map[string]interface{}{
  708. "msg": "上传成功",
  709. })
  710. return
  711. }
  712. }
  713. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  714. newArr = make([]TempFun, 0)
  715. for i := 0; i < len(arr); i++ {
  716. repeat := false
  717. for j := i + 1; j < len(arr); j++ {
  718. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  719. repeat = true
  720. break
  721. }
  722. }
  723. if !repeat {
  724. newArr = append(newArr, arr[i])
  725. }
  726. }
  727. return
  728. }
  729. func (c *HisApiController) Get3263() {
  730. admin_user_id, _ := c.GetInt64("admin_user_id")
  731. startTime := c.GetString("start_time")
  732. //endTime, _ := c.GetString("end_time")
  733. times := strings.Split(startTime, "-")
  734. setl_mon := times[0] + times[1]
  735. upld_btch := "0"
  736. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  737. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  738. var result3263 models.JSResult3263
  739. data := make(map[string]interface{})
  740. data["org_name"] = miConfig.OrgName
  741. data["doctor"] = curRoles.UserName
  742. data["doctor_name"] = curRoles.UserName
  743. data["fixmedins_code"] = miConfig.Code
  744. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  745. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  746. data["secret_key"] = miConfig.SecretKey
  747. data["url"] = miConfig.Url
  748. data["ak"] = miConfig.AccessKey
  749. data["cainfo"] = miConfig.Cainfo
  750. data["setl_mon"] = setl_mon
  751. data["stmt_loc"] = "2"
  752. data["upld_btch"] = upld_btch
  753. client := &http.Client{}
  754. bytesData, _ := json.Marshal(data)
  755. var req *http.Request
  756. if miConfig.MdtrtareaAdmvs == "320921" {
  757. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  758. } else {
  759. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  760. }
  761. resp, _ := client.Do(req)
  762. defer resp.Body.Close()
  763. body, ioErr := ioutil.ReadAll(resp.Body)
  764. if ioErr != nil {
  765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  767. }
  768. var respJSON map[string]interface{}
  769. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  770. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  772. }
  773. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  774. fmt.Println(respJSON)
  775. result, _ := json.Marshal(respJSON)
  776. fmt.Println(result)
  777. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  778. utils.ErrorLog("解析失败:%v", err)
  779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  780. }
  781. if result3263.Infcode != "0" {
  782. c.ServeSuccessJSON(map[string]interface{}{
  783. "failed_code": -10,
  784. "msg": result3263.ErrMsg,
  785. })
  786. return
  787. } else {
  788. c.ServeSuccessJSON(map[string]interface{}{
  789. "list": result3263.Output,
  790. })
  791. return
  792. }
  793. }
  794. func (c *HisApiController) Get3264() {
  795. admin_user_id, _ := c.GetInt64("admin_user_id")
  796. startTime := c.GetString("start_time")
  797. //endTime, _ := c.GetString("end_time")
  798. times := strings.Split(startTime, "-")
  799. setl_mon := times[0] + times[1]
  800. upld_btch := "0"
  801. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  802. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  803. //solidify_id := []
  804. var result3263 models.JSResult3263
  805. data := make(map[string]interface{})
  806. data["org_name"] = miConfig.OrgName
  807. data["doctor"] = curRoles.UserName
  808. data["doctor_name"] = curRoles.UserName
  809. data["fixmedins_code"] = miConfig.Code
  810. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  811. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  812. data["secret_key"] = miConfig.SecretKey
  813. data["url"] = miConfig.Url
  814. data["ak"] = miConfig.AccessKey
  815. data["cainfo"] = miConfig.Cainfo
  816. data["setl_mon"] = setl_mon
  817. data["stmt_loc"] = "2"
  818. data["upld_btch"] = upld_btch
  819. client := &http.Client{}
  820. bytesData, _ := json.Marshal(data)
  821. var req3263 *http.Request
  822. if miConfig.MdtrtareaAdmvs == "320921" {
  823. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  824. } else {
  825. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  826. }
  827. resp, _ := client.Do(req3263)
  828. defer resp.Body.Close()
  829. body, ioErr := ioutil.ReadAll(resp.Body)
  830. if ioErr != nil {
  831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  833. }
  834. var respJSON3263 map[string]interface{}
  835. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  838. }
  839. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  840. fmt.Println(respJSON3263)
  841. result, _ := json.Marshal(respJSON3263)
  842. fmt.Println(result)
  843. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  844. utils.ErrorLog("解析失败:%v", err)
  845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  846. }
  847. var ids []string
  848. for _, item := range result3263.Output {
  849. ids = append(ids, item.SolidifyID)
  850. }
  851. var empty models.JSResultEmpty
  852. data2 := make(map[string]interface{})
  853. data2["org_name"] = miConfig.OrgName
  854. data2["doctor"] = curRoles.UserName
  855. data2["doctor_name"] = curRoles.UserName
  856. data2["fixmedins_code"] = miConfig.Code
  857. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  858. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  859. data2["secret_key"] = miConfig.SecretKey
  860. data2["url"] = miConfig.Url
  861. data2["ak"] = miConfig.AccessKey
  862. data2["cainfo"] = miConfig.Cainfo
  863. data2["setl_mon"] = setl_mon
  864. data2["stmt_loc"] = "2"
  865. data2["upld_btch"] = upld_btch
  866. data2["solidify_id"] = ids
  867. client2 := &http.Client{}
  868. bytesData2, _ := json.Marshal(data2)
  869. var req *http.Request
  870. if miConfig.MdtrtareaAdmvs == "320921" {
  871. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  872. } else {
  873. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  874. }
  875. resp2, _ := client2.Do(req)
  876. defer resp.Body.Close()
  877. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  878. if ioErr2 != nil {
  879. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  881. }
  882. var respJSON map[string]interface{}
  883. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  886. }
  887. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  888. fmt.Println(respJSON)
  889. result2, _ := json.Marshal(respJSON)
  890. fmt.Println(result2)
  891. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  892. utils.ErrorLog("解析失败:%v", err)
  893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  894. }
  895. if empty.Infcode != "0" {
  896. c.ServeSuccessJSON(map[string]interface{}{
  897. "failed_code": -10,
  898. "msg": empty.ErrMsg,
  899. })
  900. return
  901. } else {
  902. c.ServeSuccessJSON(map[string]interface{}{
  903. "msg": "",
  904. })
  905. return
  906. }
  907. }
  908. func (c *HisApiController) Get3265() {
  909. admin_user_id, _ := c.GetInt64("admin_user_id")
  910. startTime := c.GetString("start_time")
  911. //endTime, _ := c.GetString("end_time")
  912. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  913. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  914. times := strings.Split(startTime, "-")
  915. setl_mon := times[0] + times[1]
  916. var upld_btch string
  917. upld_btch = "0"
  918. //var empty models.JSResultEmpty
  919. var result3265 models.JSResult3264
  920. var result3263 models.JSResult3263
  921. data2 := make(map[string]interface{})
  922. data2["org_name"] = miConfig.OrgName
  923. data2["doctor"] = curRoles.UserName
  924. data2["doctor_name"] = curRoles.UserName
  925. data2["fixmedins_code"] = miConfig.Code
  926. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  927. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  928. data2["secret_key"] = miConfig.SecretKey
  929. data2["url"] = miConfig.Url
  930. data2["ak"] = miConfig.AccessKey
  931. data2["cainfo"] = miConfig.Cainfo
  932. data2["setl_mon"] = setl_mon
  933. data2["stmt_loc"] = "2"
  934. data2["upld_btch"] = upld_btch
  935. client2 := &http.Client{}
  936. bytesData2, _ := json.Marshal(data2)
  937. var req3263 *http.Request
  938. if miConfig.MdtrtareaAdmvs == "320921" {
  939. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  940. } else {
  941. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  942. }
  943. resp2, _ := client2.Do(req3263)
  944. defer resp2.Body.Close()
  945. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  946. if ioErr2 != nil {
  947. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  949. }
  950. var respJSON3263 map[string]interface{}
  951. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  954. }
  955. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  956. fmt.Println(respJSON3263)
  957. result2, _ := json.Marshal(respJSON3263)
  958. fmt.Println(result2)
  959. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  960. utils.ErrorLog("解析失败:%v", err)
  961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  962. }
  963. var ids []string
  964. for _, item := range result3263.Output {
  965. ids = append(ids, item.SolidifyID)
  966. }
  967. data := make(map[string]interface{})
  968. data["org_name"] = miConfig.OrgName
  969. data["doctor"] = curRoles.UserName
  970. data["doctor_name"] = curRoles.UserName
  971. data["fixmedins_code"] = miConfig.Code
  972. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  973. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  974. data["secret_key"] = miConfig.SecretKey
  975. data["url"] = miConfig.Url
  976. data["ak"] = miConfig.AccessKey
  977. data["cainfo"] = miConfig.Cainfo
  978. data["setl_mon"] = setl_mon
  979. data["solidify_id"] = ids
  980. month := time.Unix(1557042972, 0).Format("1")
  981. year := time.Now().Format("2006")
  982. month = time.Now().Format("01")
  983. day := time.Now().Format("02")
  984. hour := time.Now().Format("15")
  985. min := time.Now().Format("04")
  986. sec := time.Now().Format("05")
  987. fix_fill_date := year + month + day + hour + min + sec
  988. data["fix_fill_dept"] = miConfig.OrgName
  989. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  990. data["fix_fill_psn"] = curRoles.UserName
  991. data["fix_fill_date"] = fix_fill_date
  992. data["stmt_loc"] = "2"
  993. data["upld_btch"] = upld_btch
  994. client := &http.Client{}
  995. bytesData, _ := json.Marshal(data)
  996. var req *http.Request
  997. if miConfig.MdtrtareaAdmvs == "320921" {
  998. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  999. } else {
  1000. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1001. }
  1002. resp, _ := client.Do(req)
  1003. defer resp.Body.Close()
  1004. body, ioErr := ioutil.ReadAll(resp.Body)
  1005. if ioErr != nil {
  1006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1008. }
  1009. var respJSON map[string]interface{}
  1010. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1013. }
  1014. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1015. fmt.Println(respJSON)
  1016. result, _ := json.Marshal(respJSON)
  1017. fmt.Println(result)
  1018. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1019. utils.ErrorLog("解析失败:%v", err)
  1020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1021. }
  1022. if result3265.Infcode != "0" {
  1023. c.ServeSuccessJSON(map[string]interface{}{
  1024. "failed_code": -10,
  1025. "msg": result3265.ErrMsg,
  1026. })
  1027. return
  1028. } else {
  1029. c.ServeSuccessJSON(map[string]interface{}{
  1030. "info": result3265.Output,
  1031. })
  1032. return
  1033. }
  1034. }
  1035. func (c *HisApiController) Get3266() {
  1036. admin_user_id, _ := c.GetInt64("admin_user_id")
  1037. startTime := c.GetString("start_time")
  1038. //endTime, _ := c.GetString("end_time")
  1039. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1040. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1041. times := strings.Split(startTime, "-")
  1042. stmt_mon := times[0] + times[1]
  1043. var upld_btch string
  1044. //var empty models.JSResultEmpty
  1045. var result3265 models.JSResult3264
  1046. data := make(map[string]interface{})
  1047. data["org_name"] = miConfig.OrgName
  1048. data["doctor"] = curRoles.UserName
  1049. data["doctor_name"] = curRoles.UserName
  1050. data["fixmedins_code"] = miConfig.Code
  1051. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1052. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1053. data["secret_key"] = miConfig.SecretKey
  1054. data["url"] = miConfig.Url
  1055. data["ak"] = miConfig.AccessKey
  1056. data["cainfo"] = miConfig.Cainfo
  1057. data["setl_mon"] = stmt_mon
  1058. month := time.Unix(1557042972, 0).Format("1")
  1059. year := time.Now().Format("2006")
  1060. month = time.Now().Format("01")
  1061. day := time.Now().Format("02")
  1062. hour := time.Now().Format("15")
  1063. min := time.Now().Format("04")
  1064. sec := time.Now().Format("05")
  1065. fix_fill_date := year + month + day + hour + min + sec
  1066. data["fix_fill_dept"] = miConfig.OrgName
  1067. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1068. data["fix_fill_psn"] = curRoles.UserName
  1069. data["fix_fill_date"] = fix_fill_date
  1070. data["stmt_loc"] = "2"
  1071. upld_btch = "0"
  1072. data["upld_btch"] = upld_btch
  1073. client := &http.Client{}
  1074. bytesData, _ := json.Marshal(data)
  1075. var req *http.Request
  1076. if miConfig.MdtrtareaAdmvs == "320921" {
  1077. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1078. } else {
  1079. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1080. }
  1081. resp, _ := client.Do(req)
  1082. defer resp.Body.Close()
  1083. body, ioErr := ioutil.ReadAll(resp.Body)
  1084. if ioErr != nil {
  1085. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1087. }
  1088. var respJSON map[string]interface{}
  1089. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1092. }
  1093. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1094. fmt.Println(respJSON)
  1095. result, _ := json.Marshal(respJSON)
  1096. fmt.Println(result)
  1097. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1098. utils.ErrorLog("解析失败:%v", err)
  1099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1100. }
  1101. if result3265.Infcode != "0" {
  1102. c.ServeSuccessJSON(map[string]interface{}{
  1103. "failed_code": -10,
  1104. "msg": result3265.ErrMsg,
  1105. })
  1106. return
  1107. } else {
  1108. c.ServeSuccessJSON(map[string]interface{}{
  1109. "info": result3265.Output,
  1110. })
  1111. return
  1112. }
  1113. }
  1114. func (c *HisApiController) Get3267() {
  1115. admin_user_id, _ := c.GetInt64("admin_user_id")
  1116. startTime := c.GetString("start_time")
  1117. //endTime, _ := c.GetString("end_time")
  1118. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1119. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1120. times := strings.Split(startTime, "-")
  1121. setl_mon := times[0] + times[1]
  1122. var upld_btch string
  1123. //var empty models.JSResultEmpty
  1124. var result3265 models.JSResult3264
  1125. upld_btch = "0"
  1126. data := make(map[string]interface{})
  1127. data["org_name"] = miConfig.OrgName
  1128. data["doctor"] = curRoles.UserName
  1129. data["doctor_name"] = curRoles.UserName
  1130. data["fixmedins_code"] = miConfig.Code
  1131. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1132. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1133. data["secret_key"] = miConfig.SecretKey
  1134. data["url"] = miConfig.Url
  1135. data["ak"] = miConfig.AccessKey
  1136. data["cainfo"] = miConfig.Cainfo
  1137. data["setl_mon"] = setl_mon
  1138. data["stmt_loc"] = "2"
  1139. data["upld_btch"] = upld_btch
  1140. client := &http.Client{}
  1141. bytesData, _ := json.Marshal(data)
  1142. var req *http.Request
  1143. if miConfig.MdtrtareaAdmvs == "320921" {
  1144. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1145. } else {
  1146. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1147. }
  1148. resp, _ := client.Do(req)
  1149. defer resp.Body.Close()
  1150. body, ioErr := ioutil.ReadAll(resp.Body)
  1151. if ioErr != nil {
  1152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1154. }
  1155. var respJSON map[string]interface{}
  1156. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1159. }
  1160. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1161. fmt.Println(respJSON)
  1162. result, _ := json.Marshal(respJSON)
  1163. fmt.Println(result)
  1164. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1165. utils.ErrorLog("解析失败:%v", err)
  1166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1167. }
  1168. if result3265.Infcode != "0" {
  1169. c.ServeSuccessJSON(map[string]interface{}{
  1170. "failed_code": -10,
  1171. "msg": result3265.ErrMsg,
  1172. })
  1173. return
  1174. } else {
  1175. c.ServeSuccessJSON(map[string]interface{}{
  1176. "info": result3265.Output.Data,
  1177. })
  1178. return
  1179. }
  1180. }
  1181. func (c *HisApiController) Get3268() {
  1182. admin_user_id, _ := c.GetInt64("admin_user_id")
  1183. startTime := c.GetString("start_time")
  1184. endTime := c.GetString("end_time")
  1185. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1186. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1187. times := strings.Split(startTime, "-")
  1188. setl_mon := times[0] + times[1]
  1189. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1190. var twos []models.FixMonRecDetailFileInTwo
  1191. var funs []models.FundDetail
  1192. for _, item := range datas {
  1193. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1194. funs = append(funs, fun...)
  1195. }
  1196. var funInfos []models.Fund
  1197. for _, item := range funs {
  1198. var rf []models.FundInfo
  1199. json.Unmarshal([]byte(item.SetlDetail), &rf)
  1200. for _, subitem := range rf {
  1201. var fund models.Fund
  1202. fund.FundCode = subitem.FundPayType
  1203. fund.FundName = subitem.FundPayTypeName
  1204. fund.FundAmt = subitem.FundPayAmt
  1205. fund.FundKey = item.FundKey
  1206. fund.InsuAdmdvs = "555555"
  1207. fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  1208. funInfos = append(funInfos, fund)
  1209. }
  1210. }
  1211. for _, team := range datas {
  1212. var two models.FixMonRecDetailFileInTwo
  1213. two.SetlDate = time.Now().Format("2006-01-02")
  1214. two.MedType = team.MedType
  1215. two.Insutype = team.Insutype
  1216. two.PsnType = team.PsnType
  1217. two.MedType = team.MedType
  1218. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  1219. two.InsuAdmdvs = team.InsuAdmdvs
  1220. two.PsnTime = team.PsnTime
  1221. two.PsnCnt = team.PsnCnt
  1222. two.FundKey = team.FundKey
  1223. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1224. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1225. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1226. two.MedfeeSumAmt = ms
  1227. two.InscpAmt = ia
  1228. two.FundPaySumAmt = fps
  1229. twos = append(twos, two)
  1230. }
  1231. var upld_btch string
  1232. upld_btch = "0"
  1233. var empty models.JSResultEmpty
  1234. data := make(map[string]interface{})
  1235. data["org_name"] = miConfig.OrgName
  1236. data["doctor"] = curRoles.UserName
  1237. data["doctor_name"] = curRoles.UserName
  1238. data["fixmedins_code"] = miConfig.Code
  1239. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1240. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1241. data["secret_key"] = miConfig.SecretKey
  1242. data["url"] = miConfig.Url
  1243. data["ak"] = miConfig.AccessKey
  1244. data["cainfo"] = miConfig.Cainfo
  1245. data["datas"] = twos
  1246. data["fund"] = funInfos
  1247. data["setl_mon"] = setl_mon
  1248. month := time.Unix(1557042972, 0).Format("1")
  1249. year := time.Now().Format("2006")
  1250. month = time.Now().Format("01")
  1251. day := time.Now().Format("02")
  1252. hour := time.Now().Format("15")
  1253. min := time.Now().Format("04")
  1254. sec := time.Now().Format("05")
  1255. fix_fill_date := year + month + day + hour + min + sec
  1256. data["fix_fill_dept"] = miConfig.OrgName
  1257. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1258. data["fix_fill_psn"] = curRoles.UserName
  1259. data["fix_fill_date"] = fix_fill_date
  1260. data["stmt_loc"] = "2"
  1261. data["upld_btch"] = upld_btch
  1262. client := &http.Client{}
  1263. bytesData, _ := json.Marshal(data)
  1264. var req *http.Request
  1265. if miConfig.MdtrtareaAdmvs == "320921" {
  1266. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1267. } else {
  1268. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1269. }
  1270. resp, _ := client.Do(req)
  1271. defer resp.Body.Close()
  1272. body, ioErr := ioutil.ReadAll(resp.Body)
  1273. if ioErr != nil {
  1274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1276. }
  1277. var respJSON map[string]interface{}
  1278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1281. }
  1282. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1283. fmt.Println(respJSON)
  1284. result, _ := json.Marshal(respJSON)
  1285. fmt.Println(result)
  1286. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1287. utils.ErrorLog("解析失败:%v", err)
  1288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1289. }
  1290. if empty.Infcode != "0" {
  1291. c.ServeSuccessJSON(map[string]interface{}{
  1292. "failed_code": -10,
  1293. "msg": empty.ErrMsg,
  1294. })
  1295. return
  1296. } else {
  1297. c.ServeSuccessJSON(map[string]interface{}{
  1298. "msg": "上传成功",
  1299. })
  1300. return
  1301. }
  1302. }
  1303. func (c *HisApiController) Get3269() {
  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. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1310. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1311. var result3263 models.JSResult3263
  1312. data := make(map[string]interface{})
  1313. data["org_name"] = miConfig.OrgName
  1314. data["doctor"] = curRoles.UserName
  1315. data["doctor_name"] = curRoles.UserName
  1316. data["fixmedins_code"] = miConfig.Code
  1317. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1318. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1319. data["secret_key"] = miConfig.SecretKey
  1320. data["url"] = miConfig.Url
  1321. data["ak"] = miConfig.AccessKey
  1322. data["cainfo"] = miConfig.Cainfo
  1323. data["setl_mon"] = setl_mon
  1324. data["stmt_loc"] = "2"
  1325. client := &http.Client{}
  1326. bytesData, _ := json.Marshal(data)
  1327. var req *http.Request
  1328. if miConfig.MdtrtareaAdmvs == "320921" {
  1329. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1330. } else {
  1331. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1332. }
  1333. resp, _ := client.Do(req)
  1334. defer resp.Body.Close()
  1335. body, ioErr := ioutil.ReadAll(resp.Body)
  1336. if ioErr != nil {
  1337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1339. }
  1340. var respJSON map[string]interface{}
  1341. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1344. }
  1345. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1346. fmt.Println(respJSON)
  1347. result, _ := json.Marshal(respJSON)
  1348. fmt.Println(result)
  1349. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1350. utils.ErrorLog("解析失败:%v", err)
  1351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1352. }
  1353. if result3263.Infcode != "0" {
  1354. c.ServeSuccessJSON(map[string]interface{}{
  1355. "failed_code": -10,
  1356. "msg": result3263.ErrMsg,
  1357. })
  1358. return
  1359. } else {
  1360. c.ServeSuccessJSON(map[string]interface{}{
  1361. "msg": "上传成功",
  1362. })
  1363. return
  1364. }
  1365. }
  1366. func (c *HisApiController) Get3270() {
  1367. admin_user_id, _ := c.GetInt64("admin_user_id")
  1368. startTime := c.GetString("start_time")
  1369. //endTime, _ := c.GetString("end_time")
  1370. times := strings.Split(startTime, "-")
  1371. setl_mon := times[0] + times[1]
  1372. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1373. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1374. var result3263 models.JSResult3263
  1375. data2 := make(map[string]interface{})
  1376. data2["org_name"] = miConfig.OrgName
  1377. data2["doctor"] = curRoles.UserName
  1378. data2["doctor_name"] = curRoles.UserName
  1379. data2["fixmedins_code"] = miConfig.Code
  1380. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1381. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1382. data2["secret_key"] = miConfig.SecretKey
  1383. data2["url"] = miConfig.Url
  1384. data2["ak"] = miConfig.AccessKey
  1385. data2["cainfo"] = miConfig.Cainfo
  1386. data2["setl_mon"] = setl_mon
  1387. data2["stmt_loc"] = "2"
  1388. client2 := &http.Client{}
  1389. bytesData2, _ := json.Marshal(data2)
  1390. var req3263 *http.Request
  1391. if miConfig.MdtrtareaAdmvs == "320921" {
  1392. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1393. } else {
  1394. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1395. }
  1396. resp2, _ := client2.Do(req3263)
  1397. defer resp2.Body.Close()
  1398. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1399. if ioErr2 != nil {
  1400. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1402. }
  1403. var respJSON3263 map[string]interface{}
  1404. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1407. }
  1408. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1409. fmt.Println(respJSON3263)
  1410. result2, _ := json.Marshal(respJSON3263)
  1411. fmt.Println(result2)
  1412. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1413. utils.ErrorLog("解析失败:%v", err)
  1414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1415. }
  1416. var ids []string
  1417. for _, item := range result3263.Output {
  1418. ids = append(ids, item.SolidifyID)
  1419. }
  1420. var result3264 models.JSResult3264
  1421. data := make(map[string]interface{})
  1422. data["org_name"] = miConfig.OrgName
  1423. data["doctor"] = curRoles.UserName
  1424. data["doctor_name"] = curRoles.UserName
  1425. data["fixmedins_code"] = miConfig.Code
  1426. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1427. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1428. data["secret_key"] = miConfig.SecretKey
  1429. data["url"] = miConfig.Url
  1430. data["ak"] = miConfig.AccessKey
  1431. data["cainfo"] = miConfig.Cainfo
  1432. data["setl_mon"] = setl_mon
  1433. data["stmt_loc"] = "2"
  1434. data["solidify_id"] = ids
  1435. client := &http.Client{}
  1436. bytesData, _ := json.Marshal(data)
  1437. var req *http.Request
  1438. if miConfig.MdtrtareaAdmvs == "320921" {
  1439. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  1440. } else {
  1441. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  1442. }
  1443. resp, _ := client.Do(req)
  1444. defer resp.Body.Close()
  1445. body, ioErr := ioutil.ReadAll(resp.Body)
  1446. if ioErr != nil {
  1447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1449. }
  1450. var respJSON map[string]interface{}
  1451. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1454. }
  1455. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1456. fmt.Println(respJSON)
  1457. result, _ := json.Marshal(respJSON)
  1458. fmt.Println(result)
  1459. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  1460. utils.ErrorLog("解析失败:%v", err)
  1461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1462. }
  1463. if result3264.Infcode != "0" {
  1464. c.ServeSuccessJSON(map[string]interface{}{
  1465. "failed_code": -10,
  1466. "msg": result3264.ErrMsg,
  1467. })
  1468. return
  1469. } else {
  1470. c.ServeSuccessJSON(map[string]interface{}{
  1471. "info": result3264.Output,
  1472. })
  1473. return
  1474. }
  1475. }
  1476. func (c *HisApiController) Get3271() {
  1477. admin_user_id, _ := c.GetInt64("admin_user_id")
  1478. startTime := c.GetString("start_time")
  1479. //endTime, _ := c.GetString("end_time")
  1480. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1481. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1482. times := strings.Split(startTime, "-")
  1483. setl_mon := times[0] + times[1]
  1484. //var empty models.JSResultEmpty
  1485. var result3265 models.JSResult3264
  1486. var result3263 models.JSResult3263
  1487. data2 := make(map[string]interface{})
  1488. data2["org_name"] = miConfig.OrgName
  1489. data2["doctor"] = curRoles.UserName
  1490. data2["doctor_name"] = curRoles.UserName
  1491. data2["fixmedins_code"] = miConfig.Code
  1492. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1493. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1494. data2["secret_key"] = miConfig.SecretKey
  1495. data2["url"] = miConfig.Url
  1496. data2["ak"] = miConfig.AccessKey
  1497. data2["cainfo"] = miConfig.Cainfo
  1498. data2["setl_mon"] = setl_mon
  1499. data2["stmt_loc"] = "2"
  1500. client2 := &http.Client{}
  1501. bytesData2, _ := json.Marshal(data2)
  1502. var req3263 *http.Request
  1503. if miConfig.MdtrtareaAdmvs == "320921" {
  1504. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1505. } else {
  1506. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1507. }
  1508. resp2, _ := client2.Do(req3263)
  1509. defer resp2.Body.Close()
  1510. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1511. if ioErr2 != nil {
  1512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1514. }
  1515. var respJSON3263 map[string]interface{}
  1516. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1519. }
  1520. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1521. fmt.Println(respJSON3263)
  1522. result2, _ := json.Marshal(respJSON3263)
  1523. fmt.Println(result2)
  1524. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1525. utils.ErrorLog("解析失败:%v", err)
  1526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1527. }
  1528. var ids []string
  1529. for _, item := range result3263.Output {
  1530. ids = append(ids, item.SolidifyID)
  1531. }
  1532. data := make(map[string]interface{})
  1533. data["org_name"] = miConfig.OrgName
  1534. data["doctor"] = curRoles.UserName
  1535. data["doctor_name"] = curRoles.UserName
  1536. data["fixmedins_code"] = miConfig.Code
  1537. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1538. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1539. data["secret_key"] = miConfig.SecretKey
  1540. data["url"] = miConfig.Url
  1541. data["ak"] = miConfig.AccessKey
  1542. data["cainfo"] = miConfig.Cainfo
  1543. data["setl_mon"] = setl_mon
  1544. data["solidify_id"] = ids
  1545. month := time.Unix(1557042972, 0).Format("1")
  1546. year := time.Now().Format("2006")
  1547. month = time.Now().Format("01")
  1548. day := time.Now().Format("02")
  1549. hour := time.Now().Format("15")
  1550. min := time.Now().Format("04")
  1551. sec := time.Now().Format("05")
  1552. fix_fill_date := year + month + day + hour + min + sec
  1553. data["fix_fill_dept"] = miConfig.OrgName
  1554. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1555. data["fix_fill_psn"] = curRoles.UserName
  1556. data["fix_fill_date"] = fix_fill_date
  1557. data["stmt_loc"] = "2"
  1558. client := &http.Client{}
  1559. bytesData, _ := json.Marshal(data)
  1560. var req *http.Request
  1561. if miConfig.MdtrtareaAdmvs == "320921" {
  1562. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  1563. } else {
  1564. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  1565. }
  1566. resp, _ := client.Do(req)
  1567. defer resp.Body.Close()
  1568. body, ioErr := ioutil.ReadAll(resp.Body)
  1569. if ioErr != nil {
  1570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1572. }
  1573. var respJSON map[string]interface{}
  1574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1577. }
  1578. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1579. fmt.Println(respJSON)
  1580. result, _ := json.Marshal(respJSON)
  1581. fmt.Println(result)
  1582. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1583. utils.ErrorLog("解析失败:%v", err)
  1584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1585. }
  1586. if result3265.Infcode != "0" {
  1587. c.ServeSuccessJSON(map[string]interface{}{
  1588. "failed_code": -10,
  1589. "msg": result3265.ErrMsg,
  1590. })
  1591. return
  1592. } else {
  1593. c.ServeSuccessJSON(map[string]interface{}{
  1594. "info": result3265.Output.Data,
  1595. })
  1596. return
  1597. }
  1598. }
  1599. func (c *HisApiController) Get3272() {
  1600. admin_user_id, _ := c.GetInt64("admin_user_id")
  1601. startTime := c.GetString("start_time")
  1602. //endTime, _ := c.GetString("end_time")
  1603. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1604. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1605. times := strings.Split(startTime, "-")
  1606. setl_mon := times[0] + times[1]
  1607. var upld_btch string
  1608. //var empty models.JSResultEmpty
  1609. var result3265 models.JSResult3264
  1610. data := make(map[string]interface{})
  1611. data["org_name"] = miConfig.OrgName
  1612. data["doctor"] = curRoles.UserName
  1613. data["doctor_name"] = curRoles.UserName
  1614. data["fixmedins_code"] = miConfig.Code
  1615. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1616. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1617. data["secret_key"] = miConfig.SecretKey
  1618. data["url"] = miConfig.Url
  1619. data["ak"] = miConfig.AccessKey
  1620. data["cainfo"] = miConfig.Cainfo
  1621. data["setl_mon"] = setl_mon
  1622. month := time.Unix(1557042972, 0).Format("1")
  1623. year := time.Now().Format("2006")
  1624. month = time.Now().Format("01")
  1625. day := time.Now().Format("02")
  1626. hour := time.Now().Format("15")
  1627. min := time.Now().Format("04")
  1628. sec := time.Now().Format("05")
  1629. fix_fill_date := year + month + day + hour + min + sec
  1630. data["fix_fill_dept"] = miConfig.OrgName
  1631. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1632. data["fix_fill_psn"] = curRoles.UserName
  1633. data["fix_fill_date"] = fix_fill_date
  1634. data["stmt_loc"] = "2"
  1635. data["upld_btch"] = upld_btch
  1636. client := &http.Client{}
  1637. bytesData, _ := json.Marshal(data)
  1638. var req *http.Request
  1639. if miConfig.MdtrtareaAdmvs == "320921" {
  1640. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  1641. } else {
  1642. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  1643. }
  1644. resp, _ := client.Do(req)
  1645. defer resp.Body.Close()
  1646. body, ioErr := ioutil.ReadAll(resp.Body)
  1647. if ioErr != nil {
  1648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1650. }
  1651. var respJSON map[string]interface{}
  1652. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1655. }
  1656. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1657. fmt.Println(respJSON)
  1658. result, _ := json.Marshal(respJSON)
  1659. fmt.Println(result)
  1660. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1661. utils.ErrorLog("解析失败:%v", err)
  1662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1663. }
  1664. if result3265.Infcode != "0" {
  1665. c.ServeSuccessJSON(map[string]interface{}{
  1666. "failed_code": -10,
  1667. "msg": result3265.ErrMsg,
  1668. })
  1669. return
  1670. } else {
  1671. c.ServeSuccessJSON(map[string]interface{}{
  1672. "info": result3265.Output,
  1673. })
  1674. return
  1675. }
  1676. }
  1677. func (c *HisApiController) Get3273() {
  1678. admin_user_id, _ := c.GetInt64("admin_user_id")
  1679. startTime := c.GetString("start_time")
  1680. //endTime, _ := c.GetString("end_time")
  1681. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1682. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1683. times := strings.Split(startTime, "-")
  1684. setl_mon := times[0] + times[1]
  1685. var result3265 models.JSResult3264
  1686. data := make(map[string]interface{})
  1687. data["org_name"] = miConfig.OrgName
  1688. data["doctor"] = curRoles.UserName
  1689. data["doctor_name"] = curRoles.UserName
  1690. data["fixmedins_code"] = miConfig.Code
  1691. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1692. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1693. data["secret_key"] = miConfig.SecretKey
  1694. data["url"] = miConfig.Url
  1695. data["ak"] = miConfig.AccessKey
  1696. data["cainfo"] = miConfig.Cainfo
  1697. data["setl_mon"] = setl_mon
  1698. data["stmt_loc"] = "2"
  1699. client := &http.Client{}
  1700. bytesData, _ := json.Marshal(data)
  1701. var req *http.Request
  1702. if miConfig.MdtrtareaAdmvs == "320921" {
  1703. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  1704. } else {
  1705. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  1706. }
  1707. resp, _ := client.Do(req)
  1708. defer resp.Body.Close()
  1709. body, ioErr := ioutil.ReadAll(resp.Body)
  1710. if ioErr != nil {
  1711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1713. }
  1714. var respJSON map[string]interface{}
  1715. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1718. }
  1719. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1720. fmt.Println(respJSON)
  1721. result, _ := json.Marshal(respJSON)
  1722. fmt.Println(result)
  1723. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1724. utils.ErrorLog("解析失败:%v", err)
  1725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1726. }
  1727. if result3265.Infcode != "0" {
  1728. c.ServeSuccessJSON(map[string]interface{}{
  1729. "failed_code": -10,
  1730. "msg": result3265.ErrMsg,
  1731. })
  1732. return
  1733. } else {
  1734. c.ServeSuccessJSON(map[string]interface{}{
  1735. "info": result3265.Output.Data,
  1736. })
  1737. return
  1738. }
  1739. }
  1740. func (c *HisApiController) Get3274() {
  1741. //if miConfig.MdtrtareaAdmvs == "320921" {
  1742. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1743. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1744. // "&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
  1745. //
  1746. //} else {
  1747. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1748. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1749. // "&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
  1750. //
  1751. //}
  1752. }
  1753. func (c *HisApiController) Get3275() {
  1754. //if miConfig.MdtrtareaAdmvs == "320921" {
  1755. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1756. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1757. // "&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
  1758. //
  1759. //} else {
  1760. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1761. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1762. // "&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
  1763. //
  1764. //}
  1765. }
  1766. func (c *HisApiController) Get3276() {
  1767. //admin_user_id, _ := c.GetInt64("admin_user_id")
  1768. //month := c.GetString("month")
  1769. //
  1770. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1771. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1772. //var api string
  1773. //var res Result5301
  1774. //
  1775. //if miConfig.MdtrtareaAdmvs == "320921" {
  1776. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1777. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1778. //} else {
  1779. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1780. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1781. //}
  1782. //
  1783. //resp, requestErr := http.Get(api)
  1784. //if requestErr != nil {
  1785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1786. // return
  1787. //}
  1788. //
  1789. //body, ioErr := ioutil.ReadAll(resp.Body)
  1790. //if ioErr != nil {
  1791. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1792. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1793. // return
  1794. //}
  1795. //var respJSON map[string]interface{}
  1796. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1797. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1798. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1799. // return
  1800. //}
  1801. //
  1802. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1803. //result, _ := json.Marshal(respJSON)
  1804. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1805. // utils.ErrorLog("解析失败:%v", err)
  1806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1807. // return
  1808. //}
  1809. }
  1810. func (c *HisApiController) Get3277() {
  1811. //admin_user_id, _ := c.GetInt64("admin_user_id")
  1812. //month := c.GetString("month")
  1813. //
  1814. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1815. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1816. //var api string
  1817. //var res Result5301
  1818. //
  1819. //if miConfig.MdtrtareaAdmvs == "320921" {
  1820. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1821. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1822. //} else {
  1823. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1824. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1825. //}
  1826. //
  1827. //resp, requestErr := http.Get(api)
  1828. //if requestErr != nil {
  1829. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1830. // return
  1831. //}
  1832. //
  1833. //body, ioErr := ioutil.ReadAll(resp.Body)
  1834. //if ioErr != nil {
  1835. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1836. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1837. // return
  1838. //}
  1839. //var respJSON map[string]interface{}
  1840. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1841. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1843. // return
  1844. //}
  1845. //
  1846. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1847. //result, _ := json.Marshal(respJSON)
  1848. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1849. // utils.ErrorLog("解析失败:%v", err)
  1850. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1851. // return
  1852. //}
  1853. }
  1854. func (c *HisApiController) GetCFYLJG001() {
  1855. admin_user_id, _ := c.GetInt64("admin_user_id")
  1856. patient_id, _ := c.GetInt64("patient_id")
  1857. his_patient_id, _ := c.GetInt64("his_patient_id")
  1858. record_time := c.GetString("record_time")
  1859. admin_user_id = 3626
  1860. //patient_id = 23834
  1861. //his_patient_id = 271193
  1862. //record_time = "2023-09-07"
  1863. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1864. psn, _ := service.GetPsnByPatientId(patient_id)
  1865. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  1866. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  1867. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1868. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1869. var cFYLJG001 models.CFYLJG001
  1870. timeLayout := "2006-01-02"
  1871. loc, _ := time.LoadLocation("Local")
  1872. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1873. if err != nil {
  1874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1875. return
  1876. }
  1877. recordDateTime := theTime.Unix()
  1878. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  1879. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  1880. for _, item := range prescriptions {
  1881. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  1882. if his.IdCardType == 1 {
  1883. bas := strings.Split(psn.CardInfo, "|")
  1884. basNumber := bas[1]
  1885. fmt.Println(basNumber)
  1886. card_sn := bas[3]
  1887. card_no := bas[2]
  1888. cFYLJG001.MdtrtCertType = "03"
  1889. cFYLJG001.CardSn = card_sn
  1890. cFYLJG001.MdtrtCertNo = card_no
  1891. cFYLJG001.EcToken = ""
  1892. cFYLJG001.AuthNo = ""
  1893. } else if his.IdCardType == 2 {
  1894. cFYLJG001.MdtrtCertType = "02"
  1895. cFYLJG001.CardSn = ""
  1896. cFYLJG001.MdtrtCertNo = his.IdCardNo
  1897. cFYLJG001.EcToken = ""
  1898. cFYLJG001.AuthNo = ""
  1899. } else if his.IdCardType == 4 {
  1900. cFYLJG001.MdtrtCertType = "01"
  1901. cFYLJG001.CardSn = ""
  1902. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  1903. cFYLJG001.EcToken = psn.VerifyNumber
  1904. cFYLJG001.AuthNo = ""
  1905. }
  1906. cFYLJG001.BizTypeCode = "01"
  1907. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  1908. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  1909. cFYLJG001.RxTypeCode = "1"
  1910. tempTime := time.Unix(item.PreTime, 0)
  1911. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1912. cFYLJG001.PrscTime = timeFormatOne
  1913. var count float64
  1914. if item.Type == 1 {
  1915. for _, sumItem := range item.HisDoctorAdviceInfo {
  1916. count = count + sumItem.PrescribingNumber
  1917. }
  1918. }
  1919. cFYLJG001.RxDrugCnt = count
  1920. cFYLJG001.ValiDays = "5"
  1921. ts := time.Unix(item.PreTime, 0)
  1922. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  1923. tempTime3 := time.Unix(record_time2, 0)
  1924. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  1925. cFYLJG001.ValiEndTime = timeFormat3
  1926. cFYLJG001.RxCotnFlag = "0"
  1927. for _, subItem := range item.HisDoctorAdviceInfo {
  1928. var drug models.RxDrug
  1929. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  1930. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  1931. drug.RxItemTypeCode = "11"
  1932. drug.DrugDosform = "乳膏剂" //TODO
  1933. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  1934. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  1935. }
  1936. drug.MedcWayDscr = subItem.DeliveryWay
  1937. tempTime2 := time.Unix(subItem.StartTime, 0)
  1938. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  1939. drug.MedcBegntime = timeFormatTwo
  1940. if subItem.Day > 0 {
  1941. ts := time.Unix(subItem.StartTime, 0)
  1942. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  1943. tempTime4 := time.Unix(record_time, 0)
  1944. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  1945. drug.MedcEndtime = timeFormat5
  1946. } else {
  1947. tempTime2 := time.Unix(subItem.StartTime, 0)
  1948. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  1949. drug.MedcEndtime = timeFormatTwo
  1950. }
  1951. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  1952. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  1953. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  1954. drug.DrugCnt = subItem.PrescribingNumber
  1955. drug.DrugDosunt = subItem.PrescribingNumberUnit
  1956. drug.DrugGenname = subItem.AdviceName
  1957. drug.MedcWayCodg = subItem.DeliveryWay
  1958. //drug.DrugTotlcnt = subItem.PrescribingNumber
  1959. drug.SinDoscnt = subItem.SingleDose
  1960. drug.SinDosunt = subItem.SingleDoseUnit
  1961. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  1962. drug.UsedFrquName = subItem.ExecutionFrequency
  1963. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1964. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  1965. drug.HospApprFlag = "1"
  1966. cFYLJG001.List = append(cFYLJG001.List, drug)
  1967. }
  1968. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  1969. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  1970. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  1971. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  1972. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  1973. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  1974. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  1975. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  1976. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  1977. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  1978. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  1979. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  1980. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  1981. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  1982. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  1983. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  1984. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  1985. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  1986. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  1987. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  1988. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  1989. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  1990. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  1991. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  1992. tempTime2 := time.Now().Unix()
  1993. tempTime6 := time.Unix(tempTime2, 0)
  1994. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  1995. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  1996. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  1997. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  1998. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  1999. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  2000. //memo := make(map[string]interface{})
  2001. //inputData := make(map[string]interface{}, 0)
  2002. //type MyData struct {
  2003. // Insutype string `json:"insutype"`
  2004. //}
  2005. //
  2006. // data := MyData{
  2007. // Insutype: his.Insutype,
  2008. //}
  2009. //
  2010. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  2011. var config []*models.HisXtDiagnoseConfig
  2012. for _, item := range diagnosis_ids {
  2013. id, _ := strconv.ParseInt(item, 10, 64)
  2014. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2015. config = append(config, &diagnosisConfig)
  2016. }
  2017. for index, subitem := range config {
  2018. if index == 0 {
  2019. var dia models.DiseInfo
  2020. dia.DiagType = "1"
  2021. dia.MaindiagFlag = "1"
  2022. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2023. dia.DiagCode = subitem.CountryCode
  2024. dia.DiagName = subitem.ClassName
  2025. dia.DiagDept = "肾内科"
  2026. dia.DiagDrNo = doctor.DoctorNumber
  2027. dia.DiagDrName = doctor.UserName
  2028. tempTime3 := time.Unix(item.PreTime, 0)
  2029. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2030. dia.DiagTime = timeFormatTwo
  2031. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2032. } else {
  2033. var dia models.DiseInfo
  2034. dia.DiagType = "1"
  2035. dia.MaindiagFlag = "0"
  2036. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2037. dia.DiagCode = subitem.CountryCode
  2038. dia.DiagName = subitem.ClassName
  2039. dia.DiagDept = "肾内科"
  2040. dia.DiagDrNo = doctor.DoctorNumber
  2041. dia.DiagDrName = doctor.UserName
  2042. tempTime3 := time.Unix(item.PreTime, 0)
  2043. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2044. dia.DiagTime = timeFormatTwo
  2045. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2046. }
  2047. }
  2048. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  2049. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  2050. }
  2051. }
  2052. func (c *HisApiController) GetCFYLJG002() {
  2053. admin_user_id, _ := c.GetInt64("admin_user_id")
  2054. id, _ := c.GetInt64("id")
  2055. admin_user_id = 3626
  2056. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2057. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2058. flow, _ := service.Getflow(id)
  2059. his, _ := service.GetHisPatientByNumber(flow.MID)
  2060. record_time := c.GetString("record_time")
  2061. patient_id, _ := c.GetInt64("patient_id")
  2062. //patient_id = 23834
  2063. //record_time = "2023-09-18"
  2064. timeLayout := "2006-01-02"
  2065. loc, _ := time.LoadLocation("Local")
  2066. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2067. if err != nil {
  2068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2069. return
  2070. }
  2071. recordDateTime := theTime.Unix()
  2072. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2073. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2074. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2075. dept, _ := service.GetDepartMentDetail(info.Departments)
  2076. inputData := make(map[string]interface{})
  2077. inputData["rxTraceCode"] = flow.RxTraceCode
  2078. inputData["hiRxno"] = flow.HiRxno
  2079. inputData["mdtrtId"] = flow.MID
  2080. inputData["patnName"] = his.PsnName
  2081. inputData["psnCertType"] = his.PsnCertType
  2082. inputData["certno"] = his.Certno
  2083. inputData["fixmedinsName"] = miConfig.OrgName
  2084. inputData["fixmedinsCode"] = miConfig.Code
  2085. inputData["drCode"] = doctor_info.DoctorNumber
  2086. inputData["prscDrName"] = doctor_info.UserName
  2087. inputData["pharDeptName"] = dept.Name
  2088. inputData["pharDeptCode"] = dept.Number
  2089. inputData["pharProfttlCodg"] = dept.Name
  2090. inputData["pharProfttlName"] = ""
  2091. inputData["pharCode"] = "HY440309002107"
  2092. inputData["pharCertType"] = "01"
  2093. inputData["pharCertno"] = "430482199408260023"
  2094. inputData["pharName"] = "彭斯遥"
  2095. inputData["pharPracCertNo"] = ""
  2096. tempTime2 := time.Unix(info.Ctime, 0)
  2097. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2098. inputData["pharChkTime"] = timeFormatTwo
  2099. bytesData, _ := json.Marshal(inputData)
  2100. fmt.Println(string(bytesData))
  2101. encoded := base64.StdEncoding.EncodeToString(bytesData)
  2102. //
  2103. //// 创建一个新的 PDF 文档
  2104. //pdf := gofpdf.New("P", "mm", "A4", "")
  2105. //
  2106. //// 添加一个页面
  2107. //pdf.AddPage()
  2108. //
  2109. //// 设置字体和字号
  2110. //pdf.SetFont("Arial", "B", 16)
  2111. //
  2112. //
  2113. //// 将签名后的信息添加到 PDF 文档中
  2114. //pdf.MultiCell(0, 10, string(bytesData), "", "L", false)
  2115. //
  2116. //// 保存 PDF 文件
  2117. //err = pdf.OutputFileAndClose("signed_data.pdf")
  2118. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  2119. if err != nil {
  2120. fmt.Println("Error reading PDF file:", err)
  2121. return
  2122. }
  2123. // 将 PDF 文件内容进行 Base64 编码
  2124. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  2125. fmt.Println(err)
  2126. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  2127. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  2128. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  2129. var res2 Result002
  2130. var respJSON2 map[string]interface{}
  2131. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2134. return
  2135. }
  2136. userJSONBytes2, _ := json.Marshal(respJSON2)
  2137. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2138. utils.ErrorLog("解析失败:%v", err)
  2139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2140. return
  2141. }
  2142. if res2.Infcode == 0 {
  2143. flow.Ctime = time.Now().Unix()
  2144. flow.SignDigest = res2.Output.SignDigest
  2145. flow.RxFile = res2.Output.RxFile
  2146. flow.MID = his.Number
  2147. flow.Status = 1
  2148. flow.DCode = doctor_info.DoctorNumber
  2149. flow.OriginalRxFile = rx_encoded
  2150. flow.OriginalValue = encoded
  2151. flow.SignCertDn = res2.Output.SignCertDn
  2152. flow.SignCertSn = res2.Output.SignCertSn
  2153. flow.Mtime = time.Now().Unix()
  2154. service.Saveflow(flow)
  2155. }
  2156. }
  2157. func (c *HisApiController) GetCFYLJG003() {
  2158. admin_user_id, _ := c.GetInt64("admin_user_id")
  2159. id, _ := c.GetInt64("id")
  2160. admin_user_id = 3626
  2161. //id = 3
  2162. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2163. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2164. flow, _ := service.Getflow(id)
  2165. his, _ := service.GetHisPatientByNumber(flow.MID)
  2166. record_time := c.GetString("record_time")
  2167. patient_id, _ := c.GetInt64("patient_id")
  2168. //patient_id = 23834
  2169. //record_time = "2023-09-18"
  2170. timeLayout := "2006-01-02"
  2171. loc, _ := time.LoadLocation("Local")
  2172. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2173. if err != nil {
  2174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2175. return
  2176. }
  2177. recordDateTime := theTime.Unix()
  2178. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2179. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2180. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2181. dept, _ := service.GetDepartMentDetail(info.Departments)
  2182. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  2183. var cFYLJG003 models.CFYLJG003
  2184. cFYLJG003.RxTraceCode = flow.RxTraceCode
  2185. cFYLJG003.HiRxno = flow.HiRxno
  2186. cFYLJG003.MdtrtID = flow.MID
  2187. cFYLJG003.PatnName = his.Name
  2188. cFYLJG003.Certno = his.Certno
  2189. cFYLJG003.FixmedinsName = miConfig.OrgName
  2190. cFYLJG003.FixmedinsCode = miConfig.Code
  2191. cFYLJG003.DrCode = doctor_info.DoctorNumber
  2192. cFYLJG003.PrscDrName = doctor_info.UserName
  2193. cFYLJG003.PharDeptName = dept.Name
  2194. cFYLJG003.PharDeptCode = dept.Number
  2195. cFYLJG003.PharCode = "HY440309002107"
  2196. cFYLJG003.PharCertType = "01"
  2197. cFYLJG003.PharCertno = "430482199408260023"
  2198. cFYLJG003.PharName = "彭斯遥"
  2199. cFYLJG003.PsnCertType = "01"
  2200. cFYLJG003.RxFile = flow.RxFile
  2201. cFYLJG003.SignDigest = flow.SignDigest
  2202. cFYLJG003.FixmedinsCode = miConfig.Code
  2203. cFYLJG003.PsnCertType = "01"
  2204. cFYLJG003.PharProfttlCodg = dept.Name
  2205. //inputData["pharProfttlCodg"] =dept.Name
  2206. tempTime2 := time.Unix(info.Ctime, 0)
  2207. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2208. cFYLJG003.PharChkTime = timeFormatTwo
  2209. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  2210. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  2211. }
  2212. func (c *HisApiController) GetCFYLJG004() {
  2213. admin_user_id, _ := c.GetInt64("admin_user_id")
  2214. id, _ := c.GetInt64("id")
  2215. admin_user_id = 3626
  2216. //id = 3
  2217. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2218. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2219. flow, _ := service.Getflow(id)
  2220. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2221. record_time := c.GetString("record_time")
  2222. patient_id, _ := c.GetInt64("patient_id")
  2223. //patient_id = 23834
  2224. //record_time = "2023-09-18"
  2225. timeLayout := "2006-01-02"
  2226. loc, _ := time.LoadLocation("Local")
  2227. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2228. if err != nil {
  2229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2230. return
  2231. }
  2232. recordDateTime := theTime.Unix()
  2233. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2234. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2235. var cFYLJG004 models.CFYLJG004
  2236. cFYLJG004.HiRxno = flow.HiRxno
  2237. cFYLJG004.FixmedinsCode = miConfig.Code
  2238. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  2239. cFYLJG004.UndoDrCertType = "01"
  2240. cFYLJG004.UndoRea = "撤销处方"
  2241. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  2242. cFYLJG004.UndoDrName = doctor_info.UserName
  2243. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  2244. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  2245. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  2246. }
  2247. func (c *HisApiController) GetCFYLJG005() {
  2248. admin_user_id, _ := c.GetInt64("admin_user_id")
  2249. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2250. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2251. var cFYLJG005 models.CFYLJG005
  2252. id, _ := c.GetInt64("id")
  2253. patient_id, _ := c.GetInt64("patient_id")
  2254. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  2255. flow, _ := service.Getflow(id)
  2256. cFYLJG005.HiRxno = flow.HiRxno
  2257. cFYLJG005.MdtrtID = flow.MID
  2258. cFYLJG005.EcToken = ""
  2259. cFYLJG005.PsnName = patient.Name
  2260. cFYLJG005.PsnCertType = "01"
  2261. cFYLJG005.Certno = patient.IdCardNo
  2262. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  2263. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  2264. }
  2265. func (c *HisApiController) GetCFYLJG006() {
  2266. admin_user_id, _ := c.GetInt64("admin_user_id")
  2267. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2268. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2269. var cFYLJG006 models.CFYLJG006
  2270. id, _ := c.GetInt64("id")
  2271. patient_id, _ := c.GetInt64("patient_id")
  2272. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  2273. flow, _ := service.Getflow(id)
  2274. cFYLJG006.HiRxno = flow.HiRxno
  2275. cFYLJG006.MdtrtID = flow.MID
  2276. cFYLJG006.PsnName = patient.Name
  2277. cFYLJG006.PsnCertType = "01"
  2278. cFYLJG006.Certno = patient.IdCardNo
  2279. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  2280. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  2281. }
  2282. func (c *HisApiController) GetCFYLJG007() {
  2283. admin_user_id, _ := c.GetInt64("admin_user_id")
  2284. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2285. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2286. var cFYLJG007 models.CFYLJG007
  2287. id, _ := c.GetInt64("id")
  2288. patient_id, _ := c.GetInt64("patient_id")
  2289. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  2290. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  2291. flow, _ := service.Getflow(id)
  2292. his, _ := service.GetHisPatientByNumber(flow.MID)
  2293. cFYLJG007.HiRxno = flow.HiRxno
  2294. cFYLJG007.MdtrtID = flow.MID
  2295. cFYLJG007.PsnNo = his.PsnNo
  2296. cFYLJG007.PsnCertType = "01"
  2297. cFYLJG007.Certno = patient.IdCardNo
  2298. cFYLJG007.PsnName = patient.Name
  2299. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  2300. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  2301. }
  2302. func (c *HisApiController) GetCFYLJG008() {
  2303. admin_user_id, _ := c.GetInt64("admin_user_id")
  2304. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2305. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2306. var cFYLJG008 models.CFYLJG008
  2307. //id, _ := c.GetInt64("id")
  2308. patient_id, _ := c.GetInt64("patient_id")
  2309. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  2310. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  2311. //id = 3
  2312. //flow, _ := service.Getflow(id)
  2313. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2314. //
  2315. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2316. //patient_id, _ := c.GetInt64("patient_id")
  2317. //his_patient_id, _ := c.GetInt64("his_patient_id")
  2318. record_time := c.GetString("record_time")
  2319. admin_user_id = 3626
  2320. patient_id = 19424
  2321. //his_patient_id = 263947
  2322. record_time = "2023-08-29"
  2323. timeLayout := "2006-01-02"
  2324. loc, _ := time.LoadLocation("Local")
  2325. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2326. if err != nil {
  2327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2328. return
  2329. }
  2330. recordDateTime := theTime.Unix()
  2331. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2332. cFYLJG008.FixmedinsName = ""
  2333. cFYLJG008.Lat = ""
  2334. cFYLJG008.Lng = ""
  2335. cFYLJG008.OrderType = "1"
  2336. cFYLJG008.PoolareaNo = ""
  2337. cFYLJG008.Lng = ""
  2338. cFYLJG008.PageNum = 1
  2339. cFYLJG008.PageSize = 10
  2340. var MPI models.MedinsProdInvChgDDTO
  2341. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  2342. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  2343. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  2344. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  2345. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  2346. }
  2347. func (c *HisApiController) GetBL4201A() {
  2348. order_id, _ := c.GetInt64("order_id")
  2349. admin_user_id, _ := c.GetInt64("admin_user_id")
  2350. order, _ := service.GetHisOrderByIDTwo(order_id)
  2351. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2352. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  2353. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  2354. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2355. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2356. department, _ := service.GetDepartMentDetail(his.Departments)
  2357. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  2358. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  2359. if order.ID == 0 {
  2360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2361. return
  2362. }
  2363. var struct4201A models.Struct4201A
  2364. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  2365. for _, items := range order_info {
  2366. memo := make(map[string]interface{})
  2367. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2368. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2369. fsiOPFLD.MedType = "14"
  2370. fsiOPFLD.BkkpSn = items.FeedetlSn
  2371. fsiOPFLD.FixmedinsCode = miConfig.Code
  2372. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2373. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2374. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2375. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2376. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2377. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2378. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2379. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2380. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2381. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2382. fsiOPFLD.BilgDeptName = department.Name
  2383. fsiOPFLD.BilgDeptCodg = department.Number
  2384. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2385. fsiOPFLD.BilgDrName = doctor.UserName
  2386. fsiOPFLD.MedChrgitmType = "09"
  2387. memo["hosp_appr_flag"] = "1"
  2388. memo["invoice_no"] = order.MdtrtId
  2389. memo["memo"] = "自费"
  2390. bytesData, _ := json.Marshal(memo)
  2391. fsiOPFLD.Memo = string(bytesData)
  2392. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2393. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2394. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2395. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2396. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2397. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2398. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2399. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2400. fsiOPFLD.BilgDeptName = department.Name
  2401. fsiOPFLD.BilgDeptCodg = department.Number
  2402. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2403. fsiOPFLD.BilgDrName = doctor.UserName
  2404. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2405. case 0:
  2406. break
  2407. case 1:
  2408. fsiOPFLD.MedChrgitmType = "14"
  2409. break
  2410. case 2:
  2411. fsiOPFLD.MedChrgitmType = "05"
  2412. break
  2413. case 3:
  2414. fsiOPFLD.MedChrgitmType = "03"
  2415. break
  2416. case 4:
  2417. fsiOPFLD.MedChrgitmType = "03"
  2418. break
  2419. case 5:
  2420. fsiOPFLD.MedChrgitmType = "08"
  2421. break
  2422. case 6:
  2423. fsiOPFLD.MedChrgitmType = "14"
  2424. break
  2425. case 7:
  2426. fsiOPFLD.MedChrgitmType = "14"
  2427. break
  2428. case 8:
  2429. fsiOPFLD.MedChrgitmType = "03"
  2430. break
  2431. case 9:
  2432. fsiOPFLD.MedChrgitmType = "14"
  2433. break
  2434. case 10:
  2435. fsiOPFLD.MedChrgitmType = "14"
  2436. break
  2437. case 11:
  2438. fsiOPFLD.MedChrgitmType = "06"
  2439. break
  2440. case 12:
  2441. fsiOPFLD.MedChrgitmType = "12"
  2442. break
  2443. case 13:
  2444. fsiOPFLD.MedChrgitmType = "01"
  2445. break
  2446. case 14:
  2447. fsiOPFLD.MedChrgitmType = "04"
  2448. break
  2449. case 15:
  2450. fsiOPFLD.MedChrgitmType = "14"
  2451. break
  2452. }
  2453. memo["hosp_appr_flag"] = "1"
  2454. memo["invoice_no"] = order.MdtrtId
  2455. memo["memo"] = "自费"
  2456. bytesData, _ := json.Marshal(memo)
  2457. fsiOPFLD.Memo = string(bytesData)
  2458. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2459. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  2460. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2461. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2462. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2463. fsiOPFLD.BilgDeptName = department.Name
  2464. fsiOPFLD.BilgDeptCodg = department.Number
  2465. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2466. fsiOPFLD.BilgDrName = doctor.UserName
  2467. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2468. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2469. fsiOPFLD.MedChrgitmType = "08"
  2470. memo["hosp_appr_flag"] = "1"
  2471. memo["invoice_no"] = order.MdtrtId
  2472. memo["memo"] = "自费"
  2473. bytesData, _ := json.Marshal(memo)
  2474. fsiOPFLD.Memo = string(bytesData)
  2475. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2476. }
  2477. }
  2478. }
  2479. for _, items := range order_info_two {
  2480. memo := make(map[string]interface{})
  2481. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2482. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2483. fsiOPFLD.MedType = "14"
  2484. fsiOPFLD.BkkpSn = items.FeedetlSn
  2485. fsiOPFLD.FixmedinsCode = miConfig.Code
  2486. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2487. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2488. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2489. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2490. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2491. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2492. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2493. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2494. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2495. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2496. fsiOPFLD.BilgDeptName = department.Name
  2497. fsiOPFLD.BilgDeptCodg = department.Number
  2498. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2499. fsiOPFLD.BilgDrName = doctor.UserName
  2500. fsiOPFLD.MedChrgitmType = "09"
  2501. memo["hosp_appr_flag"] = "1"
  2502. memo["invoice_no"] = order.MdtrtId
  2503. memo["memo"] = "自费"
  2504. bytesData, _ := json.Marshal(memo)
  2505. fsiOPFLD.Memo = string(bytesData)
  2506. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2507. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2508. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2509. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2510. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2511. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2512. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2513. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2514. fsiOPFLD.BilgDeptName = department.Name
  2515. fsiOPFLD.BilgDeptCodg = department.Number
  2516. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2517. fsiOPFLD.BilgDrName = doctor.UserName
  2518. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2519. case 0:
  2520. break
  2521. case 1:
  2522. fsiOPFLD.MedChrgitmType = "14"
  2523. break
  2524. case 2:
  2525. fsiOPFLD.MedChrgitmType = "05"
  2526. break
  2527. case 3:
  2528. fsiOPFLD.MedChrgitmType = "03"
  2529. break
  2530. case 4:
  2531. fsiOPFLD.MedChrgitmType = "03"
  2532. break
  2533. case 5:
  2534. fsiOPFLD.MedChrgitmType = "08"
  2535. break
  2536. case 6:
  2537. fsiOPFLD.MedChrgitmType = "14"
  2538. break
  2539. case 7:
  2540. fsiOPFLD.MedChrgitmType = "14"
  2541. break
  2542. case 8:
  2543. fsiOPFLD.MedChrgitmType = "03"
  2544. break
  2545. case 9:
  2546. fsiOPFLD.MedChrgitmType = "14"
  2547. break
  2548. case 10:
  2549. fsiOPFLD.MedChrgitmType = "14"
  2550. break
  2551. case 11:
  2552. fsiOPFLD.MedChrgitmType = "06"
  2553. break
  2554. case 12:
  2555. fsiOPFLD.MedChrgitmType = "12"
  2556. break
  2557. case 13:
  2558. fsiOPFLD.MedChrgitmType = "01"
  2559. break
  2560. case 14:
  2561. fsiOPFLD.MedChrgitmType = "04"
  2562. break
  2563. case 15:
  2564. fsiOPFLD.MedChrgitmType = "14"
  2565. break
  2566. }
  2567. memo["hosp_appr_flag"] = "1"
  2568. memo["invoice_no"] = order.MdtrtId
  2569. memo["memo"] = "自费"
  2570. bytesData, _ := json.Marshal(memo)
  2571. fsiOPFLD.Memo = string(bytesData)
  2572. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2573. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  2574. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2575. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2576. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2577. fsiOPFLD.BilgDeptName = department.Name
  2578. fsiOPFLD.BilgDeptCodg = department.Number
  2579. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2580. fsiOPFLD.BilgDrName = doctor.UserName
  2581. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2582. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2583. fsiOPFLD.MedChrgitmType = "08"
  2584. memo["hosp_appr_flag"] = "1"
  2585. memo["invoice_no"] = order.MdtrtId
  2586. memo["memo"] = "自费"
  2587. bytesData, _ := json.Marshal(memo)
  2588. fsiOPFLD.Memo = string(bytesData)
  2589. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2590. }
  2591. }
  2592. }
  2593. fmt.Println(fsiOPFLDs)
  2594. struct4201A.Fopfd = fsiOPFLDs
  2595. fmt.Println(struct4201A.Fopfd)
  2596. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  2597. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  2598. var res2 ResultSix
  2599. var respJSON2 map[string]interface{}
  2600. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2603. return
  2604. }
  2605. userJSONBytes2, _ := json.Marshal(respJSON2)
  2606. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2607. utils.ErrorLog("解析失败:%v", err)
  2608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2609. return
  2610. }
  2611. if res2.Infcode != 0 {
  2612. c.ServeSuccessJSON(map[string]interface{}{
  2613. "failed_code": -10,
  2614. "msg": res2.ErrMsg,
  2615. })
  2616. return
  2617. } else {
  2618. order.IsUploadOrderInfo = 1
  2619. service.UpdateOrder(order)
  2620. c.ServeSuccessJSON(map[string]interface{}{
  2621. "msg": "上传成功",
  2622. })
  2623. }
  2624. }
  2625. func (c *HisApiController) Get2505() {
  2626. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  2627. service.Gdyb2505("44120000000010585742", "高慧裕", miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2022-12-23 09:00:00", "2023-12-31 23:00:00")
  2628. }
  2629. func (c *HisApiController) Get4201A() {
  2630. order_id, _ := c.GetInt64("order_id")
  2631. admin_user_id, _ := c.GetInt64("admin_user_id")
  2632. order, _ := service.GetHisOrderByIDTwo(order_id)
  2633. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2634. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  2635. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  2636. //order_info = append(order_info, order_info_two...)
  2637. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2638. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2639. department, _ := service.GetDepartMentDetail(his.Departments)
  2640. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  2641. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  2642. if order.ID == 0 {
  2643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2644. return
  2645. }
  2646. var struct4201A models.Struct4201A
  2647. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  2648. for _, items := range order_info {
  2649. memo := make(map[string]interface{})
  2650. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2651. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2652. fsiOPFLD.MedType = "14"
  2653. fsiOPFLD.BkkpSn = items.FeedetlSn
  2654. fsiOPFLD.FixmedinsCode = miConfig.Code
  2655. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2656. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2657. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2658. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2659. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2660. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2661. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2662. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2663. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2664. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2665. fsiOPFLD.BilgDeptName = department.Name
  2666. fsiOPFLD.BilgDeptCodg = department.Number
  2667. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2668. fsiOPFLD.BilgDrName = doctor.UserName
  2669. fsiOPFLD.MedChrgitmType = "09"
  2670. memo["hosp_appr_flag"] = "1"
  2671. memo["invoice_no"] = order.MdtrtId
  2672. memo["memo"] = "自费"
  2673. bytesData, _ := json.Marshal(memo)
  2674. fsiOPFLD.Memo = string(bytesData)
  2675. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2676. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2677. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2678. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2679. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2680. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2681. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2682. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2683. fsiOPFLD.BilgDeptName = department.Name
  2684. fsiOPFLD.BilgDeptCodg = department.Number
  2685. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2686. fsiOPFLD.BilgDrName = doctor.UserName
  2687. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2688. case 0:
  2689. break
  2690. case 1:
  2691. fsiOPFLD.MedChrgitmType = "14"
  2692. break
  2693. case 2:
  2694. fsiOPFLD.MedChrgitmType = "05"
  2695. break
  2696. case 3:
  2697. fsiOPFLD.MedChrgitmType = "03"
  2698. break
  2699. case 4:
  2700. fsiOPFLD.MedChrgitmType = "03"
  2701. break
  2702. case 5:
  2703. fsiOPFLD.MedChrgitmType = "08"
  2704. break
  2705. case 6:
  2706. fsiOPFLD.MedChrgitmType = "14"
  2707. break
  2708. case 7:
  2709. fsiOPFLD.MedChrgitmType = "14"
  2710. break
  2711. case 8:
  2712. fsiOPFLD.MedChrgitmType = "03"
  2713. break
  2714. case 9:
  2715. fsiOPFLD.MedChrgitmType = "14"
  2716. break
  2717. case 10:
  2718. fsiOPFLD.MedChrgitmType = "14"
  2719. break
  2720. case 11:
  2721. fsiOPFLD.MedChrgitmType = "06"
  2722. break
  2723. case 12:
  2724. fsiOPFLD.MedChrgitmType = "12"
  2725. break
  2726. case 13:
  2727. fsiOPFLD.MedChrgitmType = "01"
  2728. break
  2729. case 14:
  2730. fsiOPFLD.MedChrgitmType = "04"
  2731. break
  2732. case 15:
  2733. fsiOPFLD.MedChrgitmType = "14"
  2734. break
  2735. }
  2736. memo["hosp_appr_flag"] = "1"
  2737. memo["invoice_no"] = order.MdtrtId
  2738. memo["memo"] = "自费"
  2739. bytesData, _ := json.Marshal(memo)
  2740. fsiOPFLD.Memo = string(bytesData)
  2741. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2742. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  2743. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2744. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2745. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2746. fsiOPFLD.BilgDeptName = department.Name
  2747. fsiOPFLD.BilgDeptCodg = department.Number
  2748. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2749. fsiOPFLD.BilgDrName = doctor.UserName
  2750. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2751. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2752. fsiOPFLD.MedChrgitmType = "08"
  2753. memo["hosp_appr_flag"] = "1"
  2754. memo["invoice_no"] = order.MdtrtId
  2755. memo["memo"] = "自费"
  2756. bytesData, _ := json.Marshal(memo)
  2757. fsiOPFLD.Memo = string(bytesData)
  2758. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2759. }
  2760. }
  2761. }
  2762. for _, items := range order_info_two {
  2763. memo := make(map[string]interface{})
  2764. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2765. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2766. fsiOPFLD.MedType = "14"
  2767. fsiOPFLD.BkkpSn = items.FeedetlSn
  2768. fsiOPFLD.FixmedinsCode = miConfig.Code
  2769. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2770. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2771. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2772. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2773. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2774. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2775. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2776. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2777. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2778. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2779. fsiOPFLD.BilgDeptName = department.Name
  2780. fsiOPFLD.BilgDeptCodg = department.Number
  2781. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2782. fsiOPFLD.BilgDrName = doctor.UserName
  2783. fsiOPFLD.MedChrgitmType = "09"
  2784. memo["hosp_appr_flag"] = "1"
  2785. memo["invoice_no"] = order.MdtrtId
  2786. memo["memo"] = "自费"
  2787. bytesData, _ := json.Marshal(memo)
  2788. fsiOPFLD.Memo = string(bytesData)
  2789. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2790. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2791. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2792. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2793. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2794. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2795. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2796. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2797. fsiOPFLD.BilgDeptName = department.Name
  2798. fsiOPFLD.BilgDeptCodg = department.Number
  2799. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2800. fsiOPFLD.BilgDrName = doctor.UserName
  2801. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2802. case 0:
  2803. break
  2804. case 1:
  2805. fsiOPFLD.MedChrgitmType = "14"
  2806. break
  2807. case 2:
  2808. fsiOPFLD.MedChrgitmType = "05"
  2809. break
  2810. case 3:
  2811. fsiOPFLD.MedChrgitmType = "03"
  2812. break
  2813. case 4:
  2814. fsiOPFLD.MedChrgitmType = "03"
  2815. break
  2816. case 5:
  2817. fsiOPFLD.MedChrgitmType = "08"
  2818. break
  2819. case 6:
  2820. fsiOPFLD.MedChrgitmType = "14"
  2821. break
  2822. case 7:
  2823. fsiOPFLD.MedChrgitmType = "14"
  2824. break
  2825. case 8:
  2826. fsiOPFLD.MedChrgitmType = "03"
  2827. break
  2828. case 9:
  2829. fsiOPFLD.MedChrgitmType = "14"
  2830. break
  2831. case 10:
  2832. fsiOPFLD.MedChrgitmType = "14"
  2833. break
  2834. case 11:
  2835. fsiOPFLD.MedChrgitmType = "06"
  2836. break
  2837. case 12:
  2838. fsiOPFLD.MedChrgitmType = "12"
  2839. break
  2840. case 13:
  2841. fsiOPFLD.MedChrgitmType = "01"
  2842. break
  2843. case 14:
  2844. fsiOPFLD.MedChrgitmType = "04"
  2845. break
  2846. case 15:
  2847. fsiOPFLD.MedChrgitmType = "14"
  2848. break
  2849. }
  2850. memo["hosp_appr_flag"] = "1"
  2851. memo["invoice_no"] = order.MdtrtId
  2852. memo["memo"] = "自费"
  2853. bytesData, _ := json.Marshal(memo)
  2854. fsiOPFLD.Memo = string(bytesData)
  2855. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2856. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  2857. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2858. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2859. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2860. fsiOPFLD.BilgDeptName = department.Name
  2861. fsiOPFLD.BilgDeptCodg = department.Number
  2862. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2863. fsiOPFLD.BilgDrName = doctor.UserName
  2864. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2865. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2866. fsiOPFLD.MedChrgitmType = "08"
  2867. memo["hosp_appr_flag"] = "1"
  2868. memo["invoice_no"] = order.MdtrtId
  2869. memo["memo"] = "自费"
  2870. bytesData, _ := json.Marshal(memo)
  2871. fsiOPFLD.Memo = string(bytesData)
  2872. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2873. }
  2874. }
  2875. }
  2876. fmt.Println(fsiOPFLDs)
  2877. struct4201A.Fopfd = fsiOPFLDs
  2878. fmt.Println(struct4201A.Fopfd)
  2879. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  2880. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  2881. var res2 ResultSix
  2882. var respJSON2 map[string]interface{}
  2883. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2886. return
  2887. }
  2888. userJSONBytes2, _ := json.Marshal(respJSON2)
  2889. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2890. utils.ErrorLog("解析失败:%v", err)
  2891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2892. return
  2893. }
  2894. if res2.Infcode != 0 {
  2895. c.ServeSuccessJSON(map[string]interface{}{
  2896. "failed_code": -10,
  2897. "msg": res2.ErrMsg,
  2898. })
  2899. return
  2900. } else {
  2901. order.IsUploadOrderInfo = 1
  2902. service.UpdateOrder(order)
  2903. c.ServeSuccessJSON(map[string]interface{}{
  2904. "msg": "上传成功",
  2905. })
  2906. }
  2907. }
  2908. func (c *HisApiController) Get4202() {
  2909. order_id, _ := c.GetInt64("order_id")
  2910. admin_user_id, _ := c.GetInt64("admin_user_id")
  2911. order, _ := service.GetHisOrderByIDTwo(order_id)
  2912. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2913. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2914. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2915. if order.ID == 0 {
  2916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2917. return
  2918. }
  2919. var struct4202 models.Struct4202
  2920. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  2921. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  2922. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  2923. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  2924. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  2925. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  2926. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  2927. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  2928. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  2929. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2930. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2931. var config []*models.HisXtDiagnoseConfig
  2932. for _, item := range diagnosis_ids {
  2933. id, _ := strconv.ParseInt(item, 10, 64)
  2934. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2935. config = append(config, &diagnosisConfig)
  2936. }
  2937. var tempDiaginfos []models.OwnPayPatnDiagListD
  2938. for index, item := range config {
  2939. if index == 0 {
  2940. var tempDiaginfo models.OwnPayPatnDiagListD
  2941. tempDiaginfo.InoutDiagType = "1"
  2942. tempDiaginfo.DiagCode = item.CountryCode
  2943. tempDiaginfo.DiagName = item.CountryContentName
  2944. tempDiaginfo.DiagType = "1"
  2945. tempDiaginfo.DiagSrtNo = "1"
  2946. tempDiaginfo.MaindiagFlag = "1"
  2947. tempDiaginfo.ValiFlag = "1"
  2948. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2949. } else {
  2950. var tempDiaginfo models.OwnPayPatnDiagListD
  2951. tempDiaginfo.DiagCode = item.CountryCode
  2952. tempDiaginfo.DiagName = item.CountryContentName
  2953. tempDiaginfo.DiagType = "2"
  2954. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2955. tempDiaginfo.MaindiagFlag = "0"
  2956. tempDiaginfo.ValiFlag = "1"
  2957. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2958. }
  2959. }
  2960. struct4202.ODiagListD = tempDiaginfos
  2961. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  2962. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  2963. var res2 ResultSix
  2964. var respJSON2 map[string]interface{}
  2965. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2968. return
  2969. }
  2970. userJSONBytes2, _ := json.Marshal(respJSON2)
  2971. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2972. utils.ErrorLog("解析失败:%v", err)
  2973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2974. return
  2975. }
  2976. if res2.Infcode != 0 {
  2977. c.ServeSuccessJSON(map[string]interface{}{
  2978. "failed_code": -10,
  2979. "msg": res2.ErrMsg,
  2980. })
  2981. return
  2982. } else {
  2983. order.IsUploadDiagnose = 1
  2984. service.UpdateOrder(order)
  2985. c.ServeSuccessJSON(map[string]interface{}{
  2986. "msg": "上传成功",
  2987. })
  2988. }
  2989. }
  2990. func (c *HisApiController) Get4203() {
  2991. admin_user_id, _ := c.GetInt64("admin_user_id")
  2992. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2993. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2994. order_id, _ := c.GetInt64("order_id")
  2995. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  2996. number := ""
  2997. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2998. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2999. if his.ID == 0 {
  3000. number = hospital.Number
  3001. } else {
  3002. number = his.Number
  3003. }
  3004. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  3005. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  3006. var res2 ResultSix
  3007. var respJSON2 map[string]interface{}
  3008. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3011. return
  3012. }
  3013. userJSONBytes2, _ := json.Marshal(respJSON2)
  3014. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3015. utils.ErrorLog("解析失败:%v", err)
  3016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3017. return
  3018. }
  3019. if res2.Infcode != 0 {
  3020. c.ServeSuccessJSON(map[string]interface{}{
  3021. "failed_code": -10,
  3022. "msg": res2.ErrMsg,
  3023. })
  3024. return
  3025. } else {
  3026. order.IsUploadSuccess = 1
  3027. service.UpdateOrderTwo(order)
  3028. c.ServeSuccessJSON(map[string]interface{}{
  3029. "msg": "上传成功",
  3030. })
  3031. }
  3032. }
  3033. func (c *HisApiController) Get4205() {
  3034. order_id, _ := c.GetInt64("order_id")
  3035. admin_user_id, _ := c.GetInt64("admin_user_id")
  3036. fapiao_code := c.GetString("fapiao_code")
  3037. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3038. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3039. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3040. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3041. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  3042. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  3043. //order_info = append(order_info, order_info_two...)
  3044. department, _ := service.GetDepartMentDetail(his.Departments)
  3045. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3046. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3047. if order.ID == 0 {
  3048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3049. return
  3050. }
  3051. var struct4201A models.Struct4201A
  3052. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3053. for _, items := range order_info {
  3054. memo := make(map[string]interface{})
  3055. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3056. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3057. fsiOPFLD.MedType = pre.MedType
  3058. fsiOPFLD.FixmedinsCode = miConfig.Code
  3059. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3060. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3061. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3062. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3063. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3064. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3065. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3066. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  3067. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3068. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3069. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3070. fsiOPFLD.BilgDeptName = department.Name
  3071. fsiOPFLD.BilgDeptCodg = department.Number
  3072. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3073. fsiOPFLD.BilgDrName = doctor.UserName
  3074. fsiOPFLD.MedChrgitmType = "09"
  3075. memo["hosp_appr_flag"] = "1"
  3076. memo["invoice_no"] = fapiao_code
  3077. memo["memo"] = "自费"
  3078. bytesData, _ := json.Marshal(memo)
  3079. fsiOPFLD.Memo = string(bytesData)
  3080. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3081. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3082. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  3083. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3084. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3085. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3086. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3087. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3088. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3089. fsiOPFLD.BilgDeptName = department.Name
  3090. fsiOPFLD.BilgDeptCodg = department.Number
  3091. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3092. fsiOPFLD.BilgDrName = doctor.UserName
  3093. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3094. case 0:
  3095. break
  3096. case 1:
  3097. fsiOPFLD.MedChrgitmType = "14"
  3098. break
  3099. case 2:
  3100. fsiOPFLD.MedChrgitmType = "05"
  3101. break
  3102. case 3:
  3103. fsiOPFLD.MedChrgitmType = "03"
  3104. break
  3105. case 4:
  3106. fsiOPFLD.MedChrgitmType = "03"
  3107. break
  3108. case 5:
  3109. fsiOPFLD.MedChrgitmType = "08"
  3110. break
  3111. case 6:
  3112. fsiOPFLD.MedChrgitmType = "14"
  3113. break
  3114. case 7:
  3115. fsiOPFLD.MedChrgitmType = "14"
  3116. break
  3117. case 8:
  3118. fsiOPFLD.MedChrgitmType = "03"
  3119. break
  3120. case 9:
  3121. fsiOPFLD.MedChrgitmType = "14"
  3122. break
  3123. case 10:
  3124. fsiOPFLD.MedChrgitmType = "14"
  3125. break
  3126. case 11:
  3127. fsiOPFLD.MedChrgitmType = "06"
  3128. break
  3129. case 12:
  3130. fsiOPFLD.MedChrgitmType = "12"
  3131. break
  3132. case 13:
  3133. fsiOPFLD.MedChrgitmType = "01"
  3134. break
  3135. case 14:
  3136. fsiOPFLD.MedChrgitmType = "04"
  3137. break
  3138. case 15:
  3139. fsiOPFLD.MedChrgitmType = "14"
  3140. break
  3141. }
  3142. memo["hosp_appr_flag"] = "1"
  3143. memo["invoice_no"] = fapiao_code
  3144. memo["memo"] = "自费"
  3145. bytesData, _ := json.Marshal(memo)
  3146. fsiOPFLD.Memo = string(bytesData)
  3147. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3148. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3149. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3150. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3151. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3152. fsiOPFLD.BilgDeptName = department.Name
  3153. fsiOPFLD.BilgDeptCodg = department.Number
  3154. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3155. fsiOPFLD.BilgDrName = doctor.UserName
  3156. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3157. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3158. fsiOPFLD.MedChrgitmType = "08"
  3159. memo["hosp_appr_flag"] = "1"
  3160. memo["invoice_no"] = fapiao_code
  3161. memo["memo"] = "自费"
  3162. bytesData, _ := json.Marshal(memo)
  3163. fsiOPFLD.Memo = string(bytesData)
  3164. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3165. }
  3166. }
  3167. }
  3168. for _, items := range order_info_two {
  3169. memo := make(map[string]interface{})
  3170. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3171. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3172. fsiOPFLD.MedType = pre.MedType
  3173. fsiOPFLD.BkkpSn = items.FeedetlSn
  3174. fsiOPFLD.FixmedinsCode = miConfig.Code
  3175. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3176. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3177. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3178. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3179. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3180. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3181. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3182. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3183. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3184. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3185. fsiOPFLD.BilgDeptName = department.Name
  3186. fsiOPFLD.BilgDeptCodg = department.Number
  3187. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3188. fsiOPFLD.BilgDrName = doctor.UserName
  3189. fsiOPFLD.MedChrgitmType = "09"
  3190. memo["hosp_appr_flag"] = "1"
  3191. memo["invoice_no"] = fapiao_code
  3192. memo["memo"] = "自费"
  3193. bytesData, _ := json.Marshal(memo)
  3194. fsiOPFLD.Memo = string(bytesData)
  3195. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3196. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3197. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  3198. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3199. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3200. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3201. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3202. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3203. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3204. fsiOPFLD.BilgDeptName = department.Name
  3205. fsiOPFLD.BilgDeptCodg = department.Number
  3206. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3207. fsiOPFLD.BilgDrName = doctor.UserName
  3208. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3209. case 0:
  3210. break
  3211. case 1:
  3212. fsiOPFLD.MedChrgitmType = "14"
  3213. break
  3214. case 2:
  3215. fsiOPFLD.MedChrgitmType = "05"
  3216. break
  3217. case 3:
  3218. fsiOPFLD.MedChrgitmType = "03"
  3219. break
  3220. case 4:
  3221. fsiOPFLD.MedChrgitmType = "03"
  3222. break
  3223. case 5:
  3224. fsiOPFLD.MedChrgitmType = "08"
  3225. break
  3226. case 6:
  3227. fsiOPFLD.MedChrgitmType = "14"
  3228. break
  3229. case 7:
  3230. fsiOPFLD.MedChrgitmType = "14"
  3231. break
  3232. case 8:
  3233. fsiOPFLD.MedChrgitmType = "03"
  3234. break
  3235. case 9:
  3236. fsiOPFLD.MedChrgitmType = "14"
  3237. break
  3238. case 10:
  3239. fsiOPFLD.MedChrgitmType = "14"
  3240. break
  3241. case 11:
  3242. fsiOPFLD.MedChrgitmType = "06"
  3243. break
  3244. case 12:
  3245. fsiOPFLD.MedChrgitmType = "12"
  3246. break
  3247. case 13:
  3248. fsiOPFLD.MedChrgitmType = "01"
  3249. break
  3250. case 14:
  3251. fsiOPFLD.MedChrgitmType = "04"
  3252. break
  3253. case 15:
  3254. fsiOPFLD.MedChrgitmType = "14"
  3255. break
  3256. }
  3257. memo["hosp_appr_flag"] = "1"
  3258. memo["invoice_no"] = fapiao_code
  3259. memo["memo"] = "自费"
  3260. bytesData, _ := json.Marshal(memo)
  3261. fsiOPFLD.Memo = string(bytesData)
  3262. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3263. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3264. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3265. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3266. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3267. fsiOPFLD.BilgDeptName = department.Name
  3268. fsiOPFLD.BilgDeptCodg = department.Number
  3269. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3270. fsiOPFLD.BilgDrName = doctor.UserName
  3271. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3272. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3273. fsiOPFLD.MedChrgitmType = "08"
  3274. memo["hosp_appr_flag"] = "1"
  3275. memo["invoice_no"] = fapiao_code
  3276. memo["memo"] = "自费"
  3277. bytesData, _ := json.Marshal(memo)
  3278. fsiOPFLD.Memo = string(bytesData)
  3279. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3280. }
  3281. }
  3282. }
  3283. fmt.Println(fsiOPFLDs)
  3284. struct4201A.Fopfd = fsiOPFLDs
  3285. fmt.Println(struct4201A.Fopfd)
  3286. var struct4202 models.Struct4202
  3287. timeLayout := "2006-01-02 15:04:05"
  3288. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  3289. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  3290. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  3291. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  3292. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  3293. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  3294. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  3295. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  3296. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  3297. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  3298. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3299. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3300. var config []*models.HisXtDiagnoseConfig
  3301. for _, item := range diagnosis_ids {
  3302. id, _ := strconv.ParseInt(item, 10, 64)
  3303. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3304. config = append(config, &diagnosisConfig)
  3305. }
  3306. var tempDiaginfos []models.OwnPayPatnDiagListD
  3307. for index, item := range config {
  3308. if index == 0 {
  3309. var tempDiaginfo models.OwnPayPatnDiagListD
  3310. tempDiaginfo.InoutDiagType = "1"
  3311. tempDiaginfo.DiagCode = item.CountryCode
  3312. tempDiaginfo.DiagName = item.CountryContentName
  3313. tempDiaginfo.DiagType = "1"
  3314. tempDiaginfo.DiagSrtNo = "1"
  3315. tempDiaginfo.MaindiagFlag = "1"
  3316. tempDiaginfo.ValiFlag = "1"
  3317. tempDiaginfo.DiagDrName = doctor.UserName
  3318. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  3319. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  3320. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3321. } else {
  3322. var tempDiaginfo models.OwnPayPatnDiagListD
  3323. tempDiaginfo.DiagCode = item.CountryCode
  3324. tempDiaginfo.DiagName = item.CountryContentName
  3325. tempDiaginfo.DiagType = "2"
  3326. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3327. tempDiaginfo.MaindiagFlag = "0"
  3328. tempDiaginfo.ValiFlag = "1"
  3329. tempDiaginfo.DiagDrName = doctor.UserName
  3330. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  3331. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  3332. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3333. }
  3334. }
  3335. struct4202.ODiagListD = tempDiaginfos
  3336. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  3337. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  3338. var res2 ResultSix
  3339. var respJSON2 map[string]interface{}
  3340. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3343. return
  3344. }
  3345. userJSONBytes2, _ := json.Marshal(respJSON2)
  3346. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3347. utils.ErrorLog("解析失败:%v", err)
  3348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3349. return
  3350. }
  3351. if res2.Infcode != 0 {
  3352. c.ServeSuccessJSON(map[string]interface{}{
  3353. "failed_code": -10,
  3354. "msg": res2.ErrMsg,
  3355. })
  3356. return
  3357. } else {
  3358. order.IsUploadDiagnose = 1
  3359. order.IsUploadOrderInfo = 1
  3360. service.UpdateOrderTwo(order)
  3361. c.ServeSuccessJSON(map[string]interface{}{
  3362. "msg": "上传成功",
  3363. })
  3364. }
  3365. }
  3366. func (c *HisApiController) Get4207() {
  3367. admin_user_id, _ := c.GetInt64("admin_user_id")
  3368. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3369. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3370. order_id, _ := c.GetInt64("order_id")
  3371. order, _ := service.GetHisOrderByIDTwo(order_id)
  3372. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3373. var struct4207 models.Struct4207
  3374. struct4207.PageNum = "1"
  3375. struct4207.PageSize = "1000"
  3376. struct4207.FixmedinsCode = miConfig.Code
  3377. struct4207.FixmedinsMdtrtID = order.Number
  3378. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  3379. saveLog(result, requestLog, "4207", "查询")
  3380. var res2 ResultSix
  3381. var respJSON2 map[string]interface{}
  3382. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3385. return
  3386. }
  3387. userJSONBytes2, _ := json.Marshal(respJSON2)
  3388. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3389. utils.ErrorLog("解析失败:%v", err)
  3390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3391. return
  3392. }
  3393. if res2.Infcode != 0 {
  3394. c.ServeSuccessJSON(map[string]interface{}{
  3395. "failed_code": -10,
  3396. "msg": res2.ErrMsg,
  3397. })
  3398. return
  3399. } else {
  3400. c.ServeSuccessJSON(map[string]interface{}{
  3401. "msg": "查询成功",
  3402. })
  3403. }
  3404. }
  3405. func (c *HisApiController) Get4208() {
  3406. admin_user_id, _ := c.GetInt64("admin_user_id")
  3407. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3408. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3409. order_id, _ := c.GetInt64("order_id")
  3410. order, _ := service.GetHisOrderByIDTwo(order_id)
  3411. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3412. var struct4208 models.Struct4208
  3413. struct4208.PageNum = "1"
  3414. struct4208.PageSize = "1000"
  3415. struct4208.PsnCertType = "01"
  3416. struct4208.Certno = his.Certno
  3417. struct4208.MedType = order.MedType
  3418. struct4208.PsnName = his.Name
  3419. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  3420. saveLog(result, requestLog, "4208", "查询")
  3421. var res2 ResultSix
  3422. var respJSON2 map[string]interface{}
  3423. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3426. return
  3427. }
  3428. userJSONBytes2, _ := json.Marshal(respJSON2)
  3429. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3430. utils.ErrorLog("解析失败:%v", err)
  3431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3432. return
  3433. }
  3434. if res2.Infcode != 0 {
  3435. c.ServeSuccessJSON(map[string]interface{}{
  3436. "failed_code": -10,
  3437. "msg": res2.ErrMsg,
  3438. })
  3439. return
  3440. } else {
  3441. c.ServeSuccessJSON(map[string]interface{}{
  3442. "msg": "查询成功",
  3443. })
  3444. }
  3445. }
  3446. func (c *HisApiController) Get4209() {
  3447. admin_user_id, _ := c.GetInt64("admin_user_id")
  3448. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3449. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3450. order_id, _ := c.GetInt64("order_id")
  3451. order, _ := service.GetHisOrderByIDTwo(order_id)
  3452. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3453. var struct4209 models.Struct4209
  3454. struct4209.FixmedinsMdtrtID = order.Number
  3455. struct4209.FixmedinsCode = miConfig.Code
  3456. struct4209.PageSize = "1000"
  3457. struct4209.PageNum = "1"
  3458. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  3459. saveLog(result, requestLog, "4209", "查询")
  3460. var res2 ResultSix
  3461. var respJSON2 map[string]interface{}
  3462. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3463. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3465. return
  3466. }
  3467. userJSONBytes2, _ := json.Marshal(respJSON2)
  3468. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3469. utils.ErrorLog("解析失败:%v", err)
  3470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3471. return
  3472. }
  3473. if res2.Infcode != 0 {
  3474. c.ServeSuccessJSON(map[string]interface{}{
  3475. "failed_code": -10,
  3476. "msg": res2.ErrMsg,
  3477. })
  3478. return
  3479. } else {
  3480. c.ServeSuccessJSON(map[string]interface{}{
  3481. "msg": "查询成功",
  3482. })
  3483. }
  3484. }
  3485. type Result3101 struct {
  3486. Infcode string `json:"infcode"`
  3487. InfRefmsgid string `json:"inf_refmsgid"`
  3488. RefmsgTime string `json:"refmsg_time"`
  3489. RespondTime string `json:"respond_time"`
  3490. Enctype string `json:"enctype"`
  3491. Signtype string `json:"signtype"`
  3492. ErrMsg string `json:"err_msg"`
  3493. Output struct {
  3494. Result []struct {
  3495. JudgeResultDetailDtos []struct {
  3496. VolaItemType string `json:"vola_item_type"`
  3497. MdtrtID string `json:"mdtrt_id"`
  3498. JrdID string `json:"jrd_id"`
  3499. PatnID string `json:"patn_id"`
  3500. RxID string `json:"rx_id"`
  3501. VolaAmt interface{} `json:"vola_amt"`
  3502. } `json:"judge_result_detail_dtos"`
  3503. RuleID string `json:"rule_id"`
  3504. VolaEvid string `json:"vola_evid"`
  3505. MdtrtID string `json:"mdtrt_id"`
  3506. RuleName string `json:"rule_name"`
  3507. VolaAmtStas string `json:"vola_amt_stas"`
  3508. JrID string `json:"jr_id"`
  3509. PatnID string `json:"patn_id"`
  3510. SevDeg string `json:"sev_deg"`
  3511. VolaAmt float64 `json:"vola_amt"`
  3512. VolaBhvrType string `json:"vola_bhvr_type"`
  3513. VolaCont string `json:"vola_cont"`
  3514. } `json:"result"`
  3515. } `json:"output"`
  3516. }
  3517. type Resultgd3101 struct {
  3518. Infcode int64 `json:"infcode"`
  3519. InfRefmsgid string `json:"inf_refmsgid"`
  3520. RefmsgTime string `json:"refmsg_time"`
  3521. RespondTime string `json:"respond_time"`
  3522. Enctype string `json:"enctype"`
  3523. Signtype string `json:"signtype"`
  3524. ErrMsg string `json:"err_msg"`
  3525. Output struct {
  3526. Result []struct {
  3527. JudgeResultDetailDtos []struct {
  3528. VolaItemType string `json:"vola_item_type"`
  3529. MdtrtID string `json:"mdtrt_id"`
  3530. JrdID string `json:"jrd_id"`
  3531. PatnID string `json:"patn_id"`
  3532. RxID string `json:"rx_id"`
  3533. VolaAmt interface{} `json:"vola_amt"`
  3534. } `json:"judge_result_detail_dtos"`
  3535. RuleID string `json:"rule_id"`
  3536. VolaEvid string `json:"vola_evid"`
  3537. MdtrtID string `json:"mdtrt_id"`
  3538. RuleName string `json:"rule_name"`
  3539. VolaAmtStas string `json:"vola_amt_stas"`
  3540. JrID string `json:"jr_id"`
  3541. PatnID string `json:"patn_id"`
  3542. SevDeg string `json:"sev_deg"`
  3543. VolaAmt float64 `json:"vola_amt"`
  3544. VolaBhvrType string `json:"vola_bhvr_type"`
  3545. VolaCont string `json:"vola_cont"`
  3546. } `json:"result"`
  3547. } `json:"output"`
  3548. }
  3549. func (c *HisApiController) ReadEleToken() {
  3550. admin_user_id, _ := c.GetInt64("admin_user_id")
  3551. his_patient_id, _ := c.GetInt64("his_patient_id")
  3552. adminUser := c.GetAdminUserInfo()
  3553. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3554. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3555. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3556. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3557. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  3558. if len(tokens) > 0 {
  3559. c.ServeSuccessJSON(map[string]interface{}{
  3560. "msg": "读取成功",
  3561. })
  3562. } else {
  3563. c.ServeSuccessJSON(map[string]interface{}{
  3564. "failed_code": -10,
  3565. "msg": "读取失败",
  3566. })
  3567. }
  3568. } else if miConfig.MdtrtareaAdmvs == "150499" {
  3569. var api string
  3570. 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 +
  3571. "&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"
  3572. resp, requestErr := http.Get(api)
  3573. if requestErr != nil {
  3574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3575. }
  3576. body, ioErr := ioutil.ReadAll(resp.Body)
  3577. if ioErr != nil {
  3578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3580. }
  3581. var respJSON map[string]interface{}
  3582. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3585. return
  3586. }
  3587. var status string
  3588. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3589. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3590. var token string
  3591. var res ResultTwo //1101结果
  3592. var res10265 ResultTwo10265 //1101结果
  3593. if status == "0" { //读卡成功
  3594. var card_info string //卡信息
  3595. var busi_card_info string
  3596. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3597. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3598. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3599. fmt.Println(card_info)
  3600. fmt.Println(busi_card_info)
  3601. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3602. result, _ := json.Marshal(respJSON)
  3603. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3604. utils.ErrorLog("解析失败:%v", err)
  3605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3606. return
  3607. }
  3608. res.ErrMsg = res10265.ErrMsg
  3609. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3610. res.Infcode = infocode
  3611. res.Output = res10265.Output
  3612. res.InfRefmsgid = res10265.InfRefmsgid
  3613. if res.Infcode == 0 {
  3614. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3615. if err == gorm.ErrRecordNotFound {
  3616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3617. return
  3618. } else if err != nil {
  3619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3620. return
  3621. } else {
  3622. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3623. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3624. infoStr := string(Iinfos)
  3625. idetinfoStr := string(Idetinfos)
  3626. psn := &models.HisPsn{
  3627. PsnNo: res.Output.Baseinfo.PsnNo,
  3628. Age: res.Output.Baseinfo.Age,
  3629. PatientId: patient.ID,
  3630. Certno: res.Output.Baseinfo.Certno,
  3631. Brdy: res.Output.Baseinfo.Brdy,
  3632. Gend: res.Output.Baseinfo.Gend,
  3633. Naty: res.Output.Baseinfo.Naty,
  3634. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3635. PsnName: res.Output.Baseinfo.PsnName,
  3636. Idetinfo: idetinfoStr,
  3637. Insuinfo: infoStr,
  3638. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3639. CardInfo: card_info,
  3640. VerifyNumber: token,
  3641. IdCardType: 4,
  3642. }
  3643. var rf []*ResultFive
  3644. json.Unmarshal([]byte(infoStr), &rf)
  3645. var insutypes []*ResultFive
  3646. var insutype string
  3647. var is390 int = 0
  3648. var is310 int = 0
  3649. for _, item := range rf {
  3650. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3651. insutypes = append(insutypes, item)
  3652. }
  3653. }
  3654. if len(insutypes) == 1 {
  3655. insutype = insutypes[0].Insutype
  3656. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3657. } else {
  3658. for _, i := range insutypes {
  3659. if i.Insutype == "390" {
  3660. is390 = 1
  3661. }
  3662. if i.Insutype == "310" {
  3663. is310 = 1
  3664. }
  3665. }
  3666. }
  3667. if is390 == 1 {
  3668. insutype = "390"
  3669. }
  3670. if is310 == 1 {
  3671. insutype = "310"
  3672. }
  3673. if len(insutypes) == 0 {
  3674. insutype = "310"
  3675. }
  3676. service.CreateHisPsn(psn)
  3677. c.ServeSuccessJSON(map[string]interface{}{
  3678. "patient": patient,
  3679. "number": token,
  3680. "insutype": insutype,
  3681. })
  3682. }
  3683. } else {
  3684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3685. return
  3686. }
  3687. } else { //读卡失败
  3688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3689. return
  3690. }
  3691. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3692. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  3693. if len(errMsg) == 0 {
  3694. type ELeData struct {
  3695. Data struct {
  3696. IdNo string `json:"idNo"`
  3697. IdType string `json:"idType"`
  3698. UserName string `json:"userName"`
  3699. EcToken string `json:"ecToken"`
  3700. InsuOrg string `json:"insuOrg"`
  3701. Gender string `json:"gender"`
  3702. Birthday string `json:"birthday"`
  3703. Nationality string `json:"nationality"`
  3704. Email string `json:"email"`
  3705. Extra string `json:"extra"`
  3706. } `json:"data"`
  3707. Code int `json:"code"`
  3708. Message string `json:"message"`
  3709. }
  3710. var ele ELeData
  3711. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3712. if err != nil {
  3713. utils.ErrorLog("解析失败:%v", err)
  3714. }
  3715. token := ele.Data.EcToken
  3716. if len(token) > 0 {
  3717. psn := &models.HisPsn{
  3718. PsnNo: his.PsnNo,
  3719. Age: 0,
  3720. PatientId: his.PatientId,
  3721. Certno: his.Certno,
  3722. Brdy: his.Brdy,
  3723. Gend: his.Gend,
  3724. Naty: his.Naty,
  3725. PsnCertType: his.PsnCertType,
  3726. PsnName: his.PsnName,
  3727. Idetinfo: his.Idetinfo,
  3728. Insuinfo: his.Iinfo,
  3729. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3730. CardInfo: outPutInfo,
  3731. VerifyNumber: token,
  3732. }
  3733. service.CreateHisPsn(psn)
  3734. }
  3735. if len(token) > 0 {
  3736. c.ServeSuccessJSON(map[string]interface{}{
  3737. "msg": "读取成功",
  3738. })
  3739. } else {
  3740. c.ServeSuccessJSON(map[string]interface{}{
  3741. "failed_code": -10,
  3742. "msg": "读取失败",
  3743. })
  3744. }
  3745. }
  3746. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3747. if initFlag == 0 {
  3748. c.TestGetJiangXiBasBaseInit()
  3749. }
  3750. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3751. type ELeData struct {
  3752. Data struct {
  3753. IdNo string `json:"idNo"`
  3754. IdType string `json:"idType"`
  3755. UserName string `json:"userName"`
  3756. EcToken string `json:"ecToken"`
  3757. InsuOrg string `json:"insuOrg"`
  3758. Gender string `json:"gender"`
  3759. Birthday string `json:"birthday"`
  3760. Nationality string `json:"nationality"`
  3761. Email string `json:"email"`
  3762. Extra string `json:"extra"`
  3763. } `json:"data"`
  3764. Code int `json:"code"`
  3765. Message string `json:"message"`
  3766. }
  3767. var ele ELeData
  3768. err := json.Unmarshal([]byte(json_result), &ele)
  3769. if err != nil {
  3770. utils.ErrorLog("解析失败:%v", err)
  3771. }
  3772. token := ele.Data.EcToken
  3773. token = Remove0000(token)
  3774. fmt.Println(ele.Data.UserName)
  3775. 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)
  3776. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3777. var res ResultTwo
  3778. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3779. utils.ErrorLog("解析失败:%v", err)
  3780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3781. return
  3782. }
  3783. if res.Infcode == 0 {
  3784. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3785. if err == gorm.ErrRecordNotFound {
  3786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3787. return
  3788. } else if err != nil {
  3789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3790. return
  3791. } else {
  3792. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3793. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3794. infoStr := string(Iinfos)
  3795. idetinfoStr := string(Idetinfos)
  3796. psn := &models.HisPsn{
  3797. PsnNo: res.Output.Baseinfo.PsnNo,
  3798. Age: res.Output.Baseinfo.Age,
  3799. PatientId: patient.ID,
  3800. Certno: res.Output.Baseinfo.Certno,
  3801. Brdy: res.Output.Baseinfo.Brdy,
  3802. Gend: res.Output.Baseinfo.Gend,
  3803. Naty: res.Output.Baseinfo.Naty,
  3804. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3805. PsnName: res.Output.Baseinfo.PsnName,
  3806. Idetinfo: idetinfoStr,
  3807. Insuinfo: infoStr,
  3808. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3809. CardInfo: "",
  3810. VerifyNumber: token,
  3811. }
  3812. service.CreateHisPsn(psn)
  3813. c.ServeSuccessJSON(map[string]interface{}{
  3814. "patient": patient,
  3815. "number": token,
  3816. })
  3817. }
  3818. } else {
  3819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3820. return
  3821. }
  3822. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3823. idNo := c.GetString("idNo")
  3824. userName := c.GetString("userName")
  3825. ecToken := c.GetString("ecToken")
  3826. insuOrg := c.GetString("insuOrg")
  3827. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  3828. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3829. var res ResultTwo
  3830. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3831. utils.ErrorLog("解析失败:%v", err)
  3832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3833. return
  3834. }
  3835. if res.Infcode == 0 {
  3836. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3837. if err == gorm.ErrRecordNotFound {
  3838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3839. return
  3840. } else if err != nil {
  3841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3842. return
  3843. } else {
  3844. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3845. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3846. infoStr := string(Iinfos)
  3847. idetinfoStr := string(Idetinfos)
  3848. psn := &models.HisPsn{
  3849. PsnNo: res.Output.Baseinfo.PsnNo,
  3850. Age: res.Output.Baseinfo.Age,
  3851. PatientId: patient.ID,
  3852. Certno: res.Output.Baseinfo.Certno,
  3853. Brdy: res.Output.Baseinfo.Brdy,
  3854. Gend: res.Output.Baseinfo.Gend,
  3855. Naty: res.Output.Baseinfo.Naty,
  3856. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3857. PsnName: res.Output.Baseinfo.PsnName,
  3858. Idetinfo: idetinfoStr,
  3859. Insuinfo: infoStr,
  3860. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3861. CardInfo: "",
  3862. VerifyNumber: ecToken,
  3863. InsuplcAdmdvs: insuOrg,
  3864. }
  3865. service.CreateHisPsn(psn)
  3866. c.ServeSuccessJSON(map[string]interface{}{
  3867. "patient": patient,
  3868. "number": ecToken,
  3869. })
  3870. }
  3871. } else {
  3872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3873. return
  3874. }
  3875. } else {
  3876. //if initFlag == 0 {
  3877. // c.TestGetBasBaseInit()
  3878. //}
  3879. //token := c.GetEleBaseInfo()
  3880. //token = Remove0000(token)
  3881. type ELeData struct {
  3882. Code string `json:"code"`
  3883. Data struct {
  3884. Aac002 string `json:"aac002"`
  3885. Aaz500 string `json:"aaz500"`
  3886. ActCardNo string `json:"actCardNo"`
  3887. Bab520 string `json:"bab520"`
  3888. Bkz543 string `json:"bkz543"`
  3889. BusinessType string `json:"businessType"`
  3890. CertfCodg string `json:"certfCodg"`
  3891. EcIndexNo string `json:"ecIndexNo"`
  3892. EcToken string `json:"ecToken"`
  3893. ID0000 string `json:"id0000"`
  3894. IDNo string `json:"idNo"`
  3895. IDType string `json:"idType"`
  3896. Idcode string `json:"idcode"`
  3897. IdentityToken string `json:"identity_token"`
  3898. InsuOrg string `json:"insuOrg"`
  3899. OfficeID string `json:"officeId"`
  3900. OfficeName string `json:"officeName"`
  3901. OperatorID string `json:"operatorId"`
  3902. OperatorName string `json:"operatorName"`
  3903. OrgID string `json:"orgId"`
  3904. UserName string `json:"userName"`
  3905. } `json:"data"`
  3906. Infno interface{} `json:"infno"`
  3907. Message string `json:"message"`
  3908. OrgID string `json:"orgId"`
  3909. TransType string `json:"transType"`
  3910. }
  3911. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  3912. fmt.Println(result)
  3913. outPutInfo := Remove0000(result)
  3914. fmt.Println(outPutInfo)
  3915. var ele ELeData
  3916. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3917. if err != nil {
  3918. utils.ErrorLog("解析失败:%v", err)
  3919. }
  3920. token := ele.Data.EcToken
  3921. if len(token) > 0 {
  3922. result2, requestLog2 := service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  3923. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3924. var res ResultTwo
  3925. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3926. utils.ErrorLog("解析失败:%v", err)
  3927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3928. return
  3929. }
  3930. if res.Infcode == 0 {
  3931. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3932. if err == gorm.ErrRecordNotFound {
  3933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3934. return
  3935. } else if err != nil {
  3936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3937. return
  3938. } else {
  3939. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3940. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3941. infoStr := string(Iinfos)
  3942. idetinfoStr := string(Idetinfos)
  3943. psn := &models.HisPsn{
  3944. PsnNo: res.Output.Baseinfo.PsnNo,
  3945. Age: res.Output.Baseinfo.Age,
  3946. PatientId: patient.ID,
  3947. Certno: res.Output.Baseinfo.Certno,
  3948. Brdy: res.Output.Baseinfo.Brdy,
  3949. Gend: res.Output.Baseinfo.Gend,
  3950. Naty: res.Output.Baseinfo.Naty,
  3951. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3952. PsnName: res.Output.Baseinfo.PsnName,
  3953. Idetinfo: idetinfoStr,
  3954. Insuinfo: infoStr,
  3955. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3956. CardInfo: "",
  3957. VerifyNumber: token,
  3958. }
  3959. service.CreateHisPsn(psn)
  3960. c.ServeSuccessJSON(map[string]interface{}{
  3961. "msg": "读取成功",
  3962. })
  3963. }
  3964. } else {
  3965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3966. return
  3967. }
  3968. } else {
  3969. c.ServeSuccessJSON(map[string]interface{}{
  3970. "failed_code": -10,
  3971. "msg": "读取失败",
  3972. })
  3973. }
  3974. }
  3975. }
  3976. func (c *HisApiController) Get9001() {
  3977. adminUser := c.GetAdminUserInfo()
  3978. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3979. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  3980. if miConfig.MdtrtareaAdmvs == "350500" {
  3981. service.GetFjAuthorizationInfo(miConfig.Code)
  3982. } else if miConfig.MdtrtareaAdmvs == "131023" {
  3983. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  3984. var dat map[string]interface{}
  3985. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3986. fmt.Println(dat)
  3987. } else {
  3988. fmt.Println(err)
  3989. }
  3990. userJSONBytes, _ := json.Marshal(dat)
  3991. var res models.Result9001
  3992. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3993. utils.ErrorLog("解析失败:%v", err)
  3994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3995. return
  3996. }
  3997. } else {
  3998. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  3999. var dat map[string]interface{}
  4000. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4001. fmt.Println(dat)
  4002. } else {
  4003. fmt.Println(err)
  4004. }
  4005. userJSONBytes, _ := json.Marshal(dat)
  4006. var res models.Result9001
  4007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4008. utils.ErrorLog("解析失败:%v", err)
  4009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4010. return
  4011. }
  4012. }
  4013. }
  4014. 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) {
  4015. var res Result3101
  4016. adminUser := c.GetAdminUserInfo()
  4017. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4018. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4019. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4020. //record_time := c.GetString("record_time")
  4021. //trig_scen := c.GetString("trig_scen")
  4022. timeLayout := "2006-01-02"
  4023. loc, _ := time.LoadLocation("Local")
  4024. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4025. if err != nil {
  4026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4027. return res
  4028. }
  4029. recordDateTime := theTime.Unix()
  4030. var patientPrescription models.HisPrescriptionInfo
  4031. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4032. //if patientPrescription.ID == 0 {
  4033. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4034. //}
  4035. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4036. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4037. //
  4038. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  4039. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4040. var pp models.PublicParams
  4041. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4042. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4043. pp.FixmedinsName = miConfig.OrgName
  4044. pp.FixmedinsCode = miConfig.Code
  4045. pp.RequestUrl = miConfig.Url
  4046. pp.Cainfo = miConfig.Cainfo
  4047. pp.SecretKey = miConfig.SecretKey
  4048. pp.AccessKey = miConfig.AccessKey
  4049. pp.OpterName = roles.UserName
  4050. var config []*models.HisXtDiagnoseConfig
  4051. for _, item := range diagnosis_ids {
  4052. id, _ := strconv.ParseInt(item, 10, 64)
  4053. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4054. config = append(config, &diagnosisConfig)
  4055. }
  4056. var pd models.PatientDtos
  4057. pd.PatnID = his.PsnNo
  4058. pd.PatnName = his.Name
  4059. pd.Gend = his.Gend
  4060. pd.Brdy = his.Brdy
  4061. pd.Poolarea = miConfig.MdtrtareaAdmvs
  4062. pd.CurrMdtrtID = his.Number
  4063. var fed models.FsiEncounterDtos
  4064. fed.MdtrtID = his.Number
  4065. fed.MedinsID = miConfig.Code
  4066. fed.MedinsName = miConfig.OrgName
  4067. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  4068. fed.MedMdtrtType = "1"
  4069. fed.MedinsType = "1"
  4070. fed.MedinsLv = "11"
  4071. tm := time.Unix(his.RecordDate, 0)
  4072. s_tm := tm.Format("2006-01-02 15:04:05")
  4073. fed.AdmDate = s_tm
  4074. fed.DscgDate = s_tm
  4075. fed.DscgMainDiseCodg = config[0].CountryCode
  4076. fed.DscgMainDiseName = config[0].CountryContentName
  4077. //诊断信息
  4078. var fdds []*models.FsiDiagnoseDtos
  4079. for index, item := range config {
  4080. if index == 0 {
  4081. var fdd models.FsiDiagnoseDtos
  4082. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4083. fdd.InoutDiseType = "1"
  4084. fdd.MaindiseFlag = "1"
  4085. fdd.DiseDate = s_tm
  4086. fdd.DiasSrtNo = "1"
  4087. fdd.DiseName = item.CountryContentName
  4088. fdd.DiseCodg = item.CountryCode
  4089. fdds = append(fdds, &fdd)
  4090. } else {
  4091. var fdd models.FsiDiagnoseDtos
  4092. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4093. fdd.InoutDiseType = "1"
  4094. fdd.MaindiseFlag = "1"
  4095. fdd.DiseDate = s_tm
  4096. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  4097. fdd.DiseName = item.CountryContentName
  4098. fdd.DiseCodg = item.CountryCode
  4099. fdds = append(fdds, &fdd)
  4100. }
  4101. }
  4102. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  4103. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  4104. fed.AdmDeptName = department.Name
  4105. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  4106. fed.DscgDeptName = department.Name
  4107. fed.MedMdtrtType = "1"
  4108. fed.MedType = "11"
  4109. //if his.Insutype == "390" {
  4110. // fed.MedType = "1402"
  4111. //} else {
  4112. // fed.MedType = "9933"
  4113. //}
  4114. var orders []*models.FsiOrderDtos
  4115. if trig_scen == "2" {
  4116. //处方医嘱信息
  4117. for _, item := range prescriptions {
  4118. for _, subItem := range item.HisDoctorAdviceInfo {
  4119. var order models.FsiOrderDtos
  4120. order.RxID = strconv.FormatInt(item.ID, 10)
  4121. order.Rxno = strconv.FormatInt(item.ID, 10)
  4122. order.LongDrordFlag = "0"
  4123. order.HilistType = "1"
  4124. order.ChrgType = "1"
  4125. order.DrordBhvr = "-"
  4126. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4127. order.HosplistName = subItem.BaseDrugLib.DrugName
  4128. order.HilistLv = "1"
  4129. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4130. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4131. order.HosplistName = subItem.BaseDrugLib.DrugName
  4132. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  4133. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4134. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  4135. order.OwnpayAmt = ""
  4136. order.SelfpayAmt = ""
  4137. order.Spec = ""
  4138. order.SpecUnt = ""
  4139. order.DrordBegnDate = s_tm
  4140. order.DrordStopDate = ""
  4141. order.DrordDrCodg = doctor_info.DoctorNumber
  4142. order.DrordDeptName = department.Name
  4143. order.DrordDeptCodg = department.Number
  4144. order.DrordDrName = doctor_info.UserName
  4145. order.DrordDrProfttl = "234"
  4146. order.CurrDrordFlag = "1"
  4147. orders = append(orders, &order)
  4148. }
  4149. for _, subItem := range item.HisPrescriptionProject {
  4150. if subItem.Type == 2 {
  4151. var order models.FsiOrderDtos
  4152. order.RxID = strconv.FormatInt(item.ID, 10)
  4153. order.Rxno = strconv.FormatInt(item.ID, 10)
  4154. order.LongDrordFlag = "0"
  4155. order.HilistType = "1"
  4156. order.ChrgType = "1"
  4157. order.DrordBhvr = "-"
  4158. order.HilistCode = subItem.HisProject.MedicalCode
  4159. order.HosplistName = subItem.HisProject.ProjectName
  4160. order.HilistLv = "1"
  4161. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4162. order.HosplistCode = subItem.HisProject.MedicalCode
  4163. order.HosplistName = subItem.HisProject.ProjectName
  4164. order.Cnt = subItem.Count
  4165. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4166. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4167. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4168. order.OwnpayAmt = ""
  4169. order.SelfpayAmt = ""
  4170. order.Spec = ""
  4171. order.SpecUnt = ""
  4172. order.DrordBegnDate = s_tm
  4173. order.DrordStopDate = ""
  4174. order.DrordDrCodg = doctor_info.DoctorNumber
  4175. order.DrordDeptName = department.Name
  4176. order.DrordDeptCodg = department.Number
  4177. order.DrordDrName = doctor_info.UserName
  4178. order.DrordDrProfttl = "234"
  4179. order.CurrDrordFlag = "1"
  4180. orders = append(orders, &order)
  4181. }
  4182. if subItem.Type == 3 {
  4183. var order models.FsiOrderDtos
  4184. order.RxID = strconv.FormatInt(item.ID, 10)
  4185. order.Rxno = strconv.FormatInt(item.ID, 10)
  4186. order.LongDrordFlag = "0"
  4187. order.HilistType = "1"
  4188. order.ChrgType = "1"
  4189. order.DrordBhvr = "-"
  4190. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4191. order.HosplistName = subItem.GoodInfo.GoodName
  4192. order.HilistLv = "1"
  4193. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4194. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4195. order.HosplistName = subItem.GoodInfo.GoodName
  4196. order.Cnt = subItem.Count
  4197. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4198. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4199. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4200. order.OwnpayAmt = ""
  4201. order.SelfpayAmt = ""
  4202. order.Spec = ""
  4203. order.SpecUnt = ""
  4204. order.DrordBegnDate = s_tm
  4205. order.DrordStopDate = ""
  4206. order.DrordDrCodg = doctor_info.DoctorNumber
  4207. order.DrordDeptName = department.Name
  4208. order.DrordDeptCodg = department.Number
  4209. order.DrordDrName = doctor_info.UserName
  4210. order.DrordDrProfttl = "234"
  4211. order.CurrDrordFlag = "1"
  4212. orders = append(orders, &order)
  4213. }
  4214. }
  4215. }
  4216. //处方医嘱信息
  4217. }
  4218. fed.MatnStas = "0"
  4219. fed.MedfeeSumamt = "0"
  4220. fed.OwnpayAmt = "0"
  4221. fed.SelfpayAmt = "0"
  4222. fed.AcctPayamt = "0"
  4223. fed.MaAmt = "0"
  4224. fed.HifpPayamt = "0"
  4225. fed.SetlTotlnum = "1"
  4226. fed.Insutype = his.Insutype
  4227. fed.ReimFlag = "0"
  4228. fed.OutSetlFlag = "0"
  4229. var fopd []*models.FsiOperationDtosData
  4230. data := make(map[string]interface{})
  4231. data["fed"] = fed
  4232. data["fdd"] = fdds
  4233. data["fod"] = orders
  4234. data["pd"] = pd
  4235. data["pp"] = pp
  4236. data["fopd"] = fopd
  4237. data["trig_scen"] = trig_scen
  4238. fmt.Println(data)
  4239. fmt.Println(fed)
  4240. fmt.Println(fdds)
  4241. fmt.Println(orders)
  4242. fmt.Println(pd)
  4243. fmt.Println(pp)
  4244. fmt.Println(fopd)
  4245. client := &http.Client{}
  4246. bytesData, _ := json.Marshal(data)
  4247. var req *http.Request
  4248. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4249. if miConfig.MdtrtareaAdmvs == "320921" {
  4250. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  4251. } else {
  4252. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  4253. }
  4254. resp, _ := client.Do(req)
  4255. defer resp.Body.Close()
  4256. body, ioErr := ioutil.ReadAll(resp.Body)
  4257. if ioErr != nil {
  4258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4260. return res
  4261. }
  4262. var respJSON map[string]interface{}
  4263. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4266. return res
  4267. }
  4268. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4269. fmt.Println(respJSON)
  4270. result, _ := json.Marshal(respJSON)
  4271. fmt.Println(result)
  4272. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4273. utils.ErrorLog("解析失败:%v", err)
  4274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4275. return res
  4276. }
  4277. return res
  4278. } else {
  4279. //if miConfig.MdtrtareaAdmvs == "441202" {
  4280. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  4281. saveLog(output, input, "3101", "事前")
  4282. if err := json.Unmarshal([]byte(output), &res); err != nil {
  4283. utils.ErrorLog("解析失败:%v", err)
  4284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4285. return
  4286. }
  4287. return res
  4288. //}
  4289. }
  4290. }
  4291. 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) {
  4292. adminUser := c.GetAdminUserInfo()
  4293. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4294. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4295. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4296. //record_time := c.GetString("record_time")
  4297. //trig_scen := c.GetString("trig_scen")
  4298. timeLayout := "2006-01-02"
  4299. loc, _ := time.LoadLocation("Local")
  4300. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4301. if err != nil {
  4302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4303. return res
  4304. }
  4305. recordDateTime := theTime.Unix()
  4306. var patientPrescription models.HisPrescriptionInfo
  4307. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4308. if patientPrescription.ID == 0 {
  4309. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4310. }
  4311. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4312. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4313. //
  4314. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  4315. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4316. var pp models.PublicParams
  4317. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4318. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4319. pp.FixmedinsName = miConfig.OrgName
  4320. pp.FixmedinsCode = miConfig.Code
  4321. pp.RequestUrl = miConfig.Url
  4322. pp.Cainfo = miConfig.Cainfo
  4323. pp.SecretKey = miConfig.SecretKey
  4324. pp.AccessKey = miConfig.AccessKey
  4325. pp.OpterName = roles.UserName
  4326. var config []*models.HisXtDiagnoseConfig
  4327. for _, item := range diagnosis_ids {
  4328. id, _ := strconv.ParseInt(item, 10, 64)
  4329. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4330. config = append(config, &diagnosisConfig)
  4331. }
  4332. var pd models.PatientDtos
  4333. pd.PatnID = his.PsnNo
  4334. pd.PatnName = his.Name
  4335. pd.Gend = his.Gend
  4336. pd.Brdy = his.Brdy
  4337. pd.Poolarea = his.InsuplcAdmdvs
  4338. pd.CurrMdtrtID = his.Number
  4339. var fed models.FsiEncounterDtos
  4340. fed.MdtrtID = his.Number
  4341. fed.MedinsID = miConfig.Code
  4342. fed.MedinsName = miConfig.OrgName
  4343. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  4344. fed.MedMdtrtType = "1"
  4345. fed.MedinsType = "1"
  4346. fed.MedinsLv = "11"
  4347. tm := time.Unix(his.RecordDate, 0)
  4348. s_tm := tm.Format("2006-01-02 15:04:05")
  4349. fed.AdmDate = s_tm
  4350. fed.DscgDate = s_tm
  4351. fed.DscgMainDiseCodg = config[0].CountryCode
  4352. fed.DscgMainDiseName = config[0].CountryContentName
  4353. //诊断信息
  4354. var fdds []*models.FsiDiagnoseDtos
  4355. for index, item := range config {
  4356. if index == 0 {
  4357. var fdd models.FsiDiagnoseDtos
  4358. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4359. fdd.InoutDiseType = "1"
  4360. fdd.MaindiseFlag = "1"
  4361. fdd.DiseDate = s_tm
  4362. fdd.DiasSrtNo = "1"
  4363. fdd.DiseName = item.CountryContentName
  4364. fdd.DiseCodg = item.CountryCode
  4365. fdds = append(fdds, &fdd)
  4366. } else {
  4367. var fdd models.FsiDiagnoseDtos
  4368. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4369. fdd.InoutDiseType = "1"
  4370. fdd.MaindiseFlag = "1"
  4371. fdd.DiseDate = s_tm
  4372. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  4373. fdd.DiseName = item.CountryContentName
  4374. fdd.DiseCodg = item.CountryCode
  4375. fdds = append(fdds, &fdd)
  4376. }
  4377. }
  4378. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  4379. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  4380. fed.AdmDeptName = department.Name
  4381. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  4382. fed.DscgDeptName = department.Name
  4383. fed.MedMdtrtType = "1"
  4384. fed.MedType = "11"
  4385. //if his.Insutype == "390" {
  4386. // fed.MedType = "1402"
  4387. //} else {
  4388. // fed.MedType = "9933"
  4389. //}
  4390. var orders []*models.FsiOrderDtos
  4391. if trig_scen == "2" {
  4392. //处方医嘱信息
  4393. for _, item := range prescriptions {
  4394. for _, subItem := range item.HisDoctorAdviceInfo {
  4395. var order models.FsiOrderDtos
  4396. order.RxID = strconv.FormatInt(item.ID, 10)
  4397. order.Rxno = strconv.FormatInt(item.ID, 10)
  4398. order.LongDrordFlag = "0"
  4399. order.HilistType = "1"
  4400. order.ChrgType = "1"
  4401. order.DrordBhvr = "-"
  4402. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4403. order.HosplistName = subItem.BaseDrugLib.DrugName
  4404. order.HilistLv = "1"
  4405. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4406. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4407. order.HosplistName = subItem.BaseDrugLib.DrugName
  4408. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  4409. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4410. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  4411. order.OwnpayAmt = ""
  4412. order.SelfpayAmt = ""
  4413. order.Spec = ""
  4414. order.SpecUnt = ""
  4415. order.DrordBegnDate = s_tm
  4416. order.DrordStopDate = ""
  4417. order.DrordDrCodg = doctor_info.DoctorNumber
  4418. order.DrordDeptName = department.Name
  4419. order.DrordDeptCodg = department.Number
  4420. order.DrordDrName = doctor_info.UserName
  4421. order.DrordDrProfttl = "234"
  4422. order.CurrDrordFlag = "1"
  4423. orders = append(orders, &order)
  4424. }
  4425. for _, subItem := range item.HisPrescriptionProject {
  4426. if subItem.Type == 2 {
  4427. var order models.FsiOrderDtos
  4428. order.RxID = strconv.FormatInt(item.ID, 10)
  4429. order.Rxno = strconv.FormatInt(item.ID, 10)
  4430. order.LongDrordFlag = "0"
  4431. order.HilistType = "1"
  4432. order.ChrgType = "1"
  4433. order.DrordBhvr = "-"
  4434. order.HilistCode = subItem.HisProject.MedicalCode
  4435. order.HosplistName = subItem.HisProject.ProjectName
  4436. order.HilistLv = "1"
  4437. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4438. order.HosplistCode = subItem.HisProject.MedicalCode
  4439. order.HosplistName = subItem.HisProject.ProjectName
  4440. order.Cnt = subItem.Count
  4441. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4442. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4443. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4444. order.OwnpayAmt = ""
  4445. order.SelfpayAmt = ""
  4446. order.Spec = ""
  4447. order.SpecUnt = ""
  4448. order.DrordBegnDate = s_tm
  4449. order.DrordStopDate = ""
  4450. order.DrordDrCodg = doctor_info.DoctorNumber
  4451. order.DrordDeptName = department.Name
  4452. order.DrordDeptCodg = department.Number
  4453. order.DrordDrName = doctor_info.UserName
  4454. order.DrordDrProfttl = "234"
  4455. order.CurrDrordFlag = "1"
  4456. orders = append(orders, &order)
  4457. }
  4458. if subItem.Type == 3 {
  4459. var order models.FsiOrderDtos
  4460. order.RxID = strconv.FormatInt(item.ID, 10)
  4461. order.Rxno = strconv.FormatInt(item.ID, 10)
  4462. order.LongDrordFlag = "0"
  4463. order.HilistType = "1"
  4464. order.ChrgType = "1"
  4465. order.DrordBhvr = "-"
  4466. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4467. order.HosplistName = subItem.GoodInfo.GoodName
  4468. order.HilistLv = "1"
  4469. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4470. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4471. order.HosplistName = subItem.GoodInfo.GoodName
  4472. order.Cnt = subItem.Count
  4473. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4474. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4475. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4476. order.OwnpayAmt = ""
  4477. order.SelfpayAmt = ""
  4478. order.Spec = ""
  4479. order.SpecUnt = ""
  4480. order.DrordBegnDate = s_tm
  4481. order.DrordStopDate = ""
  4482. order.DrordDrCodg = doctor_info.DoctorNumber
  4483. order.DrordDeptName = department.Name
  4484. order.DrordDeptCodg = department.Number
  4485. order.DrordDrName = doctor_info.UserName
  4486. order.DrordDrProfttl = "234"
  4487. order.CurrDrordFlag = "1"
  4488. orders = append(orders, &order)
  4489. }
  4490. }
  4491. }
  4492. //处方医嘱信息
  4493. }
  4494. fed.MatnStas = "0"
  4495. fed.MedfeeSumamt = "0"
  4496. fed.OwnpayAmt = "0"
  4497. fed.SelfpayAmt = "0"
  4498. fed.AcctPayamt = "0"
  4499. fed.MaAmt = "0"
  4500. fed.HifpPayamt = "0"
  4501. fed.SetlTotlnum = "1"
  4502. fed.Insutype = his.Insutype
  4503. fed.ReimFlag = "0"
  4504. fed.OutSetlFlag = "0"
  4505. var fopd []*models.FsiOperationDtosData
  4506. data := make(map[string]interface{})
  4507. data["fed"] = fed
  4508. data["fdd"] = fdds
  4509. data["fod"] = orders
  4510. data["pd"] = pd
  4511. data["pp"] = pp
  4512. data["fopd"] = fopd
  4513. data["trig_scen"] = trig_scen
  4514. fmt.Println(data)
  4515. fmt.Println(fed)
  4516. fmt.Println(fdds)
  4517. fmt.Println(orders)
  4518. fmt.Println(pd)
  4519. fmt.Println(pp)
  4520. fmt.Println(fopd)
  4521. client := &http.Client{}
  4522. bytesData, _ := json.Marshal(data)
  4523. var req *http.Request
  4524. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4525. if miConfig.MdtrtareaAdmvs == "320921" {
  4526. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  4527. } else {
  4528. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  4529. }
  4530. resp, _ := client.Do(req)
  4531. defer resp.Body.Close()
  4532. body, ioErr := ioutil.ReadAll(resp.Body)
  4533. if ioErr != nil {
  4534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4536. return res
  4537. }
  4538. var respJSON map[string]interface{}
  4539. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4542. return res
  4543. }
  4544. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4545. fmt.Println(respJSON)
  4546. result, _ := json.Marshal(respJSON)
  4547. fmt.Println(result)
  4548. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4549. utils.ErrorLog("解析失败:%v", err)
  4550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4551. return res
  4552. }
  4553. return res
  4554. } else {
  4555. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  4556. saveLog(output, input, "3101", "事前")
  4557. if err := json.Unmarshal([]byte(output), &res); err != nil {
  4558. utils.ErrorLog("解析失败:%v", err)
  4559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4560. return
  4561. }
  4562. return res
  4563. }
  4564. return res
  4565. }
  4566. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  4567. ////patient_id, _ := c.GetInt64("patient_id")
  4568. //order_id, _ := c.GetInt64("order_id")
  4569. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  4570. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  4571. //trig_scen := c.GetString("trig_scen")
  4572. adminUser := c.GetAdminUserInfo()
  4573. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4574. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4575. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4576. record_time := c.GetString("record_time")
  4577. order, _ := service.GetHisOrderByID(order_id)
  4578. timeLayout := "2006-01-02"
  4579. loc, _ := time.LoadLocation("Local")
  4580. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4581. if err != nil {
  4582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4583. return
  4584. }
  4585. recordDateTime := theTime.Unix()
  4586. var patientPrescription models.HisPrescriptionInfo
  4587. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4588. if patientPrescription.ID == 0 {
  4589. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4590. }
  4591. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4592. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4593. //
  4594. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4595. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4596. var pp models.PublicParams
  4597. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4598. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4599. pp.FixmedinsName = miConfig.OrgName
  4600. pp.FixmedinsCode = miConfig.Code
  4601. pp.RequestUrl = miConfig.Url
  4602. pp.Cainfo = miConfig.Cainfo
  4603. pp.SecretKey = miConfig.SecretKey
  4604. pp.AccessKey = miConfig.AccessKey
  4605. pp.OpterName = roles.UserName
  4606. var config []*models.HisXtDiagnoseConfig
  4607. for _, item := range diagnosis_ids {
  4608. id, _ := strconv.ParseInt(item, 10, 64)
  4609. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4610. config = append(config, &diagnosisConfig)
  4611. }
  4612. var pd models.PatientDtos
  4613. pd.PatnID = his.PsnNo
  4614. pd.PatnName = his.Name
  4615. pd.Gend = his.Gend
  4616. pd.Brdy = his.Brdy
  4617. pd.Poolarea = his.InsuplcAdmdvs
  4618. pd.CurrMdtrtID = his.Number
  4619. var fed models.FsiEncounterDtos
  4620. fed.MdtrtID = his.Number
  4621. fed.MedinsID = miConfig.Code
  4622. fed.MedinsName = miConfig.OrgName
  4623. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  4624. fed.MedMdtrtType = "1"
  4625. fed.MedinsType = "1"
  4626. fed.MedinsLv = "11"
  4627. tm := time.Unix(his.RecordDate, 0)
  4628. s_tm := tm.Format("2006-01-02 15:04:05")
  4629. fed.AdmDate = s_tm
  4630. fed.DscgDate = s_tm
  4631. fed.DscgMainDiseCodg = config[0].CountryCode
  4632. fed.DscgMainDiseName = config[0].CountryContentName
  4633. //诊断信息
  4634. var fdds []*models.FsiDiagnoseDtos
  4635. for index, item := range config {
  4636. if index == 0 {
  4637. var fdd models.FsiDiagnoseDtos
  4638. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4639. fdd.InoutDiseType = "1"
  4640. fdd.MaindiseFlag = "1"
  4641. fdd.DiseDate = s_tm
  4642. fdd.DiasSrtNo = "1"
  4643. fdd.DiseName = item.CountryContentName
  4644. fdd.DiseCodg = item.CountryCode
  4645. fdds = append(fdds, &fdd)
  4646. } else {
  4647. var fdd models.FsiDiagnoseDtos
  4648. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4649. fdd.InoutDiseType = "1"
  4650. fdd.MaindiseFlag = "1"
  4651. fdd.DiseDate = s_tm
  4652. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  4653. fdd.DiseName = item.CountryContentName
  4654. fdd.DiseCodg = item.CountryCode
  4655. fdds = append(fdds, &fdd)
  4656. }
  4657. }
  4658. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  4659. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  4660. fed.AdmDeptName = department.Name
  4661. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  4662. fed.DscgDeptName = department.Name
  4663. fed.MedType = order.MedType
  4664. //处方医嘱信息
  4665. var orders []*models.FsiOrderDtos
  4666. //for _, item := range prescriptions {
  4667. // for _, subItem := range item.HisDoctorAdviceInfo {
  4668. // var order models.FsiOrderDtos
  4669. // order.RxID = strconv.FormatInt(item.ID, 10)
  4670. // order.Rxno = strconv.FormatInt(item.ID, 10)
  4671. // order.LongDrordFlag = "0"
  4672. // order.HilistType = "1"
  4673. // order.ChrgType = "1"
  4674. // order.DrordBhvr = "-"
  4675. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4676. // order.HosplistName = subItem.BaseDrugLib.DrugName
  4677. // order.HilistLv = "1"
  4678. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4679. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4680. // order.HosplistName = subItem.BaseDrugLib.DrugName
  4681. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  4682. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4683. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  4684. // order.OwnpayAmt = ""
  4685. // order.SelfpayAmt = ""
  4686. // order.Spec = ""
  4687. // order.SpecUnt = ""
  4688. // order.DrordBegnDate = s_tm
  4689. // order.DrordStopDate = ""
  4690. // order.DrordDrCodg = "1"
  4691. // order.DrordDeptName = department.Name
  4692. // order.DrordDrCodg = "1"
  4693. // order.DrordDrName = doctor_info.UserName
  4694. // order.DrordDrProfttl = ""
  4695. // order.CurrDrordFlag = "1"
  4696. // orders = append(orders, &order)
  4697. // }
  4698. // for _, subItem := range item.HisPrescriptionProject {
  4699. // if subItem.Type == 2 {
  4700. // var order models.FsiOrderDtos
  4701. // order.RxID = strconv.FormatInt(item.ID, 10)
  4702. // order.Rxno = strconv.FormatInt(item.ID, 10)
  4703. // order.LongDrordFlag = "0"
  4704. // order.HilistType = "1"
  4705. // order.ChrgType = "1"
  4706. // order.DrordBhvr = "-"
  4707. // order.HilistCode = subItem.HisProject.MedicalCode
  4708. // order.HosplistName = subItem.HisProject.ProjectName
  4709. // order.HilistLv = "1"
  4710. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4711. // order.HosplistCode = subItem.HisProject.MedicalCode
  4712. // order.HosplistName = subItem.HisProject.ProjectName
  4713. // order.Cnt = subItem.Count
  4714. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4715. //
  4716. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4717. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  4718. // order.OwnpayAmt = ""
  4719. // order.SelfpayAmt = ""
  4720. // order.Spec = ""
  4721. // order.SpecUnt = ""
  4722. // order.DrordBegnDate = s_tm
  4723. // order.DrordStopDate = ""
  4724. // order.DrordDrCodg = "1"
  4725. // order.DrordDeptName = department.Name
  4726. // order.DrordDrCodg = "1"
  4727. // order.DrordDrName = doctor_info.UserName
  4728. // order.DrordDrProfttl = ""
  4729. // order.CurrDrordFlag = "1"
  4730. // orders = append(orders, &order)
  4731. //
  4732. // }
  4733. // if subItem.Type == 3 {
  4734. //
  4735. // var order models.FsiOrderDtos
  4736. // order.RxID = strconv.FormatInt(item.ID, 10)
  4737. // order.Rxno = strconv.FormatInt(item.ID, 10)
  4738. // order.LongDrordFlag = "0"
  4739. // order.HilistType = "1"
  4740. // order.ChrgType = "1"
  4741. // order.DrordBhvr = "-"
  4742. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4743. // order.HosplistName = subItem.GoodInfo.GoodName
  4744. // order.HilistLv = "1"
  4745. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4746. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4747. // order.HosplistName = subItem.GoodInfo.GoodName
  4748. // order.Cnt = subItem.Count
  4749. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4750. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4751. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  4752. // order.OwnpayAmt = ""
  4753. // order.SelfpayAmt = ""
  4754. // order.Spec = ""
  4755. // order.SpecUnt = ""
  4756. // order.DrordBegnDate = s_tm
  4757. // order.DrordStopDate = ""
  4758. // order.DrordDrCodg = "1"
  4759. // order.DrordDeptName = department.Name
  4760. // order.DrordDrCodg = "1"
  4761. // order.DrordDrName = doctor_info.UserName
  4762. // order.DrordDrProfttl = ""
  4763. // order.CurrDrordFlag = "1"
  4764. // orders = append(orders, &order)
  4765. //
  4766. // }
  4767. // }
  4768. //}
  4769. for _, item := range prescriptions {
  4770. for _, subItem := range item.HisDoctorAdviceInfo {
  4771. var order models.FsiOrderDtos
  4772. order.RxID = strconv.FormatInt(item.ID, 10)
  4773. order.Rxno = strconv.FormatInt(item.ID, 10)
  4774. order.LongDrordFlag = "0"
  4775. order.HilistType = "1"
  4776. order.ChrgType = "1"
  4777. order.DrordBhvr = "-"
  4778. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4779. order.HosplistName = subItem.BaseDrugLib.DrugName
  4780. order.HilistLv = "1"
  4781. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4782. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4783. order.HosplistName = subItem.BaseDrugLib.DrugName
  4784. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  4785. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4786. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  4787. order.OwnpayAmt = ""
  4788. order.SelfpayAmt = ""
  4789. order.Spec = ""
  4790. order.SpecUnt = ""
  4791. order.DrordBegnDate = s_tm
  4792. order.DrordStopDate = ""
  4793. order.DrordDrCodg = doctor_info.DoctorNumber
  4794. order.DrordDeptName = department.Name
  4795. order.DrordDeptCodg = department.Number
  4796. order.DrordDrName = doctor_info.UserName
  4797. order.DrordDrProfttl = "234"
  4798. order.CurrDrordFlag = "1"
  4799. orders = append(orders, &order)
  4800. }
  4801. for _, subItem := range item.HisPrescriptionProject {
  4802. if subItem.Type == 2 {
  4803. var order models.FsiOrderDtos
  4804. order.RxID = strconv.FormatInt(item.ID, 10)
  4805. order.Rxno = strconv.FormatInt(item.ID, 10)
  4806. order.LongDrordFlag = "0"
  4807. order.HilistType = "1"
  4808. order.ChrgType = "1"
  4809. order.DrordBhvr = "-"
  4810. order.HilistCode = subItem.HisProject.MedicalCode
  4811. order.HosplistName = subItem.HisProject.ProjectName
  4812. order.HilistLv = "1"
  4813. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4814. order.HosplistCode = subItem.HisProject.MedicalCode
  4815. order.HosplistName = subItem.HisProject.ProjectName
  4816. order.Cnt = subItem.Count
  4817. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4818. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4819. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4820. order.OwnpayAmt = ""
  4821. order.SelfpayAmt = ""
  4822. order.Spec = ""
  4823. order.SpecUnt = ""
  4824. order.DrordBegnDate = s_tm
  4825. order.DrordStopDate = ""
  4826. order.DrordDrCodg = doctor_info.DoctorNumber
  4827. order.DrordDeptName = department.Name
  4828. order.DrordDeptCodg = department.Number
  4829. order.DrordDrName = doctor_info.UserName
  4830. order.DrordDrProfttl = "234"
  4831. order.CurrDrordFlag = "1"
  4832. orders = append(orders, &order)
  4833. }
  4834. if subItem.Type == 3 {
  4835. var order models.FsiOrderDtos
  4836. order.RxID = strconv.FormatInt(item.ID, 10)
  4837. order.Rxno = strconv.FormatInt(item.ID, 10)
  4838. order.LongDrordFlag = "0"
  4839. order.HilistType = "1"
  4840. order.ChrgType = "1"
  4841. order.DrordBhvr = "0"
  4842. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4843. order.HosplistName = subItem.GoodInfo.GoodName
  4844. order.HilistLv = "1"
  4845. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4846. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4847. order.HosplistName = subItem.GoodInfo.GoodName
  4848. order.Cnt = subItem.Count
  4849. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4850. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4851. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4852. order.OwnpayAmt = ""
  4853. order.SelfpayAmt = ""
  4854. order.Spec = ""
  4855. order.SpecUnt = ""
  4856. order.DrordBegnDate = s_tm
  4857. order.DrordStopDate = ""
  4858. order.DrordDrCodg = doctor_info.DoctorNumber
  4859. order.DrordDeptName = department.Name
  4860. order.DrordDeptCodg = department.Number
  4861. order.DrordDrName = doctor_info.UserName
  4862. order.DrordDrProfttl = "234"
  4863. order.CurrDrordFlag = "1"
  4864. orders = append(orders, &order)
  4865. }
  4866. }
  4867. }
  4868. //处方医嘱信息
  4869. fed.MatnStas = "0"
  4870. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4871. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  4872. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  4873. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  4874. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  4875. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  4876. fed.SetlTotlnum = "1"
  4877. fed.Insutype = his.Insutype
  4878. fed.ReimFlag = "0"
  4879. fed.OutSetlFlag = "0"
  4880. var fopd []*models.FsiOperationDtosData
  4881. data := make(map[string]interface{})
  4882. data["fed"] = fed
  4883. data["fdd"] = fdds
  4884. data["fod"] = orders
  4885. data["pd"] = pd
  4886. data["pp"] = pp
  4887. data["fopd"] = fopd
  4888. data["trig_scen"] = trig_scen
  4889. client := &http.Client{}
  4890. bytesData, _ := json.Marshal(data)
  4891. var req *http.Request
  4892. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4893. if miConfig.MdtrtareaAdmvs == "320921" {
  4894. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  4895. } else {
  4896. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  4897. }
  4898. resp, _ := client.Do(req)
  4899. defer resp.Body.Close()
  4900. body, ioErr := ioutil.ReadAll(resp.Body)
  4901. if ioErr != nil {
  4902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4904. return res
  4905. }
  4906. var respJSON map[string]interface{}
  4907. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4910. return res
  4911. }
  4912. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4913. result, _ := json.Marshal(respJSON)
  4914. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4915. utils.ErrorLog("解析失败:%v", err)
  4916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4917. return res
  4918. }
  4919. return res
  4920. } else {
  4921. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  4922. saveLog(output, input, "3102", "事中")
  4923. if err := json.Unmarshal([]byte(output), &res); err != nil {
  4924. utils.ErrorLog("解析失败:%v", err)
  4925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4926. return
  4927. }
  4928. return res
  4929. }
  4930. return res
  4931. }
  4932. 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) {
  4933. var res Resultgd3101
  4934. adminUser := c.GetAdminUserInfo()
  4935. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4936. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4937. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4938. //record_time := c.GetString("record_time")
  4939. //trig_scen := c.GetString("trig_scen")
  4940. timeLayout := "2006-01-02"
  4941. loc, _ := time.LoadLocation("Local")
  4942. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4943. if err != nil {
  4944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4945. return res
  4946. }
  4947. recordDateTime := theTime.Unix()
  4948. var patientPrescription models.HisPrescriptionInfo
  4949. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4950. //if patientPrescription.ID == 0 {
  4951. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4952. //}
  4953. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4954. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4955. //
  4956. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  4957. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4958. var pp models.PublicParams
  4959. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4960. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4961. pp.FixmedinsName = miConfig.OrgName
  4962. pp.FixmedinsCode = miConfig.Code
  4963. pp.RequestUrl = miConfig.Url
  4964. pp.Cainfo = miConfig.Cainfo
  4965. pp.SecretKey = miConfig.SecretKey
  4966. pp.AccessKey = miConfig.AccessKey
  4967. pp.OpterName = roles.UserName
  4968. var config []*models.HisXtDiagnoseConfig
  4969. for _, item := range diagnosis_ids {
  4970. id, _ := strconv.ParseInt(item, 10, 64)
  4971. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4972. config = append(config, &diagnosisConfig)
  4973. }
  4974. var pd models.PatientDtos
  4975. pd.PatnID = his.PsnNo
  4976. pd.PatnName = his.Name
  4977. pd.Gend = his.Gend
  4978. pd.Brdy = his.Brdy
  4979. pd.Poolarea = miConfig.MdtrtareaAdmvs
  4980. pd.CurrMdtrtID = his.Number
  4981. var fed models.FsiEncounterDtos
  4982. fed.MdtrtID = his.Number
  4983. fed.MedinsID = miConfig.Code
  4984. fed.MedinsName = miConfig.OrgName
  4985. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  4986. fed.MedMdtrtType = "1"
  4987. fed.MedinsType = "1"
  4988. fed.MedinsLv = "11"
  4989. tm := time.Unix(his.RecordDate, 0)
  4990. s_tm := tm.Format("2006-01-02 15:04:05")
  4991. fed.AdmDate = s_tm
  4992. fed.DscgDate = s_tm
  4993. fed.DscgMainDiseCodg = config[0].CountryCode
  4994. fed.DscgMainDiseName = config[0].CountryContentName
  4995. //诊断信息
  4996. var fdds []*models.FsiDiagnoseDtos
  4997. for index, item := range config {
  4998. if index == 0 {
  4999. var fdd models.FsiDiagnoseDtos
  5000. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5001. fdd.InoutDiseType = "1"
  5002. fdd.MaindiseFlag = "1"
  5003. fdd.DiseDate = s_tm
  5004. fdd.DiasSrtNo = "1"
  5005. fdd.DiseName = item.CountryContentName
  5006. fdd.DiseCodg = item.CountryCode
  5007. fdds = append(fdds, &fdd)
  5008. } else {
  5009. var fdd models.FsiDiagnoseDtos
  5010. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5011. fdd.InoutDiseType = "1"
  5012. fdd.MaindiseFlag = "1"
  5013. fdd.DiseDate = s_tm
  5014. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5015. fdd.DiseName = item.CountryContentName
  5016. fdd.DiseCodg = item.CountryCode
  5017. fdds = append(fdds, &fdd)
  5018. }
  5019. }
  5020. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5021. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5022. fed.AdmDeptName = department.Name
  5023. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5024. fed.DscgDeptName = department.Name
  5025. fed.MedMdtrtType = "1"
  5026. fed.MedType = "11"
  5027. //if his.Insutype == "390" {
  5028. // fed.MedType = "1402"
  5029. //} else {
  5030. // fed.MedType = "9933"
  5031. //}
  5032. var orders []*models.FsiOrderDtos
  5033. if trig_scen == "2" {
  5034. //处方医嘱信息
  5035. for _, item := range prescriptions {
  5036. for _, subItem := range item.HisDoctorAdviceInfo {
  5037. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  5038. var order models.FsiOrderDtos
  5039. order.RxID = strconv.FormatInt(item.ID, 10)
  5040. order.Rxno = strconv.FormatInt(item.ID, 10)
  5041. order.LongDrordFlag = "0"
  5042. order.HilistType = "1"
  5043. order.ChrgType = "1"
  5044. order.DrordBhvr = "0"
  5045. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5046. order.HosplistName = subItem.BaseDrugLib.DrugName
  5047. order.HilistLv = "1"
  5048. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5049. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5050. order.HosplistName = subItem.BaseDrugLib.DrugName
  5051. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5052. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5053. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5054. order.OwnpayAmt = ""
  5055. order.SelfpayAmt = ""
  5056. order.Spec = spec
  5057. order.SpecUnt = subItem.PrescribingNumberUnit
  5058. order.DrordBegnDate = s_tm
  5059. order.DrordStopDate = ""
  5060. order.DrordDrCodg = doctor_info.DoctorNumber
  5061. order.DrordDeptName = department.Name
  5062. order.DrordDeptCodg = department.Number
  5063. order.DrordDrName = doctor_info.UserName
  5064. order.DrordDrProfttl = "234"
  5065. order.CurrDrordFlag = "1"
  5066. orders = append(orders, &order)
  5067. }
  5068. for _, subItem := range item.HisPrescriptionProject {
  5069. if subItem.Type == 2 {
  5070. var order models.FsiOrderDtos
  5071. order.RxID = strconv.FormatInt(item.ID, 10)
  5072. order.Rxno = strconv.FormatInt(item.ID, 10)
  5073. order.LongDrordFlag = "0"
  5074. order.HilistType = "1"
  5075. order.ChrgType = "1"
  5076. order.DrordBhvr = "0"
  5077. order.HilistCode = subItem.HisProject.MedicalCode
  5078. order.HosplistName = subItem.HisProject.ProjectName
  5079. order.HilistLv = "1"
  5080. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5081. order.HosplistCode = subItem.HisProject.MedicalCode
  5082. order.HosplistName = subItem.HisProject.ProjectName
  5083. order.Cnt = subItem.Count
  5084. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5085. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5086. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5087. order.OwnpayAmt = ""
  5088. order.SelfpayAmt = ""
  5089. order.Spec = subItem.Unit
  5090. order.SpecUnt = subItem.Unit
  5091. order.DrordBegnDate = s_tm
  5092. order.DrordStopDate = ""
  5093. order.DrordDrCodg = doctor_info.DoctorNumber
  5094. order.DrordDeptName = department.Name
  5095. order.DrordDeptCodg = department.Number
  5096. order.DrordDrName = doctor_info.UserName
  5097. order.DrordDrProfttl = "234"
  5098. order.CurrDrordFlag = "1"
  5099. orders = append(orders, &order)
  5100. }
  5101. if subItem.Type == 3 {
  5102. var order models.FsiOrderDtos
  5103. order.RxID = strconv.FormatInt(item.ID, 10)
  5104. order.Rxno = strconv.FormatInt(item.ID, 10)
  5105. order.LongDrordFlag = "0"
  5106. order.HilistType = "1"
  5107. order.ChrgType = "1"
  5108. order.DrordBhvr = "0"
  5109. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5110. order.HosplistName = subItem.GoodInfo.GoodName
  5111. order.HilistLv = "1"
  5112. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5113. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5114. order.HosplistName = subItem.GoodInfo.GoodName
  5115. order.Cnt = subItem.Count
  5116. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5117. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5118. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5119. order.OwnpayAmt = ""
  5120. order.SelfpayAmt = ""
  5121. order.Spec = subItem.GoodInfo.SpecificationName
  5122. order.SpecUnt = subItem.Unit
  5123. order.DrordBegnDate = s_tm
  5124. order.DrordStopDate = ""
  5125. order.DrordDrCodg = doctor_info.DoctorNumber
  5126. order.DrordDeptName = department.Name
  5127. order.DrordDeptCodg = department.Number
  5128. order.DrordDrName = doctor_info.UserName
  5129. order.DrordDrProfttl = "234"
  5130. order.CurrDrordFlag = "1"
  5131. orders = append(orders, &order)
  5132. }
  5133. }
  5134. }
  5135. //处方医嘱信息
  5136. }
  5137. fed.MatnStas = "0"
  5138. fed.MedfeeSumamt = "0"
  5139. fed.OwnpayAmt = "0"
  5140. fed.SelfpayAmt = "0"
  5141. fed.AcctPayamt = "0"
  5142. fed.MaAmt = "0"
  5143. fed.HifpPayamt = "0"
  5144. fed.SetlTotlnum = "1"
  5145. fed.Insutype = his.Insutype
  5146. fed.ReimFlag = "0"
  5147. fed.OutSetlFlag = "0"
  5148. var fopd []*models.FsiOperationDtosData
  5149. data := make(map[string]interface{})
  5150. data["fed"] = fed
  5151. data["fdd"] = fdds
  5152. data["fod"] = orders
  5153. data["pd"] = pd
  5154. data["pp"] = pp
  5155. data["fopd"] = fopd
  5156. data["trig_scen"] = trig_scen
  5157. fmt.Println(data)
  5158. fmt.Println(fed)
  5159. fmt.Println(fdds)
  5160. fmt.Println(orders)
  5161. fmt.Println(pd)
  5162. fmt.Println(pp)
  5163. fmt.Println(fopd)
  5164. client := &http.Client{}
  5165. bytesData, _ := json.Marshal(data)
  5166. var req *http.Request
  5167. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5168. if miConfig.MdtrtareaAdmvs == "320921" {
  5169. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5170. } else {
  5171. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5172. }
  5173. resp, _ := client.Do(req)
  5174. defer resp.Body.Close()
  5175. body, ioErr := ioutil.ReadAll(resp.Body)
  5176. if ioErr != nil {
  5177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5179. return res
  5180. }
  5181. var respJSON map[string]interface{}
  5182. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5185. return res
  5186. }
  5187. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5188. fmt.Println(respJSON)
  5189. result, _ := json.Marshal(respJSON)
  5190. fmt.Println(result)
  5191. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5192. utils.ErrorLog("解析失败:%v", err)
  5193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5194. return res
  5195. }
  5196. return res
  5197. } else {
  5198. //if miConfig.MdtrtareaAdmvs == "441202" {
  5199. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5200. saveLog(output, input, "3101", "事前")
  5201. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5202. utils.ErrorLog("解析失败:%v", err)
  5203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5204. return
  5205. }
  5206. return res
  5207. //}
  5208. }
  5209. }
  5210. 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) {
  5211. adminUser := c.GetAdminUserInfo()
  5212. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5213. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5214. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5215. //record_time := c.GetString("record_time")
  5216. //trig_scen := c.GetString("trig_scen")
  5217. timeLayout := "2006-01-02"
  5218. loc, _ := time.LoadLocation("Local")
  5219. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5220. if err != nil {
  5221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5222. return res
  5223. }
  5224. recordDateTime := theTime.Unix()
  5225. var patientPrescription models.HisPrescriptionInfo
  5226. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5227. if patientPrescription.ID == 0 {
  5228. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5229. }
  5230. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5231. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5232. //
  5233. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5234. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5235. var pp models.PublicParams
  5236. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5237. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5238. pp.FixmedinsName = miConfig.OrgName
  5239. pp.FixmedinsCode = miConfig.Code
  5240. pp.RequestUrl = miConfig.Url
  5241. pp.Cainfo = miConfig.Cainfo
  5242. pp.SecretKey = miConfig.SecretKey
  5243. pp.AccessKey = miConfig.AccessKey
  5244. pp.OpterName = roles.UserName
  5245. var config []*models.HisXtDiagnoseConfig
  5246. for _, item := range diagnosis_ids {
  5247. id, _ := strconv.ParseInt(item, 10, 64)
  5248. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5249. config = append(config, &diagnosisConfig)
  5250. }
  5251. var pd models.PatientDtos
  5252. pd.PatnID = his.PsnNo
  5253. pd.PatnName = his.Name
  5254. pd.Gend = his.Gend
  5255. pd.Brdy = his.Brdy
  5256. pd.Poolarea = his.InsuplcAdmdvs
  5257. pd.CurrMdtrtID = his.Number
  5258. var fed models.FsiEncounterDtos
  5259. fed.MdtrtID = his.Number
  5260. fed.MedinsID = miConfig.Code
  5261. fed.MedinsName = miConfig.OrgName
  5262. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5263. fed.MedMdtrtType = "1"
  5264. fed.MedinsType = "1"
  5265. fed.MedinsLv = "11"
  5266. tm := time.Unix(his.RecordDate, 0)
  5267. s_tm := tm.Format("2006-01-02 15:04:05")
  5268. fed.AdmDate = s_tm
  5269. fed.DscgDate = s_tm
  5270. fed.DscgMainDiseCodg = config[0].CountryCode
  5271. fed.DscgMainDiseName = config[0].CountryContentName
  5272. //诊断信息
  5273. var fdds []*models.FsiDiagnoseDtos
  5274. for index, item := range config {
  5275. if index == 0 {
  5276. var fdd models.FsiDiagnoseDtos
  5277. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5278. fdd.InoutDiseType = "1"
  5279. fdd.MaindiseFlag = "1"
  5280. fdd.DiseDate = s_tm
  5281. fdd.DiasSrtNo = "1"
  5282. fdd.DiseName = item.CountryContentName
  5283. fdd.DiseCodg = item.CountryCode
  5284. fdds = append(fdds, &fdd)
  5285. } else {
  5286. var fdd models.FsiDiagnoseDtos
  5287. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5288. fdd.InoutDiseType = "1"
  5289. fdd.MaindiseFlag = "1"
  5290. fdd.DiseDate = s_tm
  5291. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5292. fdd.DiseName = item.CountryContentName
  5293. fdd.DiseCodg = item.CountryCode
  5294. fdds = append(fdds, &fdd)
  5295. }
  5296. }
  5297. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5298. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5299. fed.AdmDeptName = department.Name
  5300. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5301. fed.DscgDeptName = department.Name
  5302. fed.MedMdtrtType = "1"
  5303. fed.MedType = "11"
  5304. //if his.Insutype == "390" {
  5305. // fed.MedType = "1402"
  5306. //} else {
  5307. // fed.MedType = "9933"
  5308. //}
  5309. var orders []*models.FsiOrderDtos
  5310. if trig_scen == "2" {
  5311. //处方医嘱信息
  5312. for _, item := range prescriptions {
  5313. for _, subItem := range item.HisDoctorAdviceInfo {
  5314. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  5315. var order models.FsiOrderDtos
  5316. order.RxID = strconv.FormatInt(item.ID, 10)
  5317. order.Rxno = strconv.FormatInt(item.ID, 10)
  5318. order.LongDrordFlag = "0"
  5319. order.HilistType = "1"
  5320. order.ChrgType = "1"
  5321. order.DrordBhvr = "0"
  5322. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5323. order.HosplistName = subItem.BaseDrugLib.DrugName
  5324. order.HilistLv = "1"
  5325. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5326. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5327. order.HosplistName = subItem.BaseDrugLib.DrugName
  5328. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5329. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5330. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5331. order.OwnpayAmt = ""
  5332. order.SelfpayAmt = ""
  5333. order.Spec = spec
  5334. order.SpecUnt = subItem.PrescribingNumberUnit
  5335. order.DrordBegnDate = s_tm
  5336. order.DrordStopDate = ""
  5337. order.DrordDrCodg = doctor_info.DoctorNumber
  5338. order.DrordDeptName = department.Name
  5339. order.DrordDeptCodg = department.Number
  5340. order.DrordDrName = doctor_info.UserName
  5341. order.DrordDrProfttl = "234"
  5342. order.CurrDrordFlag = "1"
  5343. orders = append(orders, &order)
  5344. }
  5345. for _, subItem := range item.HisPrescriptionProject {
  5346. if subItem.Type == 2 {
  5347. var order models.FsiOrderDtos
  5348. order.RxID = strconv.FormatInt(item.ID, 10)
  5349. order.Rxno = strconv.FormatInt(item.ID, 10)
  5350. order.LongDrordFlag = "0"
  5351. order.HilistType = "1"
  5352. order.ChrgType = "1"
  5353. order.DrordBhvr = "0"
  5354. order.HilistCode = subItem.HisProject.MedicalCode
  5355. order.HosplistName = subItem.HisProject.ProjectName
  5356. order.HilistLv = "1"
  5357. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5358. order.HosplistCode = subItem.HisProject.MedicalCode
  5359. order.HosplistName = subItem.HisProject.ProjectName
  5360. order.Cnt = subItem.Count
  5361. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5362. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5363. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5364. order.OwnpayAmt = ""
  5365. order.SelfpayAmt = ""
  5366. order.Spec = subItem.Unit
  5367. order.SpecUnt = subItem.Unit
  5368. order.DrordBegnDate = s_tm
  5369. order.DrordStopDate = ""
  5370. order.DrordDrCodg = doctor_info.DoctorNumber
  5371. order.DrordDeptName = department.Name
  5372. order.DrordDeptCodg = department.Number
  5373. order.DrordDrName = doctor_info.UserName
  5374. order.DrordDrProfttl = "234"
  5375. order.CurrDrordFlag = "1"
  5376. orders = append(orders, &order)
  5377. }
  5378. if subItem.Type == 3 {
  5379. var order models.FsiOrderDtos
  5380. order.RxID = strconv.FormatInt(item.ID, 10)
  5381. order.Rxno = strconv.FormatInt(item.ID, 10)
  5382. order.LongDrordFlag = "0"
  5383. order.HilistType = "1"
  5384. order.ChrgType = "1"
  5385. order.DrordBhvr = "0"
  5386. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5387. order.HosplistName = subItem.GoodInfo.GoodName
  5388. order.HilistLv = "1"
  5389. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5390. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5391. order.HosplistName = subItem.GoodInfo.GoodName
  5392. order.Cnt = subItem.Count
  5393. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5394. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5395. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5396. order.OwnpayAmt = ""
  5397. order.SelfpayAmt = ""
  5398. order.Spec = subItem.GoodInfo.SpecificationName
  5399. order.SpecUnt = subItem.Unit
  5400. order.DrordBegnDate = s_tm
  5401. order.DrordStopDate = ""
  5402. order.DrordDrCodg = doctor_info.DoctorNumber
  5403. order.DrordDeptName = department.Name
  5404. order.DrordDeptCodg = department.Number
  5405. order.DrordDrName = doctor_info.UserName
  5406. order.DrordDrProfttl = "234"
  5407. order.CurrDrordFlag = "1"
  5408. orders = append(orders, &order)
  5409. }
  5410. }
  5411. }
  5412. //处方医嘱信息
  5413. }
  5414. fed.MatnStas = "0"
  5415. fed.MedfeeSumamt = "0"
  5416. fed.OwnpayAmt = "0"
  5417. fed.SelfpayAmt = "0"
  5418. fed.AcctPayamt = "0"
  5419. fed.MaAmt = "0"
  5420. fed.HifpPayamt = "0"
  5421. fed.SetlTotlnum = "1"
  5422. fed.Insutype = his.Insutype
  5423. fed.ReimFlag = "0"
  5424. fed.OutSetlFlag = "0"
  5425. var fopd []*models.FsiOperationDtosData
  5426. data := make(map[string]interface{})
  5427. data["fed"] = fed
  5428. data["fdd"] = fdds
  5429. data["fod"] = orders
  5430. data["pd"] = pd
  5431. data["pp"] = pp
  5432. data["fopd"] = fopd
  5433. data["trig_scen"] = trig_scen
  5434. fmt.Println(data)
  5435. fmt.Println(fed)
  5436. fmt.Println(fdds)
  5437. fmt.Println(orders)
  5438. fmt.Println(pd)
  5439. fmt.Println(pp)
  5440. fmt.Println(fopd)
  5441. client := &http.Client{}
  5442. bytesData, _ := json.Marshal(data)
  5443. var req *http.Request
  5444. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5445. if miConfig.MdtrtareaAdmvs == "320921" {
  5446. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5447. } else {
  5448. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5449. }
  5450. resp, _ := client.Do(req)
  5451. defer resp.Body.Close()
  5452. body, ioErr := ioutil.ReadAll(resp.Body)
  5453. if ioErr != nil {
  5454. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5456. return res
  5457. }
  5458. var respJSON map[string]interface{}
  5459. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5462. return res
  5463. }
  5464. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5465. fmt.Println(respJSON)
  5466. result, _ := json.Marshal(respJSON)
  5467. fmt.Println(result)
  5468. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5469. utils.ErrorLog("解析失败:%v", err)
  5470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5471. return res
  5472. }
  5473. return res
  5474. } else {
  5475. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5476. saveLog(output, input, "3101", "事前")
  5477. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5478. utils.ErrorLog("解析失败:%v", err)
  5479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5480. return
  5481. }
  5482. return res
  5483. }
  5484. return res
  5485. }
  5486. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  5487. ////patient_id, _ := c.GetInt64("patient_id")
  5488. //order_id, _ := c.GetInt64("order_id")
  5489. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  5490. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  5491. //trig_scen := c.GetString("trig_scen")
  5492. adminUser := c.GetAdminUserInfo()
  5493. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5494. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5495. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5496. record_time := c.GetString("record_time")
  5497. order, _ := service.GetHisOrderByID(order_id)
  5498. timeLayout := "2006-01-02"
  5499. loc, _ := time.LoadLocation("Local")
  5500. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5501. if err != nil {
  5502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5503. return
  5504. }
  5505. recordDateTime := theTime.Unix()
  5506. var patientPrescription models.HisPrescriptionInfo
  5507. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5508. if patientPrescription.ID == 0 {
  5509. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5510. }
  5511. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5512. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5513. //
  5514. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5515. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5516. var pp models.PublicParams
  5517. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5518. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5519. pp.FixmedinsName = miConfig.OrgName
  5520. pp.FixmedinsCode = miConfig.Code
  5521. pp.RequestUrl = miConfig.Url
  5522. pp.Cainfo = miConfig.Cainfo
  5523. pp.SecretKey = miConfig.SecretKey
  5524. pp.AccessKey = miConfig.AccessKey
  5525. pp.OpterName = roles.UserName
  5526. var config []*models.HisXtDiagnoseConfig
  5527. for _, item := range diagnosis_ids {
  5528. id, _ := strconv.ParseInt(item, 10, 64)
  5529. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5530. config = append(config, &diagnosisConfig)
  5531. }
  5532. var pd models.PatientDtos
  5533. pd.PatnID = his.PsnNo
  5534. pd.PatnName = his.Name
  5535. pd.Gend = his.Gend
  5536. pd.Brdy = his.Brdy
  5537. pd.Poolarea = his.InsuplcAdmdvs
  5538. pd.CurrMdtrtID = his.Number
  5539. var fed models.FsiEncounterDtos
  5540. fed.MdtrtID = his.Number
  5541. fed.MedinsID = miConfig.Code
  5542. fed.MedinsName = miConfig.OrgName
  5543. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5544. fed.MedMdtrtType = "1"
  5545. fed.MedinsType = "1"
  5546. fed.MedinsLv = "11"
  5547. tm := time.Unix(his.RecordDate, 0)
  5548. s_tm := tm.Format("2006-01-02 15:04:05")
  5549. fed.AdmDate = s_tm
  5550. fed.DscgDate = s_tm
  5551. fed.DscgMainDiseCodg = config[0].CountryCode
  5552. fed.DscgMainDiseName = config[0].CountryContentName
  5553. //诊断信息
  5554. var fdds []*models.FsiDiagnoseDtos
  5555. for index, item := range config {
  5556. if index == 0 {
  5557. var fdd models.FsiDiagnoseDtos
  5558. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5559. fdd.InoutDiseType = "1"
  5560. fdd.MaindiseFlag = "1"
  5561. fdd.DiseDate = s_tm
  5562. fdd.DiasSrtNo = "1"
  5563. fdd.DiseName = item.CountryContentName
  5564. fdd.DiseCodg = item.CountryCode
  5565. fdds = append(fdds, &fdd)
  5566. } else {
  5567. var fdd models.FsiDiagnoseDtos
  5568. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5569. fdd.InoutDiseType = "1"
  5570. fdd.MaindiseFlag = "1"
  5571. fdd.DiseDate = s_tm
  5572. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5573. fdd.DiseName = item.CountryContentName
  5574. fdd.DiseCodg = item.CountryCode
  5575. fdds = append(fdds, &fdd)
  5576. }
  5577. }
  5578. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5579. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5580. fed.AdmDeptName = department.Name
  5581. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5582. fed.DscgDeptName = department.Name
  5583. fed.MedType = order.MedType
  5584. //处方医嘱信息
  5585. var orders []*models.FsiOrderDtos
  5586. //for _, item := range prescriptions {
  5587. // for _, subItem := range item.HisDoctorAdviceInfo {
  5588. // var order models.FsiOrderDtos
  5589. // order.RxID = strconv.FormatInt(item.ID, 10)
  5590. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5591. // order.LongDrordFlag = "0"
  5592. // order.HilistType = "1"
  5593. // order.ChrgType = "1"
  5594. // order.DrordBhvr = "-"
  5595. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5596. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5597. // order.HilistLv = "1"
  5598. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5599. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5600. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5601. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  5602. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5603. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  5604. // order.OwnpayAmt = ""
  5605. // order.SelfpayAmt = ""
  5606. // order.Spec = ""
  5607. // order.SpecUnt = ""
  5608. // order.DrordBegnDate = s_tm
  5609. // order.DrordStopDate = ""
  5610. // order.DrordDrCodg = "1"
  5611. // order.DrordDeptName = department.Name
  5612. // order.DrordDrCodg = "1"
  5613. // order.DrordDrName = doctor_info.UserName
  5614. // order.DrordDrProfttl = ""
  5615. // order.CurrDrordFlag = "1"
  5616. // orders = append(orders, &order)
  5617. // }
  5618. // for _, subItem := range item.HisPrescriptionProject {
  5619. // if subItem.Type == 2 {
  5620. // var order models.FsiOrderDtos
  5621. // order.RxID = strconv.FormatInt(item.ID, 10)
  5622. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5623. // order.LongDrordFlag = "0"
  5624. // order.HilistType = "1"
  5625. // order.ChrgType = "1"
  5626. // order.DrordBhvr = "-"
  5627. // order.HilistCode = subItem.HisProject.MedicalCode
  5628. // order.HosplistName = subItem.HisProject.ProjectName
  5629. // order.HilistLv = "1"
  5630. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5631. // order.HosplistCode = subItem.HisProject.MedicalCode
  5632. // order.HosplistName = subItem.HisProject.ProjectName
  5633. // order.Cnt = subItem.Count
  5634. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5635. //
  5636. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5637. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5638. // order.OwnpayAmt = ""
  5639. // order.SelfpayAmt = ""
  5640. // order.Spec = ""
  5641. // order.SpecUnt = ""
  5642. // order.DrordBegnDate = s_tm
  5643. // order.DrordStopDate = ""
  5644. // order.DrordDrCodg = "1"
  5645. // order.DrordDeptName = department.Name
  5646. // order.DrordDrCodg = "1"
  5647. // order.DrordDrName = doctor_info.UserName
  5648. // order.DrordDrProfttl = ""
  5649. // order.CurrDrordFlag = "1"
  5650. // orders = append(orders, &order)
  5651. //
  5652. // }
  5653. // if subItem.Type == 3 {
  5654. //
  5655. // var order models.FsiOrderDtos
  5656. // order.RxID = strconv.FormatInt(item.ID, 10)
  5657. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5658. // order.LongDrordFlag = "0"
  5659. // order.HilistType = "1"
  5660. // order.ChrgType = "1"
  5661. // order.DrordBhvr = "-"
  5662. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5663. // order.HosplistName = subItem.GoodInfo.GoodName
  5664. // order.HilistLv = "1"
  5665. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5666. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5667. // order.HosplistName = subItem.GoodInfo.GoodName
  5668. // order.Cnt = subItem.Count
  5669. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5670. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5671. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5672. // order.OwnpayAmt = ""
  5673. // order.SelfpayAmt = ""
  5674. // order.Spec = ""
  5675. // order.SpecUnt = ""
  5676. // order.DrordBegnDate = s_tm
  5677. // order.DrordStopDate = ""
  5678. // order.DrordDrCodg = "1"
  5679. // order.DrordDeptName = department.Name
  5680. // order.DrordDrCodg = "1"
  5681. // order.DrordDrName = doctor_info.UserName
  5682. // order.DrordDrProfttl = ""
  5683. // order.CurrDrordFlag = "1"
  5684. // orders = append(orders, &order)
  5685. //
  5686. // }
  5687. // }
  5688. //}
  5689. for _, item := range prescriptions {
  5690. for _, subItem := range item.HisDoctorAdviceInfo {
  5691. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  5692. var order models.FsiOrderDtos
  5693. order.RxID = strconv.FormatInt(item.ID, 10)
  5694. order.Rxno = strconv.FormatInt(item.ID, 10)
  5695. order.LongDrordFlag = "0"
  5696. order.HilistType = "1"
  5697. order.ChrgType = "1"
  5698. order.DrordBhvr = "0"
  5699. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5700. order.HosplistName = subItem.BaseDrugLib.DrugName
  5701. order.HilistLv = "1"
  5702. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5703. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5704. order.HosplistName = subItem.BaseDrugLib.DrugName
  5705. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5706. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5707. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5708. order.OwnpayAmt = ""
  5709. order.SelfpayAmt = ""
  5710. order.Spec = spec
  5711. order.SpecUnt = subItem.PrescribingNumberUnit
  5712. order.DrordBegnDate = s_tm
  5713. order.DrordStopDate = ""
  5714. order.DrordDrCodg = doctor_info.DoctorNumber
  5715. order.DrordDeptName = department.Name
  5716. order.DrordDeptCodg = department.Number
  5717. order.DrordDrName = doctor_info.UserName
  5718. order.DrordDrProfttl = "234"
  5719. order.CurrDrordFlag = "1"
  5720. orders = append(orders, &order)
  5721. }
  5722. for _, subItem := range item.HisPrescriptionProject {
  5723. if subItem.Type == 2 {
  5724. var order models.FsiOrderDtos
  5725. order.RxID = strconv.FormatInt(item.ID, 10)
  5726. order.Rxno = strconv.FormatInt(item.ID, 10)
  5727. order.LongDrordFlag = "0"
  5728. order.HilistType = "1"
  5729. order.ChrgType = "1"
  5730. order.DrordBhvr = "0"
  5731. order.HilistCode = subItem.HisProject.MedicalCode
  5732. order.HosplistName = subItem.HisProject.ProjectName
  5733. order.HilistLv = "1"
  5734. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5735. order.HosplistCode = subItem.HisProject.MedicalCode
  5736. order.HosplistName = subItem.HisProject.ProjectName
  5737. order.Cnt = subItem.Count
  5738. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5739. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5740. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5741. order.OwnpayAmt = ""
  5742. order.SelfpayAmt = ""
  5743. order.Spec = subItem.Unit
  5744. order.SpecUnt = subItem.Unit
  5745. order.DrordBegnDate = s_tm
  5746. order.DrordStopDate = ""
  5747. order.DrordDrCodg = doctor_info.DoctorNumber
  5748. order.DrordDeptName = department.Name
  5749. order.DrordDeptCodg = department.Number
  5750. order.DrordDrName = doctor_info.UserName
  5751. order.DrordDrProfttl = "234"
  5752. order.CurrDrordFlag = "1"
  5753. orders = append(orders, &order)
  5754. }
  5755. if subItem.Type == 3 {
  5756. var order models.FsiOrderDtos
  5757. order.RxID = strconv.FormatInt(item.ID, 10)
  5758. order.Rxno = strconv.FormatInt(item.ID, 10)
  5759. order.LongDrordFlag = "0"
  5760. order.HilistType = "1"
  5761. order.ChrgType = "1"
  5762. order.DrordBhvr = "0"
  5763. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5764. order.HosplistName = subItem.GoodInfo.GoodName
  5765. order.HilistLv = "1"
  5766. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5767. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5768. order.HosplistName = subItem.GoodInfo.GoodName
  5769. order.Cnt = subItem.Count
  5770. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5771. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5772. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5773. order.OwnpayAmt = ""
  5774. order.SelfpayAmt = ""
  5775. order.Spec = subItem.GoodInfo.SpecificationName
  5776. order.SpecUnt = subItem.Unit
  5777. order.DrordBegnDate = s_tm
  5778. order.DrordStopDate = ""
  5779. order.DrordDrCodg = doctor_info.DoctorNumber
  5780. order.DrordDeptName = department.Name
  5781. order.DrordDeptCodg = department.Number
  5782. order.DrordDrName = doctor_info.UserName
  5783. order.DrordDrProfttl = "234"
  5784. order.CurrDrordFlag = "1"
  5785. orders = append(orders, &order)
  5786. }
  5787. }
  5788. }
  5789. //处方医嘱信息
  5790. fed.MatnStas = "0"
  5791. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  5792. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  5793. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  5794. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  5795. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  5796. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  5797. fed.SetlTotlnum = "1"
  5798. fed.Insutype = his.Insutype
  5799. fed.ReimFlag = "0"
  5800. fed.OutSetlFlag = "0"
  5801. var fopd []*models.FsiOperationDtosData
  5802. data := make(map[string]interface{})
  5803. data["fed"] = fed
  5804. data["fdd"] = fdds
  5805. data["fod"] = orders
  5806. data["pd"] = pd
  5807. data["pp"] = pp
  5808. data["fopd"] = fopd
  5809. data["trig_scen"] = trig_scen
  5810. client := &http.Client{}
  5811. bytesData, _ := json.Marshal(data)
  5812. var req *http.Request
  5813. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5814. if miConfig.MdtrtareaAdmvs == "320921" {
  5815. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5816. } else {
  5817. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5818. }
  5819. resp, _ := client.Do(req)
  5820. defer resp.Body.Close()
  5821. body, ioErr := ioutil.ReadAll(resp.Body)
  5822. if ioErr != nil {
  5823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5825. return res
  5826. }
  5827. var respJSON map[string]interface{}
  5828. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5831. return res
  5832. }
  5833. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5834. result, _ := json.Marshal(respJSON)
  5835. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5836. utils.ErrorLog("解析失败:%v", err)
  5837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5838. return res
  5839. }
  5840. return res
  5841. } else {
  5842. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5843. saveLog(output, input, "3102", "事中")
  5844. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5845. utils.ErrorLog("解析失败:%v", err)
  5846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5847. return
  5848. }
  5849. return res
  5850. }
  5851. return res
  5852. }
  5853. func (c *HisApiController) Check() {
  5854. psn_no := c.GetString("psn_no")
  5855. in := c.GetString("in")
  5856. mt := c.GetString("mt")
  5857. baseParams := models.BaseParams{
  5858. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  5859. FixmedinsCode: "H15049901371",
  5860. InsuplcAdmdvs: "150499",
  5861. MdtrtareaAdmvs: "150499",
  5862. OrgName: "赤峰费森血液透析中心",
  5863. Doctor: "1111",
  5864. }
  5865. service.Gdyb2001(baseParams, psn_no, in, mt)
  5866. }
  5867. func (c *HisApiController) GetPsnNcdsInfo() {
  5868. admin_user_id, _ := c.GetInt64("admin_user_id")
  5869. patient_id, _ := c.GetInt64("patient_id")
  5870. id, _ := c.GetInt64("id")
  5871. adminUser := c.GetAdminUserInfo()
  5872. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5873. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5874. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  5875. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5876. psn_record, _ := service.GetPsnNCDSRecordById(id)
  5877. //
  5878. //if psn_record.ID == 0 {
  5879. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  5880. // return
  5881. //}
  5882. var res Result5301
  5883. var res10265 Result5301For10265
  5884. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5885. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5886. var api string
  5887. if miConfig.MdtrtareaAdmvs == "320921" {
  5888. 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 +
  5889. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  5890. } else {
  5891. 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 +
  5892. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  5893. }
  5894. resp, requestErr := http.Get(api)
  5895. if requestErr != nil {
  5896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5897. return
  5898. }
  5899. body, ioErr := ioutil.ReadAll(resp.Body)
  5900. if ioErr != nil {
  5901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5903. return
  5904. }
  5905. var respJSON map[string]interface{}
  5906. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5909. return
  5910. }
  5911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5912. result, _ := json.Marshal(respJSON)
  5913. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5914. utils.ErrorLog("解析失败:%v", err)
  5915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5916. return
  5917. }
  5918. res.ErrMsg = res10265.ErrMsg
  5919. res.Output = res10265.Output
  5920. res.InfRefmsgid = res10265.InfRefmsgid
  5921. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5922. res.Infcode = infocode
  5923. } else if miConfig.MdtrtareaAdmvs == "360399" {
  5924. p, _ := service.GetHisPatientById(patient_id)
  5925. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  5926. var dat map[string]interface{}
  5927. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5928. fmt.Println(dat)
  5929. } else {
  5930. fmt.Println(err)
  5931. }
  5932. userJSONBytes, _ := json.Marshal(dat)
  5933. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5934. utils.ErrorLog("解析失败:%v", err)
  5935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5936. return
  5937. }
  5938. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5939. p, _ := service.GetHisPatientById(patient_id)
  5940. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  5941. var dat map[string]interface{}
  5942. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5943. fmt.Println(dat)
  5944. } else {
  5945. fmt.Println(err)
  5946. }
  5947. userJSONBytes, _ := json.Marshal(dat)
  5948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5949. utils.ErrorLog("解析失败:%v", err)
  5950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5951. return
  5952. }
  5953. } else {
  5954. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  5955. var dat map[string]interface{}
  5956. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5957. fmt.Println(dat)
  5958. } else {
  5959. fmt.Println(err)
  5960. }
  5961. userJSONBytes, _ := json.Marshal(dat)
  5962. if miConfig.Code == "H15049901371" {
  5963. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  5964. utils.ErrorLog("解析失败:%v", err)
  5965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5966. return
  5967. }
  5968. res.InfRefmsgid = res10265.InfRefmsgid
  5969. res.Output = res10265.Output
  5970. res.ErrMsg = res10265.ErrMsg
  5971. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5972. res.Infcode = infocode
  5973. } else {
  5974. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5975. utils.ErrorLog("解析失败:%v", err)
  5976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5977. return
  5978. }
  5979. }
  5980. }
  5981. if res.Infcode == 0 {
  5982. c.ServeSuccessJSON(map[string]interface{}{
  5983. "result": res.Output.Result,
  5984. })
  5985. }
  5986. }
  5987. func (c *HisApiController) CheckInsutype() {
  5988. his_patient_id, _ := c.GetInt64("his_patient_id")
  5989. admin_user_id, _ := c.GetInt64("admin_user_id")
  5990. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5991. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5992. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5993. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  5994. var dat map[string]interface{}
  5995. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5996. fmt.Println(dat)
  5997. } else {
  5998. fmt.Println(err)
  5999. }
  6000. userJSONBytes, _ := json.Marshal(dat)
  6001. var res Result90100
  6002. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6003. utils.ErrorLog("解析失败:%v", err)
  6004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6005. return
  6006. }
  6007. if res.Infcode != 0 {
  6008. c.ServeSuccessJSON(map[string]interface{}{
  6009. "failed_code": -10,
  6010. "msg": res.ErrMsg,
  6011. })
  6012. return
  6013. } else {
  6014. fmt.Println(res)
  6015. }
  6016. }
  6017. func (c *HisApiController) CheckCardPWD() {
  6018. card_pwd := c.GetString("card_pwd")
  6019. his_patient_id, _ := c.GetInt64("his_patient_id")
  6020. admin_user_id, _ := c.GetInt64("admin_user_id")
  6021. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6022. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6023. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6024. psn, _ := service.GetPsnByPatientId(his.PatientId)
  6025. bas := strings.Split(psn.CardInfo, "|")
  6026. basNumber := bas[2]
  6027. if psn.InsuplcAdmdvs[:4] == "4403" {
  6028. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  6029. var dat map[string]interface{}
  6030. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6031. fmt.Println(dat)
  6032. } else {
  6033. fmt.Println(err)
  6034. }
  6035. userJSONBytes, _ := json.Marshal(dat)
  6036. var res Result90991
  6037. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6038. utils.ErrorLog("解析失败:%v", err)
  6039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6040. return
  6041. }
  6042. if res.Infcode != 0 {
  6043. c.ServeSuccessJSON(map[string]interface{}{
  6044. "failed_code": -10,
  6045. "msg": res.ErrMsg,
  6046. })
  6047. return
  6048. } else {
  6049. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  6050. var msg string
  6051. switch res.Output.Result.CardStat {
  6052. case "00":
  6053. msg = "未激活"
  6054. break
  6055. case "10":
  6056. msg = "激活"
  6057. break
  6058. case "20":
  6059. msg = "窗口挂失"
  6060. break
  6061. case "21":
  6062. msg = "电话挂失"
  6063. break
  6064. case "22":
  6065. msg = "单位网上申报挂失"
  6066. break
  6067. case "23":
  6068. msg = "保健办挂失"
  6069. break
  6070. case "24":
  6071. msg = "个人网上挂失"
  6072. break
  6073. case "25":
  6074. msg = "网上服务大厅挂失"
  6075. break
  6076. case "30":
  6077. msg = "注销"
  6078. break
  6079. case "40":
  6080. msg = "回收"
  6081. break
  6082. case "99":
  6083. msg = "制卡中(无效卡)"
  6084. break
  6085. }
  6086. c.ServeSuccessJSON(map[string]interface{}{
  6087. "failed_code": -10,
  6088. "msg": msg,
  6089. })
  6090. return
  6091. } else {
  6092. c.ServeSuccessJSON(map[string]interface{}{
  6093. "msg": "校验成功",
  6094. })
  6095. return
  6096. }
  6097. }
  6098. } else {
  6099. c.ServeSuccessJSON(map[string]interface{}{
  6100. "msg": "校验成功",
  6101. })
  6102. return
  6103. }
  6104. }
  6105. func (c *HisApiController) CheckCardPWDTwo() {
  6106. //card_pwd := c.GetString("card_pwd")
  6107. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6108. admin_user_id, _ := c.GetInt64("admin_user_id")
  6109. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6110. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6111. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  6112. var dat map[string]interface{}
  6113. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6114. fmt.Println(dat)
  6115. } else {
  6116. fmt.Println(err)
  6117. }
  6118. userJSONBytes, _ := json.Marshal(dat)
  6119. var res Result90991
  6120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6121. utils.ErrorLog("解析失败:%v", err)
  6122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6123. return
  6124. }
  6125. if res.Infcode != 0 {
  6126. c.ServeSuccessJSON(map[string]interface{}{
  6127. "failed_code": -10,
  6128. "msg": res.ErrMsg,
  6129. })
  6130. return
  6131. } else {
  6132. if res.Output.Result.SscnoCheckStat == "0" {
  6133. var msg string
  6134. switch res.Output.Result.CardStat {
  6135. case "00":
  6136. msg = "未激活"
  6137. break
  6138. case "10":
  6139. msg = "激活"
  6140. break
  6141. case "20":
  6142. msg = "窗口挂失"
  6143. break
  6144. case "21":
  6145. msg = "电话挂失"
  6146. break
  6147. case "22":
  6148. msg = "单位网上申报挂失"
  6149. break
  6150. case "23":
  6151. msg = "保健办挂失"
  6152. break
  6153. case "24":
  6154. msg = "个人网上挂失"
  6155. break
  6156. case "25":
  6157. msg = "网上服务大厅挂失"
  6158. break
  6159. case "30":
  6160. msg = "注销"
  6161. break
  6162. case "40":
  6163. msg = "回收"
  6164. break
  6165. case "99":
  6166. msg = "制卡中(无效卡)"
  6167. break
  6168. }
  6169. c.ServeSuccessJSON(map[string]interface{}{
  6170. "failed_code": -10,
  6171. "msg": msg,
  6172. })
  6173. return
  6174. } else {
  6175. c.ServeSuccessJSON(map[string]interface{}{
  6176. "msg": "校验成功",
  6177. })
  6178. return
  6179. }
  6180. }
  6181. }
  6182. type ELeCertData struct {
  6183. Data struct {
  6184. Extra string `json:"extra"`
  6185. IDNo string `json:"idNo"`
  6186. IDType string `json:"idType"`
  6187. EcToken string `json:"ecToken"`
  6188. InsuOrg string `json:"insuOrg"`
  6189. UserName string `json:"userName"`
  6190. EcIndexNo string `json:"ecIndexNo"`
  6191. Gender string `json:"gender"`
  6192. Birthday string `json:"birthday"`
  6193. Nationality string `json:"nationality"`
  6194. Email string `json:"email"`
  6195. } `json:"OutData"`
  6196. }
  6197. func (c *HisApiController) ReadCard() {
  6198. id_card_type, _ := c.GetInt64("id_card_type")
  6199. admin_user_id, _ := c.GetInt64("admin_user_id")
  6200. certificates, _ := c.GetInt64("certificates")
  6201. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  6202. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6203. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6204. switch id_card_type {
  6205. case 1:
  6206. if miConfig.MdtrtareaAdmvs == "421300" {
  6207. var res ResultTwo
  6208. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  6209. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6210. "&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)
  6211. resp, requestErr := http.Get(api)
  6212. if requestErr != nil {
  6213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6214. return
  6215. }
  6216. body, ioErr := ioutil.ReadAll(resp.Body)
  6217. if ioErr != nil {
  6218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6220. return
  6221. }
  6222. var respJSON map[string]interface{}
  6223. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6226. return
  6227. }
  6228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6229. result, _ := json.Marshal(respJSON)
  6230. fmt.Println("log")
  6231. fmt.Println(string(result))
  6232. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6233. utils.ErrorLog("解析失败:%v", err)
  6234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6235. return
  6236. }
  6237. if res.Infcode == 0 {
  6238. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6239. if err == gorm.ErrRecordNotFound {
  6240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6241. return
  6242. } else if err != nil {
  6243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6244. return
  6245. } else {
  6246. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6247. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6248. infoStr := string(Iinfos)
  6249. idetinfoStr := string(Idetinfos)
  6250. psn := &models.HisPsn{
  6251. PsnNo: res.Output.Baseinfo.PsnNo,
  6252. Age: res.Output.Baseinfo.Age,
  6253. PatientId: patient.ID,
  6254. Certno: res.Output.Baseinfo.Certno,
  6255. Brdy: res.Output.Baseinfo.Brdy,
  6256. Gend: res.Output.Baseinfo.Gend,
  6257. Naty: res.Output.Baseinfo.Naty,
  6258. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6259. PsnName: res.Output.Baseinfo.PsnName,
  6260. Idetinfo: idetinfoStr,
  6261. Insuinfo: infoStr,
  6262. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6263. }
  6264. service.CreateHisPsn(psn)
  6265. c.ServeSuccessJSON(map[string]interface{}{
  6266. "patient": patient,
  6267. "number": res.Output.Baseinfo.Certno,
  6268. })
  6269. }
  6270. } else {
  6271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6272. return
  6273. }
  6274. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6275. var api string
  6276. if miConfig.MdtrtareaAdmvs == "320921" {
  6277. 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 +
  6278. "&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
  6279. fmt.Println(api)
  6280. } else {
  6281. 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 +
  6282. "&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)
  6283. }
  6284. resp, requestErr := http.Get(api)
  6285. if requestErr != nil {
  6286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6287. return
  6288. }
  6289. body, ioErr := ioutil.ReadAll(resp.Body)
  6290. if ioErr != nil {
  6291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6293. return
  6294. }
  6295. var respJSON map[string]interface{}
  6296. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6299. return
  6300. }
  6301. var status string
  6302. status = respJSON["data"].(map[string]interface{})["status"].(string)
  6303. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  6304. //console.log()
  6305. fmt.Println("type===")
  6306. fmt.Println(card_type)
  6307. var token string
  6308. var res ResultTwo //1101结果
  6309. var res10265 ResultTwo10265 //1101结果
  6310. var card_info string //卡信息
  6311. var busi_card_info string
  6312. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  6313. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  6314. if status == "0" { //读卡成功
  6315. if card_type == "1" {
  6316. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  6317. result, _ := json.Marshal(respJSON)
  6318. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6319. utils.ErrorLog("解析失败:%v", err)
  6320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6321. return
  6322. }
  6323. res.ErrMsg = res10265.ErrMsg
  6324. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6325. res.Infcode = infocode
  6326. res.Output = res10265.Output
  6327. res.InfRefmsgid = res10265.InfRefmsgid
  6328. } else {
  6329. //var card_info string //卡信息
  6330. //var busi_card_info string
  6331. token = respJSON["data"].(map[string]interface{})["token"].(string)
  6332. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  6333. //fmt.Println(card_info)
  6334. //fmt.Println(busi_card_info)
  6335. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  6336. result, _ := json.Marshal(respJSON)
  6337. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6338. utils.ErrorLog("解析失败:%v", err)
  6339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6340. return
  6341. }
  6342. res.ErrMsg = res10265.ErrMsg
  6343. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6344. res.Infcode = infocode
  6345. res.Output = res10265.Output
  6346. res.InfRefmsgid = res10265.InfRefmsgid
  6347. }
  6348. if res.Infcode == 0 {
  6349. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6350. if err == gorm.ErrRecordNotFound {
  6351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6352. return
  6353. } else if err != nil {
  6354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6355. return
  6356. } else {
  6357. if card_type == "1" {
  6358. bas := strings.Split(card_info, "|")
  6359. basNumber := bas[2]
  6360. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6361. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6362. infoStr := string(Iinfos)
  6363. idetinfoStr := string(Idetinfos)
  6364. psn := &models.HisPsn{
  6365. PsnNo: res.Output.Baseinfo.PsnNo,
  6366. Age: res.Output.Baseinfo.Age,
  6367. PatientId: patient.ID,
  6368. Certno: res.Output.Baseinfo.Certno,
  6369. Brdy: res.Output.Baseinfo.Brdy,
  6370. Gend: res.Output.Baseinfo.Gend,
  6371. Naty: res.Output.Baseinfo.Naty,
  6372. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6373. PsnName: res.Output.Baseinfo.PsnName,
  6374. Idetinfo: idetinfoStr,
  6375. Insuinfo: infoStr,
  6376. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6377. CardInfo: card_info,
  6378. VerifyNumber: busi_card_info,
  6379. }
  6380. service.CreateHisPsn(psn)
  6381. var rf []*ResultFive
  6382. json.Unmarshal([]byte(infoStr), &rf)
  6383. var insutypes []*ResultFive
  6384. var insutype string
  6385. var is390 int = 0
  6386. var is310 int = 0
  6387. for _, item := range rf {
  6388. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6389. insutypes = append(insutypes, item)
  6390. }
  6391. }
  6392. if len(insutypes) == 1 {
  6393. insutype = insutypes[0].Insutype
  6394. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6395. } else {
  6396. for _, i := range insutypes {
  6397. if i.Insutype == "390" {
  6398. is390 = 1
  6399. }
  6400. if i.Insutype == "310" {
  6401. is310 = 1
  6402. }
  6403. }
  6404. }
  6405. if is390 == 1 {
  6406. insutype = "390"
  6407. }
  6408. if is310 == 1 {
  6409. insutype = "310"
  6410. }
  6411. if len(insutypes) == 0 {
  6412. insutype = "310"
  6413. }
  6414. c.ServeSuccessJSON(map[string]interface{}{
  6415. "patient": patient,
  6416. "number": basNumber,
  6417. "insutype": insutype,
  6418. })
  6419. } else {
  6420. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6421. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6422. infoStr := string(Iinfos)
  6423. idetinfoStr := string(Idetinfos)
  6424. psn := &models.HisPsn{
  6425. PsnNo: res.Output.Baseinfo.PsnNo,
  6426. Age: res.Output.Baseinfo.Age,
  6427. PatientId: patient.ID,
  6428. Certno: res.Output.Baseinfo.Certno,
  6429. Brdy: res.Output.Baseinfo.Brdy,
  6430. Gend: res.Output.Baseinfo.Gend,
  6431. Naty: res.Output.Baseinfo.Naty,
  6432. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6433. PsnName: res.Output.Baseinfo.PsnName,
  6434. Idetinfo: idetinfoStr,
  6435. Insuinfo: infoStr,
  6436. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6437. CardInfo: card_info,
  6438. VerifyNumber: token,
  6439. }
  6440. service.CreateHisPsn(psn)
  6441. c.ServeSuccessJSON(map[string]interface{}{
  6442. "patient": patient,
  6443. "number": token,
  6444. })
  6445. }
  6446. }
  6447. } else {
  6448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6449. return
  6450. }
  6451. } else { //读卡失败
  6452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6453. return
  6454. }
  6455. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6456. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  6457. cardnum = DeleteExtraSpaceTwo(cardnum)
  6458. cardCode = DeleteExtraSpaceTwo(cardCode)
  6459. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  6460. name = DeleteExtraSpaceTwo(name)
  6461. errmsg = DeleteExtraSpaceTwo(errmsg)
  6462. cardnum = Remove0000(cardnum)
  6463. cardCode = Remove0000(cardCode)
  6464. id_card_no = Remove0000(id_card_no)
  6465. name = Remove0000(name)
  6466. errmsg = Remove0000(errmsg)
  6467. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  6468. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  6469. //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)
  6470. //fmt.Println(result2)
  6471. //fmt.Println(requestLog2)
  6472. //fmt.Println(errMsgLog2)
  6473. 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)
  6474. saveLog(result, requestLog, "1101", "获取人员信息")
  6475. fmt.Println(errMsgLog)
  6476. if len(errMsgLog) > 0 {
  6477. } else {
  6478. var dat map[string]interface{}
  6479. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6480. fmt.Println(dat)
  6481. } else {
  6482. fmt.Println(err)
  6483. }
  6484. userJSONBytes, _ := json.Marshal(dat)
  6485. var res ResultTwo
  6486. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6487. utils.ErrorLog("解析失败:%v", err)
  6488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6489. return
  6490. }
  6491. res.ErrMsg = errMsgLog
  6492. if res.Infcode == 0 {
  6493. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  6494. if err == gorm.ErrRecordNotFound {
  6495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6496. return
  6497. } else if err != nil {
  6498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6499. return
  6500. } else {
  6501. fmt.Println(res)
  6502. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6503. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6504. infoStr := string(Iinfos)
  6505. idetinfoStr := string(Idetinfos)
  6506. var rf []*ResultFive
  6507. json.Unmarshal([]byte(infoStr), &rf)
  6508. var insutypes []*ResultFive
  6509. var insutype string
  6510. var is390 int = 0
  6511. var is310 int = 0
  6512. for _, item := range rf {
  6513. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6514. insutypes = append(insutypes, item)
  6515. }
  6516. }
  6517. if len(insutypes) == 1 {
  6518. insutype = insutypes[0].Insutype
  6519. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6520. } else {
  6521. for _, i := range insutypes {
  6522. if i.Insutype == "390" {
  6523. is390 = 1
  6524. }
  6525. if i.Insutype == "310" {
  6526. is310 = 1
  6527. }
  6528. }
  6529. }
  6530. if is390 == 1 {
  6531. insutype = "390"
  6532. }
  6533. if is310 == 1 {
  6534. insutype = "310"
  6535. }
  6536. if len(insutypes) == 0 {
  6537. insutype = "390"
  6538. }
  6539. var insuplc_admdvs string
  6540. for _, item := range rf {
  6541. if item.Insutype == insutype {
  6542. insuplc_admdvs = item.InsuplcAdmdvs
  6543. }
  6544. }
  6545. psn := &models.HisPsn{
  6546. PsnNo: res.Output.Baseinfo.PsnNo,
  6547. Age: res.Output.Baseinfo.Age,
  6548. PatientId: patient.ID,
  6549. Certno: res.Output.Baseinfo.Certno,
  6550. Brdy: res.Output.Baseinfo.Brdy,
  6551. Gend: res.Output.Baseinfo.Gend,
  6552. Naty: res.Output.Baseinfo.Naty,
  6553. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6554. PsnName: res.Output.Baseinfo.PsnName,
  6555. Idetinfo: idetinfoStr,
  6556. Insuinfo: infoStr,
  6557. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6558. CardInfo: basStr,
  6559. VerifyNumber: "",
  6560. InsuplcAdmdvs: insuplc_admdvs,
  6561. }
  6562. service.CreateHisPsn(psn)
  6563. c.ServeSuccessJSON(map[string]interface{}{
  6564. "patient": patient,
  6565. "number": cardnum,
  6566. "insutype": insutype,
  6567. })
  6568. }
  6569. } else {
  6570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6571. return
  6572. }
  6573. }
  6574. } else if miConfig.MdtrtareaAdmvs == "360399" {
  6575. fmt.Println(initFlag)
  6576. fmt.Println("initFlag")
  6577. if initFlag == 0 {
  6578. c.TestGetJiangXiBasBaseInit()
  6579. }
  6580. basStr := c.GetBasBaseInfo()
  6581. if len(basStr) == 0 {
  6582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  6583. return
  6584. }
  6585. fmt.Println(basStr)
  6586. bas := strings.Split(basStr, "|")
  6587. basNumber := bas[1]
  6588. fmt.Println(basNumber)
  6589. card_sn := bas[3]
  6590. fmt.Println(card_sn)
  6591. 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, "")
  6592. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  6593. var dat map[string]interface{}
  6594. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6595. fmt.Println(dat)
  6596. } else {
  6597. fmt.Println(err)
  6598. }
  6599. userJSONBytes, _ := json.Marshal(dat)
  6600. var res ResultTwo
  6601. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6602. utils.ErrorLog("解析失败:%v", err)
  6603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6604. return
  6605. }
  6606. if res.Infcode == 0 {
  6607. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  6608. if err == gorm.ErrRecordNotFound {
  6609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6610. return
  6611. } else if err != nil {
  6612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6613. return
  6614. } else {
  6615. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6616. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6617. infoStr := string(Iinfos)
  6618. idetinfoStr := string(Idetinfos)
  6619. psn := &models.HisPsn{
  6620. PsnNo: res.Output.Baseinfo.PsnNo,
  6621. Age: res.Output.Baseinfo.Age,
  6622. PatientId: patient.ID,
  6623. Certno: res.Output.Baseinfo.Certno,
  6624. Brdy: res.Output.Baseinfo.Brdy,
  6625. Gend: res.Output.Baseinfo.Gend,
  6626. Naty: res.Output.Baseinfo.Naty,
  6627. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6628. PsnName: res.Output.Baseinfo.PsnName,
  6629. Idetinfo: idetinfoStr,
  6630. Insuinfo: infoStr,
  6631. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6632. CardInfo: basStr,
  6633. VerifyNumber: "",
  6634. }
  6635. service.CreateHisPsn(psn)
  6636. var rf []*ResultFive
  6637. json.Unmarshal([]byte(infoStr), &rf)
  6638. var insutypes []*ResultFive
  6639. var insutype string
  6640. var is390 int = 0
  6641. var is310 int = 0
  6642. for _, item := range rf {
  6643. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6644. insutypes = append(insutypes, item)
  6645. }
  6646. }
  6647. if len(insutypes) == 1 {
  6648. insutype = insutypes[0].Insutype
  6649. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6650. } else {
  6651. for _, i := range insutypes {
  6652. if i.Insutype == "390" {
  6653. is390 = 1
  6654. }
  6655. if i.Insutype == "310" {
  6656. is310 = 1
  6657. }
  6658. }
  6659. }
  6660. if is390 == 1 {
  6661. insutype = "390"
  6662. }
  6663. if is310 == 1 {
  6664. insutype = "310"
  6665. }
  6666. if len(insutypes) == 0 {
  6667. insutype = "310"
  6668. }
  6669. c.ServeSuccessJSON(map[string]interface{}{
  6670. "patient": patient,
  6671. "number": basNumber,
  6672. "insutype": insutype,
  6673. })
  6674. }
  6675. } else {
  6676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6677. return
  6678. }
  6679. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6680. fmt.Println(initFlag)
  6681. fmt.Println("initFlag")
  6682. if initFlag == 0 {
  6683. c.TestGetHnBasBaseInit()
  6684. }
  6685. basStr := c.GetBasBaseInfo()
  6686. if len(basStr) == 0 {
  6687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  6688. return
  6689. }
  6690. fmt.Println(basStr)
  6691. bas := strings.Split(basStr, "|")
  6692. basNumber := bas[1]
  6693. fmt.Println(basNumber)
  6694. card_sn := bas[3]
  6695. card_no := bas[2]
  6696. fmt.Println(card_sn)
  6697. name := bas[4]
  6698. name = ConvertToString(name, "gbk", "utf-8")
  6699. 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)
  6700. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  6701. var dat map[string]interface{}
  6702. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6703. fmt.Println(dat)
  6704. } else {
  6705. fmt.Println(err)
  6706. }
  6707. userJSONBytes, _ := json.Marshal(dat)
  6708. var res ResultTwo
  6709. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6710. utils.ErrorLog("解析失败:%v", err)
  6711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6712. return
  6713. }
  6714. if res.Infcode == 0 {
  6715. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  6716. if err == gorm.ErrRecordNotFound {
  6717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6718. return
  6719. } else if err != nil {
  6720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6721. return
  6722. } else {
  6723. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6724. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6725. infoStr := string(Iinfos)
  6726. idetinfoStr := string(Idetinfos)
  6727. psn := &models.HisPsn{
  6728. PsnNo: res.Output.Baseinfo.PsnNo,
  6729. Age: res.Output.Baseinfo.Age,
  6730. PatientId: patient.ID,
  6731. Certno: res.Output.Baseinfo.Certno,
  6732. Brdy: res.Output.Baseinfo.Brdy,
  6733. Gend: res.Output.Baseinfo.Gend,
  6734. Naty: res.Output.Baseinfo.Naty,
  6735. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6736. PsnName: res.Output.Baseinfo.PsnName,
  6737. Idetinfo: idetinfoStr,
  6738. Insuinfo: infoStr,
  6739. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6740. CardInfo: basStr,
  6741. VerifyNumber: "",
  6742. }
  6743. service.CreateHisPsn(psn)
  6744. var rf []*ResultFive
  6745. json.Unmarshal([]byte(infoStr), &rf)
  6746. var insutypes []*ResultFive
  6747. var insutype string
  6748. var is390 int = 0
  6749. var is310 int = 0
  6750. for _, item := range rf {
  6751. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6752. insutypes = append(insutypes, item)
  6753. }
  6754. }
  6755. if len(insutypes) == 1 {
  6756. insutype = insutypes[0].Insutype
  6757. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6758. } else {
  6759. for _, i := range insutypes {
  6760. if i.Insutype == "390" {
  6761. is390 = 1
  6762. }
  6763. if i.Insutype == "310" {
  6764. is310 = 1
  6765. }
  6766. }
  6767. }
  6768. if is390 == 1 {
  6769. insutype = "390"
  6770. }
  6771. if is310 == 1 {
  6772. insutype = "310"
  6773. }
  6774. if len(insutypes) == 0 {
  6775. insutype = "310"
  6776. }
  6777. c.ServeSuccessJSON(map[string]interface{}{
  6778. "patient": patient,
  6779. "number": basNumber,
  6780. "insutype": insutype,
  6781. })
  6782. }
  6783. } else {
  6784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6785. return
  6786. }
  6787. } else if miConfig.MdtrtareaAdmvs == "150499" {
  6788. var api string
  6789. 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 +
  6790. "&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
  6791. fmt.Println(api)
  6792. resp, requestErr := http.Get(api)
  6793. if requestErr != nil {
  6794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6795. return
  6796. }
  6797. body, ioErr := ioutil.ReadAll(resp.Body)
  6798. if ioErr != nil {
  6799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6801. return
  6802. }
  6803. var respJSON map[string]interface{}
  6804. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6807. return
  6808. }
  6809. var res ResultTwo //1101结果
  6810. var res10265 ResultTwo10265 //1101结果
  6811. var card_info string //卡信息
  6812. token := respJSON["data"].(map[string]interface{})["token"].(string)
  6813. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  6814. result, _ := json.Marshal(respJSON)
  6815. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6816. utils.ErrorLog("解析失败:%v", err)
  6817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6818. return
  6819. }
  6820. res.ErrMsg = res10265.ErrMsg
  6821. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6822. res.Infcode = infocode
  6823. res.Output = res10265.Output
  6824. res.InfRefmsgid = res10265.InfRefmsgid
  6825. if res.Infcode == 0 {
  6826. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6827. if err == gorm.ErrRecordNotFound {
  6828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6829. return
  6830. } else if err != nil {
  6831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6832. return
  6833. } else {
  6834. bas := strings.Split(card_info, "|")
  6835. basNumber := bas[2]
  6836. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6837. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6838. infoStr := string(Iinfos)
  6839. idetinfoStr := string(Idetinfos)
  6840. psn := &models.HisPsn{
  6841. PsnNo: res.Output.Baseinfo.PsnNo,
  6842. Age: res.Output.Baseinfo.Age,
  6843. PatientId: patient.ID,
  6844. Certno: res.Output.Baseinfo.Certno,
  6845. Brdy: res.Output.Baseinfo.Brdy,
  6846. Gend: res.Output.Baseinfo.Gend,
  6847. Naty: res.Output.Baseinfo.Naty,
  6848. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6849. PsnName: res.Output.Baseinfo.PsnName,
  6850. Idetinfo: idetinfoStr,
  6851. Insuinfo: infoStr,
  6852. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6853. CardInfo: card_info,
  6854. VerifyNumber: token,
  6855. }
  6856. service.CreateHisPsn(psn)
  6857. var rf []*ResultFive
  6858. json.Unmarshal([]byte(infoStr), &rf)
  6859. var insutypes []*ResultFive
  6860. var insutype string
  6861. var is390 int = 0
  6862. var is310 int = 0
  6863. for _, item := range rf {
  6864. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6865. insutypes = append(insutypes, item)
  6866. }
  6867. }
  6868. if len(insutypes) == 1 {
  6869. insutype = insutypes[0].Insutype
  6870. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6871. } else {
  6872. for _, i := range insutypes {
  6873. if i.Insutype == "390" {
  6874. is390 = 1
  6875. }
  6876. if i.Insutype == "310" {
  6877. is310 = 1
  6878. }
  6879. }
  6880. }
  6881. if is390 == 1 {
  6882. insutype = "390"
  6883. }
  6884. if is310 == 1 {
  6885. insutype = "310"
  6886. }
  6887. if len(insutypes) == 0 {
  6888. insutype = "310"
  6889. }
  6890. c.ServeSuccessJSON(map[string]interface{}{
  6891. "patient": patient,
  6892. "number": basNumber,
  6893. "insutype": insutype,
  6894. })
  6895. }
  6896. } else {
  6897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6898. return
  6899. }
  6900. } else {
  6901. if initFlag == 0 {
  6902. c.TestGetBasBaseInit()
  6903. }
  6904. basStr := c.GetBasBaseInfo()
  6905. if len(basStr) == 0 {
  6906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  6907. return
  6908. }
  6909. fmt.Println(basStr)
  6910. bas := strings.Split(basStr, "|")
  6911. basNumber := bas[1]
  6912. fmt.Println(basNumber)
  6913. card_sn := bas[3]
  6914. fmt.Println(card_sn)
  6915. cardNumber := bas[2]
  6916. fmt.Println(cardNumber)
  6917. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  6918. var result string
  6919. if bas[0][:2] == "44" {
  6920. 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)
  6921. } else {
  6922. 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)
  6923. }
  6924. var dat map[string]interface{}
  6925. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6926. fmt.Println(dat)
  6927. } else {
  6928. fmt.Println(err)
  6929. }
  6930. userJSONBytes, _ := json.Marshal(dat)
  6931. var res ResultTwo
  6932. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6933. utils.ErrorLog("解析失败:%v", err)
  6934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6935. return
  6936. }
  6937. if res.Infcode == 0 {
  6938. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  6939. if err == gorm.ErrRecordNotFound {
  6940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6941. return
  6942. } else if err != nil {
  6943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6944. return
  6945. } else {
  6946. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6947. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6948. infoStr := string(Iinfos)
  6949. idetinfoStr := string(Idetinfos)
  6950. var rf []*ResultFive
  6951. json.Unmarshal([]byte(infoStr), &rf)
  6952. var insutypes []*ResultFive
  6953. var insutype string
  6954. var is390 int = 0
  6955. var is310 int = 0
  6956. var insuplc_admdvs string
  6957. for _, item := range rf {
  6958. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6959. insutypes = append(insutypes, item)
  6960. }
  6961. }
  6962. if len(insutypes) == 1 {
  6963. insutype = insutypes[0].Insutype
  6964. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6965. } else {
  6966. for _, i := range insutypes {
  6967. if i.Insutype == "390" {
  6968. is390 = 1
  6969. }
  6970. if i.Insutype == "310" {
  6971. is310 = 1
  6972. }
  6973. }
  6974. }
  6975. if is390 == 1 {
  6976. insutype = "390"
  6977. }
  6978. if is310 == 1 {
  6979. insutype = "310"
  6980. }
  6981. if len(insutypes) == 0 {
  6982. insutype = "310"
  6983. }
  6984. for _, item := range rf {
  6985. if item.Insutype == insutype {
  6986. insuplc_admdvs = item.InsuplcAdmdvs
  6987. }
  6988. }
  6989. psn := &models.HisPsn{
  6990. PsnNo: res.Output.Baseinfo.PsnNo,
  6991. Age: res.Output.Baseinfo.Age,
  6992. PatientId: patient.ID,
  6993. Certno: res.Output.Baseinfo.Certno,
  6994. Brdy: res.Output.Baseinfo.Brdy,
  6995. Gend: res.Output.Baseinfo.Gend,
  6996. Naty: res.Output.Baseinfo.Naty,
  6997. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6998. PsnName: res.Output.Baseinfo.PsnName,
  6999. Idetinfo: idetinfoStr,
  7000. Insuinfo: infoStr,
  7001. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7002. CardInfo: basStr,
  7003. VerifyNumber: "",
  7004. InsuplcAdmdvs: insuplc_admdvs,
  7005. }
  7006. service.CreateHisPsn(psn)
  7007. c.ServeSuccessJSON(map[string]interface{}{
  7008. "patient": patient,
  7009. "number": basNumber,
  7010. })
  7011. }
  7012. } else {
  7013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7014. return
  7015. }
  7016. break
  7017. }
  7018. case 2:
  7019. if miConfig.MdtrtareaAdmvs == "430800" {
  7020. if initFlag == 0 {
  7021. c.TestGetHnBasBaseInit()
  7022. }
  7023. SFZStr := c.GetSFZBaseInfo()
  7024. if len(SFZStr) == 0 {
  7025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  7026. return
  7027. }
  7028. fmt.Println(SFZStr)
  7029. id_card_str := strings.Split(SFZStr, "^")
  7030. card_no := id_card_str[0]
  7031. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  7032. //name := id_card_str[1]
  7033. //name = ConvertToString(name, "gbk", "utf-8")
  7034. 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)
  7035. var dat map[string]interface{}
  7036. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7037. fmt.Println(dat)
  7038. } else {
  7039. fmt.Println(err)
  7040. }
  7041. userJSONBytes, _ := json.Marshal(dat)
  7042. var res ResultTwo
  7043. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7044. utils.ErrorLog("解析失败:%v", err)
  7045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7046. return
  7047. }
  7048. if res.Infcode == 0 {
  7049. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  7050. if err == gorm.ErrRecordNotFound {
  7051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7052. return
  7053. } else if err != nil {
  7054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7055. return
  7056. } else {
  7057. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7058. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7059. infoStr := string(Iinfos)
  7060. idetinfoStr := string(Idetinfos)
  7061. psn := &models.HisPsn{
  7062. PsnNo: res.Output.Baseinfo.PsnNo,
  7063. Age: res.Output.Baseinfo.Age,
  7064. PatientId: patient.ID,
  7065. Certno: res.Output.Baseinfo.Certno,
  7066. Brdy: res.Output.Baseinfo.Brdy,
  7067. Gend: res.Output.Baseinfo.Gend,
  7068. Naty: res.Output.Baseinfo.Naty,
  7069. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7070. PsnName: res.Output.Baseinfo.PsnName,
  7071. Idetinfo: idetinfoStr,
  7072. Insuinfo: infoStr,
  7073. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7074. CardInfo: SFZStr,
  7075. VerifyNumber: "",
  7076. }
  7077. service.CreateHisPsn(psn)
  7078. var rf []*ResultFive
  7079. json.Unmarshal([]byte(infoStr), &rf)
  7080. var insutypes []*ResultFive
  7081. var insutype string
  7082. var is390 int = 0
  7083. var is310 int = 0
  7084. for _, item := range rf {
  7085. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7086. insutypes = append(insutypes, item)
  7087. }
  7088. }
  7089. if len(insutypes) == 1 {
  7090. insutype = insutypes[0].Insutype
  7091. } else {
  7092. for _, i := range insutypes {
  7093. if i.Insutype == "390" {
  7094. is390 = 1
  7095. }
  7096. if i.Insutype == "310" {
  7097. is310 = 1
  7098. }
  7099. }
  7100. }
  7101. if is390 == 1 {
  7102. insutype = "390"
  7103. }
  7104. if is310 == 1 {
  7105. insutype = "310"
  7106. }
  7107. if len(insutypes) == 0 {
  7108. insutype = "310"
  7109. }
  7110. c.ServeSuccessJSON(map[string]interface{}{
  7111. "patient": patient,
  7112. "number": card_no,
  7113. "insutype": insutype,
  7114. })
  7115. }
  7116. } else {
  7117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7118. return
  7119. }
  7120. } else {
  7121. SFZStr := c.GetSFZBaseInfo()
  7122. id_card_str := strings.Split(SFZStr, "^")
  7123. id_card_number := id_card_str[0]
  7124. card_sn := ""
  7125. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "")
  7126. var dat map[string]interface{}
  7127. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7128. fmt.Println(dat)
  7129. } else {
  7130. fmt.Println(err)
  7131. }
  7132. userJSONBytes, _ := json.Marshal(dat)
  7133. var res ResultTwo
  7134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7135. utils.ErrorLog("解析失败:%v", err)
  7136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7137. return
  7138. }
  7139. if res.Infcode == 0 {
  7140. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  7141. if err == gorm.ErrRecordNotFound {
  7142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7143. return
  7144. } else if err != nil {
  7145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7146. return
  7147. } else {
  7148. c.ServeSuccessJSON(map[string]interface{}{
  7149. "patient": patient,
  7150. "number": id_card_number,
  7151. })
  7152. }
  7153. } else {
  7154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7155. return
  7156. }
  7157. }
  7158. break
  7159. case 3:
  7160. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7161. var api string
  7162. if miConfig.MdtrtareaAdmvs == "320921" {
  7163. 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 +
  7164. "&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
  7165. fmt.Println(api)
  7166. } else {
  7167. 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 +
  7168. "&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)
  7169. }
  7170. resp, requestErr := http.Get(api)
  7171. if requestErr != nil {
  7172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7173. return
  7174. }
  7175. body, ioErr := ioutil.ReadAll(resp.Body)
  7176. if ioErr != nil {
  7177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7179. return
  7180. }
  7181. var respJSON map[string]interface{}
  7182. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7185. return
  7186. }
  7187. var status string
  7188. status = respJSON["data"].(map[string]interface{})["status"].(string)
  7189. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  7190. var token string
  7191. var res ResultTwo //1101结果
  7192. var res10265 ResultTwo10265 //1101结果
  7193. var card_info string //卡信息
  7194. var busi_card_info string
  7195. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  7196. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7197. if status == "0" { //读卡成功
  7198. if card_type == "1" {
  7199. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7200. result, _ := json.Marshal(respJSON)
  7201. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7202. utils.ErrorLog("解析失败:%v", err)
  7203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7204. return
  7205. }
  7206. res.ErrMsg = res10265.ErrMsg
  7207. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7208. res.Infcode = infocode
  7209. res.Output = res10265.Output
  7210. res.InfRefmsgid = res10265.InfRefmsgid
  7211. } else {
  7212. //var card_info string //卡信息
  7213. //var busi_card_info string
  7214. token = respJSON["data"].(map[string]interface{})["token"].(string)
  7215. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7216. //fmt.Println(card_info)
  7217. //fmt.Println(busi_card_info)
  7218. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7219. result, _ := json.Marshal(respJSON)
  7220. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7221. utils.ErrorLog("解析失败:%v", err)
  7222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7223. return
  7224. }
  7225. res.ErrMsg = res10265.ErrMsg
  7226. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7227. res.Infcode = infocode
  7228. res.Output = res10265.Output
  7229. res.InfRefmsgid = res10265.InfRefmsgid
  7230. }
  7231. if res.Infcode == 0 {
  7232. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7233. if err == gorm.ErrRecordNotFound {
  7234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7235. return
  7236. } else if err != nil {
  7237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7238. return
  7239. } else {
  7240. if card_type == "1" {
  7241. bas := strings.Split(card_info, "|")
  7242. basNumber := bas[2]
  7243. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7244. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7245. infoStr := string(Iinfos)
  7246. idetinfoStr := string(Idetinfos)
  7247. psn := &models.HisPsn{
  7248. PsnNo: res.Output.Baseinfo.PsnNo,
  7249. Age: res.Output.Baseinfo.Age,
  7250. PatientId: patient.ID,
  7251. Certno: res.Output.Baseinfo.Certno,
  7252. Brdy: res.Output.Baseinfo.Brdy,
  7253. Gend: res.Output.Baseinfo.Gend,
  7254. Naty: res.Output.Baseinfo.Naty,
  7255. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7256. PsnName: res.Output.Baseinfo.PsnName,
  7257. Idetinfo: idetinfoStr,
  7258. Insuinfo: infoStr,
  7259. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7260. CardInfo: card_info,
  7261. VerifyNumber: busi_card_info,
  7262. }
  7263. service.CreateHisPsn(psn)
  7264. c.ServeSuccessJSON(map[string]interface{}{
  7265. "patient": patient,
  7266. "number": basNumber,
  7267. })
  7268. } else {
  7269. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7270. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7271. infoStr := string(Iinfos)
  7272. idetinfoStr := string(Idetinfos)
  7273. psn := &models.HisPsn{
  7274. PsnNo: res.Output.Baseinfo.PsnNo,
  7275. Age: res.Output.Baseinfo.Age,
  7276. PatientId: patient.ID,
  7277. Certno: res.Output.Baseinfo.Certno,
  7278. Brdy: res.Output.Baseinfo.Brdy,
  7279. Gend: res.Output.Baseinfo.Gend,
  7280. Naty: res.Output.Baseinfo.Naty,
  7281. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7282. PsnName: res.Output.Baseinfo.PsnName,
  7283. Idetinfo: idetinfoStr,
  7284. Insuinfo: infoStr,
  7285. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7286. CardInfo: card_info,
  7287. VerifyNumber: token,
  7288. }
  7289. service.CreateHisPsn(psn)
  7290. var rf []*ResultFive
  7291. json.Unmarshal([]byte(infoStr), &rf)
  7292. var insutypes []*ResultFive
  7293. var insutype string
  7294. var is390 int = 0
  7295. var is310 int = 0
  7296. for _, item := range rf {
  7297. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7298. insutypes = append(insutypes, item)
  7299. }
  7300. }
  7301. if len(insutypes) == 1 {
  7302. insutype = insutypes[0].Insutype
  7303. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7304. } else {
  7305. for _, i := range insutypes {
  7306. if i.Insutype == "390" {
  7307. is390 = 1
  7308. }
  7309. if i.Insutype == "310" {
  7310. is310 = 1
  7311. }
  7312. }
  7313. }
  7314. if is390 == 1 {
  7315. insutype = "390"
  7316. }
  7317. if is310 == 1 {
  7318. insutype = "310"
  7319. }
  7320. if len(insutypes) == 0 {
  7321. insutype = "310"
  7322. }
  7323. c.ServeSuccessJSON(map[string]interface{}{
  7324. "patient": patient,
  7325. "number": token,
  7326. "insutype": insutype,
  7327. })
  7328. }
  7329. }
  7330. } else {
  7331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7332. return
  7333. }
  7334. } else { //读卡失败
  7335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7336. return
  7337. }
  7338. }
  7339. break
  7340. case 4:
  7341. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7342. var api string
  7343. if miConfig.MdtrtareaAdmvs == "320921" {
  7344. 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 +
  7345. "&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
  7346. fmt.Println(api)
  7347. } else {
  7348. 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 +
  7349. "&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)
  7350. }
  7351. resp, requestErr := http.Get(api)
  7352. if requestErr != nil {
  7353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7354. return
  7355. }
  7356. body, ioErr := ioutil.ReadAll(resp.Body)
  7357. if ioErr != nil {
  7358. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7360. return
  7361. }
  7362. var respJSON map[string]interface{}
  7363. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7364. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7366. return
  7367. }
  7368. var status string
  7369. status = respJSON["data"].(map[string]interface{})["status"].(string)
  7370. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  7371. var token string
  7372. var res ResultTwo //1101结果
  7373. var res10265 ResultTwo10265 //1101结果
  7374. if status == "0" { //读卡成功
  7375. var card_info string //卡信息
  7376. var busi_card_info string
  7377. token = respJSON["data"].(map[string]interface{})["token"].(string)
  7378. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7379. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  7380. fmt.Println(card_info)
  7381. fmt.Println(busi_card_info)
  7382. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7383. result, _ := json.Marshal(respJSON)
  7384. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7385. utils.ErrorLog("解析失败:%v", err)
  7386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7387. return
  7388. }
  7389. res.ErrMsg = res10265.ErrMsg
  7390. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7391. res.Infcode = infocode
  7392. res.Output = res10265.Output
  7393. res.InfRefmsgid = res10265.InfRefmsgid
  7394. if res.Infcode == 0 {
  7395. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7396. if err == gorm.ErrRecordNotFound {
  7397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7398. return
  7399. } else if err != nil {
  7400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7401. return
  7402. } else {
  7403. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7404. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7405. infoStr := string(Iinfos)
  7406. idetinfoStr := string(Idetinfos)
  7407. psn := &models.HisPsn{
  7408. PsnNo: res.Output.Baseinfo.PsnNo,
  7409. Age: res.Output.Baseinfo.Age,
  7410. PatientId: patient.ID,
  7411. Certno: res.Output.Baseinfo.Certno,
  7412. Brdy: res.Output.Baseinfo.Brdy,
  7413. Gend: res.Output.Baseinfo.Gend,
  7414. Naty: res.Output.Baseinfo.Naty,
  7415. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7416. PsnName: res.Output.Baseinfo.PsnName,
  7417. Idetinfo: idetinfoStr,
  7418. Insuinfo: infoStr,
  7419. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7420. CardInfo: card_info,
  7421. VerifyNumber: token,
  7422. }
  7423. var rf []*ResultFive
  7424. json.Unmarshal([]byte(infoStr), &rf)
  7425. var insutypes []*ResultFive
  7426. var insutype string
  7427. var is390 int = 0
  7428. var is310 int = 0
  7429. for _, item := range rf {
  7430. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7431. insutypes = append(insutypes, item)
  7432. }
  7433. }
  7434. if len(insutypes) == 1 {
  7435. insutype = insutypes[0].Insutype
  7436. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7437. } else {
  7438. for _, i := range insutypes {
  7439. if i.Insutype == "390" {
  7440. is390 = 1
  7441. }
  7442. if i.Insutype == "310" {
  7443. is310 = 1
  7444. }
  7445. }
  7446. }
  7447. if is390 == 1 {
  7448. insutype = "390"
  7449. }
  7450. if is310 == 1 {
  7451. insutype = "310"
  7452. }
  7453. if len(insutypes) == 0 {
  7454. insutype = "310"
  7455. }
  7456. service.CreateHisPsn(psn)
  7457. c.ServeSuccessJSON(map[string]interface{}{
  7458. "patient": patient,
  7459. "number": token,
  7460. "insutype": insutype,
  7461. })
  7462. }
  7463. } else {
  7464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7465. return
  7466. }
  7467. } else { //读卡失败
  7468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7469. return
  7470. }
  7471. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7472. idNo := c.GetString("idNo")
  7473. userName := c.GetString("userName")
  7474. ecToken := c.GetString("ecToken")
  7475. insuOrg := c.GetString("insuOrg")
  7476. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  7477. saveLog(result2, requestLog2, "1101", "获取人员信息")
  7478. var res ResultTwo
  7479. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7480. utils.ErrorLog("解析失败:%v", err)
  7481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7482. return
  7483. }
  7484. if res.Infcode == 0 {
  7485. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7486. if err == gorm.ErrRecordNotFound {
  7487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7488. return
  7489. } else if err != nil {
  7490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7491. return
  7492. } else {
  7493. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7494. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7495. infoStr := string(Iinfos)
  7496. idetinfoStr := string(Idetinfos)
  7497. psn := &models.HisPsn{
  7498. PsnNo: res.Output.Baseinfo.PsnNo,
  7499. Age: res.Output.Baseinfo.Age,
  7500. PatientId: patient.ID,
  7501. Certno: res.Output.Baseinfo.Certno,
  7502. Brdy: res.Output.Baseinfo.Brdy,
  7503. Gend: res.Output.Baseinfo.Gend,
  7504. Naty: res.Output.Baseinfo.Naty,
  7505. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7506. PsnName: res.Output.Baseinfo.PsnName,
  7507. Idetinfo: idetinfoStr,
  7508. Insuinfo: infoStr,
  7509. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7510. CardInfo: "",
  7511. Stage: "1",
  7512. VerifyNumber: ecToken,
  7513. InsuplcAdmdvs: insuOrg,
  7514. }
  7515. service.CreateHisPsn(psn)
  7516. var rf []*ResultFive
  7517. json.Unmarshal([]byte(infoStr), &rf)
  7518. var insutypes []*ResultFive
  7519. var insutype string
  7520. var is390 int = 0
  7521. var is310 int = 0
  7522. for _, item := range rf {
  7523. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7524. insutypes = append(insutypes, item)
  7525. }
  7526. }
  7527. if len(insutypes) == 1 {
  7528. insutype = insutypes[0].Insutype
  7529. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7530. } else {
  7531. for _, i := range insutypes {
  7532. if i.Insutype == "390" {
  7533. is390 = 1
  7534. }
  7535. if i.Insutype == "310" {
  7536. is310 = 1
  7537. }
  7538. }
  7539. }
  7540. if is390 == 1 {
  7541. insutype = "390"
  7542. }
  7543. if is310 == 1 {
  7544. insutype = "310"
  7545. }
  7546. if len(insutypes) == 0 {
  7547. insutype = "310"
  7548. }
  7549. c.ServeSuccessJSON(map[string]interface{}{
  7550. "patient": patient,
  7551. "number": ecToken,
  7552. "insutype": insutype,
  7553. })
  7554. }
  7555. } else {
  7556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7557. return
  7558. }
  7559. } else if miConfig.MdtrtareaAdmvs == "360399" {
  7560. //if initFlag == 0 {
  7561. c.TestGetJiangXiBasBaseInit()
  7562. //}
  7563. //if initEleFlag == 0 {
  7564. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  7565. //}
  7566. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  7567. type ELeData struct {
  7568. Data struct {
  7569. IdNo string `json:"idNo"`
  7570. IdType string `json:"idType"`
  7571. UserName string `json:"userName"`
  7572. EcToken string `json:"ecToken"`
  7573. InsuOrg string `json:"insuOrg"`
  7574. Gender string `json:"gender"`
  7575. Birthday string `json:"birthday"`
  7576. Nationality string `json:"nationality"`
  7577. Email string `json:"email"`
  7578. Extra string `json:"extra"`
  7579. } `json:"data"`
  7580. Code int `json:"code"`
  7581. Message string `json:"message"`
  7582. }
  7583. var ele ELeData
  7584. err := json.Unmarshal([]byte(json_result), &ele)
  7585. if err != nil {
  7586. utils.ErrorLog("解析失败:%v", err)
  7587. }
  7588. token := ele.Data.EcToken
  7589. token = Remove0000(token)
  7590. 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)
  7591. saveLog(result2, requestLog2, "1101", "获取人员信息")
  7592. var res ResultTwo
  7593. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7594. utils.ErrorLog("解析失败:%v", err)
  7595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7596. return
  7597. }
  7598. if res.Infcode == 0 {
  7599. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7600. if err == gorm.ErrRecordNotFound {
  7601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7602. return
  7603. } else if err != nil {
  7604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7605. return
  7606. } else {
  7607. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7608. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7609. infoStr := string(Iinfos)
  7610. idetinfoStr := string(Idetinfos)
  7611. psn := &models.HisPsn{
  7612. PsnNo: res.Output.Baseinfo.PsnNo,
  7613. Age: res.Output.Baseinfo.Age,
  7614. PatientId: patient.ID,
  7615. Certno: res.Output.Baseinfo.Certno,
  7616. Brdy: res.Output.Baseinfo.Brdy,
  7617. Gend: res.Output.Baseinfo.Gend,
  7618. Naty: res.Output.Baseinfo.Naty,
  7619. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7620. PsnName: res.Output.Baseinfo.PsnName,
  7621. Idetinfo: idetinfoStr,
  7622. Insuinfo: infoStr,
  7623. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7624. CardInfo: "",
  7625. //RecordDate:
  7626. VerifyNumber: token,
  7627. }
  7628. service.CreateHisPsn(psn)
  7629. var rf []*ResultFive
  7630. json.Unmarshal([]byte(infoStr), &rf)
  7631. var insutypes []*ResultFive
  7632. var insutype string
  7633. var is390 int = 0
  7634. var is310 int = 0
  7635. for _, item := range rf {
  7636. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7637. insutypes = append(insutypes, item)
  7638. }
  7639. }
  7640. if len(insutypes) == 1 {
  7641. insutype = insutypes[0].Insutype
  7642. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7643. } else {
  7644. for _, i := range insutypes {
  7645. if i.Insutype == "390" {
  7646. is390 = 1
  7647. }
  7648. if i.Insutype == "310" {
  7649. is310 = 1
  7650. }
  7651. }
  7652. }
  7653. if is390 == 1 {
  7654. insutype = "390"
  7655. }
  7656. if is310 == 1 {
  7657. insutype = "310"
  7658. }
  7659. if len(insutypes) == 0 {
  7660. insutype = "310"
  7661. }
  7662. c.ServeSuccessJSON(map[string]interface{}{
  7663. "patient": patient,
  7664. "number": token,
  7665. "insutype": insutype,
  7666. })
  7667. }
  7668. } else {
  7669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7670. return
  7671. }
  7672. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7673. //if initFlag == 0 {
  7674. c.TestGetJiangXiBasBaseInit()
  7675. //}
  7676. //if initEleFlag == 0 {
  7677. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  7678. //}
  7679. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  7680. type ELeData struct {
  7681. Data struct {
  7682. IdNo string `json:"idNo"`
  7683. IdType string `json:"idType"`
  7684. UserName string `json:"userName"`
  7685. EcToken string `json:"ecToken"`
  7686. InsuOrg string `json:"insuOrg"`
  7687. Gender string `json:"gender"`
  7688. Birthday string `json:"birthday"`
  7689. Nationality string `json:"nationality"`
  7690. Email string `json:"email"`
  7691. Extra string `json:"extra"`
  7692. } `json:"data"`
  7693. Code int `json:"code"`
  7694. Message string `json:"message"`
  7695. }
  7696. var ele ELeData
  7697. err := json.Unmarshal([]byte(json_result), &ele)
  7698. if err != nil {
  7699. utils.ErrorLog("解析失败:%v", err)
  7700. }
  7701. token := ele.Data.EcToken
  7702. token = Remove0000(token)
  7703. 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)
  7704. saveLog(result2, requestLog2, "1101", "获取人员信息")
  7705. var res ResultTwo
  7706. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7707. utils.ErrorLog("解析失败:%v", err)
  7708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7709. return
  7710. }
  7711. if res.Infcode == 0 {
  7712. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7713. if err == gorm.ErrRecordNotFound {
  7714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7715. return
  7716. } else if err != nil {
  7717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7718. return
  7719. } else {
  7720. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7721. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7722. infoStr := string(Iinfos)
  7723. idetinfoStr := string(Idetinfos)
  7724. psn := &models.HisPsn{
  7725. PsnNo: res.Output.Baseinfo.PsnNo,
  7726. Age: res.Output.Baseinfo.Age,
  7727. PatientId: patient.ID,
  7728. Certno: res.Output.Baseinfo.Certno,
  7729. Brdy: res.Output.Baseinfo.Brdy,
  7730. Gend: res.Output.Baseinfo.Gend,
  7731. Naty: res.Output.Baseinfo.Naty,
  7732. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7733. PsnName: res.Output.Baseinfo.PsnName,
  7734. Idetinfo: idetinfoStr,
  7735. Insuinfo: infoStr,
  7736. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7737. CardInfo: "",
  7738. VerifyNumber: token,
  7739. }
  7740. service.CreateHisPsn(psn)
  7741. var rf []*ResultFive
  7742. json.Unmarshal([]byte(infoStr), &rf)
  7743. var insutypes []*ResultFive
  7744. var insutype string
  7745. var is390 int = 0
  7746. var is310 int = 0
  7747. for _, item := range rf {
  7748. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7749. insutypes = append(insutypes, item)
  7750. }
  7751. }
  7752. if len(insutypes) == 1 {
  7753. insutype = insutypes[0].Insutype
  7754. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7755. } else {
  7756. for _, i := range insutypes {
  7757. if i.Insutype == "390" {
  7758. is390 = 1
  7759. }
  7760. if i.Insutype == "310" {
  7761. is310 = 1
  7762. }
  7763. }
  7764. }
  7765. if is390 == 1 {
  7766. insutype = "390"
  7767. }
  7768. if is310 == 1 {
  7769. insutype = "310"
  7770. }
  7771. if len(insutypes) == 0 {
  7772. insutype = "310"
  7773. }
  7774. c.ServeSuccessJSON(map[string]interface{}{
  7775. "patient": patient,
  7776. "number": token,
  7777. "insutype": insutype,
  7778. })
  7779. }
  7780. } else {
  7781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7782. return
  7783. }
  7784. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7785. type ELeData struct {
  7786. Code string `json:"code"`
  7787. Data struct {
  7788. Aac002 string `json:"aac002"`
  7789. Aaz500 string `json:"aaz500"`
  7790. ActCardNo string `json:"actCardNo"`
  7791. Bab520 string `json:"bab520"`
  7792. Bkz543 string `json:"bkz543"`
  7793. BusinessType string `json:"businessType"`
  7794. CertfCodg string `json:"certfCodg"`
  7795. EcIndexNo string `json:"ecIndexNo"`
  7796. EcToken string `json:"ecToken"`
  7797. ID0000 string `json:"id0000"`
  7798. IDNo string `json:"idNo"`
  7799. IDType string `json:"idType"`
  7800. Idcode string `json:"idcode"`
  7801. IdentityToken string `json:"identity_token"`
  7802. InsuOrg string `json:"insuOrg"`
  7803. OfficeID string `json:"officeId"`
  7804. OfficeName string `json:"officeName"`
  7805. OperatorID string `json:"operatorId"`
  7806. OperatorName string `json:"operatorName"`
  7807. OrgID string `json:"orgId"`
  7808. UserName string `json:"userName"`
  7809. } `json:"data"`
  7810. Infno interface{} `json:"infno"`
  7811. Message string `json:"message"`
  7812. OrgID string `json:"orgId"`
  7813. TransType string `json:"transType"`
  7814. }
  7815. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  7816. outPutInfo = Remove0000(outPutInfo)
  7817. if len(outPutInfo) > 0 {
  7818. var ele ELeData
  7819. err := json.Unmarshal([]byte(outPutInfo), &ele)
  7820. if err != nil {
  7821. utils.ErrorLog("解析失败:%v", err)
  7822. }
  7823. token := ele.Data.EcToken
  7824. fmt.Println(inputInfo)
  7825. fmt.Println(outPutInfo)
  7826. 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)
  7827. saveLog(result, requestLog, "1101", "获取人员信息")
  7828. var dat map[string]interface{}
  7829. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7830. fmt.Println(dat)
  7831. } else {
  7832. fmt.Println(err)
  7833. }
  7834. userJSONBytes, _ := json.Marshal(dat)
  7835. var res ResultTwo
  7836. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7837. utils.ErrorLog("解析失败:%v", err)
  7838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7839. return
  7840. }
  7841. res.ErrMsg = errMsgLog
  7842. if res.Infcode == 0 {
  7843. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  7844. if err == gorm.ErrRecordNotFound {
  7845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7846. return
  7847. } else if err != nil {
  7848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7849. return
  7850. } else {
  7851. fmt.Println(res)
  7852. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7853. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7854. infoStr := string(Iinfos)
  7855. idetinfoStr := string(Idetinfos)
  7856. psn := &models.HisPsn{
  7857. PsnNo: res.Output.Baseinfo.PsnNo,
  7858. Age: res.Output.Baseinfo.Age,
  7859. PatientId: patient.ID,
  7860. Certno: res.Output.Baseinfo.Certno,
  7861. Brdy: res.Output.Baseinfo.Brdy,
  7862. Gend: res.Output.Baseinfo.Gend,
  7863. Naty: res.Output.Baseinfo.Naty,
  7864. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7865. PsnName: res.Output.Baseinfo.PsnName,
  7866. Idetinfo: idetinfoStr,
  7867. Insuinfo: infoStr,
  7868. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7869. CardInfo: outPutInfo,
  7870. VerifyNumber: token,
  7871. InsuplcAdmdvs: ele.Data.InsuOrg,
  7872. }
  7873. service.CreateHisPsn(psn)
  7874. var rf []*ResultFive
  7875. json.Unmarshal([]byte(infoStr), &rf)
  7876. var insutypes []*ResultFive
  7877. var insutype string
  7878. var is390 int = 0
  7879. var is310 int = 0
  7880. for _, item := range rf {
  7881. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7882. insutypes = append(insutypes, item)
  7883. }
  7884. }
  7885. if len(insutypes) == 1 {
  7886. insutype = insutypes[0].Insutype
  7887. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7888. } else {
  7889. for _, i := range insutypes {
  7890. if i.Insutype == "390" {
  7891. is390 = 1
  7892. }
  7893. if i.Insutype == "310" {
  7894. is310 = 1
  7895. }
  7896. }
  7897. }
  7898. if is390 == 1 {
  7899. insutype = "390"
  7900. }
  7901. if is310 == 1 {
  7902. insutype = "310"
  7903. }
  7904. if len(insutypes) == 0 {
  7905. insutype = "310"
  7906. }
  7907. c.ServeSuccessJSON(map[string]interface{}{
  7908. "patient": patient,
  7909. "number": token,
  7910. "insutype": insutype,
  7911. })
  7912. }
  7913. } else {
  7914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7915. return
  7916. }
  7917. }
  7918. } else if miConfig.MdtrtareaAdmvs == "150499" {
  7919. var api string
  7920. 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 +
  7921. "&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
  7922. resp, requestErr := http.Get(api)
  7923. if requestErr != nil {
  7924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7925. return
  7926. }
  7927. body, ioErr := ioutil.ReadAll(resp.Body)
  7928. if ioErr != nil {
  7929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7931. return
  7932. }
  7933. var respJSON map[string]interface{}
  7934. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7937. return
  7938. }
  7939. var status string
  7940. status = respJSON["data"].(map[string]interface{})["status"].(string)
  7941. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  7942. var token string
  7943. var res ResultTwo //1101结果
  7944. var res10265 ResultTwo10265 //1101结果
  7945. if status == "0" { //读卡成功
  7946. var card_info string //卡信息
  7947. var busi_card_info string
  7948. token = respJSON["data"].(map[string]interface{})["token"].(string)
  7949. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7950. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  7951. fmt.Println(card_info)
  7952. fmt.Println(busi_card_info)
  7953. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7954. result, _ := json.Marshal(respJSON)
  7955. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7956. utils.ErrorLog("解析失败:%v", err)
  7957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7958. return
  7959. }
  7960. res.ErrMsg = res10265.ErrMsg
  7961. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7962. res.Infcode = infocode
  7963. res.Output = res10265.Output
  7964. res.InfRefmsgid = res10265.InfRefmsgid
  7965. if res.Infcode == 0 {
  7966. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7967. if err == gorm.ErrRecordNotFound {
  7968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7969. return
  7970. } else if err != nil {
  7971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7972. return
  7973. } else {
  7974. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7975. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7976. infoStr := string(Iinfos)
  7977. idetinfoStr := string(Idetinfos)
  7978. psn := &models.HisPsn{
  7979. PsnNo: res.Output.Baseinfo.PsnNo,
  7980. Age: res.Output.Baseinfo.Age,
  7981. PatientId: patient.ID,
  7982. Certno: res.Output.Baseinfo.Certno,
  7983. Brdy: res.Output.Baseinfo.Brdy,
  7984. Gend: res.Output.Baseinfo.Gend,
  7985. Naty: res.Output.Baseinfo.Naty,
  7986. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7987. PsnName: res.Output.Baseinfo.PsnName,
  7988. Idetinfo: idetinfoStr,
  7989. Insuinfo: infoStr,
  7990. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7991. CardInfo: card_info,
  7992. VerifyNumber: token,
  7993. }
  7994. var rf []*ResultFive
  7995. json.Unmarshal([]byte(infoStr), &rf)
  7996. var insutypes []*ResultFive
  7997. var insutype string
  7998. var is390 int = 0
  7999. var is310 int = 0
  8000. for _, item := range rf {
  8001. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8002. insutypes = append(insutypes, item)
  8003. }
  8004. }
  8005. if len(insutypes) == 1 {
  8006. insutype = insutypes[0].Insutype
  8007. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8008. } else {
  8009. for _, i := range insutypes {
  8010. if i.Insutype == "390" {
  8011. is390 = 1
  8012. }
  8013. if i.Insutype == "310" {
  8014. is310 = 1
  8015. }
  8016. }
  8017. }
  8018. if is390 == 1 {
  8019. insutype = "390"
  8020. }
  8021. if is310 == 1 {
  8022. insutype = "310"
  8023. }
  8024. if len(insutypes) == 0 {
  8025. insutype = "310"
  8026. }
  8027. service.CreateHisPsn(psn)
  8028. c.ServeSuccessJSON(map[string]interface{}{
  8029. "patient": patient,
  8030. "number": token,
  8031. "insutype": insutype,
  8032. })
  8033. }
  8034. } else {
  8035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8036. return
  8037. }
  8038. } else { //读卡失败
  8039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8040. return
  8041. }
  8042. } else {
  8043. type ELeData struct {
  8044. Code string `json:"code"`
  8045. Data struct {
  8046. Aac002 string `json:"aac002"`
  8047. Aaz500 string `json:"aaz500"`
  8048. ActCardNo string `json:"actCardNo"`
  8049. Bab520 string `json:"bab520"`
  8050. Bkz543 string `json:"bkz543"`
  8051. BusinessType string `json:"businessType"`
  8052. CertfCodg string `json:"certfCodg"`
  8053. EcIndexNo string `json:"ecIndexNo"`
  8054. EcToken string `json:"ecToken"`
  8055. ID0000 string `json:"id0000"`
  8056. IDNo string `json:"idNo"`
  8057. IDType string `json:"idType"`
  8058. Idcode string `json:"idcode"`
  8059. IdentityToken string `json:"identity_token"`
  8060. InsuOrg string `json:"insuOrg"`
  8061. OfficeID string `json:"officeId"`
  8062. OfficeName string `json:"officeName"`
  8063. OperatorID string `json:"operatorId"`
  8064. OperatorName string `json:"operatorName"`
  8065. OrgID string `json:"orgId"`
  8066. UserName string `json:"userName"`
  8067. } `json:"data"`
  8068. Infno interface{} `json:"infno"`
  8069. Message string `json:"message"`
  8070. OrgID string `json:"orgId"`
  8071. TransType string `json:"transType"`
  8072. }
  8073. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  8074. fmt.Println(result)
  8075. outPutInfo := Remove0000(result)
  8076. fmt.Println(outPutInfo)
  8077. if len(outPutInfo) > 0 {
  8078. var ele ELeData
  8079. err := json.Unmarshal([]byte(outPutInfo), &ele)
  8080. if err != nil {
  8081. utils.ErrorLog("解析失败:%v", err)
  8082. }
  8083. token := ele.Data.EcToken
  8084. fmt.Println(outPutInfo)
  8085. result, requestLog := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  8086. saveLog(result, requestLog, "1101", "获取人员信息")
  8087. var dat map[string]interface{}
  8088. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8089. fmt.Println(dat)
  8090. } else {
  8091. fmt.Println(err)
  8092. }
  8093. userJSONBytes, _ := json.Marshal(dat)
  8094. var res ResultTwo
  8095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8096. utils.ErrorLog("解析失败:%v", err)
  8097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8098. return
  8099. }
  8100. if res.Infcode == 0 {
  8101. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  8102. if err == gorm.ErrRecordNotFound {
  8103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8104. return
  8105. } else if err != nil {
  8106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8107. return
  8108. } else {
  8109. fmt.Println(res)
  8110. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8111. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8112. infoStr := string(Iinfos)
  8113. idetinfoStr := string(Idetinfos)
  8114. psn := &models.HisPsn{
  8115. PsnNo: res.Output.Baseinfo.PsnNo,
  8116. Age: res.Output.Baseinfo.Age,
  8117. PatientId: patient.ID,
  8118. Certno: res.Output.Baseinfo.Certno,
  8119. Brdy: res.Output.Baseinfo.Brdy,
  8120. Gend: res.Output.Baseinfo.Gend,
  8121. Naty: res.Output.Baseinfo.Naty,
  8122. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8123. PsnName: res.Output.Baseinfo.PsnName,
  8124. Idetinfo: idetinfoStr,
  8125. Insuinfo: infoStr,
  8126. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8127. CardInfo: outPutInfo,
  8128. VerifyNumber: token,
  8129. InsuplcAdmdvs: ele.Data.InsuOrg,
  8130. }
  8131. service.CreateHisPsn(psn)
  8132. var rf []*ResultFive
  8133. json.Unmarshal([]byte(infoStr), &rf)
  8134. var insutypes []*ResultFive
  8135. var insutype string
  8136. var is390 int = 0
  8137. var is310 int = 0
  8138. for _, item := range rf {
  8139. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8140. insutypes = append(insutypes, item)
  8141. }
  8142. }
  8143. if len(insutypes) == 1 {
  8144. insutype = insutypes[0].Insutype
  8145. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8146. } else {
  8147. for _, i := range insutypes {
  8148. if i.Insutype == "390" {
  8149. is390 = 1
  8150. }
  8151. if i.Insutype == "310" {
  8152. is310 = 1
  8153. }
  8154. }
  8155. }
  8156. if is390 == 1 {
  8157. insutype = "390"
  8158. }
  8159. if is310 == 1 {
  8160. insutype = "310"
  8161. }
  8162. if len(insutypes) == 0 {
  8163. insutype = "310"
  8164. }
  8165. c.ServeSuccessJSON(map[string]interface{}{
  8166. "patient": patient,
  8167. "number": token,
  8168. "insutype": insutype,
  8169. })
  8170. }
  8171. } else {
  8172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8173. return
  8174. }
  8175. }
  8176. //fmt.Println(result)
  8177. //
  8178. //if initFlag == 0 {
  8179. // c.TestGetBasBaseInit()
  8180. //}
  8181. //token := c.GetEleBaseInfo()
  8182. //
  8183. //token = Remove0000(token)
  8184. //
  8185. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  8186. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  8187. ////
  8188. //var res ResultTwo
  8189. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8190. // utils.ErrorLog("解析失败:%v", err)
  8191. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8192. // return
  8193. //}
  8194. //
  8195. //if res.Infcode == 0 {
  8196. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8197. // if err == gorm.ErrRecordNotFound {
  8198. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8199. // return
  8200. // } else if err != nil {
  8201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8202. // return
  8203. //
  8204. // } else {
  8205. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8206. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8207. // infoStr := string(Iinfos)
  8208. // idetinfoStr := string(Idetinfos)
  8209. //
  8210. //
  8211. //
  8212. //
  8213. // var rf []*ResultFive
  8214. // json.Unmarshal([]byte(infoStr), &rf)
  8215. //
  8216. // var insutypes []*ResultFive
  8217. // var insutype string
  8218. // var is390 int = 0
  8219. // var is310 int = 0
  8220. // var insuplc_admdvs string
  8221. //
  8222. // for _, item := range rf {
  8223. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8224. // insutypes = append(insutypes, item)
  8225. // }
  8226. // }
  8227. //
  8228. // if len(insutypes) == 1 {
  8229. // insutype = insutypes[0].Insutype
  8230. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8231. // } else {
  8232. // for _, i := range insutypes {
  8233. // if i.Insutype == "390" {
  8234. // is390 = 1
  8235. // }
  8236. //
  8237. // if i.Insutype == "310" {
  8238. // is310 = 1
  8239. // }
  8240. // }
  8241. // }
  8242. // if is390 == 1 {
  8243. // insutype = "390"
  8244. // }
  8245. //
  8246. // if is310 == 1 {
  8247. // insutype = "310"
  8248. // }
  8249. // if len(insutypes) == 0 {
  8250. // insutype = "310"
  8251. // }
  8252. // for _, item := range rf {
  8253. // if item.Insutype == insutype {
  8254. // insuplc_admdvs = item.InsuplcAdmdvs
  8255. // }
  8256. // }
  8257. // psn := &models.HisPsn{
  8258. // PsnNo: res.Output.Baseinfo.PsnNo,
  8259. // Age: res.Output.Baseinfo.Age,
  8260. // PatientId: patient.ID,
  8261. // Certno: res.Output.Baseinfo.Certno,
  8262. // Brdy: res.Output.Baseinfo.Brdy,
  8263. // Gend: res.Output.Baseinfo.Gend,
  8264. // Naty: res.Output.Baseinfo.Naty,
  8265. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8266. // PsnName: res.Output.Baseinfo.PsnName,
  8267. // Idetinfo: idetinfoStr,
  8268. // Insuinfo: infoStr,
  8269. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8270. // CardInfo: "",
  8271. // VerifyNumber: token,
  8272. // InsuplcAdmdvs: insuplc_admdvs,
  8273. // }
  8274. // service.CreateHisPsn(psn)
  8275. //
  8276. // c.ServeSuccessJSON(map[string]interface{}{
  8277. // "patient": patient,
  8278. // "number": token,
  8279. // })
  8280. // }
  8281. //} else {
  8282. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8283. // return
  8284. //}
  8285. }
  8286. break
  8287. }
  8288. }
  8289. var initFlag int64 = 0
  8290. var initEleFlag int64 = 0
  8291. func (c *HisApiController) TestGetBasBaseInit() {
  8292. DllDef := syscall.MustLoadDLL("SSCard.dll")
  8293. Iinit := DllDef.MustFindProc("Init")
  8294. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8295. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  8296. if ret != 0 {
  8297. fmt.Println("SSCard的报错原因:", err)
  8298. fmt.Println("SSCard的运算结果为:", ret)
  8299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8300. return
  8301. }
  8302. result := int(ret)
  8303. fmt.Println("SSCard的运算结果为1:", result)
  8304. initFlag = 1
  8305. return
  8306. }
  8307. func (c *HisApiController) HandleJiangXiReadCard() {
  8308. fmt.Println("~~~~~~")
  8309. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8310. admin_user_id, _ := c.GetInt64("admin_user_id")
  8311. id_card_type, _ := c.GetInt64("id_card_type")
  8312. //certificates, _ := c.GetInt64("certificates")
  8313. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8314. if initFlag == 0 {
  8315. c.TestGetJiangXiBasBaseInit()
  8316. }
  8317. basStr := c.GetBasBaseInfo()
  8318. if len(basStr) == 0 {
  8319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8320. return
  8321. }
  8322. fmt.Println(basStr)
  8323. bas := strings.Split(basStr, "|")
  8324. basNumber := bas[1]
  8325. fmt.Println(basNumber)
  8326. card_sn := bas[3]
  8327. fmt.Println(card_sn)
  8328. 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, "")
  8329. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8330. var dat map[string]interface{}
  8331. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8332. fmt.Println(dat)
  8333. } else {
  8334. fmt.Println(err)
  8335. }
  8336. userJSONBytes, _ := json.Marshal(dat)
  8337. var res ResultTwo
  8338. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8339. utils.ErrorLog("解析失败:%v", err)
  8340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8341. return
  8342. }
  8343. if res.Infcode == 0 {
  8344. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8345. if err == gorm.ErrRecordNotFound {
  8346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8347. return
  8348. } else if err != nil {
  8349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8350. return
  8351. } else {
  8352. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8353. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8354. infoStr := string(Iinfos)
  8355. idetinfoStr := string(Idetinfos)
  8356. psn := &models.HisPsn{
  8357. PsnNo: res.Output.Baseinfo.PsnNo,
  8358. Age: res.Output.Baseinfo.Age,
  8359. PatientId: patient.ID,
  8360. Certno: res.Output.Baseinfo.Certno,
  8361. Brdy: res.Output.Baseinfo.Brdy,
  8362. Gend: res.Output.Baseinfo.Gend,
  8363. Naty: res.Output.Baseinfo.Naty,
  8364. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8365. PsnName: res.Output.Baseinfo.PsnName,
  8366. Idetinfo: idetinfoStr,
  8367. Insuinfo: infoStr,
  8368. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8369. CardInfo: basStr,
  8370. VerifyNumber: "",
  8371. }
  8372. service.CreateHisPsn(psn)
  8373. c.ServeSuccessJSON(map[string]interface{}{
  8374. "patient": patient,
  8375. "number": basNumber,
  8376. })
  8377. }
  8378. } else {
  8379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8380. return
  8381. }
  8382. }
  8383. func (c *HisApiController) TestGetHnBasBaseInit() {
  8384. DllDef := syscall.MustLoadDLL("SSCard.dll")
  8385. Iinit := DllDef.MustFindProc("Init")
  8386. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8387. //http://10.77.211.236/CSB/hsa-fsi-1303
  8388. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  8389. if ret != 0 {
  8390. fmt.Println("SSCard的报错原因:", err)
  8391. fmt.Println("SSCard的运算结果为:", ret)
  8392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8393. return
  8394. }
  8395. result := int(ret)
  8396. fmt.Println("SSCard的运算结果为1:", result)
  8397. initFlag = 1
  8398. return
  8399. }
  8400. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  8401. DllDef := syscall.MustLoadDLL("SSCard.dll")
  8402. Iinit := DllDef.MustFindProc("Init")
  8403. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8404. //http://10.77.211.236/CSB/hsa-fsi-1303
  8405. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  8406. if ret != 0 {
  8407. fmt.Println("SSCard的报错原因:", err)
  8408. fmt.Println("SSCard的运算结果为:", ret)
  8409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8410. return
  8411. }
  8412. result := int(ret)
  8413. fmt.Println("SSCard的运算结果为1:", result)
  8414. initFlag = 1
  8415. return
  8416. }
  8417. func (c *HisApiController) GetSFZBaseInfo() string {
  8418. DllDef := syscall.MustLoadDLL("SSCard.dll")
  8419. readCard := DllDef.MustFindProc("ReadSFZ")
  8420. if readCard == nil {
  8421. fmt.Println("readcard is nil")
  8422. readCard = DllDef.MustFindProc("ReadSFZ")
  8423. }
  8424. str := make([]byte, 8096)
  8425. str1 := make([]byte, 8096)
  8426. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  8427. fmt.Println(r)
  8428. return Remove0000(string(str))
  8429. }
  8430. func (c *HisApiController) GetEleBaseInfo() string {
  8431. DllDef := syscall.MustLoadDLL("SSCard.dll")
  8432. readCard := DllDef.MustFindProc("GetQRBase")
  8433. fmt.Println(readCard)
  8434. if readCard == nil {
  8435. fmt.Println("readcard is nil")
  8436. readCard = DllDef.MustFindProc("GetQRBase")
  8437. }
  8438. str := make([]byte, 1024)
  8439. str1 := make([]byte, 1024)
  8440. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  8441. fmt.Println(ret2)
  8442. fmt.Println(string(str1))
  8443. fmt.Println(string(str))
  8444. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  8445. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  8446. if ret2 != 0 {
  8447. return ""
  8448. }
  8449. return string(str)
  8450. }
  8451. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  8452. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  8453. readCard := DllDef.MustFindProc("NationEcTrans")
  8454. fmt.Println(readCard)
  8455. fmt.Println("!!!!!")
  8456. pBusiCardInfo := make([]byte, 2048)
  8457. input := make(map[string]interface{})
  8458. inputData := make(map[string]interface{})
  8459. inputData["orgId"] = code
  8460. inputData["businessType"] = "01101"
  8461. inputData["operatorId"] = "1"
  8462. inputData["operatorName"] = "admin"
  8463. inputData["officeId"] = "001"
  8464. inputData["officeName"] = "血透室"
  8465. inputData["deviceType"] = ""
  8466. input["data"] = inputData
  8467. input["orgId"] = code
  8468. input["transType"] = "ec.query"
  8469. bytesData, _ := json.Marshal(input)
  8470. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  8471. fmt.Println(ret2)
  8472. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  8473. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  8474. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  8475. }
  8476. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  8477. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  8478. readCard := DllDef.MustFindProc("NationEcTrans")
  8479. fmt.Println(readCard)
  8480. fmt.Println("!!!!!")
  8481. pBusiCardInfo := make([]byte, 2048)
  8482. input := make(map[string]interface{})
  8483. inputData := make(map[string]interface{})
  8484. inputData["orgId"] = code
  8485. inputData["businessType"] = "01101"
  8486. inputData["operatorId"] = "9"
  8487. inputData["operatorName"] = "admin"
  8488. inputData["officeId"] = "001"
  8489. inputData["officeName"] = "血透室"
  8490. inputData["deviceType"] = ""
  8491. input["data"] = inputData
  8492. input["orgId"] = code
  8493. input["transType"] = "ec.query"
  8494. bytesData, _ := json.Marshal(input)
  8495. 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])))
  8496. fmt.Println(ret2)
  8497. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  8498. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  8499. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  8500. }
  8501. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  8502. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  8503. readCard := DllDef.MustFindProc("NationEcTrans")
  8504. fmt.Println(readCard)
  8505. fmt.Println("!!!!!")
  8506. pBusiCardInfo := make([]byte, 2048)
  8507. input := make(map[string]interface{})
  8508. inputData := make(map[string]interface{})
  8509. inputData["orgId"] = code
  8510. inputData["businessType"] = "01301"
  8511. inputData["operatorId"] = "9"
  8512. inputData["operatorName"] = "admin"
  8513. inputData["officeId"] = "001"
  8514. inputData["officeName"] = "血透室"
  8515. inputData["deviceType"] = ""
  8516. input["data"] = inputData
  8517. input["orgId"] = code
  8518. input["transType"] = "ec.query"
  8519. bytesData, _ := json.Marshal(input)
  8520. 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])))
  8521. fmt.Println(ret2)
  8522. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  8523. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  8524. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  8525. }
  8526. func GetJxEleBaseInfo(org_id int64) string {
  8527. DllDef := syscall.MustLoadDLL("SSCard.dll")
  8528. readCard := DllDef.MustFindProc("NationEcTrans")
  8529. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  8530. if readCard == nil {
  8531. fmt.Println("readcard is nil")
  8532. readCard = DllDef.MustFindProc("NationEcTrans")
  8533. }
  8534. str1 := make([]byte, 1024)
  8535. data := make(map[string]interface{})
  8536. inputData := make(map[string]interface{})
  8537. inputData["orgId"] = miConfig.Code
  8538. inputData["businessType"] = "01101"
  8539. inputData["operatorId"] = "test001"
  8540. inputData["operatorName"] = "cn"
  8541. inputData["officeId"] = "32760"
  8542. inputData["officeName"] = "waike"
  8543. inputData["deviceType"] = ""
  8544. data["data"] = inputData
  8545. data["transType"] = "ec.query"
  8546. data["extra "] = ""
  8547. data["orgId"] = miConfig.Code
  8548. bytesData, _ := json.Marshal(data)
  8549. //bytesData, _ := json.Marshal(data)
  8550. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  8551. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  8552. fmt.Println(ret2)
  8553. fmt.Println(string(str1))
  8554. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  8555. if ret2 != 0 {
  8556. return ""
  8557. }
  8558. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  8559. }
  8560. func GetJxEleBaseInitInfo(org_id int64) string {
  8561. DllDef := syscall.MustLoadDLL("SSCard.dll")
  8562. readCard := DllDef.MustFindProc("NationEcTrans")
  8563. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  8564. if readCard == nil {
  8565. fmt.Println("readcard is nil")
  8566. readCard = DllDef.MustFindProc("NationEcTrans")
  8567. }
  8568. str1 := make([]byte, 2048)
  8569. data := make(map[string]interface{})
  8570. inputData := make(map[string]interface{})
  8571. inputData["orgId"] = miConfig.Code
  8572. inputData["businessType"] = "01101"
  8573. inputData["operatorId"] = "1"
  8574. inputData["operatorName"] = "huangchuang"
  8575. inputData["officeId"] = "101"
  8576. inputData["officeName"] = "xuetou"
  8577. inputData["deviceType"] = ""
  8578. data["data"] = inputData
  8579. data["transType"] = "ec.query"
  8580. data["orgId"] = miConfig.Code
  8581. bytesData, _ := json.Marshal(data)
  8582. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  8583. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  8584. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  8585. fmt.Println(ret2)
  8586. fmt.Println(string(str1))
  8587. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  8588. if ret2 != 0 {
  8589. return ""
  8590. }
  8591. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  8592. initEleFlag = 1
  8593. }
  8594. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  8595. }
  8596. func (c *HisApiController) GetBasBaseInfo() string {
  8597. DllDef := syscall.MustLoadDLL("SSCard.dll")
  8598. readCard := DllDef.MustFindProc("ReadCardBas")
  8599. if readCard == nil {
  8600. fmt.Println("readcard is nil")
  8601. readCard = DllDef.MustFindProc("ReadCardBas")
  8602. }
  8603. str := make([]byte, 1024)
  8604. str1 := make([]byte, 1024)
  8605. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  8606. fmt.Println(string(str1))
  8607. fmt.Println(string(str))
  8608. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  8609. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  8610. if ret2 != 0 {
  8611. return ""
  8612. }
  8613. return string(str)
  8614. }
  8615. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  8616. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  8617. readCard := DllDef.MustFindProc("read_cardinfo")
  8618. if readCard == nil {
  8619. fmt.Println("readcard is nil")
  8620. readCard = DllDef.MustFindProc("read_cardinfo")
  8621. }
  8622. str := make([]byte, 1024) //卡号
  8623. str1 := make([]byte, 1024) //卡识别码
  8624. str2 := make([]byte, 1024) //身份证号
  8625. str3 := make([]byte, 1024) //姓名
  8626. str4 := make([]byte, 1024) //错误信息
  8627. 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])))
  8628. fmt.Println(string(str1))
  8629. fmt.Println(string(str))
  8630. fmt.Println(string(str2))
  8631. fmt.Println(string(str3))
  8632. fmt.Println(string(str4))
  8633. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  8634. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  8635. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  8636. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  8637. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  8638. if ret2 != 0 {
  8639. return "", "", "", "", ""
  8640. }
  8641. return string(str), string(str1), string(str2), string(str3), string(str4)
  8642. }
  8643. type CustomFundPay struct {
  8644. FundPayType string `json:"fund_pay_type"`
  8645. FundPayamt float64 `json:"fund_payamt"`
  8646. }
  8647. func (c *HisApiController) GetSettleList() {
  8648. order_id, _ := c.GetInt64("order_id")
  8649. admin_user_id, _ := c.GetInt64("admin_user_id")
  8650. order, _ := service.GetHisOrderByIDTwo(order_id)
  8651. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  8652. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8653. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  8654. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8655. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  8656. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8657. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8658. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8659. if order.ID == 0 {
  8660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8661. return
  8662. }
  8663. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  8664. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  8665. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  8666. //fmt.Println(count)
  8667. //var zero string
  8668. //number := count + 1
  8669. //if number >= 1000 {
  8670. // zero = "0000" + strconv.FormatInt(number, 10)
  8671. //} else if number >= 10000 {
  8672. // zero = "000" + strconv.FormatInt(number, 10)
  8673. //} else if number >= 100000 {
  8674. // zero = "00" + strconv.FormatInt(number, 10)
  8675. //} else if number >= 1000000 {
  8676. // zero = "0" + strconv.FormatInt(number, 10)
  8677. //} else {
  8678. // zero = strconv.FormatInt(number, 10)
  8679. //}
  8680. //fmt.Println(zero)
  8681. struct4101 := service.Struct4101{
  8682. PsnNo: order.PsnNo,
  8683. MdtrtId: order.MdtrtId,
  8684. SetlId: order.SetlId,
  8685. PsnName: order.PsnName,
  8686. Gend: order.Gend,
  8687. Brdy: his.Brdy,
  8688. Age: his.Age,
  8689. Naty: order.Naty,
  8690. PatnCertType: "01",
  8691. Certno: order.Certno,
  8692. Prfs: "90",
  8693. ConerName: roles[0].UserName,
  8694. PatnRlts: "99",
  8695. ConerAddr: miConfig.OrgName,
  8696. ConerTel: admin.Mobile,
  8697. HiType: order.Insutype,
  8698. Insuplc: miConfig.InsuplcAdmdvs,
  8699. MaindiagFlag: "1",
  8700. BillCode: order.SetlId,
  8701. BillNo: order.SetlId,
  8702. BizSn: order.Number,
  8703. PsnSelfPay: order.PsnPartAmt,
  8704. PsnOwnPay: order.PsnPartAmt,
  8705. AcctPay: order.AcctPay,
  8706. PsnCashpay: order.PsnCashPay,
  8707. HiPaymtd: "1",
  8708. Hsorg: miConfig.InsuplcAdmdvs,
  8709. HsorgOpter: miConfig.InsuplcAdmdvs,
  8710. MedinsFillPsn: curRoles.UserName,
  8711. MedinsFillDept: miConfig.OrgName,
  8712. IptMedType: "2",
  8713. }
  8714. struct4101.SetlBegnDate = order.SetlTime
  8715. struct4101.SetlEndDate = order.SetlTime
  8716. time_arr := strings.Split(order.SetlTime, " ")
  8717. struct4101.AdmTime = time_arr[0]
  8718. struct4101.AdmEndTime = time_arr[0]
  8719. var rf []CustomFundPay
  8720. json.Unmarshal([]byte(order.SetlDetail), &rf)
  8721. var tempFunPays []service.CustomStruct
  8722. for _, item := range rf {
  8723. var tempFunPay service.CustomStruct
  8724. tempFunPay.FundPayamt = item.FundPayamt
  8725. tempFunPay.FundPayType = item.FundPayType
  8726. tempFunPays = append(tempFunPays, tempFunPay)
  8727. }
  8728. struct4101.CustomStruct = tempFunPays
  8729. var tempDiaginfos []service.DiaginfoStructTwo
  8730. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  8731. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  8732. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8733. var config []*models.HisXtDiagnoseConfig
  8734. for _, item := range diagnosis_ids {
  8735. id, _ := strconv.ParseInt(item, 10, 64)
  8736. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8737. config = append(config, &diagnosisConfig)
  8738. }
  8739. for index, item := range config {
  8740. if index == 0 {
  8741. var tempDiaginfo service.DiaginfoStructTwo
  8742. tempDiaginfo.DiagCode = item.CountryCode
  8743. tempDiaginfo.DiagName = item.CountryContentName
  8744. tempDiaginfo.DiagType = "1"
  8745. tempDiaginfo.MaindiagFlag = "1"
  8746. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8747. } else {
  8748. var tempDiaginfo service.DiaginfoStructTwo
  8749. tempDiaginfo.DiagCode = item.CountryCode
  8750. tempDiaginfo.DiagName = item.CountryContentName
  8751. tempDiaginfo.DiagType = "2"
  8752. tempDiaginfo.MaindiagFlag = "0"
  8753. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8754. }
  8755. }
  8756. struct4101.Diseinfo = tempDiaginfos
  8757. sickConfigTwo, _ := service.FindSickById(his.SickType)
  8758. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  8759. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  8760. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  8761. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  8762. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  8763. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  8764. var iteminfo service.IteminfoStruct
  8765. var bedCostTotal float64 = 0 //床位总费
  8766. var bedCostSelfTotal float64 = 0 //床位自费
  8767. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8768. var operationCostTotal float64 = 0 //手术费
  8769. var operationCostSelfTotal float64 = 0 //手术费
  8770. var operationCostPartSelfTotal float64 = 0 //手术费
  8771. var otherCostTotal float64 = 0 //其他费用
  8772. var otherCostSelfTotal float64 = 0 //其他费用
  8773. var otherCostPartSelfTotal float64 = 0 //其他费用
  8774. var materialCostTotal float64 = 0 //材料费
  8775. var materialCostSelfTotal float64 = 0 //材料费
  8776. var materialCostPartSelfTotal float64 = 0 //材料费
  8777. var westernMedicineCostTotal float64 = 0 //西药费
  8778. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8779. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8780. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8781. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8782. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8783. var checkCostTotal float64 = 0 //检查费
  8784. var checkCostSelfTotal float64 = 0 //检查费
  8785. var checkCostPartSelfTotal float64 = 0 //检查费
  8786. var laboratoryCostTotal float64 = 0 //化验费
  8787. var laboratoryCostSelfTotal float64 = 0 //化验费
  8788. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8789. var treatCostTotal float64 = 0 //治疗费用
  8790. var treatCostSelfTotal float64 = 0 //治疗费用
  8791. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8792. decimal.DivisionPrecision = 2
  8793. var bed_fulamt_ownpay_amt float64 = 0
  8794. var operation_fulamt_ownpay_amt float64 = 0
  8795. var other_fulamt_ownpay_amt float64 = 0
  8796. var westernMedicine_fulamt_ownpay_amt float64 = 0
  8797. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  8798. var check_fulamt_ownpay_amt float64 = 0
  8799. var material_fulamt_ownpay_amt float64 = 0
  8800. var laboratory_fulamt_ownpay_amt float64 = 0
  8801. var treat_fulamt_ownpay_amt float64 = 0
  8802. var bed_claa_sunmfee float64 = 0
  8803. var bed_clab_amt float64 = 0
  8804. var bed_other_amt float64 = 0
  8805. var operation_claa_sunmfee float64 = 0
  8806. var operation_clab_amt float64 = 0
  8807. var operation_other_amt float64 = 0
  8808. var other_claa_sunmfee float64 = 0
  8809. var other_clab_amt float64 = 0
  8810. var other_other_amt float64 = 0
  8811. var westernMedicine_claa_sunmfee float64 = 0
  8812. var westernMedicine_clab_amt float64 = 0
  8813. var westernMedicine_other_amt float64 = 0
  8814. var chineseTraditional_claa_sunmfee float64 = 0
  8815. var chineseTraditional_clab_amt float64 = 0
  8816. var chineseTraditional_other_amt float64 = 0
  8817. var check_claa_sunmfee float64 = 0
  8818. var check_clab_amt float64 = 0
  8819. var check_other_amt float64 = 0
  8820. var material_claa_sunmfee float64 = 0
  8821. var material_clab_amt float64 = 0
  8822. var material_other_amt float64 = 0
  8823. var laboratory_claa_sunmfee float64 = 0
  8824. var laboratory_clab_amt float64 = 0
  8825. var laboratory_other_amt float64 = 0
  8826. var treat_claa_sunmfee float64 = 0
  8827. var treat_clab_amt float64 = 0
  8828. var treat_other_amt float64 = 0
  8829. for _, item := range order.HisOrderInfo {
  8830. if item.MedChrgitmType == "01" { //床位费
  8831. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8832. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8833. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8834. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8835. if item.ChrgitmLv == "1" {
  8836. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8837. }
  8838. if item.ChrgitmLv == "2" {
  8839. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8840. }
  8841. if item.ChrgitmLv == "3" {
  8842. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8843. }
  8844. }
  8845. if item.MedChrgitmType == "03" { //检查费
  8846. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8847. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8848. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8849. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8850. if item.ChrgitmLv == "1" {
  8851. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8852. }
  8853. if item.ChrgitmLv == "2" {
  8854. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8855. }
  8856. if item.ChrgitmLv == "3" {
  8857. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8858. }
  8859. }
  8860. if item.MedChrgitmType == "04" { //化验费
  8861. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8862. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8863. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8864. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8865. if item.ChrgitmLv == "1" {
  8866. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8867. }
  8868. if item.ChrgitmLv == "2" {
  8869. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8870. }
  8871. if item.ChrgitmLv == "3" {
  8872. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8873. }
  8874. }
  8875. if item.MedChrgitmType == "05" { //治疗费
  8876. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8877. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8878. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8879. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8880. if item.ChrgitmLv == "1" {
  8881. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8882. }
  8883. if item.ChrgitmLv == "2" {
  8884. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8885. }
  8886. if item.ChrgitmLv == "3" {
  8887. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8888. }
  8889. }
  8890. if item.MedChrgitmType == "06" { //手术费
  8891. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8892. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8893. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8894. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8895. if item.ChrgitmLv == "1" {
  8896. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8897. }
  8898. if item.ChrgitmLv == "2" {
  8899. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8900. }
  8901. if item.ChrgitmLv == "3" {
  8902. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8903. }
  8904. }
  8905. if item.MedChrgitmType == "08" { //材料费
  8906. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8907. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8908. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8909. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8910. if item.ChrgitmLv == "1" {
  8911. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8912. }
  8913. if item.ChrgitmLv == "2" {
  8914. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8915. }
  8916. if item.ChrgitmLv == "3" {
  8917. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8918. }
  8919. }
  8920. if item.MedChrgitmType == "09" { //西药费
  8921. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8922. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8923. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8924. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8925. if item.ChrgitmLv == "1" {
  8926. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8927. }
  8928. if item.ChrgitmLv == "2" {
  8929. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8930. }
  8931. if item.ChrgitmLv == "3" {
  8932. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8933. }
  8934. }
  8935. if item.MedChrgitmType == "11" { //中成费
  8936. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8937. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8938. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8939. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8940. if item.ChrgitmLv == "1" {
  8941. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8942. }
  8943. if item.ChrgitmLv == "2" {
  8944. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8945. }
  8946. if item.ChrgitmLv == "3" {
  8947. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8948. }
  8949. }
  8950. if item.MedChrgitmType == "14" { //其他费
  8951. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8952. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8953. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8954. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8955. if item.ChrgitmLv == "1" {
  8956. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8957. }
  8958. if item.ChrgitmLv == "2" {
  8959. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8960. }
  8961. if item.ChrgitmLv == "3" {
  8962. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8963. }
  8964. }
  8965. }
  8966. var iteminfoStructs []service.IteminfoStruct
  8967. if bedCostTotal != 0 {
  8968. iteminfo.MedChrgitm = "01"
  8969. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  8970. iteminfo.Amt = bedCostTotal
  8971. iteminfo.ClaaSumfee = bed_claa_sunmfee
  8972. iteminfo.ClabAmt = bed_clab_amt
  8973. iteminfo.OthAmt = bed_other_amt
  8974. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8975. }
  8976. if checkCostTotal != 0 {
  8977. iteminfo.MedChrgitm = "03"
  8978. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  8979. iteminfo.Amt = checkCostTotal
  8980. iteminfo.ClaaSumfee = check_claa_sunmfee
  8981. iteminfo.ClabAmt = check_clab_amt
  8982. iteminfo.OthAmt = check_other_amt
  8983. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8984. }
  8985. if laboratoryCostTotal != 0 {
  8986. iteminfo.MedChrgitm = "04"
  8987. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  8988. iteminfo.Amt = laboratoryCostTotal
  8989. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  8990. iteminfo.ClabAmt = laboratory_clab_amt
  8991. iteminfo.OthAmt = laboratory_other_amt
  8992. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8993. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8994. }
  8995. if treatCostTotal != 0 {
  8996. iteminfo.MedChrgitm = "05"
  8997. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  8998. iteminfo.Amt = treatCostTotal
  8999. iteminfo.ClaaSumfee = treat_claa_sunmfee
  9000. iteminfo.ClabAmt = treat_clab_amt
  9001. iteminfo.OthAmt = treat_other_amt
  9002. iteminfoStructs = append(iteminfoStructs, iteminfo)
  9003. //(struct4101.IteminfoStruct, iteminfo)
  9004. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  9005. }
  9006. if operationCostTotal != 0 {
  9007. iteminfo.MedChrgitm = "06"
  9008. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  9009. iteminfo.Amt = operationCostTotal
  9010. iteminfo.ClaaSumfee = operation_claa_sunmfee
  9011. iteminfo.ClabAmt = operation_clab_amt
  9012. iteminfo.OthAmt = operation_other_amt
  9013. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  9014. iteminfoStructs = append(iteminfoStructs, iteminfo)
  9015. }
  9016. if materialCostTotal != 0 {
  9017. iteminfo.MedChrgitm = "08"
  9018. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  9019. iteminfo.Amt = materialCostTotal
  9020. iteminfo.ClaaSumfee = material_claa_sunmfee
  9021. iteminfo.ClabAmt = material_clab_amt
  9022. iteminfo.OthAmt = material_other_amt
  9023. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  9024. iteminfoStructs = append(iteminfoStructs, iteminfo)
  9025. }
  9026. if westernMedicineCostTotal != 0 {
  9027. iteminfo.MedChrgitm = "09"
  9028. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  9029. iteminfo.Amt = westernMedicineCostTotal
  9030. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  9031. iteminfo.ClabAmt = westernMedicine_clab_amt
  9032. iteminfo.OthAmt = westernMedicine_other_amt
  9033. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  9034. iteminfoStructs = append(iteminfoStructs, iteminfo)
  9035. }
  9036. if chineseTraditionalMedicineCostTotal != 0 {
  9037. iteminfo.MedChrgitm = "11"
  9038. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  9039. iteminfo.Amt = westernMedicineCostTotal
  9040. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  9041. iteminfo.ClabAmt = westernMedicine_clab_amt
  9042. iteminfo.OthAmt = westernMedicine_other_amt
  9043. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  9044. iteminfoStructs = append(iteminfoStructs, iteminfo)
  9045. }
  9046. if otherCostTotal != 0 {
  9047. iteminfo.MedChrgitm = "14"
  9048. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  9049. iteminfo.Amt = otherCostTotal
  9050. iteminfo.ClaaSumfee = other_claa_sunmfee
  9051. iteminfo.ClabAmt = other_clab_amt
  9052. iteminfo.OthAmt = other_other_amt
  9053. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  9054. iteminfoStructs = append(iteminfoStructs, iteminfo)
  9055. }
  9056. struct4101.IteminfoStruct = iteminfoStructs
  9057. struct4101.Ntly = "中国"
  9058. struct4101.AdmCaty = "A03.06"
  9059. struct4101.DoctorName = doctor.UserName
  9060. struct4101.DoctorCode = doctor.DoctorNumber
  9061. var res ResultSeventeen
  9062. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9063. struct4101.BillCode = order.Number
  9064. struct4101.BillNo = order.SetlId
  9065. var resOther ResultSeventeenOther
  9066. var pp models.PublicParams
  9067. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9068. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9069. pp.FixmedinsName = miConfig.OrgName
  9070. pp.FixmedinsCode = miConfig.Code
  9071. pp.RequestUrl = miConfig.Url
  9072. pp.Cainfo = miConfig.Cainfo
  9073. pp.SecretKey = miConfig.SecretKey
  9074. pp.AccessKey = miConfig.AccessKey
  9075. pp.OpterName = curRoles.UserName
  9076. client := &http.Client{}
  9077. var req *http.Request
  9078. data := make(map[string]interface{})
  9079. data["struct4101"] = struct4101
  9080. data["pp"] = pp
  9081. bytesData, _ := json.Marshal(data)
  9082. if miConfig.MdtrtareaAdmvs == "320921" {
  9083. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  9084. } else {
  9085. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  9086. }
  9087. resp, _ := client.Do(req)
  9088. defer resp.Body.Close()
  9089. body, ioErr := ioutil.ReadAll(resp.Body)
  9090. if ioErr != nil {
  9091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9093. return
  9094. }
  9095. var respJSON map[string]interface{}
  9096. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9099. return
  9100. }
  9101. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  9102. userJSONBytes, _ := json.Marshal(respJSON)
  9103. fmt.Println("log")
  9104. fmt.Println(string(userJSONBytes))
  9105. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  9106. utils.ErrorLog("解析失败:%v", err)
  9107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9108. return
  9109. }
  9110. res.InfRefmsgid = resOther.InfRefmsgid
  9111. res.Output = resOther.Output
  9112. res.ErrMsg = resOther.ErrMsg
  9113. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  9114. res.Infcode = infocode
  9115. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9116. var pp models.PublicParams
  9117. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9118. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9119. pp.FixmedinsName = miConfig.OrgName
  9120. pp.FixmedinsCode = miConfig.Code
  9121. pp.RequestUrl = miConfig.Url
  9122. pp.Cainfo = miConfig.Cainfo
  9123. pp.SecretKey = miConfig.SecretKey
  9124. pp.AccessKey = miConfig.AccessKey
  9125. pp.OpterName = curRoles.UserName
  9126. result, _ := service.Jxyb4101(struct4101, pp)
  9127. var dat map[string]interface{}
  9128. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9129. fmt.Println(dat)
  9130. } else {
  9131. fmt.Println(err)
  9132. }
  9133. userJSONBytes, _ := json.Marshal(dat)
  9134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9135. utils.ErrorLog("解析失败:%v", err)
  9136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9137. return
  9138. }
  9139. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9140. var pp models.PublicParams
  9141. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9142. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9143. pp.FixmedinsName = miConfig.OrgName
  9144. pp.FixmedinsCode = miConfig.Code
  9145. pp.RequestUrl = miConfig.Url
  9146. pp.Cainfo = miConfig.Cainfo
  9147. pp.SecretKey = miConfig.SecretKey
  9148. pp.AccessKey = miConfig.AccessKey
  9149. pp.OpterName = curRoles.UserName
  9150. result, _ := service.Hnyb4101(struct4101, pp)
  9151. var dat map[string]interface{}
  9152. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9153. fmt.Println(dat)
  9154. } else {
  9155. fmt.Println(err)
  9156. }
  9157. userJSONBytes, _ := json.Marshal(dat)
  9158. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9159. utils.ErrorLog("解析失败:%v", err)
  9160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9161. return
  9162. }
  9163. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9164. var resOther ResultSeventeenOther
  9165. var pp models.PublicParams
  9166. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9167. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9168. pp.FixmedinsName = miConfig.OrgName
  9169. pp.FixmedinsCode = miConfig.Code
  9170. pp.RequestUrl = miConfig.Url
  9171. pp.Cainfo = miConfig.Cainfo
  9172. pp.SecretKey = miConfig.SecretKey
  9173. pp.AccessKey = miConfig.AccessKey
  9174. pp.OpterName = curRoles.UserName
  9175. client := &http.Client{}
  9176. var req *http.Request
  9177. data := make(map[string]interface{})
  9178. data["struct4101"] = struct4101
  9179. data["pp"] = pp
  9180. bytesData, _ := json.Marshal(data)
  9181. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  9182. resp, _ := client.Do(req)
  9183. defer resp.Body.Close()
  9184. body, ioErr := ioutil.ReadAll(resp.Body)
  9185. if ioErr != nil {
  9186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9188. return
  9189. }
  9190. var respJSON map[string]interface{}
  9191. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9194. return
  9195. }
  9196. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9197. userJSONBytes, _ := json.Marshal(respJSON)
  9198. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  9199. utils.ErrorLog("解析失败:%v", err)
  9200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9201. return
  9202. }
  9203. res.InfRefmsgid = resOther.InfRefmsgid
  9204. res.Output = resOther.Output
  9205. res.ErrMsg = resOther.ErrMsg
  9206. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  9207. res.Infcode = infocode
  9208. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9209. var pp models.PublicParams
  9210. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9211. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9212. pp.FixmedinsName = miConfig.OrgName
  9213. pp.FixmedinsCode = miConfig.Code
  9214. pp.RequestUrl = miConfig.Url
  9215. pp.Cainfo = miConfig.Cainfo
  9216. pp.SecretKey = miConfig.SecretKey
  9217. pp.AccessKey = miConfig.AccessKey
  9218. pp.OpterName = curRoles.UserName
  9219. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  9220. fmt.Println(requestLog)
  9221. fmt.Println(errMsgLog)
  9222. saveLog(result, requestLog, "4101a", "上传清单")
  9223. var dat map[string]interface{}
  9224. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9225. fmt.Println(dat)
  9226. } else {
  9227. fmt.Println(err)
  9228. }
  9229. userJSONBytes, _ := json.Marshal(dat)
  9230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9231. utils.ErrorLog("解析失败:%v", err)
  9232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9233. return
  9234. }
  9235. } else {
  9236. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  9237. var dat map[string]interface{}
  9238. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9239. fmt.Println(dat)
  9240. } else {
  9241. fmt.Println(err)
  9242. }
  9243. userJSONBytes, _ := json.Marshal(dat)
  9244. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9245. utils.ErrorLog("解析失败:%v", err)
  9246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9247. return
  9248. }
  9249. }
  9250. if res.Infcode != 0 {
  9251. c.ServeSuccessJSON(map[string]interface{}{
  9252. "failed_code": -10,
  9253. "msg": res.ErrMsg,
  9254. })
  9255. return
  9256. } else {
  9257. //order.FaPiaoNumber = zero
  9258. //order.FaPiaoCode = last_order.FaPiaoCode
  9259. //service.UpdateOrder(order)
  9260. hisFundSettleListResult := &models.HisFundSettleListResult{
  9261. Number: res.Output.SetlListId,
  9262. Status: 1,
  9263. Ctime: time.Now().Unix(),
  9264. Mtime: time.Now().Unix(),
  9265. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9266. IsUpload: 1,
  9267. OrderId: order_id,
  9268. }
  9269. service.CreateUploadRecord(hisFundSettleListResult)
  9270. c.ServeSuccessJSON(map[string]interface{}{
  9271. "msg": "上传成功",
  9272. "result": hisFundSettleListResult,
  9273. })
  9274. return
  9275. }
  9276. }
  9277. func (c *HisApiController) GetSettleListHospital() {
  9278. order_id, _ := c.GetInt64("order_id")
  9279. admin_user_id, _ := c.GetInt64("admin_user_id")
  9280. order, _ := service.GetHisOrderByIDTwo(order_id)
  9281. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  9282. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9283. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  9284. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9285. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  9286. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9287. if order.ID == 0 {
  9288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9289. return
  9290. }
  9291. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  9292. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  9293. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  9294. fmt.Println(count)
  9295. var zero string
  9296. number := count + 1
  9297. if number >= 1000 {
  9298. zero = "0000" + strconv.FormatInt(number, 10)
  9299. } else if number >= 10000 {
  9300. zero = "000" + strconv.FormatInt(number, 10)
  9301. } else if number >= 100000 {
  9302. zero = "00" + strconv.FormatInt(number, 10)
  9303. } else if number >= 1000000 {
  9304. zero = "0" + strconv.FormatInt(number, 10)
  9305. } else {
  9306. zero = strconv.FormatInt(number, 10)
  9307. }
  9308. fmt.Println(zero)
  9309. struct4101 := service.Struct4101{
  9310. PsnNo: order.PsnNo,
  9311. MdtrtId: order.MdtrtId,
  9312. SetlId: order.SetlId,
  9313. PsnName: order.PsnName,
  9314. Gend: order.Gend,
  9315. Brdy: his.Brdy,
  9316. Age: int64(order.Age),
  9317. Naty: order.Naty,
  9318. PatnCertType: "01",
  9319. Certno: order.Certno,
  9320. Prfs: "90",
  9321. ConerName: roles[0].UserName,
  9322. PatnRlts: "99",
  9323. ConerAddr: miConfig.OrgName,
  9324. ConerTel: admin.Mobile,
  9325. HiType: order.Insutype,
  9326. Insuplc: miConfig.InsuplcAdmdvs,
  9327. MaindiagFlag: "1",
  9328. BillCode: order.SetlId,
  9329. BillNo: order.SetlId,
  9330. BizSn: order.Number,
  9331. PsnSelfPay: order.PsnPartAmt,
  9332. PsnOwnPay: order.PsnPartAmt,
  9333. AcctPay: order.AcctPay,
  9334. PsnCashpay: order.PsnCashPay,
  9335. HiPaymtd: "1",
  9336. Hsorg: miConfig.InsuplcAdmdvs,
  9337. HsorgOpter: miConfig.InsuplcAdmdvs,
  9338. MedinsFillPsn: curRoles.UserName,
  9339. MedinsFillDept: depart.Name,
  9340. IptMedType: "2",
  9341. AdmTime: his.InHosptialTime,
  9342. AdmEndTime: his.OutHosptialTime,
  9343. }
  9344. struct4101.SetlBegnDate = order.SetlTime
  9345. struct4101.SetlEndDate = order.SetlTime
  9346. var rf []CustomFundPay
  9347. json.Unmarshal([]byte(order.SetlDetail), &rf)
  9348. var tempFunPays []service.CustomStruct
  9349. for _, item := range rf {
  9350. var tempFunPay service.CustomStruct
  9351. tempFunPay.FundPayamt = item.FundPayamt
  9352. tempFunPay.FundPayType = item.FundPayType
  9353. tempFunPays = append(tempFunPays, tempFunPay)
  9354. }
  9355. struct4101.CustomStruct = tempFunPays
  9356. var tempDiaginfos []service.DiaginfoStructTwo
  9357. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  9358. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  9359. infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  9360. for _, item := range infos {
  9361. his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  9362. }
  9363. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  9364. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  9365. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9366. fmt.Println(diagnosis_ids_arr)
  9367. var config []*models.HisXtDiagnoseConfig
  9368. for _, item := range diagnosis_ids_arr {
  9369. id, _ := strconv.ParseInt(item, 10, 64)
  9370. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9371. if diagnosisConfig.ID > 0 {
  9372. config = append(config, &diagnosisConfig)
  9373. }
  9374. }
  9375. for index, item := range config {
  9376. if item.ID > 0 {
  9377. if index == 0 {
  9378. var tempDiaginfo service.DiaginfoStructTwo
  9379. tempDiaginfo.DiagCode = item.CountryCode
  9380. tempDiaginfo.DiagName = item.CountryContentName
  9381. tempDiaginfo.DiagType = "1"
  9382. tempDiaginfo.MaindiagFlag = "1"
  9383. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9384. } else {
  9385. var tempDiaginfo service.DiaginfoStructTwo
  9386. tempDiaginfo.DiagCode = item.CountryCode
  9387. tempDiaginfo.DiagName = item.CountryContentName
  9388. tempDiaginfo.DiagType = "2"
  9389. tempDiaginfo.MaindiagFlag = "0"
  9390. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9391. }
  9392. }
  9393. }
  9394. struct4101.Diseinfo = tempDiaginfos
  9395. sickConfigTwo, _ := service.FindSickById(his.SickType)
  9396. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  9397. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  9398. tempOpspdiseinfo2.OprnOprtCode = ""
  9399. tempOpspdiseinfo2.OprnOprtName = ""
  9400. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  9401. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  9402. var iteminfo service.IteminfoStruct
  9403. var bedCostTotal float64 = 0 //床位总费
  9404. var bedCostSelfTotal float64 = 0 //床位自费
  9405. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9406. var operationCostTotal float64 = 0 //手术费
  9407. var operationCostSelfTotal float64 = 0 //手术费
  9408. var operationCostPartSelfTotal float64 = 0 //手术费
  9409. var otherCostTotal float64 = 0 //其他费用
  9410. var otherCostSelfTotal float64 = 0 //其他费用
  9411. var otherCostPartSelfTotal float64 = 0 //其他费用
  9412. var materialCostTotal float64 = 0 //材料费
  9413. var materialCostSelfTotal float64 = 0 //材料费
  9414. var materialCostPartSelfTotal float64 = 0 //材料费
  9415. var westernMedicineCostTotal float64 = 0 //西药费
  9416. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9417. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9418. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9419. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9420. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9421. var checkCostTotal float64 = 0 //检查费
  9422. var checkCostSelfTotal float64 = 0 //检查费
  9423. var checkCostPartSelfTotal float64 = 0 //检查费
  9424. var laboratoryCostTotal float64 = 0 //化验费
  9425. var laboratoryCostSelfTotal float64 = 0 //化验费
  9426. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9427. var treatCostTotal float64 = 0 //治疗费用
  9428. var treatCostSelfTotal float64 = 0 //治疗费用
  9429. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9430. decimal.DivisionPrecision = 2
  9431. var bed_fulamt_ownpay_amt float64 = 0
  9432. var operation_fulamt_ownpay_amt float64 = 0
  9433. var other_fulamt_ownpay_amt float64 = 0
  9434. var westernMedicine_fulamt_ownpay_amt float64 = 0
  9435. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  9436. var check_fulamt_ownpay_amt float64 = 0
  9437. var material_fulamt_ownpay_amt float64 = 0
  9438. var laboratory_fulamt_ownpay_amt float64 = 0
  9439. var treat_fulamt_ownpay_amt float64 = 0
  9440. var bed_claa_sunmfee float64 = 0
  9441. var bed_clab_amt float64 = 0
  9442. var bed_other_amt float64 = 0
  9443. var operation_claa_sunmfee float64 = 0
  9444. var operation_clab_amt float64 = 0
  9445. var operation_other_amt float64 = 0
  9446. var other_claa_sunmfee float64 = 0
  9447. var other_clab_amt float64 = 0
  9448. var other_other_amt float64 = 0
  9449. var westernMedicine_claa_sunmfee float64 = 0
  9450. var westernMedicine_clab_amt float64 = 0
  9451. var westernMedicine_other_amt float64 = 0
  9452. var chineseTraditional_claa_sunmfee float64 = 0
  9453. var chineseTraditional_clab_amt float64 = 0
  9454. var chineseTraditional_other_amt float64 = 0
  9455. var check_claa_sunmfee float64 = 0
  9456. var check_clab_amt float64 = 0
  9457. var check_other_amt float64 = 0
  9458. var material_claa_sunmfee float64 = 0
  9459. var material_clab_amt float64 = 0
  9460. var material_other_amt float64 = 0
  9461. var laboratory_claa_sunmfee float64 = 0
  9462. var laboratory_clab_amt float64 = 0
  9463. var laboratory_other_amt float64 = 0
  9464. var treat_claa_sunmfee float64 = 0
  9465. var treat_clab_amt float64 = 0
  9466. var treat_other_amt float64 = 0
  9467. for _, item := range order.HisOrderInfo {
  9468. if item.MedChrgitmType == "01" { //床位费
  9469. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9470. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9471. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9472. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  9473. if item.ChrgitmLv == "1" {
  9474. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9475. }
  9476. if item.ChrgitmLv == "2" {
  9477. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9478. }
  9479. if item.ChrgitmLv == "3" {
  9480. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9481. }
  9482. }
  9483. if item.MedChrgitmType == "03" { //检查费
  9484. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9485. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9486. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9487. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  9488. if item.ChrgitmLv == "1" {
  9489. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9490. }
  9491. if item.ChrgitmLv == "2" {
  9492. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9493. }
  9494. if item.ChrgitmLv == "3" {
  9495. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9496. }
  9497. }
  9498. if item.MedChrgitmType == "04" { //化验费
  9499. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9500. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9501. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9502. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  9503. if item.ChrgitmLv == "1" {
  9504. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9505. }
  9506. if item.ChrgitmLv == "2" {
  9507. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9508. }
  9509. if item.ChrgitmLv == "3" {
  9510. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9511. }
  9512. }
  9513. if item.MedChrgitmType == "05" { //治疗费
  9514. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9515. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9516. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9517. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  9518. if item.ChrgitmLv == "1" {
  9519. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9520. }
  9521. if item.ChrgitmLv == "2" {
  9522. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9523. }
  9524. if item.ChrgitmLv == "3" {
  9525. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9526. }
  9527. }
  9528. if item.MedChrgitmType == "06" { //手术费
  9529. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9530. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9531. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9532. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  9533. if item.ChrgitmLv == "1" {
  9534. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9535. }
  9536. if item.ChrgitmLv == "2" {
  9537. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9538. }
  9539. if item.ChrgitmLv == "3" {
  9540. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9541. }
  9542. }
  9543. if item.MedChrgitmType == "08" { //材料费
  9544. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9545. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9546. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9547. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  9548. if item.ChrgitmLv == "1" {
  9549. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9550. }
  9551. if item.ChrgitmLv == "2" {
  9552. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9553. }
  9554. if item.ChrgitmLv == "3" {
  9555. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9556. }
  9557. }
  9558. if item.MedChrgitmType == "09" { //西药费
  9559. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9560. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9561. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9562. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  9563. if item.ChrgitmLv == "1" {
  9564. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9565. }
  9566. if item.ChrgitmLv == "2" {
  9567. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9568. }
  9569. if item.ChrgitmLv == "3" {
  9570. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9571. }
  9572. }
  9573. if item.MedChrgitmType == "11" { //中成费
  9574. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9575. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9576. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9577. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  9578. if item.ChrgitmLv == "1" {
  9579. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9580. }
  9581. if item.ChrgitmLv == "2" {
  9582. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9583. }
  9584. if item.ChrgitmLv == "3" {
  9585. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9586. }
  9587. }
  9588. if item.MedChrgitmType == "14" { //其他费
  9589. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9590. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9591. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9592. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  9593. if item.ChrgitmLv == "1" {
  9594. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9595. }
  9596. if item.ChrgitmLv == "2" {
  9597. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9598. }
  9599. if item.ChrgitmLv == "3" {
  9600. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9601. }
  9602. }
  9603. }
  9604. var iteminfoStructs []service.IteminfoStruct
  9605. if bedCostTotal != 0 {
  9606. iteminfo.MedChrgitm = "01"
  9607. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  9608. iteminfo.Amt = bedCostTotal
  9609. iteminfo.ClaaSumfee = bed_claa_sunmfee
  9610. iteminfo.ClabAmt = bed_clab_amt
  9611. iteminfo.OthAmt = bed_other_amt
  9612. iteminfoStructs = append(iteminfoStructs, iteminfo)
  9613. }
  9614. if checkCostTotal != 0 {
  9615. iteminfo.MedChrgitm = "03"
  9616. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  9617. iteminfo.Amt = checkCostTotal
  9618. iteminfo.ClaaSumfee = check_claa_sunmfee
  9619. iteminfo.ClabAmt = check_clab_amt
  9620. iteminfo.OthAmt = check_other_amt
  9621. iteminfoStructs = append(iteminfoStructs, iteminfo)
  9622. }
  9623. if laboratoryCostTotal != 0 {
  9624. iteminfo.MedChrgitm = "04"
  9625. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  9626. iteminfo.Amt = laboratoryCostTotal
  9627. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  9628. iteminfo.ClabAmt = laboratory_clab_amt
  9629. iteminfo.OthAmt = laboratory_other_amt
  9630. iteminfoStructs = append(iteminfoStructs, iteminfo)
  9631. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  9632. }
  9633. if treatCostTotal != 0 {
  9634. iteminfo.MedChrgitm = "05"
  9635. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  9636. iteminfo.Amt = treatCostTotal
  9637. iteminfo.ClaaSumfee = treat_claa_sunmfee
  9638. iteminfo.ClabAmt = treat_clab_amt
  9639. iteminfo.OthAmt = treat_other_amt
  9640. iteminfoStructs = append(iteminfoStructs, iteminfo)
  9641. //(struct4101.IteminfoStruct, iteminfo)
  9642. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  9643. }
  9644. if operationCostTotal != 0 {
  9645. iteminfo.MedChrgitm = "06"
  9646. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  9647. iteminfo.Amt = operationCostTotal
  9648. iteminfo.ClaaSumfee = operation_claa_sunmfee
  9649. iteminfo.ClabAmt = operation_clab_amt
  9650. iteminfo.OthAmt = operation_other_amt
  9651. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  9652. iteminfoStructs = append(iteminfoStructs, iteminfo)
  9653. }
  9654. if materialCostTotal != 0 {
  9655. iteminfo.MedChrgitm = "08"
  9656. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  9657. iteminfo.Amt = materialCostTotal
  9658. iteminfo.ClaaSumfee = material_claa_sunmfee
  9659. iteminfo.ClabAmt = material_clab_amt
  9660. iteminfo.OthAmt = material_other_amt
  9661. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  9662. iteminfoStructs = append(iteminfoStructs, iteminfo)
  9663. }
  9664. if westernMedicineCostTotal != 0 {
  9665. iteminfo.MedChrgitm = "09"
  9666. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  9667. iteminfo.Amt = westernMedicineCostTotal
  9668. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  9669. iteminfo.ClabAmt = westernMedicine_clab_amt
  9670. iteminfo.OthAmt = westernMedicine_other_amt
  9671. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  9672. iteminfoStructs = append(iteminfoStructs, iteminfo)
  9673. }
  9674. if chineseTraditionalMedicineCostTotal != 0 {
  9675. iteminfo.MedChrgitm = "11"
  9676. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  9677. iteminfo.Amt = westernMedicineCostTotal
  9678. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  9679. iteminfo.ClabAmt = westernMedicine_clab_amt
  9680. iteminfo.OthAmt = westernMedicine_other_amt
  9681. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  9682. iteminfoStructs = append(iteminfoStructs, iteminfo)
  9683. }
  9684. if otherCostTotal != 0 {
  9685. iteminfo.MedChrgitm = "14"
  9686. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  9687. iteminfo.Amt = otherCostTotal
  9688. iteminfo.ClaaSumfee = other_claa_sunmfee
  9689. iteminfo.ClabAmt = other_clab_amt
  9690. iteminfo.OthAmt = other_other_amt
  9691. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  9692. iteminfoStructs = append(iteminfoStructs, iteminfo)
  9693. }
  9694. struct4101.IteminfoStruct = iteminfoStructs
  9695. struct4101.Ntly = "中国"
  9696. struct4101.AdmCaty = "A03.06"
  9697. var resOther ResultSeventeenOther
  9698. var res ResultSeventeen
  9699. if miConfig.MdtrtareaAdmvs == "150499" {
  9700. var pp models.PublicParams
  9701. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9702. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9703. pp.FixmedinsName = miConfig.OrgName
  9704. pp.FixmedinsCode = miConfig.Code
  9705. pp.RequestUrl = miConfig.Url
  9706. pp.Cainfo = miConfig.Cainfo
  9707. pp.SecretKey = miConfig.SecretKey
  9708. pp.AccessKey = miConfig.AccessKey
  9709. pp.OpterName = curRoles.UserName
  9710. client := &http.Client{}
  9711. var req *http.Request
  9712. data := make(map[string]interface{})
  9713. data["struct4101"] = struct4101
  9714. data["pp"] = pp
  9715. bytesData, _ := json.Marshal(data)
  9716. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  9717. resp, _ := client.Do(req)
  9718. defer resp.Body.Close()
  9719. body, ioErr := ioutil.ReadAll(resp.Body)
  9720. if ioErr != nil {
  9721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9723. return
  9724. }
  9725. var respJSON map[string]interface{}
  9726. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9729. return
  9730. }
  9731. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9732. userJSONBytes, _ := json.Marshal(respJSON)
  9733. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  9734. utils.ErrorLog("解析失败:%v", err)
  9735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9736. return
  9737. }
  9738. res.InfRefmsgid = resOther.InfRefmsgid
  9739. res.Output = resOther.Output
  9740. res.ErrMsg = resOther.ErrMsg
  9741. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  9742. res.Infcode = infocode
  9743. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9744. var pp models.PublicParams
  9745. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9746. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9747. pp.FixmedinsName = miConfig.OrgName
  9748. pp.FixmedinsCode = miConfig.Code
  9749. pp.RequestUrl = miConfig.Url
  9750. pp.Cainfo = miConfig.Cainfo
  9751. pp.SecretKey = miConfig.SecretKey
  9752. pp.AccessKey = miConfig.AccessKey
  9753. pp.OpterName = curRoles.UserName
  9754. result, _ := service.Jxyb4101(struct4101, pp)
  9755. var dat map[string]interface{}
  9756. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9757. fmt.Println(dat)
  9758. } else {
  9759. fmt.Println(err)
  9760. }
  9761. userJSONBytes, _ := json.Marshal(dat)
  9762. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9763. utils.ErrorLog("解析失败:%v", err)
  9764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9765. return
  9766. }
  9767. } else {
  9768. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  9769. var dat map[string]interface{}
  9770. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9771. fmt.Println(dat)
  9772. } else {
  9773. fmt.Println(err)
  9774. }
  9775. userJSONBytes, _ := json.Marshal(dat)
  9776. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9777. utils.ErrorLog("解析失败:%v", err)
  9778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9779. return
  9780. }
  9781. }
  9782. if res.Infcode != 0 {
  9783. c.ServeSuccessJSON(map[string]interface{}{
  9784. "failed_code": -10,
  9785. "msg": res.ErrMsg,
  9786. })
  9787. return
  9788. } else {
  9789. if miConfig.MdtrtareaAdmvs != "150499" {
  9790. order.FaPiaoNumber = zero
  9791. order.FaPiaoCode = last_order.FaPiaoCode
  9792. service.UpdateOrder(order)
  9793. }
  9794. hisFundSettleListResult := &models.HisFundSettleListResult{
  9795. Number: res.Output.SetlListId,
  9796. Status: 1,
  9797. Ctime: time.Now().Unix(),
  9798. Mtime: time.Now().Unix(),
  9799. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9800. IsUpload: 1,
  9801. OrderId: order_id,
  9802. }
  9803. service.CreateUploadRecord(hisFundSettleListResult)
  9804. c.ServeSuccessJSON(map[string]interface{}{
  9805. "msg": "上传成功",
  9806. "result": hisFundSettleListResult,
  9807. })
  9808. return
  9809. }
  9810. }
  9811. func (c *HisApiController) GetBatchSettleList() {
  9812. orders, _ := service.GetAllHisOrder(10106)
  9813. for _, item := range orders {
  9814. order_id := item.ID
  9815. order, _ := service.GetHisOrderByIDTwo(order_id)
  9816. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  9817. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9818. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  9819. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  9820. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  9821. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9822. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9823. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9824. if order.ID == 0 {
  9825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9826. return
  9827. }
  9828. if his.BalanceAccountsType == 2 {
  9829. continue
  9830. }
  9831. struct4101 := service.Struct4101{
  9832. PsnNo: order.PsnNo,
  9833. MdtrtId: order.MdtrtId,
  9834. SetlId: order.SetlId,
  9835. PsnName: order.PsnName,
  9836. Gend: order.Gend,
  9837. Brdy: his.Brdy,
  9838. Age: his.Age,
  9839. Naty: order.Naty,
  9840. PatnCertType: "01",
  9841. Certno: order.Certno,
  9842. Prfs: "90",
  9843. ConerName: roles[0].UserName,
  9844. PatnRlts: "99",
  9845. ConerAddr: miConfig.OrgName,
  9846. ConerTel: admin.Mobile,
  9847. HiType: order.Insutype,
  9848. Insuplc: his.InsuplcAdmdvs,
  9849. MaindiagFlag: "1",
  9850. BillCode: order.SetlId,
  9851. BillNo: order.SetlId,
  9852. BizSn: order.Number,
  9853. PsnSelfPay: order.PsnPartAmt,
  9854. PsnOwnPay: order.PsnPartAmt,
  9855. AcctPay: order.AcctPay,
  9856. PsnCashpay: order.PsnCashPay,
  9857. HiPaymtd: "1",
  9858. Hsorg: his.InsuplcAdmdvs,
  9859. HsorgOpter: his.InsuplcAdmdvs,
  9860. MedinsFillPsn: curRoles.UserName,
  9861. MedinsFillDept: depart.Name,
  9862. IptMedType: "2",
  9863. }
  9864. struct4101.SetlBegnDate = order.SetlTime
  9865. struct4101.SetlEndDate = order.SetlTime
  9866. //if order.SettleType == 1 {
  9867. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  9868. // dateStr := t.Format("2006-01-02")
  9869. // struct4101.SetlBegnDate = dateStr
  9870. // struct4101.SetlEndDate = dateStr
  9871. //} else {
  9872. // t := time.Unix(int64(order.SettleStartTime), 0)
  9873. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  9874. // dateStartStr := t.Format("2006-01-02")
  9875. // dateEndStr := t2.Format("2006-01-02")
  9876. // struct4101.SetlBegnDate = dateStartStr
  9877. // struct4101.SetlEndDate = dateEndStr
  9878. //}
  9879. var rf []CustomFundPay
  9880. json.Unmarshal([]byte(order.SetlDetail), &rf)
  9881. var tempFunPays []service.CustomStruct
  9882. var tempFunPay610100 service.CustomStruct
  9883. for _, item := range rf {
  9884. if item.FundPayType == "610100" {
  9885. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  9886. tempFunPay610100.FundPayType = item.FundPayType
  9887. } else {
  9888. var tempFunPay service.CustomStruct
  9889. tempFunPay.FundPayamt = item.FundPayamt
  9890. tempFunPay.FundPayType = item.FundPayType
  9891. tempFunPays = append(tempFunPays, tempFunPay)
  9892. }
  9893. }
  9894. tempFunPays = append(tempFunPays, tempFunPay610100)
  9895. struct4101.CustomStruct = tempFunPays
  9896. var tempDiaginfos []service.DiaginfoStructTwo
  9897. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  9898. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  9899. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9900. var config []*models.HisXtDiagnoseConfig
  9901. for _, item := range diagnosis_ids {
  9902. id, _ := strconv.ParseInt(item, 10, 64)
  9903. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9904. config = append(config, &diagnosisConfig)
  9905. }
  9906. for index, item := range config {
  9907. if index == 0 {
  9908. var tempDiaginfo service.DiaginfoStructTwo
  9909. tempDiaginfo.DiagCode = item.CountryCode
  9910. tempDiaginfo.DiagName = item.CountryContentName
  9911. tempDiaginfo.DiagType = "1"
  9912. tempDiaginfo.MaindiagFlag = "1"
  9913. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9914. } else {
  9915. var tempDiaginfo service.DiaginfoStructTwo
  9916. tempDiaginfo.DiagCode = item.CountryCode
  9917. tempDiaginfo.DiagName = item.CountryContentName
  9918. tempDiaginfo.DiagType = "2"
  9919. tempDiaginfo.MaindiagFlag = "0"
  9920. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9921. }
  9922. }
  9923. struct4101.Diseinfo = tempDiaginfos
  9924. sickConfigTwo, _ := service.FindSickById(his.SickType)
  9925. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  9926. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  9927. tempOpspdiseinfo2.OprnOprtCode = ""
  9928. tempOpspdiseinfo2.OprnOprtName = ""
  9929. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  9930. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  9931. var iteminfo service.IteminfoStruct
  9932. var bedCostTotal float64 = 0 //床位总费
  9933. var bedCostSelfTotal float64 = 0 //床位自费
  9934. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9935. var examineCostTotal float64 = 0 //诊查总费
  9936. var examineCostSelfTotal float64 = 0 //诊查自费
  9937. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  9938. var nursingCostTotal float64 = 0 //护理总费
  9939. var nursingCostSelfTotal float64 = 0 //护理自费
  9940. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  9941. var chineseMedicineCostTotal float64 = 0 //中成药
  9942. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  9943. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  9944. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  9945. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  9946. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  9947. var registerCostTotal float64 = 0 //一般诊疗费
  9948. var registerCostSelfTotal float64 = 0 //一般诊疗费
  9949. var registerPartSelfTotal float64 = 0 //一般诊疗费
  9950. var operationCostTotal float64 = 0 //手术费
  9951. var operationCostSelfTotal float64 = 0 //手术费
  9952. var operationCostPartSelfTotal float64 = 0 //手术费
  9953. var otherCostTotal float64 = 0 //其他费用
  9954. var otherCostSelfTotal float64 = 0 //其他费用
  9955. var otherCostPartSelfTotal float64 = 0 //其他费用
  9956. var materialCostTotal float64 = 0 //材料费
  9957. var materialCostSelfTotal float64 = 0 //材料费
  9958. var materialCostPartSelfTotal float64 = 0 //材料费
  9959. var westernMedicineCostTotal float64 = 0 //西药费
  9960. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9961. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9962. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9963. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9964. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9965. var checkCostTotal float64 = 0 //检查费
  9966. var checkCostSelfTotal float64 = 0 //检查费
  9967. var checkCostPartSelfTotal float64 = 0 //检查费
  9968. var laboratoryCostTotal float64 = 0 //化验费
  9969. var laboratoryCostSelfTotal float64 = 0 //化验费
  9970. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9971. var treatCostTotal float64 = 0 //治疗费用
  9972. var treatCostSelfTotal float64 = 0 //治疗费用
  9973. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9974. decimal.DivisionPrecision = 2
  9975. var bed_fulamt_ownpay_amt float64 = 0
  9976. var examine_fulamt_ownpay_amt float64 = 0
  9977. var nursing_fulamt_ownpay_amt float64 = 0
  9978. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  9979. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  9980. var register_fulamt_ownpay_amt float64 = 0
  9981. var operation_fulamt_ownpay_amt float64 = 0
  9982. var other_fulamt_ownpay_amt float64 = 0
  9983. var westernMedicine_fulamt_ownpay_amt float64 = 0
  9984. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  9985. var check_fulamt_ownpay_amt float64 = 0
  9986. var material_fulamt_ownpay_amt float64 = 0
  9987. var laboratory_fulamt_ownpay_amt float64 = 0
  9988. var treat_fulamt_ownpay_amt float64 = 0
  9989. var bed_claa_sunmfee float64 = 0
  9990. var bed_clab_amt float64 = 0
  9991. var bed_other_amt float64 = 0
  9992. var examine_claa_sunmfee float64 = 0
  9993. var examine_clab_amt float64 = 0
  9994. var examine_other_amt float64 = 0
  9995. var nursing_claa_sunmfee float64 = 0
  9996. var nursing_clab_amt float64 = 0
  9997. var nursing_other_amt float64 = 0
  9998. var chinese_medicine_claa_sunmfee float64 = 0
  9999. var chinese_medicine_clab_amt float64 = 0
  10000. var chinese_medicine_other_amt float64 = 0
  10001. var commonly_treatment_claa_sunmfee float64 = 0
  10002. var commonly_treatment_clab_amt float64 = 0
  10003. var commonly_treatment_other_amt float64 = 0
  10004. var operation_claa_sunmfee float64 = 0
  10005. var operation_clab_amt float64 = 0
  10006. var operation_other_amt float64 = 0
  10007. var other_claa_sunmfee float64 = 0
  10008. var other_clab_amt float64 = 0
  10009. var other_other_amt float64 = 0
  10010. var westernMedicine_claa_sunmfee float64 = 0
  10011. var westernMedicine_clab_amt float64 = 0
  10012. var westernMedicine_other_amt float64 = 0
  10013. var chineseTraditional_claa_sunmfee float64 = 0
  10014. var chineseTraditional_clab_amt float64 = 0
  10015. var chineseTraditional_other_amt float64 = 0
  10016. var check_claa_sunmfee float64 = 0
  10017. var check_clab_amt float64 = 0
  10018. var check_other_amt float64 = 0
  10019. var material_claa_sunmfee float64 = 0
  10020. var material_clab_amt float64 = 0
  10021. var material_other_amt float64 = 0
  10022. var laboratory_claa_sunmfee float64 = 0
  10023. var laboratory_clab_amt float64 = 0
  10024. var laboratory_other_amt float64 = 0
  10025. var treat_claa_sunmfee float64 = 0
  10026. var treat_clab_amt float64 = 0
  10027. var treat_other_amt float64 = 0
  10028. var register_claa_sunmfee float64 = 0
  10029. var register_clab_amt float64 = 0
  10030. var register_other_amt float64 = 0
  10031. for _, item := range order.HisOrderInfo {
  10032. if item.MedChrgitmType == "01" { //床位费
  10033. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10034. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10035. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10036. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10037. if item.ChrgitmLv == "1" {
  10038. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10039. }
  10040. if item.ChrgitmLv == "2" {
  10041. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10042. }
  10043. if item.ChrgitmLv == "3" {
  10044. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10045. }
  10046. }
  10047. if item.MedChrgitmType == "02" { //诊查
  10048. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10049. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10050. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10051. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10052. if item.ChrgitmLv == "1" {
  10053. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10054. }
  10055. if item.ChrgitmLv == "2" {
  10056. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10057. }
  10058. if item.ChrgitmLv == "3" {
  10059. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10060. }
  10061. }
  10062. if item.MedChrgitmType == "03" { //检查费
  10063. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10064. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10065. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10066. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10067. if item.ChrgitmLv == "1" {
  10068. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10069. }
  10070. if item.ChrgitmLv == "2" {
  10071. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10072. }
  10073. if item.ChrgitmLv == "3" {
  10074. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10075. }
  10076. }
  10077. if item.MedChrgitmType == "04" { //化验费
  10078. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10079. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10080. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10081. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10082. if item.ChrgitmLv == "1" {
  10083. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10084. }
  10085. if item.ChrgitmLv == "2" {
  10086. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10087. }
  10088. if item.ChrgitmLv == "3" {
  10089. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10090. }
  10091. }
  10092. if item.MedChrgitmType == "05" { //治疗费
  10093. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10094. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10095. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10096. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10097. if item.ChrgitmLv == "1" {
  10098. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10099. }
  10100. if item.ChrgitmLv == "2" {
  10101. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10102. }
  10103. if item.ChrgitmLv == "3" {
  10104. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10105. }
  10106. }
  10107. if item.MedChrgitmType == "06" { //手术费
  10108. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10109. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10110. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10111. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10112. if item.ChrgitmLv == "1" {
  10113. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10114. }
  10115. if item.ChrgitmLv == "2" {
  10116. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10117. }
  10118. if item.ChrgitmLv == "3" {
  10119. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10120. }
  10121. }
  10122. if item.MedChrgitmType == "07" { //手术费
  10123. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10124. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10125. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10126. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10127. if item.ChrgitmLv == "1" {
  10128. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10129. }
  10130. if item.ChrgitmLv == "2" {
  10131. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10132. }
  10133. if item.ChrgitmLv == "3" {
  10134. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10135. }
  10136. }
  10137. if item.MedChrgitmType == "08" { //材料费
  10138. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10139. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10140. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10141. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10142. if item.ChrgitmLv == "1" {
  10143. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10144. }
  10145. if item.ChrgitmLv == "2" {
  10146. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10147. }
  10148. if item.ChrgitmLv == "3" {
  10149. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10150. }
  10151. }
  10152. if item.MedChrgitmType == "09" { //西药费
  10153. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10154. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10155. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10156. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10157. if item.ChrgitmLv == "1" {
  10158. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10159. }
  10160. if item.ChrgitmLv == "2" {
  10161. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10162. }
  10163. if item.ChrgitmLv == "3" {
  10164. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10165. }
  10166. }
  10167. if item.MedChrgitmType == "10" { //中药饮片
  10168. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10169. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10170. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10171. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10172. if item.ChrgitmLv == "1" {
  10173. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10174. }
  10175. if item.ChrgitmLv == "2" {
  10176. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10177. }
  10178. if item.ChrgitmLv == "3" {
  10179. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10180. }
  10181. }
  10182. if item.MedChrgitmType == "11" { //中成费
  10183. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10184. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10185. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10186. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10187. if item.ChrgitmLv == "1" {
  10188. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10189. }
  10190. if item.ChrgitmLv == "2" {
  10191. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10192. }
  10193. if item.ChrgitmLv == "3" {
  10194. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10195. }
  10196. }
  10197. if item.MedChrgitmType == "12" { //中成费
  10198. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10199. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10200. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10201. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10202. if item.ChrgitmLv == "1" {
  10203. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10204. }
  10205. if item.ChrgitmLv == "2" {
  10206. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10207. }
  10208. if item.ChrgitmLv == "3" {
  10209. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10210. }
  10211. }
  10212. if item.MedChrgitmType == "13" { //中成费
  10213. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10214. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10215. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10216. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10217. if item.ChrgitmLv == "1" {
  10218. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10219. }
  10220. if item.ChrgitmLv == "2" {
  10221. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10222. }
  10223. if item.ChrgitmLv == "3" {
  10224. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10225. }
  10226. }
  10227. if item.MedChrgitmType == "14" { //其他费
  10228. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10229. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10230. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10231. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10232. if item.ChrgitmLv == "1" {
  10233. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10234. }
  10235. if item.ChrgitmLv == "2" {
  10236. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10237. }
  10238. if item.ChrgitmLv == "3" {
  10239. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10240. }
  10241. }
  10242. }
  10243. var iteminfoStructs []service.IteminfoStruct
  10244. if bedCostTotal != 0 {
  10245. iteminfo.MedChrgitm = "01"
  10246. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  10247. iteminfo.Amt = bedCostTotal
  10248. iteminfo.ClaaSumfee = bed_claa_sunmfee
  10249. iteminfo.ClabAmt = bed_clab_amt
  10250. iteminfo.OthAmt = bed_other_amt
  10251. iteminfoStructs = append(iteminfoStructs, iteminfo)
  10252. }
  10253. if examineCostTotal != 0 {
  10254. iteminfo.MedChrgitm = "02"
  10255. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  10256. iteminfo.Amt = examineCostTotal
  10257. iteminfo.ClaaSumfee = examine_claa_sunmfee
  10258. iteminfo.ClabAmt = examine_clab_amt
  10259. iteminfo.OthAmt = examine_other_amt
  10260. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10261. iteminfoStructs = append(iteminfoStructs, iteminfo)
  10262. }
  10263. if checkCostTotal != 0 {
  10264. iteminfo.MedChrgitm = "03"
  10265. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  10266. iteminfo.Amt = checkCostTotal
  10267. iteminfo.ClaaSumfee = check_claa_sunmfee
  10268. iteminfo.ClabAmt = check_clab_amt
  10269. iteminfo.OthAmt = check_other_amt
  10270. iteminfoStructs = append(iteminfoStructs, iteminfo)
  10271. }
  10272. if laboratoryCostTotal != 0 {
  10273. iteminfo.MedChrgitm = "04"
  10274. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  10275. iteminfo.Amt = laboratoryCostTotal
  10276. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  10277. iteminfo.ClabAmt = laboratory_clab_amt
  10278. iteminfo.OthAmt = laboratory_other_amt
  10279. iteminfoStructs = append(iteminfoStructs, iteminfo)
  10280. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10281. }
  10282. if treatCostTotal != 0 {
  10283. iteminfo.MedChrgitm = "05"
  10284. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  10285. iteminfo.Amt = treatCostTotal
  10286. iteminfo.ClaaSumfee = treat_claa_sunmfee
  10287. iteminfo.ClabAmt = treat_clab_amt
  10288. iteminfo.OthAmt = treat_other_amt
  10289. iteminfoStructs = append(iteminfoStructs, iteminfo)
  10290. //(struct4101.IteminfoStruct, iteminfo)
  10291. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10292. }
  10293. if operationCostTotal != 0 {
  10294. iteminfo.MedChrgitm = "06"
  10295. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  10296. iteminfo.Amt = operationCostTotal
  10297. iteminfo.ClaaSumfee = operation_claa_sunmfee
  10298. iteminfo.ClabAmt = operation_clab_amt
  10299. iteminfo.OthAmt = operation_other_amt
  10300. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10301. iteminfoStructs = append(iteminfoStructs, iteminfo)
  10302. }
  10303. if nursingCostTotal != 0 {
  10304. iteminfo.MedChrgitm = "07"
  10305. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  10306. iteminfo.Amt = nursingCostTotal
  10307. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  10308. iteminfo.ClabAmt = nursing_clab_amt
  10309. iteminfo.OthAmt = nursing_other_amt
  10310. iteminfoStructs = append(iteminfoStructs, iteminfo)
  10311. }
  10312. if materialCostTotal != 0 {
  10313. iteminfo.MedChrgitm = "08"
  10314. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  10315. iteminfo.Amt = materialCostTotal
  10316. iteminfo.ClaaSumfee = material_claa_sunmfee
  10317. iteminfo.ClabAmt = material_clab_amt
  10318. iteminfo.OthAmt = material_other_amt
  10319. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10320. iteminfoStructs = append(iteminfoStructs, iteminfo)
  10321. }
  10322. if westernMedicineCostTotal != 0 {
  10323. iteminfo.MedChrgitm = "09"
  10324. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  10325. iteminfo.Amt = westernMedicineCostTotal
  10326. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  10327. iteminfo.ClabAmt = westernMedicine_clab_amt
  10328. iteminfo.OthAmt = westernMedicine_other_amt
  10329. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10330. iteminfoStructs = append(iteminfoStructs, iteminfo)
  10331. }
  10332. if chineseMedicineCostTotal != 0 {
  10333. iteminfo.MedChrgitm = "10"
  10334. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  10335. iteminfo.Amt = chineseMedicineCostTotal
  10336. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  10337. iteminfo.ClabAmt = chinese_medicine_clab_amt
  10338. iteminfo.OthAmt = chinese_medicine_other_amt
  10339. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10340. iteminfoStructs = append(iteminfoStructs, iteminfo)
  10341. }
  10342. if chineseTraditionalMedicineCostTotal != 0 {
  10343. iteminfo.MedChrgitm = "11"
  10344. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  10345. iteminfo.Amt = westernMedicineCostTotal
  10346. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  10347. iteminfo.ClabAmt = westernMedicine_clab_amt
  10348. iteminfo.OthAmt = westernMedicine_other_amt
  10349. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10350. iteminfoStructs = append(iteminfoStructs, iteminfo)
  10351. }
  10352. if commonlyTreatmentCostTotal != 0 {
  10353. iteminfo.MedChrgitm = "12"
  10354. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  10355. iteminfo.Amt = commonlyTreatmentCostTotal
  10356. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  10357. iteminfo.ClabAmt = commonly_treatment_clab_amt
  10358. iteminfo.OthAmt = commonly_treatment_other_amt
  10359. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10360. iteminfoStructs = append(iteminfoStructs, iteminfo)
  10361. }
  10362. if registerCostTotal != 0 {
  10363. iteminfo.MedChrgitm = "13"
  10364. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  10365. iteminfo.Amt = registerCostTotal
  10366. iteminfo.ClaaSumfee = register_claa_sunmfee
  10367. iteminfo.ClabAmt = register_clab_amt
  10368. iteminfo.OthAmt = register_other_amt
  10369. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10370. iteminfoStructs = append(iteminfoStructs, iteminfo)
  10371. }
  10372. if otherCostTotal != 0 {
  10373. iteminfo.MedChrgitm = "14"
  10374. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  10375. iteminfo.Amt = otherCostTotal
  10376. iteminfo.ClaaSumfee = other_claa_sunmfee
  10377. iteminfo.ClabAmt = other_clab_amt
  10378. iteminfo.OthAmt = other_other_amt
  10379. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10380. iteminfoStructs = append(iteminfoStructs, iteminfo)
  10381. }
  10382. struct4101.IteminfoStruct = iteminfoStructs
  10383. time_arr := strings.Split(order.SetlTime, " ")
  10384. struct4101.AdmTime = time_arr[0]
  10385. struct4101.AdmEndTime = time_arr[0]
  10386. struct4101.DoctorName = doctor.UserName
  10387. struct4101.DoctorCode = doctor.DoctorNumber
  10388. struct4101.Ntly = "中国"
  10389. struct4101.AdmCaty = "A03.06"
  10390. var res ResultSeventeen
  10391. if miConfig.MdtrtareaAdmvs == "421300" {
  10392. data := make(map[string]interface{})
  10393. data["struct4101"] = struct4101
  10394. data["secret_key"] = miConfig.SecretKey
  10395. data["org_name"] = miConfig.OrgName
  10396. data["opera"] = curRoles.UserName
  10397. data["code"] = miConfig.Code
  10398. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  10399. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10400. client := &http.Client{}
  10401. bytesData, _ := json.Marshal(data)
  10402. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  10403. resp, _ := client.Do(req)
  10404. defer resp.Body.Close()
  10405. body, ioErr := ioutil.ReadAll(resp.Body)
  10406. if ioErr != nil {
  10407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10409. return
  10410. }
  10411. var respJSON map[string]interface{}
  10412. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10415. return
  10416. }
  10417. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10418. userJSONBytes, _ := json.Marshal(respJSON)
  10419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10420. utils.ErrorLog("解析失败:%v", err)
  10421. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10422. adminUser := c.GetAdminUserInfo()
  10423. errlog := &models.HisOrderError{
  10424. UserOrgId: adminUser.CurrentOrgId,
  10425. Ctime: time.Now().Unix(),
  10426. Mtime: time.Now().Unix(),
  10427. ErrMsg: res.ErrMsg + "解析失败",
  10428. Status: 1,
  10429. PatientId: order_id,
  10430. Stage: 10088,
  10431. }
  10432. service.CreateErrMsgLog(errlog)
  10433. continue
  10434. }
  10435. } else {
  10436. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  10437. fmt.Println(result)
  10438. var dat map[string]interface{}
  10439. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10440. fmt.Println(dat)
  10441. } else {
  10442. fmt.Println(err)
  10443. }
  10444. userJSONBytes, _ := json.Marshal(dat)
  10445. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10446. utils.ErrorLog("解析失败:%v", err)
  10447. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10448. adminUser := c.GetAdminUserInfo()
  10449. errlog := &models.HisOrderError{
  10450. UserOrgId: adminUser.CurrentOrgId,
  10451. Ctime: time.Now().Unix(),
  10452. Mtime: time.Now().Unix(),
  10453. ErrMsg: res.ErrMsg + "解析失败",
  10454. Status: 1,
  10455. PatientId: order_id,
  10456. Stage: 10106,
  10457. }
  10458. service.CreateErrMsgLog(errlog)
  10459. continue
  10460. }
  10461. }
  10462. if res.Infcode != 0 {
  10463. adminUser := c.GetAdminUserInfo()
  10464. errlog := &models.HisOrderError{
  10465. UserOrgId: adminUser.CurrentOrgId,
  10466. Ctime: time.Now().Unix(),
  10467. Mtime: time.Now().Unix(),
  10468. ErrMsg: res.ErrMsg,
  10469. Status: 1,
  10470. PatientId: order_id,
  10471. Stage: 10106,
  10472. }
  10473. service.CreateErrMsgLog(errlog)
  10474. continue
  10475. } else {
  10476. hisFundSettleListResult := &models.HisFundSettleListResult{
  10477. Number: res.Output.SetlListId,
  10478. Status: 1,
  10479. Ctime: time.Now().Unix(),
  10480. Mtime: time.Now().Unix(),
  10481. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10482. IsUpload: 1,
  10483. OrderId: order_id,
  10484. }
  10485. service.CreateUploadRecord(hisFundSettleListResult)
  10486. continue
  10487. }
  10488. }
  10489. }
  10490. func (c *HisApiController) GetOrgInfo() {
  10491. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  10492. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  10493. }
  10494. func (c *HisApiController) GetHisPatientInfo() {
  10495. medical_insurance_card := c.GetString("medical_insurance_card")
  10496. id_card_type, _ := c.GetInt64("id_card_type")
  10497. id_card := c.GetString("id_card")
  10498. adminInfo := c.GetAdminUserInfo()
  10499. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  10500. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10501. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  10502. IdCardNo := ""
  10503. if id_card_type == 1 {
  10504. IdCardNo = medical_insurance_card
  10505. } else if id_card_type == 2 {
  10506. IdCardNo = id_card
  10507. }
  10508. if config.IsOpen == 1 {
  10509. 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
  10510. resp, requestErr := http.Get(api)
  10511. if requestErr != nil {
  10512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10513. return
  10514. }
  10515. defer resp.Body.Close()
  10516. body, ioErr := ioutil.ReadAll(resp.Body)
  10517. if ioErr != nil {
  10518. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10520. return
  10521. }
  10522. var respJSON map[string]interface{}
  10523. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10526. return
  10527. }
  10528. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10529. userJSONBytes, _ := json.Marshal(userJSON)
  10530. var res ResultTwo
  10531. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10532. utils.ErrorLog("解析失败:%v", err)
  10533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10534. return
  10535. }
  10536. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10537. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10538. infoStr := string(Iinfos)
  10539. idetinfoStr := string(Idetinfos)
  10540. if res.Infcode == 0 {
  10541. his := models.VMHisPatient{
  10542. Status: 1,
  10543. Ctime: time.Now().Unix(),
  10544. Mtime: time.Now().Unix(),
  10545. PsnNo: res.Output.Baseinfo.PsnNo,
  10546. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10547. Certno: res.Output.Baseinfo.Certno,
  10548. PsnName: res.Output.Baseinfo.PsnName,
  10549. Gend: res.Output.Baseinfo.Gend,
  10550. Naty: res.Output.Baseinfo.Naty,
  10551. Brdy: res.Output.Baseinfo.Brdy,
  10552. Age: res.Output.Baseinfo.Age,
  10553. Iinfo: infoStr,
  10554. Idetinfo: idetinfoStr,
  10555. UserOrgId: adminInfo.CurrentOrgId,
  10556. IsReturn: 1,
  10557. IdCardType: id_card_type,
  10558. }
  10559. c.ServeSuccessJSON(map[string]interface{}{
  10560. "info": his,
  10561. })
  10562. } else {
  10563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10564. return
  10565. }
  10566. }
  10567. }
  10568. //func GetBasBaseInfo() (jsonStr string, err error) {
  10569. //
  10570. // handle := syscall.NewLazyDLL("SSCard.dll")
  10571. // add := handle.NewProc("ReadCardBas")
  10572. // str := make([]byte, 1024)
  10573. // str1 := make([]byte, 1024)
  10574. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  10575. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  10576. //
  10577. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  10578. //
  10579. // fmt.Println("> Add(4,5)的结果为:", ret)
  10580. // handle.Release()
  10581. //
  10582. // return "", nil
  10583. //
  10584. //}
  10585. //func GetQRBaseInfo() (jsonStr string, err error) {
  10586. // handle := syscall.LoadDLL("SSCard.dll")
  10587. // ReadCardBas := handle.FindProc("GetQRBase")
  10588. //
  10589. // str := make([]byte, 256)
  10590. // str1 := make([]byte, 256)
  10591. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  10592. //
  10593. // fmt.Println(string(str))
  10594. // fmt.Println(r)
  10595. // return string(str), nil
  10596. //}
  10597. //func CardInit() int {
  10598. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  10599. // add := DllTestDef.MustFindProc("Init")
  10600. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  10601. // if err != nil {
  10602. // fmt.Println("SSCard的运算结果为:", ret)
  10603. // }
  10604. // result := int(ret)
  10605. // return result
  10606. //}
  10607. //func CardInit() int {
  10608. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  10609. // if err != nil {
  10610. // fmt.Println("SSCard的运算结果为:", ret)
  10611. // }
  10612. // fmt.Println(err)
  10613. // result := int(ret)
  10614. // return result
  10615. //}
  10616. func IntPtr(n int) uintptr {
  10617. return uintptr(n)
  10618. }
  10619. func StrPtr(s string) uintptr {
  10620. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  10621. }
  10622. type Result2001 struct {
  10623. Cainfo interface{} `json:"cainfo"`
  10624. ErrMsg string `json:"err_msg"`
  10625. InfRefmsgid string `json:"inf_refmsgid"`
  10626. Infcode int64 `json:"infcode"`
  10627. Output struct {
  10628. Trtinfo struct {
  10629. PsnNo string `json:"psn_no"`
  10630. TrtChkType string `json:"trt_chk_type"`
  10631. FundPayType string `json:"fund_pay_type"`
  10632. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  10633. Begndate string `json:"begndate"`
  10634. Enddate string `json:"enddate"`
  10635. TrtChkRslt string `json:"trt_chk_rslt"`
  10636. } `json:"trtinfo"`
  10637. } `json:"output"`
  10638. RefmsgTime string `json:"refmsg_time"`
  10639. RespondTime string `json:"respond_time"`
  10640. Signtype interface{} `json:"signtype"`
  10641. WarnMsg interface{} `json:"warn_msg"`
  10642. }
  10643. type Result2001Org10265 struct {
  10644. Cainfo interface{} `json:"cainfo"`
  10645. ErrMsg string `json:"err_msg"`
  10646. InfRefmsgid string `json:"inf_refmsgid"`
  10647. Infcode string `json:"infcode"`
  10648. Output struct {
  10649. Trtinfo struct {
  10650. PsnNo string `json:"psn_no"`
  10651. TrtChkType string `json:"trt_chk_type"`
  10652. FundPayType string `json:"fund_pay_type"`
  10653. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  10654. Begndate string `json:"begndate"`
  10655. Enddate string `json:"enddate"`
  10656. TrtChkRslt string `json:"trt_chk_rslt"`
  10657. } `json:"trtinfo"`
  10658. } `json:"output"`
  10659. RefmsgTime string `json:"refmsg_time"`
  10660. RespondTime string `json:"respond_time"`
  10661. Signtype interface{} `json:"signtype"`
  10662. WarnMsg interface{} `json:"warn_msg"`
  10663. }
  10664. type ResultTwo struct {
  10665. ErrMsg string `json:"err_msg"`
  10666. InfRefmsgid string `json:"inf_refmsgid"`
  10667. Infcode int64 `json:"infcode"`
  10668. Output struct {
  10669. Baseinfo struct {
  10670. Age float64 `json:"age"`
  10671. Brdy string `json:"brdy"`
  10672. Certno string `json:"certno"`
  10673. Gend string `json:"gend"`
  10674. Naty string `json:"naty"`
  10675. PsnCertType string `json:"psn_cert_type"`
  10676. PsnName string `json:"psn_name"`
  10677. PsnNo string `json:"psn_no"`
  10678. } `json:"baseinfo"`
  10679. Idetinfo []interface{} `json:"idetinfo"`
  10680. Iinfo []struct {
  10681. Balc float64 `json:"balc"`
  10682. CvlservFlag string `json:"cvlserv_flag"`
  10683. EmpName string `json:"emp_name"`
  10684. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  10685. Insutype string `json:"insutype"`
  10686. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  10687. PausInsuDate string `json:"paus_insu_date"`
  10688. PsnInsuDate string `json:"psn_insu_date"`
  10689. PsnInsuStas string `json:"psn_insu_stas"`
  10690. PsnType string `json:"psn_type"`
  10691. } `json:"insuinfo"`
  10692. } `json:"output"`
  10693. RefmsgTime string `json:"refmsg_time"`
  10694. RespondTime string `json:"respond_time"`
  10695. Signtype interface{} `json:"signtype"`
  10696. WarnInfo interface{} `json:"warn_info"`
  10697. }
  10698. type ResultTwo10265 struct {
  10699. ErrMsg string `json:"err_msg"`
  10700. InfRefmsgid string `json:"inf_refmsgid"`
  10701. Infcode string `json:"infcode"`
  10702. Output struct {
  10703. Baseinfo struct {
  10704. Age float64 `json:"age"`
  10705. Brdy string `json:"brdy"`
  10706. Certno string `json:"certno"`
  10707. Gend string `json:"gend"`
  10708. Naty string `json:"naty"`
  10709. PsnCertType string `json:"psn_cert_type"`
  10710. PsnName string `json:"psn_name"`
  10711. PsnNo string `json:"psn_no"`
  10712. } `json:"baseinfo"`
  10713. Idetinfo []interface{} `json:"idetinfo"`
  10714. Iinfo []struct {
  10715. Balc float64 `json:"balc"`
  10716. CvlservFlag string `json:"cvlserv_flag"`
  10717. EmpName string `json:"emp_name"`
  10718. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  10719. Insutype string `json:"insutype"`
  10720. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  10721. PausInsuDate string `json:"paus_insu_date"`
  10722. PsnInsuDate string `json:"psn_insu_date"`
  10723. PsnInsuStas string `json:"psn_insu_stas"`
  10724. PsnType string `json:"psn_type"`
  10725. } `json:"insuinfo"`
  10726. } `json:"output"`
  10727. RefmsgTime string `json:"refmsg_time"`
  10728. RespondTime string `json:"respond_time"`
  10729. Signtype interface{} `json:"signtype"`
  10730. WarnInfo interface{} `json:"warn_info"`
  10731. }
  10732. type ResultThree struct {
  10733. Cainfo interface{} `json:"cainfo"`
  10734. ErrMsg string `json:"err_msg"`
  10735. InfRefmsgid string `json:"inf_refmsgid"`
  10736. Infcode int64 `json:"infcode"`
  10737. Output struct {
  10738. Data struct {
  10739. IptOtpNo string `json:"ipt_otp_no"`
  10740. MdtrtID string `json:"mdtrt_id"`
  10741. PsnNo string `json:"psn_no"`
  10742. } `json:"data"`
  10743. } `json:"output"`
  10744. RefmsgTime string `json:"refmsg_time"`
  10745. RespondTime string `json:"respond_time"`
  10746. Signtype interface{} `json:"signtype"`
  10747. WarnMsg interface{} `json:"warn_msg"`
  10748. }
  10749. type ResultThree10265 struct {
  10750. Cainfo interface{} `json:"cainfo"`
  10751. ErrMsg string `json:"err_msg"`
  10752. InfRefmsgid string `json:"inf_refmsgid"`
  10753. Infcode string `json:"infcode"`
  10754. Output struct {
  10755. Data struct {
  10756. IptOtpNo string `json:"ipt_otp_no"`
  10757. MdtrtID string `json:"mdtrt_id"`
  10758. PsnNo string `json:"psn_no"`
  10759. } `json:"data"`
  10760. } `json:"output"`
  10761. RefmsgTime string `json:"refmsg_time"`
  10762. RespondTime string `json:"respond_time"`
  10763. Signtype interface{} `json:"signtype"`
  10764. WarnMsg interface{} `json:"warn_msg"`
  10765. }
  10766. type ResultFour struct {
  10767. Cainfo string `json:"cainfo"`
  10768. ErrMsg string `json:"err_msg"`
  10769. InfRefmsgid string `json:"inf_refmsgid"`
  10770. Infcode int64 `json:"infcode"`
  10771. Output struct {
  10772. Result []struct {
  10773. BasMednFlag string `json:"bas_medn_flag"`
  10774. ChldMedcFlag string `json:"chld_medc_flag"`
  10775. ChrgitmLv string `json:"chrgitm_lv"`
  10776. Cnt float64 `json:"cnt"`
  10777. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  10778. DrtReimFlag string `json:"drt_reim_flag"`
  10779. FeedetlSn string `json:"feedetl_sn"`
  10780. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  10781. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  10782. InscpScpAmt float64 `json:"inscp_scp_amt"`
  10783. ListSpItemFlag string `json:"list_sp_item_flag"`
  10784. LmtUsedFlag string `json:"lmt_used_flag"`
  10785. MedChrgitmType string `json:"med_chrgitm_type"`
  10786. Memo string `json:"memo"`
  10787. OverlmtAmt float64 `json:"overlmt_amt"`
  10788. PreselfpayAmt float64 `json:"preselfpay_amt"`
  10789. Pric float64 `json:"pric"`
  10790. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  10791. SelfpayProp float64 `json:"selfpay_prop"`
  10792. } `json:"result"`
  10793. } `json:"output"`
  10794. RefmsgTime string `json:"refmsg_time"`
  10795. RespondTime string `json:"respond_time"`
  10796. Signtype string `json:"signtype"`
  10797. WarnMsg string `json:"warn_msg"`
  10798. }
  10799. type ResultFour10265 struct {
  10800. Cainfo string `json:"cainfo"`
  10801. ErrMsg string `json:"err_msg"`
  10802. InfRefmsgid string `json:"inf_refmsgid"`
  10803. Infcode string `json:"infcode"`
  10804. Output struct {
  10805. Result []struct {
  10806. BasMednFlag string `json:"bas_medn_flag"`
  10807. ChldMedcFlag string `json:"chld_medc_flag"`
  10808. ChrgitmLv string `json:"chrgitm_lv"`
  10809. Cnt float64 `json:"cnt"`
  10810. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  10811. DrtReimFlag string `json:"drt_reim_flag"`
  10812. FeedetlSn string `json:"feedetl_sn"`
  10813. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  10814. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  10815. InscpScpAmt float64 `json:"inscp_scp_amt"`
  10816. ListSpItemFlag string `json:"list_sp_item_flag"`
  10817. LmtUsedFlag string `json:"lmt_used_flag"`
  10818. MedChrgitmType string `json:"med_chrgitm_type"`
  10819. Memo string `json:"memo"`
  10820. OverlmtAmt float64 `json:"overlmt_amt"`
  10821. PreselfpayAmt float64 `json:"preselfpay_amt"`
  10822. Pric float64 `json:"pric"`
  10823. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  10824. SelfpayProp float64 `json:"selfpay_prop"`
  10825. } `json:"result"`
  10826. } `json:"output"`
  10827. RefmsgTime string `json:"refmsg_time"`
  10828. RespondTime string `json:"respond_time"`
  10829. Signtype string `json:"signtype"`
  10830. WarnMsg string `json:"warn_msg"`
  10831. }
  10832. type ResultMemo struct {
  10833. InsuAdmdvs string `json:"insuAdmdvs"`
  10834. }
  10835. // [{"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}]
  10836. type ResultIDInfo struct {
  10837. Begntime string `json:"begntime"`
  10838. Endtime string `json:"endtime"`
  10839. Memo string `json:"memo"`
  10840. }
  10841. type ResultFive struct {
  10842. Balc float64 `json:"balc"`
  10843. CvlservFlag string `json:"cvlserv_flag"`
  10844. EmpName string `json:"emp_name"`
  10845. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  10846. Insutype string `json:"insutype"`
  10847. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  10848. PausInsuDate string `json:"paus_insu_date"`
  10849. PsnInsuDate string `json:"psn_insu_date"`
  10850. PsnInsuStas string `json:"psn_insu_stas"`
  10851. PsnType string `json:"psn_type"`
  10852. }
  10853. type ResultSix struct {
  10854. Cainfo interface{} `json:"cainfo"`
  10855. ErrMsg string `json:"err_msg"`
  10856. InfRefmsgid string `json:"inf_refmsgid"`
  10857. Infcode int64 `json:"infcode"`
  10858. Output struct {
  10859. } `json:"output"`
  10860. RefmsgTime string `json:"refmsg_time"`
  10861. RespondTime string `json:"respond_time"`
  10862. Signtype interface{} `json:"signtype"`
  10863. WarnMsg interface{} `json:"warn_msg"`
  10864. }
  10865. type GZResultSix struct {
  10866. Cainfo interface{} `json:"cainfo"`
  10867. ErrMsg string `json:"err_msg"`
  10868. InfRefmsgid string `json:"inf_refmsgid"`
  10869. Infcode int64 `json:"infcode"`
  10870. Output string `json:"output"`
  10871. RefmsgTime string `json:"refmsg_time"`
  10872. RespondTime string `json:"respond_time"`
  10873. Signtype interface{} `json:"signtype"`
  10874. WarnMsg interface{} `json:"warn_msg"`
  10875. }
  10876. type ResultSix10265 struct {
  10877. Cainfo interface{} `json:"cainfo"`
  10878. ErrMsg string `json:"err_msg"`
  10879. InfRefmsgid string `json:"inf_refmsgid"`
  10880. Infcode string `json:"infcode"`
  10881. Output struct {
  10882. } `json:"output"`
  10883. RefmsgTime string `json:"refmsg_time"`
  10884. RespondTime string `json:"respond_time"`
  10885. Signtype interface{} `json:"signtype"`
  10886. WarnMsg interface{} `json:"warn_msg"`
  10887. }
  10888. type ResultSeven struct {
  10889. Cainfo string `json:"cainfo"`
  10890. ErrMsg string `json:"err_msg"`
  10891. InfRefmsgid string `json:"inf_refmsgid"`
  10892. Infcode int64 `json:"infcode"`
  10893. Output struct {
  10894. Setldetail []interface{} `json:"setldetail"`
  10895. Setlinfo struct {
  10896. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  10897. AcctPay float64 `json:"acct_pay"`
  10898. ActPayDedc float64 `json:"act_pay_dedc"`
  10899. Age float64 `json:"age"`
  10900. Balc float64 `json:"balc"`
  10901. Brdy string `json:"brdy"`
  10902. Certno string `json:"certno"`
  10903. ClrOptins string `json:"clr_optins"`
  10904. ClrType string `json:"clr_type"`
  10905. ClrWay string `json:"clr_way"`
  10906. CvlservFlag string `json:"cvlserv_flag"`
  10907. CvlservPay float64 `json:"cvlserv_pay"`
  10908. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  10909. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  10910. Gend string `json:"gend"`
  10911. HifesPay float64 `json:"hifes_pay"`
  10912. HifmiPay float64 `json:"hifmi_pay"`
  10913. HifpPay float64 `json:"hifp_pay"`
  10914. HospPartAmt float64 `json:"hosp_part_amt"`
  10915. InscpScpAmt float64 `json:"inscp_scp_amt"`
  10916. Insutype string `json:"insutype"`
  10917. MafPay float64 `json:"maf_pay"`
  10918. MdtrtCertType string `json:"mdtrt_cert_type"`
  10919. HifobPay float64 `json:"hifob_pay"`
  10920. MdtrtID string `json:"mdtrt_id"`
  10921. MedType string `json:"med_type"`
  10922. MedfeeSumamt float64 `json:"medfee_sumamt"`
  10923. MedinsSetlID string `json:"medins_setl_id"`
  10924. Naty string `json:"naty"`
  10925. OthPay float64 `json:"oth_pay"`
  10926. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  10927. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  10928. PreselfpayAmt float64 `json:"preselfpay_amt"`
  10929. PsnCashPay float64 `json:"psn_cash_pay"`
  10930. PsnCertType string `json:"psn_cert_type"`
  10931. PsnName string `json:"psn_name"`
  10932. PsnNo string `json:"psn_no"`
  10933. PsnPartAmt float64 `json:"psn_part_amt"`
  10934. PsnType string `json:"psn_type"`
  10935. SetlID string `json:"setl_id"`
  10936. SetlTime string `json:"setl_time"`
  10937. } `json:"setlinfo"`
  10938. } `json:"output"`
  10939. RefmsgTime string `json:"refmsg_time"`
  10940. RespondTime string `json:"respond_time"`
  10941. Signtype interface{} `json:"signtype"`
  10942. WarnMsg interface{} `json:"warn_msg"`
  10943. }
  10944. type ResultSeven10265 struct {
  10945. Cainfo string `json:"cainfo"`
  10946. ErrMsg string `json:"err_msg"`
  10947. InfRefmsgid string `json:"inf_refmsgid"`
  10948. Infcode string `json:"infcode"`
  10949. Output struct {
  10950. Setldetail []interface{} `json:"setldetail"`
  10951. Setlinfo struct {
  10952. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  10953. AcctPay float64 `json:"acct_pay"`
  10954. ActPayDedc float64 `json:"act_pay_dedc"`
  10955. Age float64 `json:"age"`
  10956. Balc float64 `json:"balc"`
  10957. Brdy string `json:"brdy"`
  10958. Certno string `json:"certno"`
  10959. ClrOptins string `json:"clr_optins"`
  10960. ClrType string `json:"clr_type"`
  10961. ClrWay string `json:"clr_way"`
  10962. CvlservFlag string `json:"cvlserv_flag"`
  10963. CvlservPay float64 `json:"cvlserv_pay"`
  10964. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  10965. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  10966. Gend string `json:"gend"`
  10967. HifesPay float64 `json:"hifes_pay"`
  10968. HifmiPay float64 `json:"hifmi_pay"`
  10969. HifpPay float64 `json:"hifp_pay"`
  10970. HospPartAmt float64 `json:"hosp_part_amt"`
  10971. InscpScpAmt float64 `json:"inscp_scp_amt"`
  10972. Insutype string `json:"insutype"`
  10973. MafPay float64 `json:"maf_pay"`
  10974. MdtrtCertType string `json:"mdtrt_cert_type"`
  10975. HifobPay float64 `json:"hifob_pay"`
  10976. MdtrtID string `json:"mdtrt_id"`
  10977. MedType string `json:"med_type"`
  10978. MedfeeSumamt float64 `json:"medfee_sumamt"`
  10979. MedinsSetlID string `json:"medins_setl_id"`
  10980. Naty string `json:"naty"`
  10981. OthPay float64 `json:"oth_pay"`
  10982. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  10983. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  10984. PreselfpayAmt float64 `json:"preselfpay_amt"`
  10985. PsnCashPay float64 `json:"psn_cash_pay"`
  10986. PsnCertType string `json:"psn_cert_type"`
  10987. PsnName string `json:"psn_name"`
  10988. PsnNo string `json:"psn_no"`
  10989. PsnPartAmt float64 `json:"psn_part_amt"`
  10990. PsnType string `json:"psn_type"`
  10991. SetlID string `json:"setl_id"`
  10992. SetlTime string `json:"setl_time"`
  10993. } `json:"setlinfo"`
  10994. } `json:"output"`
  10995. RefmsgTime string `json:"refmsg_time"`
  10996. RespondTime string `json:"respond_time"`
  10997. Signtype interface{} `json:"signtype"`
  10998. WarnMsg interface{} `json:"warn_msg"`
  10999. }
  11000. type ResultSeven10265Two struct {
  11001. Cainfo string `json:"cainfo"`
  11002. ErrMsg string `json:"err_msg"`
  11003. InfRefmsgid string `json:"inf_refmsgid"`
  11004. Infcode string `json:"infcode"`
  11005. Output struct {
  11006. Setldetail []interface{} `json:"setldetail"`
  11007. Setlinfo struct {
  11008. AcctMulaidPay string `json:"acct_mulaid_pay"`
  11009. AcctPay float64 `json:"acct_pay"`
  11010. ActPayDedc float64 `json:"act_pay_dedc"`
  11011. Age float64 `json:"age"`
  11012. Balc float64 `json:"balc"`
  11013. Brdy string `json:"brdy"`
  11014. Certno string `json:"certno"`
  11015. ClrOptins string `json:"clr_optins"`
  11016. ClrType string `json:"clr_type"`
  11017. ClrWay string `json:"clr_way"`
  11018. CvlservFlag string `json:"cvlserv_flag"`
  11019. CvlservPay float64 `json:"cvlserv_pay"`
  11020. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  11021. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  11022. Gend string `json:"gend"`
  11023. HifesPay float64 `json:"hifes_pay"`
  11024. HifmiPay float64 `json:"hifmi_pay"`
  11025. HifpPay float64 `json:"hifp_pay"`
  11026. HospPartAmt string `json:"hosp_part_amt"`
  11027. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11028. Insutype string `json:"insutype"`
  11029. MafPay float64 `json:"maf_pay"`
  11030. MdtrtCertType string `json:"mdtrt_cert_type"`
  11031. HifobPay float64 `json:"hifob_pay"`
  11032. MdtrtID string `json:"mdtrt_id"`
  11033. MedType string `json:"med_type"`
  11034. MedfeeSumamt float64 `json:"medfee_sumamt"`
  11035. MedinsSetlID string `json:"medins_setl_id"`
  11036. Naty string `json:"naty"`
  11037. OthPay float64 `json:"oth_pay"`
  11038. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  11039. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  11040. PreselfpayAmt float64 `json:"preselfpay_amt"`
  11041. PsnCashPay float64 `json:"psn_cash_pay"`
  11042. PsnCertType string `json:"psn_cert_type"`
  11043. PsnName string `json:"psn_name"`
  11044. PsnNo string `json:"psn_no"`
  11045. PsnPartAmt float64 `json:"psn_part_amt"`
  11046. PsnType string `json:"psn_type"`
  11047. SetlID string `json:"setl_id"`
  11048. SetlTime string `json:"setl_time"`
  11049. } `json:"setlinfo"`
  11050. } `json:"output"`
  11051. RefmsgTime string `json:"refmsg_time"`
  11052. RespondTime string `json:"respond_time"`
  11053. Signtype interface{} `json:"signtype"`
  11054. WarnMsg interface{} `json:"warn_msg"`
  11055. }
  11056. type GZResultSeven10265Two struct {
  11057. Cainfo string `json:"cainfo"`
  11058. ErrMsg string `json:"err_msg"`
  11059. InfRefmsgid string `json:"inf_refmsgid"`
  11060. Infcode int64 `json:"infcode"`
  11061. Output struct {
  11062. Setldetail []interface{} `json:"setldetail"`
  11063. Setlinfo struct {
  11064. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  11065. AcctPay float64 `json:"acct_pay"`
  11066. ActPayDedc float64 `json:"act_pay_dedc"`
  11067. Age float64 `json:"age"`
  11068. Balc float64 `json:"balc"`
  11069. Brdy string `json:"brdy"`
  11070. Certno string `json:"certno"`
  11071. ClrOptins string `json:"clr_optins"`
  11072. ClrType string `json:"clr_type"`
  11073. ClrWay string `json:"clr_way"`
  11074. CvlservFlag string `json:"cvlserv_flag"`
  11075. CvlservPay float64 `json:"cvlserv_pay"`
  11076. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  11077. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  11078. Gend string `json:"gend"`
  11079. HifesPay float64 `json:"hifes_pay"`
  11080. HifmiPay float64 `json:"hifmi_pay"`
  11081. HifpPay float64 `json:"hifp_pay"`
  11082. HospPartAmt float64 `json:"hosp_part_amt"`
  11083. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11084. Insutype string `json:"insutype"`
  11085. MafPay float64 `json:"maf_pay"`
  11086. MdtrtCertType string `json:"mdtrt_cert_type"`
  11087. HifobPay float64 `json:"hifob_pay"`
  11088. MdtrtID string `json:"mdtrt_id"`
  11089. MedType string `json:"med_type"`
  11090. MedfeeSumamt float64 `json:"medfee_sumamt"`
  11091. MedinsSetlID string `json:"medins_setl_id"`
  11092. Naty string `json:"naty"`
  11093. OthPay float64 `json:"oth_pay"`
  11094. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  11095. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  11096. PreselfpayAmt float64 `json:"preselfpay_amt"`
  11097. PsnCashPay float64 `json:"psn_cash_pay"`
  11098. PsnCertType string `json:"psn_cert_type"`
  11099. PsnName string `json:"psn_name"`
  11100. PsnNo string `json:"psn_no"`
  11101. PsnPartAmt float64 `json:"psn_part_amt"`
  11102. PsnType string `json:"psn_type"`
  11103. SetlID string `json:"setl_id"`
  11104. SetlTime string `json:"setl_time"`
  11105. } `json:"setlinfo"`
  11106. } `json:"output"`
  11107. RefmsgTime string `json:"refmsg_time"`
  11108. RespondTime string `json:"respond_time"`
  11109. Signtype interface{} `json:"signtype"`
  11110. WarnMsg interface{} `json:"warn_msg"`
  11111. }
  11112. type ResultEight struct {
  11113. Cainfo string `json:"cainfo"`
  11114. ErrMsg string `json:"err_msg"`
  11115. InfRefmsgid string `json:"inf_refmsgid"`
  11116. Infcode int64 `json:"infcode"`
  11117. Output struct {
  11118. Stmtinfo struct {
  11119. SetlOptins string `json:"setl_optins"`
  11120. StmtRslt string `json:"stmt_rslt"`
  11121. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  11122. } `json:"stmtinfo"`
  11123. } `json:"output"`
  11124. RefmsgTime string `json:"refmsg_time"`
  11125. RespondTime string `json:"respond_time"`
  11126. Signtype interface{} `json:"signtype"`
  11127. WarnMsg interface{} `json:"warn_msg"`
  11128. }
  11129. type ResultEightFor10188 struct {
  11130. Cainfo string `json:"cainfo"`
  11131. ErrMsg string `json:"err_msg"`
  11132. InfRefmsgid string `json:"inf_refmsgid"`
  11133. Infcode string `json:"infcode"`
  11134. Output struct {
  11135. Stmtinfo struct {
  11136. SetlOptins string `json:"setl_optins"`
  11137. StmtRslt string `json:"stmt_rslt"`
  11138. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  11139. } `json:"stmtinfo"`
  11140. } `json:"output"`
  11141. RefmsgTime string `json:"refmsg_time"`
  11142. RespondTime string `json:"respond_time"`
  11143. Signtype interface{} `json:"signtype"`
  11144. WarnMsg interface{} `json:"warn_msg"`
  11145. }
  11146. type ResultNine struct {
  11147. Cainfo string `json:"cainfo"`
  11148. ErrMsg string `json:"err_msg"`
  11149. InfRefmsgid string `json:"inf_refmsgid"`
  11150. Infcode int64 `json:"infcode"`
  11151. Output struct {
  11152. FileQuryNo string `json:"file_qury_no"`
  11153. } `json:"output"`
  11154. RefmsgTime string `json:"refmsg_time"`
  11155. RespondTime string `json:"respond_time"`
  11156. Signtype interface{} `json:"signtype"`
  11157. WarnMsg interface{} `json:"warn_msg"`
  11158. }
  11159. type ResultTen struct {
  11160. Cainfo string `json:"cainfo"`
  11161. ErrMsg string `json:"err_msg"`
  11162. InfRefmsgid string `json:"inf_refmsgid"`
  11163. Infcode int64 `json:"infcode"`
  11164. Output struct {
  11165. DldEndtime string `json:"dld_endtime"`
  11166. FileQuryNo string `json:"file_qury_no"`
  11167. Filename string `json:"filename"`
  11168. } `json:"output"`
  11169. RefmsgTime string `json:"refmsg_time"`
  11170. RespondTime string `json:"respond_time"`
  11171. Signtype interface{} `json:"signtype"`
  11172. WarnMsg interface{} `json:"warn_msg"`
  11173. }
  11174. type Result5262 struct {
  11175. ErrMsg string `json:"err_msg"`
  11176. InfRefmsgid string `json:"inf_refmsgid"`
  11177. Infcode int64 `json:"infcode"`
  11178. Output struct {
  11179. PageInfo struct {
  11180. Size int `json:"size"`
  11181. RecordCounts int `json:"record_counts"`
  11182. } `json:"page_info"`
  11183. Idetinfo []interface{} `json:"idetinfo"`
  11184. Result []struct {
  11185. SetlID string `json:"setl_id"`
  11186. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  11187. MdtrtID string `json:"mdtrt_id"`
  11188. InitSetlID string `json:"init_setl_id,omitempty"`
  11189. PsnNo string `json:"psn_no"`
  11190. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  11191. PsnName string `json:"psn_name"`
  11192. PsnCertType string `json:"psn_cert_type"`
  11193. Certno string `json:"certno"`
  11194. Gend string `json:"gend,omitempty"`
  11195. Naty string `json:"naty,omitempty"`
  11196. Brdy string `json:"brdy,omitempty"`
  11197. Age float64 `json:"age,omitempty"`
  11198. Insutype string `json:"insutype,omitempty"`
  11199. PsnType string `json:"psn_type"`
  11200. CvlservFlag string `json:"cvlserv_flag"`
  11201. CvlservLv string `json:"cvlserv_lv,omitempty"`
  11202. SpPsnType string `json:"sp_psn_type,omitempty"`
  11203. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  11204. ClctGrde string `json:"clct_grde,omitempty"`
  11205. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  11206. NwbFlag string `json:"nwb_flag,omitempty"`
  11207. InsuAdmdvs string `json:"insu_admdvs"`
  11208. EmpNo string `json:"emp_no,omitempty"`
  11209. EmpName string `json:"emp_name,omitempty"`
  11210. EmpType string `json:"emp_type,omitempty"`
  11211. EconType string `json:"econ_type,omitempty"`
  11212. AfilIndu string `json:"afil_indu,omitempty"`
  11213. AfilRlts string `json:"afil_rlts,omitempty"`
  11214. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  11215. PayLoc string `json:"pay_loc,omitempty"`
  11216. FixmedinsCode string `json:"fixmedins_code"`
  11217. FixmedinsName string `json:"fixmedins_name"`
  11218. HospLv string `json:"hosp_lv,omitempty"`
  11219. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  11220. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  11221. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  11222. Begndate string `json:"begndate"`
  11223. Enddate string `json:"enddate"`
  11224. SetlTime string `json:"setl_time"`
  11225. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  11226. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  11227. MedType string `json:"med_type"`
  11228. SetlType string `json:"setl_type,omitempty"`
  11229. ClrType string `json:"clr_type,omitempty"`
  11230. ClrWay string `json:"clr_way,omitempty"`
  11231. PsnSetlway string `json:"psn_setlway,omitempty"`
  11232. ClrOptins string `json:"clr_optins,omitempty"`
  11233. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  11234. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  11235. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  11236. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  11237. InscpAmt float64 `json:"inscp_amt,omitempty"`
  11238. DedcStd float64 `json:"dedc_std,omitempty"`
  11239. CrtDedc float64 `json:"crt_dedc,omitempty"`
  11240. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  11241. HifpPay float64 `json:"hifp_pay,omitempty"`
  11242. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  11243. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  11244. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  11245. HifesPay float64 `json:"hifes_pay,omitempty"`
  11246. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  11247. HifobPay float64 `json:"hifob_pay,omitempty"`
  11248. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  11249. MafPay float64 `json:"maf_pay,omitempty"`
  11250. OthfundPay float64 `json:"othfund_pay,omitempty"`
  11251. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  11252. PsnPay float64 `json:"psn_pay,omitempty"`
  11253. AcctPay float64 `json:"acct_pay,omitempty"`
  11254. CashPayamt float64 `json:"cash_payamt,omitempty"`
  11255. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  11256. Balc float64 `json:"balc,omitempty"`
  11257. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  11258. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  11259. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  11260. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  11261. Year string `json:"year,omitempty"`
  11262. DiseNo string `json:"dise_no,omitempty"`
  11263. DiseName string `json:"dise_name,omitempty"`
  11264. Invono string `json:"invono,omitempty"`
  11265. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  11266. ValiFlag string `json:"vali_flag,omitempty"`
  11267. Memo string `json:"memo,omitempty"`
  11268. Rid string `json:"rid"`
  11269. UpdtTime string `json:"updt_time,omitempty"`
  11270. CrterID string `json:"crter_id,omitempty"`
  11271. CrterName string `json:"crter_name,omitempty"`
  11272. CrteTime string `json:"crte_time,omitempty"`
  11273. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  11274. OpterID string `json:"opter_id,omitempty"`
  11275. OpterName string `json:"opter_name,omitempty"`
  11276. OptTime string `json:"opt_time,omitempty"`
  11277. OptinsNo string `json:"optins_no,omitempty"`
  11278. PoolareaNo string `json:"poolarea_no,omitempty"`
  11279. } `json:"result"`
  11280. } `json:"output"`
  11281. RefmsgTime string `json:"refmsg_time"`
  11282. RespondTime string `json:"respond_time"`
  11283. Signtype interface{} `json:"signtype"`
  11284. WarnInfo interface{} `json:"warn_info"`
  11285. }
  11286. type Result5267 struct {
  11287. ErrMsg string `json:"err_msg"`
  11288. InfRefmsgid string `json:"inf_refmsgid"`
  11289. Infcode int64 `json:"infcode"`
  11290. Output struct {
  11291. PageInfo struct {
  11292. Size int `json:"size"`
  11293. RecordCounts int `json:"record_counts"`
  11294. } `json:"pageinfo"`
  11295. Result []struct {
  11296. SetlID string `json:"setl_id"`
  11297. ClrOptins string `json:"clr_optins"`
  11298. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  11299. MdtrtID string `json:"mdtrt_id"`
  11300. InitSetlID string `json:"init_setl_id,omitempty"`
  11301. PsnNo string `json:"psn_no"`
  11302. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  11303. PsnName string `json:"psn_name"`
  11304. PsnCertType string `json:"psn_cert_type"`
  11305. Certno string `json:"certno"`
  11306. Gend string `json:"gend,omitempty"`
  11307. Naty string `json:"naty,omitempty"`
  11308. Brdy string `json:"brdy,omitempty"`
  11309. Age float64 `json:"age,omitempty"`
  11310. Insutype string `json:"insutype,omitempty"`
  11311. PsnType string `json:"psn_type"`
  11312. CvlservFlag string `json:"cvlserv_flag"`
  11313. CvlservLv string `json:"cvlserv_lv,omitempty"`
  11314. SpPsnType string `json:"sp_psn_type,omitempty"`
  11315. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  11316. ClctGrde string `json:"clct_grde,omitempty"`
  11317. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  11318. NwbFlag string `json:"nwb_flag,omitempty"`
  11319. InsuAdmdvs string `json:"insu_admdvs"`
  11320. EmpNo string `json:"emp_no,omitempty"`
  11321. EmpName string `json:"emp_name,omitempty"`
  11322. EmpType string `json:"emp_type,omitempty"`
  11323. EconType string `json:"econ_type,omitempty"`
  11324. AfilIndu string `json:"afil_indu,omitempty"`
  11325. AfilRlts string `json:"afil_rlts,omitempty"`
  11326. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  11327. PayLoc string `json:"pay_loc,omitempty"`
  11328. FixmedinsCode string `json:"fixmedins_code"`
  11329. FixmedinsName string `json:"fixmedins_name"`
  11330. HospLv string `json:"hosp_lv,omitempty"`
  11331. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  11332. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  11333. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  11334. Begndate string `json:"begndate,omitempty"`
  11335. Enddate string `json:"enddate,omitempty"`
  11336. SetlTime string `json:"setl_time,omitempty"`
  11337. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  11338. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  11339. MedType string `json:"med_type"`
  11340. SetlType string `json:"setl_type,omitempty"`
  11341. ClrType string `json:"clr_type,omitempty"`
  11342. ClrWay string `json:"clr_way,omitempty"`
  11343. PsnSetlway string `json:"psn_setlway,omitempty"`
  11344. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  11345. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  11346. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  11347. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  11348. InscpAmt float64 `json:"inscp_amt,omitempty"`
  11349. DedcStd float64 `json:"dedc_std,omitempty"`
  11350. CrtDedc float64 `json:"crt_dedc,omitempty"`
  11351. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  11352. HifpPay float64 `json:"hifp_pay,omitempty"`
  11353. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  11354. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  11355. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  11356. HifesPay float64 `json:"hifes_pay,omitempty"`
  11357. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  11358. HifobPay float64 `json:"hifob_pay,omitempty"`
  11359. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  11360. MafPay float64 `json:"maf_pay,omitempty"`
  11361. OthfundPay float64 `json:"othfund_pay,omitempty"`
  11362. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  11363. PsnPay float64 `json:"psn_pay,omitempty"`
  11364. AcctPay float64 `json:"acct_pay,omitempty"`
  11365. CashPayamt float64 `json:"cash_payamt,omitempty"`
  11366. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  11367. Balc float64 `json:"balc,omitempty"`
  11368. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  11369. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  11370. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  11371. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  11372. Year string `json:"year,omitempty"`
  11373. DiseNo string `json:"dise_no,omitempty"`
  11374. DiseName string `json:"dise_name,omitempty"`
  11375. Invono string `json:"invono,omitempty"`
  11376. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  11377. Memo string `json:"memo,omitempty"`
  11378. UpdtTime string `json:"updt_time,omitempty"`
  11379. OpterID string `json:"opter_id,omitempty"`
  11380. OpterName string `json:"opter_name,omitempty"`
  11381. OptTime string `json:"opt_time,omitempty"`
  11382. OptinsNo string `json:"optins_no,omitempty"`
  11383. PoolareaNo string `json:"poolarea_no,omitempty"`
  11384. } `json:"result"`
  11385. } `json:"output"`
  11386. RefmsgTime string `json:"refmsg_time"`
  11387. RespondTime string `json:"respond_time"`
  11388. Signtype interface{} `json:"signtype"`
  11389. WarnInfo interface{} `json:"warn_info"`
  11390. }
  11391. //type Autogenerated struct {
  11392. // Output struct {
  11393. // Setlinfo struct {
  11394. // SetlTime string `json:"setl_time"`
  11395. // CvlservPay float64 `json:"cvlserv_pay"`
  11396. // Year string `json:"year"`
  11397. // MedType string `json:"med_type"`
  11398. // PsnPay float64 `json:"psn_pay"`
  11399. // OpterID string `json:"opter_id"`
  11400. // Begndate string `json:"begndate"`
  11401. // FlxempeFlag string `json:"flxempe_flag"`
  11402. // HifmiPay float64 `json:"hifmi_pay"`
  11403. // PsnNo string `json:"psn_no"`
  11404. // ActPayDedc float64 `json:"act_pay_dedc"`
  11405. // MedinsSetlID interface{} `json:"medins_setl_id"`
  11406. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  11407. // ClrWay string `json:"clr_way"`
  11408. // OthPay float64 `json:"oth_pay"`
  11409. // Gend string `json:"gend"`
  11410. // MdtrtID string `json:"mdtrt_id"`
  11411. // AcctPay float64 `json:"acct_pay"`
  11412. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  11413. // Insutype string `json:"insutype"`
  11414. // Invono interface{} `json:"invono"`
  11415. // Enddate string `json:"enddate"`
  11416. // CashPayamt float64 `json:"cash_payamt"`
  11417. // PsnType string `json:"psn_type"`
  11418. // FixmedinsName string `json:"fixmedins_name"`
  11419. // HifpPay float64 `json:"hifp_pay"`
  11420. // NewFlag interface{} `json:"new_flag"`
  11421. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  11422. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  11423. // PayLoc string `json:"pay_loc"`
  11424. // ClrType string `json:"clr_type"`
  11425. // RefdSetlFlag string `json:"refd_setl_flag"`
  11426. // CvlservFlag string `json:"cvlserv_flag"`
  11427. // EmpName string `json:"emp_name"`
  11428. // Brdy string `json:"brdy"`
  11429. // Naty string `json:"naty"`
  11430. // Certno string `json:"certno"`
  11431. // DiseCode string `json:"dise_code"`
  11432. // FixmedinsCode string `json:"fixmedins_code"`
  11433. // DedcHospLv string `json:"dedc_hosp_lv"`
  11434. // OpterName string `json:"opter_name"`
  11435. // Balc float64 `json:"balc"`
  11436. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  11437. // PsnCertType string `json:"psn_cert_type"`
  11438. // HifobPay float64 `json:"hifob_pay"`
  11439. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  11440. // HifesPay float64 `json:"hifes_pay"`
  11441. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  11442. // OptTime string `json:"opt_time"`
  11443. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  11444. // SetlID string `json:"setl_id"`
  11445. // MafPay float64 `json:"maf_pay"`
  11446. // PsnName string `json:"psn_name"`
  11447. // InsuOptins interface{} `json:"insu_optins"`
  11448. // PrefFundPay interface{} `json:"pref_fund_pay"`
  11449. // ClrOptins string `json:"clr_optins"`
  11450. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  11451. // DiseName string `json:"dise_name"`
  11452. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  11453. // Age float64 `json:"age"`
  11454. // DtrtCertType string `json:"dtrt_cert_type"`
  11455. // HospLv string `json:"hosp_lv"`
  11456. // } `json:"setlinfo"`
  11457. // Setldetail []struct {
  11458. // FundPayType string `json:"fund_pay_type"`
  11459. // FundPayamt float64 `json:"fund_payamt"`
  11460. // SetlProcInfo interface{} `json:"setl_proc_info"`
  11461. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  11462. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  11463. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  11464. // PrefFundPay interface{} `json:"pref_fund_pay"`
  11465. // } `json:"setldetail"`
  11466. // } `json:"output"`
  11467. // Infcode int `json:"infcode"`
  11468. // WarnMsg interface{} `json:"warn_msg"`
  11469. // Cainfo interface{} `json:"cainfo"`
  11470. // ErrMsg interface{} `json:"err_msg"`
  11471. // RefmsgTime string `json:"refmsg_time"`
  11472. // Signtype interface{} `json:"signtype"`
  11473. // RespondTime string `json:"respond_time"`
  11474. // InfRefmsgid string `json:"inf_refmsgid"`
  11475. //}
  11476. type Result002 struct {
  11477. Cainfo interface{} `json:"cainfo"`
  11478. ErrMsg string `json:"err_msg"`
  11479. InfRefmsgid string `json:"inf_refmsgid"`
  11480. Infcode int64 `json:"infcode"`
  11481. Output struct {
  11482. RxFile string `json:"rx_file"`
  11483. SignDigest string `json:"sign_digest"`
  11484. SignCertSn string `json:"sign_cert_sn"`
  11485. SignCertDn string `json:"sign_cert_dn"`
  11486. } `json:"output"`
  11487. RefmsgTime string `json:"refmsg_time"`
  11488. RespondTime string `json:"respond_time"`
  11489. Signtype interface{} `json:"signtype"`
  11490. WarnMsg interface{} `json:"warn_msg"`
  11491. }
  11492. type Result003 struct {
  11493. Cainfo interface{} `json:"cainfo"`
  11494. ErrMsg string `json:"err_msg"`
  11495. InfRefmsgid string `json:"inf_refmsgid"`
  11496. Infcode int64 `json:"infcode"`
  11497. Output struct {
  11498. HiRxno string `json:"hi_rxno"`
  11499. RxStasCodg string `json:"rx_stas_codg"`
  11500. RxStasName string `json:"rx_stas_name"`
  11501. } `json:"output"`
  11502. RefmsgTime string `json:"refmsg_time"`
  11503. RespondTime string `json:"respond_time"`
  11504. Signtype interface{} `json:"signtype"`
  11505. WarnMsg interface{} `json:"warn_msg"`
  11506. }
  11507. type ResultEleven struct {
  11508. Cainfo string `json:"cainfo"`
  11509. ErrMsg string `json:"err_msg"`
  11510. InfRefmsgid string `json:"inf_refmsgid"`
  11511. Infcode int64 `json:"infcode"`
  11512. Output struct {
  11513. Setlinfo struct {
  11514. SetlTime string `json:"setl_time"`
  11515. CvlservPay float64 `json:"cvlserv_pay"`
  11516. Year string `json:"year"`
  11517. MedType string `json:"med_type"`
  11518. PsnPay float64 `json:"psn_pay"`
  11519. OpterID string `json:"opter_id"`
  11520. Begndate string `json:"begndate"`
  11521. FlxempeFlag string `json:"flxempe_flag"`
  11522. HifmiPay float64 `json:"hifmi_pay"`
  11523. PsnNo string `json:"psn_no"`
  11524. ActPayDedc float64 `json:"act_pay_dedc"`
  11525. MedinsSetlID interface{} `json:"medins_setl_id"`
  11526. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  11527. ClrWay string `json:"clr_way"`
  11528. OthPay float64 `json:"oth_pay"`
  11529. Gend string `json:"gend"`
  11530. MdtrtID string `json:"mdtrt_id"`
  11531. AcctPay float64 `json:"acct_pay"`
  11532. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11533. Insutype string `json:"insutype"`
  11534. Invono interface{} `json:"invono"`
  11535. Enddate string `json:"enddate"`
  11536. CashPayamt float64 `json:"cash_payamt"`
  11537. PsnType string `json:"psn_type"`
  11538. FixmedinsName string `json:"fixmedins_name"`
  11539. HifpPay float64 `json:"hifp_pay"`
  11540. NewFlag interface{} `json:"new_flag"`
  11541. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  11542. PreselfpayAmt float64 `json:"preselfpay_amt"`
  11543. PayLoc string `json:"pay_loc"`
  11544. ClrType string `json:"clr_type"`
  11545. RefdSetlFlag string `json:"refd_setl_flag"`
  11546. CvlservFlag string `json:"cvlserv_flag"`
  11547. EmpName string `json:"emp_name"`
  11548. Brdy string `json:"brdy"`
  11549. Naty string `json:"naty"`
  11550. Certno string `json:"certno"`
  11551. DiseCode string `json:"dise_code"`
  11552. FixmedinsCode string `json:"fixmedins_code"`
  11553. DedcHospLv string `json:"dedc_hosp_lv"`
  11554. OpterName string `json:"opter_name"`
  11555. Balc float64 `json:"balc"`
  11556. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  11557. PsnCertType string `json:"psn_cert_type"`
  11558. HifobPay float64 `json:"hifob_pay"`
  11559. MedfeeSumamt float64 `json:"medfee_sumamt"`
  11560. HifesPay float64 `json:"hifes_pay"`
  11561. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  11562. OptTime string `json:"opt_time"`
  11563. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  11564. SetlID string `json:"setl_id"`
  11565. MafPay float64 `json:"maf_pay"`
  11566. PsnName string `json:"psn_name"`
  11567. InsuOptins interface{} `json:"insu_optins"`
  11568. PrefFundPay interface{} `json:"pref_fund_pay"`
  11569. ClrOptins string `json:"clr_optins"`
  11570. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  11571. DiseName string `json:"dise_name"`
  11572. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  11573. Age float64 `json:"age"`
  11574. DtrtCertType string `json:"dtrt_cert_type"`
  11575. HospLv string `json:"hosp_lv"`
  11576. PsnCashPay float64 `json:"psn_cash_pay"`
  11577. } `json:"setlinfo"`
  11578. } `json:"output"`
  11579. RefmsgTime string `json:"refmsg_time"`
  11580. RespondTime string `json:"respond_time"`
  11581. Signtype interface{} `json:"signtype"`
  11582. WarnMsg interface{} `json:"warn_msg"`
  11583. }
  11584. type ResultEleven10265 struct {
  11585. Cainfo string `json:"cainfo"`
  11586. ErrMsg string `json:"err_msg"`
  11587. InfRefmsgid string `json:"inf_refmsgid"`
  11588. Infcode string `json:"infcode"`
  11589. Output struct {
  11590. Setlinfo struct {
  11591. SetlTime string `json:"setl_time"`
  11592. CvlservPay float64 `json:"cvlserv_pay"`
  11593. Year string `json:"year"`
  11594. MedType string `json:"med_type"`
  11595. PsnPay float64 `json:"psn_pay"`
  11596. OpterID string `json:"opter_id"`
  11597. Begndate string `json:"begndate"`
  11598. FlxempeFlag string `json:"flxempe_flag"`
  11599. HifmiPay float64 `json:"hifmi_pay"`
  11600. PsnNo string `json:"psn_no"`
  11601. ActPayDedc float64 `json:"act_pay_dedc"`
  11602. MedinsSetlID interface{} `json:"medins_setl_id"`
  11603. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  11604. ClrWay string `json:"clr_way"`
  11605. OthPay float64 `json:"oth_pay"`
  11606. Gend string `json:"gend"`
  11607. MdtrtID string `json:"mdtrt_id"`
  11608. AcctPay float64 `json:"acct_pay"`
  11609. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11610. Insutype string `json:"insutype"`
  11611. Invono interface{} `json:"invono"`
  11612. Enddate string `json:"enddate"`
  11613. CashPayamt float64 `json:"cash_payamt"`
  11614. PsnType string `json:"psn_type"`
  11615. FixmedinsName string `json:"fixmedins_name"`
  11616. HifpPay float64 `json:"hifp_pay"`
  11617. NewFlag interface{} `json:"new_flag"`
  11618. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  11619. PreselfpayAmt float64 `json:"preselfpay_amt"`
  11620. PayLoc string `json:"pay_loc"`
  11621. ClrType string `json:"clr_type"`
  11622. RefdSetlFlag string `json:"refd_setl_flag"`
  11623. CvlservFlag string `json:"cvlserv_flag"`
  11624. EmpName string `json:"emp_name"`
  11625. Brdy string `json:"brdy"`
  11626. Naty string `json:"naty"`
  11627. Certno string `json:"certno"`
  11628. DiseCode string `json:"dise_code"`
  11629. FixmedinsCode string `json:"fixmedins_code"`
  11630. DedcHospLv string `json:"dedc_hosp_lv"`
  11631. OpterName string `json:"opter_name"`
  11632. Balc float64 `json:"balc"`
  11633. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  11634. PsnCertType string `json:"psn_cert_type"`
  11635. HifobPay float64 `json:"hifob_pay"`
  11636. MedfeeSumamt float64 `json:"medfee_sumamt"`
  11637. HifesPay float64 `json:"hifes_pay"`
  11638. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  11639. OptTime string `json:"opt_time"`
  11640. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  11641. SetlID string `json:"setl_id"`
  11642. MafPay float64 `json:"maf_pay"`
  11643. PsnName string `json:"psn_name"`
  11644. InsuOptins interface{} `json:"insu_optins"`
  11645. PrefFundPay interface{} `json:"pref_fund_pay"`
  11646. ClrOptins string `json:"clr_optins"`
  11647. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  11648. DiseName string `json:"dise_name"`
  11649. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  11650. Age float64 `json:"age"`
  11651. DtrtCertType string `json:"dtrt_cert_type"`
  11652. HospLv string `json:"hosp_lv"`
  11653. PsnCashPay float64 `json:"psn_cash_pay"`
  11654. } `json:"setlinfo"`
  11655. } `json:"output"`
  11656. RefmsgTime string `json:"refmsg_time"`
  11657. RespondTime string `json:"respond_time"`
  11658. Signtype interface{} `json:"signtype"`
  11659. WarnMsg interface{} `json:"warn_msg"`
  11660. }
  11661. type ResultTwelve struct {
  11662. Cainfo string `json:"cainfo"`
  11663. ErrMsg string `json:"err_msg"`
  11664. InfRefmsgid string `json:"inf_refmsgid"`
  11665. Infcode int64 `json:"infcode"`
  11666. Output struct {
  11667. MdtrtId string `json:"mdtrt_id"`
  11668. ChrgBchno string `json:"chrg_bchno"`
  11669. PsnNo string `json:"psn_no"`
  11670. } `json:"output"`
  11671. RefmsgTime string `json:"refmsg_time"`
  11672. RespondTime string `json:"respond_time"`
  11673. Signtype interface{} `json:"signtype"`
  11674. WarnMsg interface{} `json:"warn_msg"`
  11675. }
  11676. type ResultThirteen struct {
  11677. ErrMsg string `json:"err_msg"`
  11678. InfRefmsgid string `json:"inf_refmsgid"`
  11679. Infcode int64 `json:"infcode"`
  11680. Output struct {
  11681. Result struct {
  11682. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  11683. } `json:"result"`
  11684. } `json:"output"`
  11685. RefmsgTime string `json:"refmsg_time"`
  11686. RespondTime string `json:"respond_time"`
  11687. Signtype interface{} `json:"signtype"`
  11688. WarnInfo interface{} `json:"warn_info"`
  11689. }
  11690. type ResultThirteen10265 struct {
  11691. ErrMsg string `json:"err_msg"`
  11692. InfRefmsgid string `json:"inf_refmsgid"`
  11693. Infcode string `json:"infcode"`
  11694. Output struct {
  11695. Result struct {
  11696. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  11697. } `json:"result"`
  11698. } `json:"output"`
  11699. RefmsgTime string `json:"refmsg_time"`
  11700. RespondTime string `json:"respond_time"`
  11701. Signtype interface{} `json:"signtype"`
  11702. WarnInfo interface{} `json:"warn_info"`
  11703. }
  11704. type ResultFourteen struct {
  11705. ErrMsg string `json:"err_msg"`
  11706. InfRefmsgid string `json:"inf_refmsgid"`
  11707. Infcode int64 `json:"infcode"`
  11708. Output struct {
  11709. } `json:"output"`
  11710. RefmsgTime string `json:"refmsg_time"`
  11711. RespondTime string `json:"respond_time"`
  11712. Signtype interface{} `json:"signtype"`
  11713. WarnInfo interface{} `json:"warn_info"`
  11714. }
  11715. type ResultFourteen10265 struct {
  11716. ErrMsg string `json:"err_msg"`
  11717. InfRefmsgid string `json:"inf_refmsgid"`
  11718. Infcode string `json:"infcode"`
  11719. Output struct {
  11720. } `json:"output"`
  11721. RefmsgTime string `json:"refmsg_time"`
  11722. RespondTime string `json:"respond_time"`
  11723. Signtype interface{} `json:"signtype"`
  11724. WarnInfo interface{} `json:"warn_info"`
  11725. }
  11726. type ResultSixteen struct {
  11727. Cainfo string `json:"cainfo"`
  11728. ErrMsg string `json:"err_msg"`
  11729. InfRefmsgid string `json:"inf_refmsgid"`
  11730. Infcode int64 `json:"infcode"`
  11731. Output struct {
  11732. Setldetail []interface{} `json:"setldetail"`
  11733. Setlinfo struct {
  11734. MdtrtID string `json:"mdtrt_id"`
  11735. SetlID string `json:"setl_id"`
  11736. ClrOptins string `json:"clr_optins"`
  11737. SetlTime string `json:"setl_time"`
  11738. MedfeeSumamt float64 `json:"medfee_sumamt"`
  11739. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  11740. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  11741. PreselfpayAmt float64 `json:"preselfpay_amt"`
  11742. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11743. ActPayDedc float64 `json:"act_pay_dedc"`
  11744. HifpPay float64 `json:"hifp_pay"`
  11745. PoolPropSe float64 `json:"pool_prop_selfpay"`
  11746. Lfpay float64 `json:"selfpay"`
  11747. CvlservPay float64 `json:"cvlserv_pay"`
  11748. HifesPay float64 `json:"hifes_pay"`
  11749. HifmiPay float64 `json:"hifmi_pay"`
  11750. HifobPay float64 `json:"hifob_pay"`
  11751. MafPay float64 `json:"maf_pay"`
  11752. OthPay float64 `json:"oth_pay"`
  11753. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  11754. PsnPartAmt float64 `json:"psn_part_amt"`
  11755. AcctPay float64 `json:"acct_pay"`
  11756. Balc float64 `json:"balc"`
  11757. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  11758. HospPartAmt float64 `json:"hosp_part_amt"`
  11759. MedinsSetlID string `json:"medins_setl_id"`
  11760. PdnCashPay string `json:"pdn_cash_pay"`
  11761. } `json:"setlinfo"`
  11762. } `json:"output"`
  11763. RefmsgTime string `json:"refmsg_time"`
  11764. RespondTime string `json:"respond_time"`
  11765. Signtype interface{} `json:"signtype"`
  11766. WarnMsg interface{} `json:"warn_msg"`
  11767. }
  11768. type ResultSixteen10265 struct {
  11769. Cainfo string `json:"cainfo"`
  11770. ErrMsg string `json:"err_msg"`
  11771. InfRefmsgid string `json:"inf_refmsgid"`
  11772. Infcode string `json:"infcode"`
  11773. Output struct {
  11774. Setldetail []interface{} `json:"setldetail"`
  11775. Setlinfo struct {
  11776. MdtrtID string `json:"mdtrt_id"`
  11777. SetlID string `json:"setl_id"`
  11778. ClrOptins string `json:"clr_optins"`
  11779. SetlTime string `json:"setl_time"`
  11780. MedfeeSumamt float64 `json:"medfee_sumamt"`
  11781. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  11782. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  11783. PreselfpayAmt float64 `json:"preselfpay_amt"`
  11784. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11785. ActPayDedc float64 `json:"act_pay_dedc"`
  11786. HifpPay float64 `json:"hifp_pay"`
  11787. PoolPropSe float64 `json:"pool_prop_selfpay"`
  11788. Lfpay float64 `json:"selfpay"`
  11789. CvlservPay float64 `json:"cvlserv_pay"`
  11790. HifesPay float64 `json:"hifes_pay"`
  11791. HifmiPay float64 `json:"hifmi_pay"`
  11792. HifobPay float64 `json:"hifob_pay"`
  11793. MafPay float64 `json:"maf_pay"`
  11794. OthPay float64 `json:"oth_pay"`
  11795. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  11796. PsnPartAmt float64 `json:"psn_part_amt"`
  11797. AcctPay float64 `json:"acct_pay"`
  11798. Balc float64 `json:"balc"`
  11799. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  11800. HospPartAmt float64 `json:"hosp_part_amt"`
  11801. MedinsSetlID string `json:"medins_setl_id"`
  11802. PdnCashPay string `json:"pdn_cash_pay"`
  11803. } `json:"setlinfo"`
  11804. } `json:"output"`
  11805. RefmsgTime string `json:"refmsg_time"`
  11806. RespondTime string `json:"respond_time"`
  11807. Signtype interface{} `json:"signtype"`
  11808. WarnMsg interface{} `json:"warn_msg"`
  11809. }
  11810. type ResultSixteen10265Two struct {
  11811. Cainfo string `json:"cainfo"`
  11812. ErrMsg string `json:"err_msg"`
  11813. InfRefmsgid string `json:"inf_refmsgid"`
  11814. Infcode string `json:"infcode"`
  11815. Output struct {
  11816. Setldetail []interface{} `json:"setldetail"`
  11817. Setlinfo interface{} `json:"setlinfo"`
  11818. } `json:"output"`
  11819. RefmsgTime string `json:"refmsg_time"`
  11820. RespondTime string `json:"respond_time"`
  11821. Signtype interface{} `json:"signtype"`
  11822. WarnMsg interface{} `json:"warn_msg"`
  11823. }
  11824. type ResultgzSixteen10265Two struct {
  11825. Cainfo string `json:"cainfo"`
  11826. ErrMsg string `json:"err_msg"`
  11827. InfRefmsgid string `json:"inf_refmsgid"`
  11828. Infcode int64 `json:"infcode"`
  11829. Output struct {
  11830. Setldetail []interface{} `json:"setldetail"`
  11831. Setlinfo interface{} `json:"setlinfo"`
  11832. } `json:"output"`
  11833. RefmsgTime string `json:"refmsg_time"`
  11834. RespondTime string `json:"respond_time"`
  11835. Signtype interface{} `json:"signtype"`
  11836. WarnMsg interface{} `json:"warn_msg"`
  11837. }
  11838. type ResultSeventeen struct {
  11839. ErrMsg string `json:"err_msg"`
  11840. InfRefmsgid string `json:"inf_refmsgid"`
  11841. Infcode int64 `json:"infcode"`
  11842. Output struct {
  11843. SetlListId string `json:"setl_list_id"`
  11844. } `json:"output"`
  11845. RefmsgTime string `json:"refmsg_time"`
  11846. RespondTime string `json:"respond_time"`
  11847. Signtype string `json:"signtype"`
  11848. WarnInfo string `json:"warn_info"`
  11849. }
  11850. type ResultSeventeenOther struct {
  11851. ErrMsg string `json:"err_msg"`
  11852. InfRefmsgid string `json:"inf_refmsgid"`
  11853. Infcode string `json:"infcode"`
  11854. Output struct {
  11855. SetlListId string `json:"setl_list_id"`
  11856. } `json:"output"`
  11857. RefmsgTime string `json:"refmsg_time"`
  11858. RespondTime string `json:"respond_time"`
  11859. Signtype string `json:"signtype"`
  11860. WarnInfo string `json:"warn_info"`
  11861. }
  11862. type Result90991 struct {
  11863. ErrMsg string `json:"err_msg"`
  11864. InfRefmsgid string `json:"inf_refmsgid"`
  11865. Infcode int64 `json:"infcode"`
  11866. Output struct {
  11867. Result struct {
  11868. PsnNo string `json:"psn_no"`
  11869. CardStat string `json:"card_stat"`
  11870. Certno string `json:"certno"`
  11871. PsnName string `json:"psn_name"`
  11872. CheckStat string `json:"check_stat"`
  11873. SscnoCheckStat string `json:"sscno_check_stat"`
  11874. } `json:"result"`
  11875. } `json:"output"`
  11876. RefmsgTime string `json:"refmsg_time"`
  11877. RespondTime string `json:"respond_time"`
  11878. Signtype interface{} `json:"signtype"`
  11879. WarnInfo interface{} `json:"warn_info"`
  11880. }
  11881. type Result90100 struct {
  11882. ErrMsg string `json:"err_msg"`
  11883. InfRefmsgid string `json:"inf_refmsgid"`
  11884. Infcode int64 `json:"infcode"`
  11885. Output struct {
  11886. PoolareaNo string `json:"poolarea_no"`
  11887. PoolareaNoName string `json:"poolarea_no_name"`
  11888. Insutype string `json:"insutype"`
  11889. InsutypeName string `json:"insutype_name"`
  11890. ClctType string `json:"clct_type"`
  11891. ClctTypeName string `json:"clct_type_name"`
  11892. ClctFlag string `json:"clct_flag"`
  11893. ClctFlagName string `json:"clct_flag_name"`
  11894. AccrymBegn string `json:"accrym_begn"`
  11895. AccrymEnd string `json:"accrym_end"`
  11896. ClctTime string `json:"clct_time"`
  11897. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  11898. } `json:"output"`
  11899. RefmsgTime string `json:"refmsg_time"`
  11900. RespondTime string `json:"respond_time"`
  11901. Signtype interface{} `json:"signtype"`
  11902. WarnInfo interface{} `json:"warn_info"`
  11903. }
  11904. type Custom struct {
  11905. DetItemFeeSumamt string
  11906. Cut string
  11907. FeedetlSn string
  11908. Price string
  11909. MedListCodg string
  11910. Type int64
  11911. AdviceId int64
  11912. ProjectId int64
  11913. ItemId int64
  11914. }
  11915. type Result5301 struct {
  11916. ErrMsg string `json:"err_msg"`
  11917. InfRefmsgid string `json:"inf_refmsgid"`
  11918. Infcode int64 `json:"infcode"`
  11919. Output struct {
  11920. Result []struct {
  11921. OpspDiseCode string `json:"opsp_dise_code"`
  11922. OpspDiseName string `json:"opsp_dise_name"`
  11923. Begndate string `json:"begndate"`
  11924. Enddate string `json:"enddate"`
  11925. } `json:"feedetail"`
  11926. } `json:"output"`
  11927. RefmsgTime string `json:"refmsg_time"`
  11928. RespondTime string `json:"respond_time"`
  11929. Signtype interface{} `json:"signtype"`
  11930. WarnInfo interface{} `json:"warn_info"`
  11931. }
  11932. type Result5301For10265 struct {
  11933. ErrMsg string `json:"err_msg"`
  11934. InfRefmsgid string `json:"inf_refmsgid"`
  11935. Infcode string `json:"infcode"`
  11936. Output struct {
  11937. Result []struct {
  11938. OpspDiseCode string `json:"opsp_dise_code"`
  11939. OpspDiseName string `json:"opsp_dise_name"`
  11940. Begndate string `json:"begndate"`
  11941. Enddate string `json:"enddate"`
  11942. } `json:"feedetail"`
  11943. } `json:"output"`
  11944. RefmsgTime string `json:"refmsg_time"`
  11945. RespondTime string `json:"respond_time"`
  11946. Signtype interface{} `json:"signtype"`
  11947. WarnInfo interface{} `json:"warn_info"`
  11948. }
  11949. //获取个人信息----挂号-----上传就诊信息
  11950. func (c *HisApiController) GetRegisterInfo() {
  11951. id, _ := c.GetInt64("id")
  11952. record_time := c.GetString("record_time")
  11953. settlementValue, _ := c.GetInt64("settlement_value")
  11954. medical_insurance_card := c.GetString("medical_insurance_card")
  11955. name := c.GetString("name")
  11956. id_card_type, _ := c.GetInt64("id_card_type")
  11957. certificates, _ := c.GetInt64("certificates")
  11958. medical_care, _ := c.GetInt64("medical_care")
  11959. birthday := c.GetString("birthday")
  11960. id_card := c.GetString("id_card")
  11961. register_type, _ := c.GetInt64("register")
  11962. doctor, _ := c.GetInt64("doctor")
  11963. department, _ := c.GetInt64("department")
  11964. gender, _ := c.GetInt64("sex")
  11965. registration_fee, _ := c.GetFloat("registration_fee")
  11966. medical_expenses, _ := c.GetFloat("medical_expenses")
  11967. social_type, _ := c.GetInt64("social_type")
  11968. admin_user_id, _ := c.GetInt64("admin_user_id")
  11969. insuplc_admdvs := c.GetString("insuplc_admdvs")
  11970. mdtrt_type := c.GetString("mdtrt_type")
  11971. timeLayout := "2006-01-02"
  11972. loc, _ := time.LoadLocation("Local")
  11973. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  11974. birthUnix := birthdays.Unix()
  11975. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11976. if err != nil {
  11977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11978. return
  11979. }
  11980. recordDateTime := theTime.Unix()
  11981. adminInfo := c.GetAdminUserInfo()
  11982. var patient service.Patients
  11983. if id == 0 {
  11984. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  11985. } else {
  11986. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  11987. }
  11988. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  11989. if patientPrescription.ID == 0 {
  11990. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  11991. }
  11992. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  11993. if patient.ID == 0 {
  11994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  11995. return
  11996. }
  11997. if len(patient.IdCardNo) == 0 {
  11998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  11999. return
  12000. }
  12001. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  12002. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  12003. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  12004. //就诊结算未完成,不能进行二次挂号
  12005. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  12006. if len(his) >= 1 {
  12007. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  12008. if len(his) >= 1 && order.ID == 0 {
  12009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  12010. return
  12011. }
  12012. }
  12013. //var register_log string
  12014. if config.IsOpen == 1 {
  12015. var res ResultTwo
  12016. var res10265 ResultTwo10265
  12017. var PsnNo string
  12018. var PsnCertType string
  12019. var Certno string
  12020. var PsnName string
  12021. var Gend string
  12022. var Naty string
  12023. var Brdy string
  12024. var Age float64
  12025. var infoStr string
  12026. var idetinfoStr string
  12027. var infocode int64
  12028. var verify_number string
  12029. fmt.Println(verify_number)
  12030. if miConfig.MdtrtareaAdmvs == "421300" {
  12031. psn_info, _ := service.GetPsnByPatientId(id)
  12032. PsnNo = psn_info.PsnNo
  12033. PsnCertType = psn_info.PsnCertType
  12034. Certno = psn_info.Certno
  12035. PsnName = psn_info.PsnName
  12036. Gend = psn_info.Gend
  12037. Naty = psn_info.Naty
  12038. Brdy = psn_info.Brdy
  12039. Age = psn_info.Age
  12040. infoStr = psn_info.Insuinfo
  12041. idetinfoStr = psn_info.Idetinfo
  12042. infocode = 0
  12043. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12044. psn_info, _ := service.GetPsnByPatientId(id)
  12045. PsnNo = psn_info.PsnNo
  12046. PsnCertType = psn_info.PsnCertType
  12047. Certno = psn_info.Certno
  12048. PsnName = psn_info.PsnName
  12049. Gend = psn_info.Gend
  12050. Naty = psn_info.Naty
  12051. Brdy = psn_info.Brdy
  12052. Age = psn_info.Age
  12053. infoStr = psn_info.Insuinfo
  12054. idetinfoStr = psn_info.Idetinfo
  12055. infocode = 0
  12056. verify_number = psn_info.VerifyNumber
  12057. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12058. if id_card_type == 2 {
  12059. //请求内网数据
  12060. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  12061. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12062. "&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
  12063. resp, requestErr := http.Get(api)
  12064. if requestErr != nil {
  12065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12066. return
  12067. }
  12068. body, ioErr := ioutil.ReadAll(resp.Body)
  12069. if ioErr != nil {
  12070. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12072. return
  12073. }
  12074. var respJSON map[string]interface{}
  12075. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12078. return
  12079. }
  12080. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12081. result_byte, _ := json.Marshal(respJSON)
  12082. result := string(result_byte)
  12083. var dat map[string]interface{}
  12084. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12085. fmt.Println(dat)
  12086. } else {
  12087. fmt.Println(err)
  12088. }
  12089. userJSONBytes, _ := json.Marshal(dat)
  12090. var res ResultTwo
  12091. var resTwo10265 ResultTwo10265
  12092. if miConfig.Code == "H15049901371" {
  12093. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  12094. utils.ErrorLog("解析失败:%v", err)
  12095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12096. return
  12097. }
  12098. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  12099. res.Infcode = Infcode
  12100. res.ErrMsg = resTwo10265.ErrMsg
  12101. res.Output = resTwo10265.Output
  12102. res.InfRefmsgid = resTwo10265.InfRefmsgid
  12103. res.RespondTime = resTwo10265.RespondTime
  12104. res.WarnInfo = resTwo10265.WarnInfo
  12105. } else {
  12106. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12107. utils.ErrorLog("解析失败:%v", err)
  12108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12109. return
  12110. }
  12111. }
  12112. //var insutypes []string
  12113. //var insutype string
  12114. //var is390 int = 0
  12115. //var is310 int = 0
  12116. //for _, item := range res.Output.Iinfo {
  12117. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12118. // insutypes = append(insutypes, item.Insutype)
  12119. // }
  12120. //}
  12121. //if len(insutypes) == 1 {
  12122. // insutype = insutypes[0]
  12123. //} else {
  12124. // for _, i := range insutypes {
  12125. // if i == "390" {
  12126. // is390 = 1
  12127. // }
  12128. //
  12129. // if i == "310" {
  12130. // is310 = 1
  12131. // }
  12132. // }
  12133. //}
  12134. //if is390 == 1 {
  12135. // insutype = "390"
  12136. //}
  12137. //if is310 == 1 {
  12138. // insutype = "310"
  12139. //}
  12140. //if len(insutypes) == 0 {
  12141. // insutype = "310"
  12142. //}
  12143. PsnNo = res.Output.Baseinfo.PsnNo
  12144. PsnCertType = res.Output.Baseinfo.PsnCertType
  12145. Certno = res.Output.Baseinfo.Certno
  12146. PsnName = res.Output.Baseinfo.PsnName
  12147. Gend = res.Output.Baseinfo.Gend
  12148. Naty = res.Output.Baseinfo.Naty
  12149. Brdy = res.Output.Baseinfo.Brdy
  12150. Age = res.Output.Baseinfo.Age
  12151. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12152. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12153. infoStr = string(Iinfos)
  12154. idetinfoStr = string(Idetinfos)
  12155. infocode = res.Infcode
  12156. //infocode = 0
  12157. //verify_number = psn_info.VerifyNumber
  12158. } else {
  12159. psn_info, _ := service.GetPsnByPatientId(id)
  12160. PsnNo = psn_info.PsnNo
  12161. PsnCertType = psn_info.PsnCertType
  12162. Certno = psn_info.Certno
  12163. PsnName = psn_info.PsnName
  12164. Gend = psn_info.Gend
  12165. Naty = psn_info.Naty
  12166. Brdy = psn_info.Brdy
  12167. Age = psn_info.Age
  12168. infoStr = psn_info.Insuinfo
  12169. idetinfoStr = psn_info.Idetinfo
  12170. infocode = 0
  12171. verify_number = psn_info.VerifyNumber
  12172. }
  12173. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12174. if id_card_type == 1 {
  12175. psn_info, _ := service.GetPsnByPatientId(id)
  12176. PsnNo = psn_info.PsnNo
  12177. PsnCertType = psn_info.PsnCertType
  12178. Certno = psn_info.Certno
  12179. PsnName = psn_info.PsnName
  12180. Gend = psn_info.Gend
  12181. Naty = psn_info.Naty
  12182. Brdy = psn_info.Brdy
  12183. Age = psn_info.Age
  12184. infoStr = psn_info.Insuinfo
  12185. idetinfoStr = psn_info.Idetinfo
  12186. infocode = 0
  12187. verify_number = psn_info.VerifyNumber
  12188. } else if id_card_type == 2 {
  12189. 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)
  12190. fmt.Println(errMsgLog)
  12191. saveLog(result, requestLog, "1101", "人员基本信息获取")
  12192. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12193. utils.ErrorLog("解析失败:%v", err)
  12194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12195. return
  12196. }
  12197. PsnNo = res.Output.Baseinfo.PsnNo
  12198. PsnCertType = res.Output.Baseinfo.PsnCertType
  12199. Certno = res.Output.Baseinfo.Certno
  12200. PsnName = res.Output.Baseinfo.PsnName
  12201. Gend = res.Output.Baseinfo.Gend
  12202. Naty = res.Output.Baseinfo.Naty
  12203. Brdy = res.Output.Baseinfo.Brdy
  12204. Age = res.Output.Baseinfo.Age
  12205. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12206. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12207. infoStr = string(Iinfos)
  12208. idetinfoStr = string(Idetinfos)
  12209. infocode = res.Infcode
  12210. }
  12211. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12212. if id_card_type == 1 {
  12213. psn_info, _ := service.GetPsnByPatientId(id)
  12214. PsnNo = psn_info.PsnNo
  12215. PsnCertType = psn_info.PsnCertType
  12216. Certno = psn_info.Certno
  12217. PsnName = psn_info.PsnName
  12218. Gend = psn_info.Gend
  12219. Naty = psn_info.Naty
  12220. Brdy = psn_info.Brdy
  12221. Age = psn_info.Age
  12222. infoStr = psn_info.Insuinfo
  12223. idetinfoStr = psn_info.Idetinfo
  12224. infocode = 0
  12225. verify_number = psn_info.VerifyNumber
  12226. } else if id_card_type == 2 {
  12227. 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, "")
  12228. saveLog(result, requestLog, "1101", "人员基本信息获取")
  12229. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12230. utils.ErrorLog("解析失败:%v", err)
  12231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12232. return
  12233. }
  12234. PsnNo = res.Output.Baseinfo.PsnNo
  12235. PsnCertType = res.Output.Baseinfo.PsnCertType
  12236. Certno = res.Output.Baseinfo.Certno
  12237. PsnName = res.Output.Baseinfo.PsnName
  12238. Gend = res.Output.Baseinfo.Gend
  12239. Naty = res.Output.Baseinfo.Naty
  12240. Brdy = res.Output.Baseinfo.Brdy
  12241. Age = res.Output.Baseinfo.Age
  12242. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12243. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12244. infoStr = string(Iinfos)
  12245. idetinfoStr = string(Idetinfos)
  12246. infocode = res.Infcode
  12247. }
  12248. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12249. if id_card_type == 1 {
  12250. psn_info, _ := service.GetPsnByPatientId(id)
  12251. PsnNo = psn_info.PsnNo
  12252. PsnCertType = psn_info.PsnCertType
  12253. Certno = psn_info.Certno
  12254. PsnName = psn_info.PsnName
  12255. Gend = psn_info.Gend
  12256. Naty = psn_info.Naty
  12257. Brdy = psn_info.Brdy
  12258. Age = psn_info.Age
  12259. infoStr = psn_info.Insuinfo
  12260. idetinfoStr = psn_info.Idetinfo
  12261. infocode = 0
  12262. verify_number = psn_info.VerifyNumber
  12263. } else if id_card_type == 2 {
  12264. 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)
  12265. saveLog(result, requestLog, "1101", "人员基本信息获取")
  12266. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12267. utils.ErrorLog("解析失败:%v", err)
  12268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12269. return
  12270. }
  12271. PsnNo = res.Output.Baseinfo.PsnNo
  12272. PsnCertType = res.Output.Baseinfo.PsnCertType
  12273. Certno = res.Output.Baseinfo.Certno
  12274. PsnName = res.Output.Baseinfo.PsnName
  12275. Gend = res.Output.Baseinfo.Gend
  12276. Naty = res.Output.Baseinfo.Naty
  12277. Brdy = res.Output.Baseinfo.Brdy
  12278. Age = res.Output.Baseinfo.Age
  12279. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12280. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12281. infoStr = string(Iinfos)
  12282. idetinfoStr = string(Idetinfos)
  12283. infocode = res.Infcode
  12284. } else if id_card_type == 4 {
  12285. psn_info, _ := service.GetPsnByPatientId(id)
  12286. PsnNo = psn_info.PsnNo
  12287. PsnCertType = psn_info.PsnCertType
  12288. Certno = psn_info.Certno
  12289. PsnName = psn_info.PsnName
  12290. Gend = psn_info.Gend
  12291. Naty = psn_info.Naty
  12292. Brdy = psn_info.Brdy
  12293. Age = psn_info.Age
  12294. infoStr = psn_info.Insuinfo
  12295. idetinfoStr = psn_info.Idetinfo
  12296. infocode = 0
  12297. verify_number = psn_info.VerifyNumber
  12298. }
  12299. } else if miConfig.MdtrtareaAdmvs == "131023" {
  12300. var result string
  12301. var requestLog string
  12302. 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), "")
  12303. if id_card_type == 4 {
  12304. psn_info, _ := service.GetPsnByPatientId(id)
  12305. PsnNo = psn_info.PsnNo
  12306. PsnCertType = psn_info.PsnCertType
  12307. Certno = psn_info.Certno
  12308. PsnName = psn_info.PsnName
  12309. Gend = psn_info.Gend
  12310. Naty = psn_info.Naty
  12311. Brdy = psn_info.Brdy
  12312. Age = psn_info.Age
  12313. infoStr = psn_info.Insuinfo
  12314. idetinfoStr = psn_info.Idetinfo
  12315. infocode = 0
  12316. verify_number = psn_info.VerifyNumber
  12317. } else {
  12318. saveLog(result, requestLog, "1101", "人员基本信息获取")
  12319. if miConfig.Code == "H15049901371" {
  12320. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12321. utils.ErrorLog("解析失败:%v", err)
  12322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12323. return
  12324. }
  12325. res.ErrMsg = res10265.ErrMsg
  12326. res.Output = res10265.Output
  12327. res.InfRefmsgid = res10265.InfRefmsgid
  12328. } else {
  12329. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12330. utils.ErrorLog("解析失败:%v", err)
  12331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12332. return
  12333. }
  12334. }
  12335. PsnNo = res.Output.Baseinfo.PsnNo
  12336. PsnCertType = res.Output.Baseinfo.PsnCertType
  12337. Certno = res.Output.Baseinfo.Certno
  12338. PsnName = res.Output.Baseinfo.PsnName
  12339. Gend = res.Output.Baseinfo.Gend
  12340. Naty = res.Output.Baseinfo.Naty
  12341. Brdy = res.Output.Baseinfo.Brdy
  12342. Age = res.Output.Baseinfo.Age
  12343. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12344. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12345. infoStr = string(Iinfos)
  12346. idetinfoStr = string(Idetinfos)
  12347. if miConfig.Code == "H15049901371" {
  12348. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  12349. } else {
  12350. infocode = res.Infcode
  12351. }
  12352. }
  12353. } else {
  12354. var result string
  12355. var requestLog string
  12356. //if miConfig.UserOrgId == 10138 {
  12357. if id_card_type != 4 || id_card_type != 1 {
  12358. var insa string
  12359. if len(patient.InsuplcAdmdvs) > 0 {
  12360. insa = patient.InsuplcAdmdvs
  12361. } else {
  12362. insa = miConfig.InsuplcAdmdvs
  12363. }
  12364. //psn_info, _ := service.GetPsnByPatientId(id)
  12365. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  12366. 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)
  12367. }
  12368. //}
  12369. //else {
  12370. // var insa string
  12371. // if len(patient.InsuplcAdmdvs) > 0 {
  12372. // insa = patient.InsuplcAdmdvs
  12373. // } else {
  12374. // insa = miConfig.InsuplcAdmdvs
  12375. // }
  12376. // 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)
  12377. //}
  12378. if id_card_type == 4 || id_card_type == 1 {
  12379. psn_info, _ := service.GetPsnByPatientId(id)
  12380. PsnNo = psn_info.PsnNo
  12381. PsnCertType = psn_info.PsnCertType
  12382. Certno = psn_info.Certno
  12383. PsnName = psn_info.PsnName
  12384. Gend = psn_info.Gend
  12385. Naty = psn_info.Naty
  12386. Brdy = psn_info.Brdy
  12387. Age = psn_info.Age
  12388. infoStr = psn_info.Insuinfo
  12389. idetinfoStr = psn_info.Idetinfo
  12390. infocode = 0
  12391. verify_number = psn_info.VerifyNumber
  12392. } else {
  12393. saveLog(result, requestLog, "1101", "人员基本信息获取")
  12394. if miConfig.Code == "H15049901371" {
  12395. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12396. utils.ErrorLog("解析失败:%v", err)
  12397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12398. return
  12399. }
  12400. res.ErrMsg = res10265.ErrMsg
  12401. res.Output = res10265.Output
  12402. res.InfRefmsgid = res10265.InfRefmsgid
  12403. } else {
  12404. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12405. utils.ErrorLog("解析失败:%v", err)
  12406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12407. return
  12408. }
  12409. }
  12410. PsnNo = res.Output.Baseinfo.PsnNo
  12411. PsnCertType = res.Output.Baseinfo.PsnCertType
  12412. Certno = res.Output.Baseinfo.Certno
  12413. PsnName = res.Output.Baseinfo.PsnName
  12414. Gend = res.Output.Baseinfo.Gend
  12415. Naty = res.Output.Baseinfo.Naty
  12416. Brdy = res.Output.Baseinfo.Brdy
  12417. Age = res.Output.Baseinfo.Age
  12418. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12419. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12420. infoStr = string(Iinfos)
  12421. idetinfoStr = string(Idetinfos)
  12422. if miConfig.Code == "H15049901371" {
  12423. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  12424. } else {
  12425. infocode = res.Infcode
  12426. }
  12427. }
  12428. }
  12429. if infocode == 0 {
  12430. his := models.VMHisPatient{
  12431. Name: name,
  12432. Gender: gender,
  12433. Birthday: birthUnix,
  12434. MedicalTreatmentType: medical_care,
  12435. IdType: certificates,
  12436. IdCardNo: id_card,
  12437. BalanceAccountsType: settlementValue,
  12438. SocialType: social_type,
  12439. MedicalInsuranceNumber: medical_insurance_card,
  12440. RegisterType: register_type,
  12441. RegisterCost: registration_fee,
  12442. TreatmentCost: medical_expenses,
  12443. Status: 1,
  12444. Ctime: time.Now().Unix(),
  12445. Mtime: time.Now().Unix(),
  12446. PsnNo: PsnNo,
  12447. PsnCertType: PsnCertType,
  12448. Certno: Certno,
  12449. PsnName: PsnName,
  12450. Gend: Gend,
  12451. Naty: Naty,
  12452. Brdy: Brdy,
  12453. Age: Age,
  12454. Iinfo: infoStr,
  12455. Idetinfo: idetinfoStr,
  12456. PatientId: patient.ID,
  12457. RecordDate: theTime.Unix(),
  12458. UserOrgId: adminInfo.CurrentOrgId,
  12459. AdminUserId: admin_user_id,
  12460. IsReturn: 1,
  12461. IdCardType: id_card_type,
  12462. Doctor: doctor,
  12463. Departments: department,
  12464. MdtrtGrpType: mdtrt_type,
  12465. }
  12466. timestamp := time.Now().Unix()
  12467. tempTime := time.Unix(timestamp, 0)
  12468. timeFormat := tempTime.Format("20060102150405")
  12469. chrgBchno := rand.Intn(100000) + 10000
  12470. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  12471. his.Number = ipt_otp_no
  12472. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  12473. department, _ := service.GetDepartMentDetail(department)
  12474. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  12475. IdCardNo := ""
  12476. if id_card_type == 1 {
  12477. // IdCardNo = medical_insurance_card
  12478. IdCardNo = patient.IdCardNo
  12479. } else {
  12480. IdCardNo = patient.IdCardNo
  12481. }
  12482. var rf []*ResultFive
  12483. json.Unmarshal([]byte(his.Iinfo), &rf)
  12484. var insutypes []*ResultFive
  12485. var insutype string
  12486. var insuplc_admdvs_temp string
  12487. var is390 int = 0
  12488. var is310 int = 0
  12489. for _, item := range rf {
  12490. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12491. insutypes = append(insutypes, item)
  12492. }
  12493. }
  12494. if len(insutypes) == 1 {
  12495. insutype = insutypes[0].Insutype
  12496. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12497. if insutype == "390" {
  12498. is390 = 1
  12499. }
  12500. if insutype == "310" {
  12501. is310 = 1
  12502. }
  12503. } else {
  12504. for _, i := range insutypes {
  12505. if i.Insutype == "390" {
  12506. is390 = 1
  12507. }
  12508. if i.Insutype == "310" {
  12509. is310 = 1
  12510. }
  12511. }
  12512. }
  12513. if is390 == 1 {
  12514. insutype = "390"
  12515. }
  12516. if is310 == 1 {
  12517. insutype = "310"
  12518. }
  12519. fmt.Println(social_type)
  12520. if social_type > 0 {
  12521. insutype = strconv.FormatInt(social_type, 10)
  12522. }
  12523. var infocode int64
  12524. var resThree ResultThree
  12525. var resThree10265 ResultThree10265
  12526. if len(insuplc_admdvs) == 0 {
  12527. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  12528. } else {
  12529. insuplc_admdvs_temp = insuplc_admdvs
  12530. }
  12531. if miConfig.MdtrtareaAdmvs == "421300" {
  12532. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  12533. if strings.Contains(insuplc_admdvs_temp,"4413"){
  12534. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  12535. }
  12536. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  12537. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  12538. "&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
  12539. resp, requestErr := http.Get(api)
  12540. if requestErr != nil {
  12541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12542. return
  12543. }
  12544. body, ioErr := ioutil.ReadAll(resp.Body)
  12545. if ioErr != nil {
  12546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12548. return
  12549. }
  12550. var respJSON map[string]interface{}
  12551. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12554. return
  12555. }
  12556. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12557. result, _ := json.Marshal(respJSON)
  12558. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  12559. utils.ErrorLog("解析失败:%v", err)
  12560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12561. return
  12562. }
  12563. infocode = resThree.Infcode
  12564. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12565. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  12566. psn_info, _ := service.GetPsnByPatientId(id)
  12567. var verify_number string
  12568. if id_card_type == 4 {
  12569. verify_number = psn_info.VerifyNumber
  12570. } else if id_card_type == 1 {
  12571. bas := strings.Split(psn_info.CardInfo, "|")
  12572. cardNumber := bas[2]
  12573. verify_number = cardNumber
  12574. }
  12575. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  12576. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  12577. "&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
  12578. resp, requestErr := http.Get(api)
  12579. if requestErr != nil {
  12580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12581. return
  12582. }
  12583. body, ioErr := ioutil.ReadAll(resp.Body)
  12584. if ioErr != nil {
  12585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12587. return
  12588. }
  12589. var respJSON map[string]interface{}
  12590. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12593. return
  12594. }
  12595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12596. result, _ := json.Marshal(respJSON)
  12597. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  12598. // utils.ErrorLog("解析失败:%v", err)
  12599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12600. // return
  12601. //}
  12602. //infocode = resThree.Infcode
  12603. //result, _ := json.Marshal(respJSON)
  12604. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  12605. utils.ErrorLog("解析失败:%v", err)
  12606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12607. return
  12608. }
  12609. resThree.ErrMsg = resThree10265.ErrMsg
  12610. resThree.Output = resThree10265.Output
  12611. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  12612. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  12613. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12614. psn_info, _ := service.GetPsnByPatientId(id)
  12615. his.PsnNo = psn_info.PsnNo
  12616. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  12617. var cert_no string
  12618. if id_card_type == 3 {
  12619. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  12620. cert_no = IdCardNo
  12621. } else if id_card_type == 4 {
  12622. cert_no = IdCardNo
  12623. psn_info.VerifyNumber = psn_info.VerifyNumber
  12624. } else {
  12625. bas := strings.Split(psn_info.CardInfo, "|")
  12626. cert_no = bas[2]
  12627. }
  12628. var hisPrescription []*models.HisPrescription
  12629. for _, item := range rf {
  12630. if item.Insutype == insutype {
  12631. //insuplc_admdvs = item.InsuplcAdmdvs
  12632. his.InsuplcAdmdvs = insuplc_admdvs
  12633. }
  12634. }
  12635. his.Insutype = insutype
  12636. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  12637. fmt.Println(res3101)
  12638. fmt.Println(res3101.Infcode)
  12639. if res3101.Infcode == "0" {
  12640. fmt.Println("33333333")
  12641. if len(res3101.Output.Result) > 0 {
  12642. fmt.Println("222222")
  12643. for _, item := range res3101.Output.Result {
  12644. if len(res3101.ErrMsg) == 0 {
  12645. res3101.ErrMsg = item.VolaCont
  12646. } else {
  12647. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  12648. }
  12649. }
  12650. c.ServeSuccessJSON(map[string]interface{}{
  12651. "failed_code": -10,
  12652. "msg": res3101.ErrMsg,
  12653. })
  12654. return
  12655. } else {
  12656. fmt.Println("11111")
  12657. var api string
  12658. if miConfig.MdtrtareaAdmvs == "320921" {
  12659. ipt_otp_no = timeFormat
  12660. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  12661. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  12662. "&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
  12663. } else {
  12664. ipt_otp_no = timeFormat
  12665. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  12666. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  12667. "&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
  12668. }
  12669. resp, requestErr := http.Get(api)
  12670. if requestErr != nil {
  12671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12672. return
  12673. }
  12674. body, ioErr := ioutil.ReadAll(resp.Body)
  12675. if ioErr != nil {
  12676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12678. return
  12679. }
  12680. var respJSON map[string]interface{}
  12681. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12684. return
  12685. }
  12686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12687. result, _ := json.Marshal(respJSON)
  12688. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  12689. utils.ErrorLog("解析失败:%v", err)
  12690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12691. return
  12692. }
  12693. resThree.ErrMsg = resThree10265.ErrMsg
  12694. resThree.Output = resThree10265.Output
  12695. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  12696. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  12697. }
  12698. } else if res3101.Infcode != "0" {
  12699. c.ServeSuccessJSON(map[string]interface{}{
  12700. "failed_code": -10,
  12701. "msg": res3101.ErrMsg,
  12702. })
  12703. return
  12704. }
  12705. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12706. psn_info, _ := service.GetPsnByPatientId(id)
  12707. var cert_no string
  12708. if id_card_type == 1 {
  12709. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  12710. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  12711. } else if id_card_type == 4 {
  12712. cert_no = psn_info.VerifyNumber
  12713. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  12714. } else {
  12715. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  12716. cert_no = psn_info.VerifyNumber
  12717. }
  12718. 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)
  12719. saveLog(result, requestLog, "2201", "挂号")
  12720. if miConfig.Code == "H15049901371" {
  12721. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  12722. utils.ErrorLog("解析失败:%v", err)
  12723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12724. return
  12725. }
  12726. resThree.ErrMsg = resThree10265.ErrMsg
  12727. resThree.Output = resThree10265.Output
  12728. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  12729. } else {
  12730. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  12731. utils.ErrorLog("解析失败:%v", err)
  12732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12733. return
  12734. }
  12735. }
  12736. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  12737. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  12738. psn_info, _ := service.GetPsnByPatientId(id)
  12739. var result string
  12740. var requestLog string
  12741. if id_card_type == 1 {
  12742. bas := strings.Split(psn_info.CardInfo, "|")
  12743. basNumber := bas[2]
  12744. card_sn := bas[3]
  12745. result, requestLog = service.Jxyb2201(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)
  12746. saveLog(result, requestLog, "2201A", "挂号")
  12747. } else if id_card_type == 2 {
  12748. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "")
  12749. saveLog(result, requestLog, "2201A", "挂号")
  12750. } else {
  12751. 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, "", "")
  12752. saveLog(result, requestLog, "2201A", "挂号")
  12753. }
  12754. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  12755. utils.ErrorLog("解析失败:%v", err)
  12756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12757. return
  12758. }
  12759. infocode = resThree.Infcode
  12760. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  12761. psn_info, _ := service.GetPsnByPatientId(id)
  12762. var result string
  12763. var requestLog string
  12764. if id_card_type == 1 {
  12765. bas := strings.Split(psn_info.CardInfo, "|")
  12766. basNumber := bas[2]
  12767. card_sn := bas[3]
  12768. 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)
  12769. saveLog(result, requestLog, "2201A", "挂号")
  12770. } else if id_card_type == 2 {
  12771. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "")
  12772. saveLog(result, requestLog, "2201A", "挂号")
  12773. } else {
  12774. 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, "", "")
  12775. saveLog(result, requestLog, "2201A", "挂号")
  12776. }
  12777. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  12778. utils.ErrorLog("解析失败:%v", err)
  12779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12780. return
  12781. }
  12782. infocode = resThree.Infcode
  12783. } else if miConfig.MdtrtareaAdmvs == "131023" {
  12784. psn_info, _ := service.GetPsnByPatientId(id)
  12785. 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)
  12786. saveLog(result, requestLog, "2201A", "挂号")
  12787. if miConfig.Code == "H15049901371" {
  12788. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  12789. utils.ErrorLog("解析失败:%v", err)
  12790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12791. return
  12792. }
  12793. resThree.ErrMsg = resThree10265.ErrMsg
  12794. resThree.Output = resThree10265.Output
  12795. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  12796. } else {
  12797. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  12798. utils.ErrorLog("解析失败:%v", err)
  12799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12800. return
  12801. }
  12802. }
  12803. if miConfig.Code == "H15049901371" {
  12804. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  12805. } else {
  12806. infocode = resThree.Infcode
  12807. }
  12808. } else {
  12809. psn_info, _ := service.GetPsnByPatientId(id)
  12810. if id_card_type == 4 || id_card_type == 1 {
  12811. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  12812. }
  12813. var rf []*ResultFive
  12814. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  12815. var insutypes []*ResultFive
  12816. var insutype string
  12817. var is390 int = 0
  12818. var is310 int = 0
  12819. for _, item := range rf {
  12820. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12821. insutypes = append(insutypes, item)
  12822. }
  12823. }
  12824. if len(insutypes) == 1 {
  12825. insutype = insutypes[0].Insutype
  12826. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12827. } else {
  12828. for _, i := range insutypes {
  12829. if i.Insutype == "390" {
  12830. is390 = 1
  12831. }
  12832. if i.Insutype == "310" {
  12833. is310 = 1
  12834. }
  12835. }
  12836. }
  12837. if is390 == 1 {
  12838. insutype = "390"
  12839. }
  12840. if is310 == 1 {
  12841. insutype = "310"
  12842. }
  12843. fmt.Println(len(insutypes))
  12844. if len(insutypes) == 0 {
  12845. for index, item := range rf {
  12846. if index == 0 {
  12847. insutype = item.Insutype
  12848. insuplc_admdvs = item.InsuplcAdmdvs
  12849. }
  12850. }
  12851. fmt.Println(insutype)
  12852. fmt.Println(insuplc_admdvs)
  12853. }
  12854. if social_type > 0 {
  12855. insutype = strconv.FormatInt(social_type, 10)
  12856. }
  12857. fmt.Println("--------")
  12858. fmt.Println(psn_info)
  12859. fmt.Println(psn_info.PsnNo)
  12860. if miConfig.MdtrtareaAdmvs == "441202" {
  12861. var hisPrescription []*models.HisPrescription
  12862. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  12863. if res3101.Infcode == 0 {
  12864. fmt.Println("33333333")
  12865. if len(res3101.Output.Result) > 0 {
  12866. fmt.Println("222222")
  12867. for _, item := range res3101.Output.Result {
  12868. if len(res3101.ErrMsg) == 0 {
  12869. res3101.ErrMsg = item.VolaCont
  12870. } else {
  12871. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  12872. }
  12873. }
  12874. c.ServeSuccessJSON(map[string]interface{}{
  12875. "failed_code": -10,
  12876. "msg": res3101.ErrMsg,
  12877. })
  12878. return
  12879. } else {
  12880. 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, psn_info.VerifyNumber)
  12881. saveLog(result, requestLog, "2201A", "挂号")
  12882. if miConfig.Code == "H15049901371" {
  12883. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  12884. utils.ErrorLog("解析失败:%v", err)
  12885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12886. return
  12887. }
  12888. resThree.ErrMsg = resThree10265.ErrMsg
  12889. resThree.Output = resThree10265.Output
  12890. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  12891. } else {
  12892. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  12893. utils.ErrorLog("解析失败:%v", err)
  12894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12895. return
  12896. }
  12897. }
  12898. if miConfig.Code == "H15049901371" {
  12899. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  12900. } else {
  12901. infocode = resThree.Infcode
  12902. }
  12903. }
  12904. } else if res3101.Infcode != 0 {
  12905. c.ServeSuccessJSON(map[string]interface{}{
  12906. "failed_code": -10,
  12907. "msg": res3101.ErrMsg,
  12908. })
  12909. return
  12910. }
  12911. } else {
  12912. 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, psn_info.VerifyNumber)
  12913. saveLog(result, requestLog, "2201A", "挂号")
  12914. if miConfig.Code == "H15049901371" {
  12915. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  12916. utils.ErrorLog("解析失败:%v", err)
  12917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12918. return
  12919. }
  12920. resThree.ErrMsg = resThree10265.ErrMsg
  12921. resThree.Output = resThree10265.Output
  12922. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  12923. } else {
  12924. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  12925. utils.ErrorLog("解析失败:%v", err)
  12926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12927. return
  12928. }
  12929. }
  12930. if miConfig.Code == "H15049901371" {
  12931. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  12932. } else {
  12933. infocode = resThree.Infcode
  12934. }
  12935. }
  12936. }
  12937. if infocode != 0 {
  12938. adminUser := c.GetAdminUserInfo()
  12939. errlog := &models.HisOrderError{
  12940. UserOrgId: adminUser.CurrentOrgId,
  12941. Ctime: time.Now().Unix(),
  12942. Mtime: time.Now().Unix(),
  12943. ErrMsg: resThree.ErrMsg,
  12944. Status: 1,
  12945. PatientId: id,
  12946. RecordTime: recordDateTime,
  12947. Stage: 2,
  12948. }
  12949. service.CreateErrMsgLog(errlog)
  12950. c.ServeSuccessJSON(map[string]interface{}{
  12951. "failed_code": -10,
  12952. "msg": resThree.ErrMsg,
  12953. })
  12954. return
  12955. }
  12956. his.Number = resThree.Output.Data.MdtrtID
  12957. his.PsnNo = resThree.Output.Data.PsnNo
  12958. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  12959. his.IdCardNo = patient.IdCardNo
  12960. his.PhoneNumber = patient.Phone
  12961. his.UserOrgId = adminInfo.CurrentOrgId
  12962. his.Insutype = insutype
  12963. his.Ctime = time.Now().Unix()
  12964. his.Mtime = time.Now().Unix()
  12965. his.InsuplcAdmdvs = insuplc_admdvs_temp
  12966. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  12967. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  12968. }
  12969. his.Status = 1
  12970. his.MdtrtGrpType = mdtrt_type
  12971. service.UpdateHisPatientStatus(&his)
  12972. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  12973. c.ServeSuccessJSON(map[string]interface{}{
  12974. "his_info": his,
  12975. })
  12976. } else {
  12977. adminUser := c.GetAdminUserInfo()
  12978. errlog := &models.HisOrderError{
  12979. UserOrgId: adminUser.CurrentOrgId,
  12980. Ctime: time.Now().Unix(),
  12981. Mtime: time.Now().Unix(),
  12982. ErrMsg: res.ErrMsg,
  12983. Status: 1,
  12984. PatientId: id,
  12985. RecordTime: recordDateTime,
  12986. Stage: 1,
  12987. }
  12988. service.CreateErrMsgLog(errlog)
  12989. c.ServeSuccessJSON(map[string]interface{}{
  12990. "failed_code": -10,
  12991. "msg": res.ErrMsg,
  12992. })
  12993. return
  12994. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  12995. }
  12996. }
  12997. }
  12998. func (c *HisApiController) GetUploadInfo() {
  12999. id, _ := c.GetInt64("id")
  13000. record_time := c.GetString("record_time")
  13001. his_patient_id, _ := c.GetInt64("his_patient_id")
  13002. order_id, _ := c.GetInt64("order_id")
  13003. pay_way, _ := c.GetInt64("pay_way")
  13004. pay_ways := c.GetString("pay_ways")
  13005. oth_desc := c.GetString("oth_desc")
  13006. pay_price, _ := c.GetFloat("pay_price")
  13007. pay_card_no := c.GetString("pay_card_no")
  13008. discount_price, _ := c.GetFloat("discount_price")
  13009. preferential_price, _ := c.GetFloat("preferential_price")
  13010. reality_price, _ := c.GetFloat("reality_price")
  13011. found_price, _ := c.GetFloat("found_price")
  13012. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  13013. private_price, _ := c.GetFloat("private_price")
  13014. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  13015. admin_user_id, _ := c.GetInt64("admin_user_id")
  13016. fapiao_code := c.GetString("fapiao_code")
  13017. fapiao_number := c.GetString("fapiao_number")
  13018. diagnosis_id := c.GetString("diagnosis")
  13019. sick_type, _ := c.GetInt64("sick_type")
  13020. reg_type, _ := c.GetInt64("p_type")
  13021. begin_time := c.GetString("begin_time")
  13022. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  13023. cash_pay := c.GetString("cash_pay")
  13024. band_card_pay := c.GetString("band_card_pay")
  13025. wechat_pay := c.GetString("wechat_pay")
  13026. ali_pay := c.GetString("ali_pay")
  13027. jifen_pay := c.GetString("jifen_pay")
  13028. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  13029. fmt.Println(acct_used_flag)
  13030. id_str := c.GetString("ids")
  13031. ids_arr := strings.Split(id_str, ",")
  13032. timeLayout := "2006-01-02"
  13033. loc, _ := time.LoadLocation("Local")
  13034. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13035. if err != nil {
  13036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13037. return
  13038. }
  13039. recordDateTime := theTime.Unix()
  13040. adminUser := c.GetAdminUserInfo()
  13041. var tempOrder models.HisOrder
  13042. tempOrder, _ = service.GetHisOrderByID(order_id)
  13043. var prescriptions []*models.HisPrescription
  13044. var start_time int64
  13045. var end_time int64
  13046. //押金模块
  13047. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  13048. tmp_decimal := c.GetString("tmp_decimal")
  13049. var decimal float64 //本次使用的押金
  13050. var errmsg error
  13051. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  13052. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  13053. return
  13054. }
  13055. if len(tmp_decimal) > 0 {
  13056. if tmp_decimal[0] == 45 {
  13057. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  13058. return
  13059. }
  13060. }
  13061. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  13062. fmt.Println(errs)
  13063. decimal = tt
  13064. //if adminUser.CurrentOrgId == 10106{
  13065. // if len(fapiao_code) == 0{
  13066. // fapiao_code = "144072080589"
  13067. // }
  13068. // if len(fapiao_number) == 0{
  13069. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  13070. // if order.ID == 0{
  13071. // fapiao_number = "00001520"
  13072. // }else{
  13073. // //fapiao_code = "00001520"
  13074. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  13075. // var zero string
  13076. // if fpNumber >= 1000{
  13077. // zero = "0000" + strconv.Itoa(fpNumber)
  13078. // }else if fpNumber >= 10000{
  13079. // zero = "000" + strconv.Itoa(fpNumber)
  13080. // } else if fpNumber >= 100000{
  13081. // zero = "00" + strconv.Itoa(fpNumber)
  13082. // } else if fpNumber >= 1000000{
  13083. // zero = "0" + strconv.Itoa(fpNumber)
  13084. // }else {
  13085. // zero = strconv.Itoa(fpNumber)
  13086. // }
  13087. // fapiao_number = zero
  13088. // }
  13089. // }
  13090. //}
  13091. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13092. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  13093. var patientPrescription models.HisPrescriptionInfo
  13094. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  13095. if patientPrescription.ID == 0 {
  13096. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  13097. }
  13098. //if patientPrescription.Do
  13099. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13100. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  13101. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  13102. diagnosis_ids := strings.Split(diagnosis_id, ",")
  13103. var config []*models.HisXtDiagnoseConfig
  13104. for _, item := range diagnosis_ids {
  13105. id, _ := strconv.ParseInt(item, 10, 64)
  13106. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13107. config = append(config, &diagnosisConfig)
  13108. }
  13109. sickConfig, _ := service.FindSickById(sick_type)
  13110. //if tempOrder.ID == 0 {
  13111. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  13112. //}
  13113. if tempOrder.ID == 0 {
  13114. var result string
  13115. var requestLog string
  13116. var res2 ResultSix
  13117. var res3 GZResultSix
  13118. var ressix10265 ResultSix10265
  13119. if miConfig.MdtrtareaAdmvs == "421300" {
  13120. data := make(map[string]interface{})
  13121. client := &http.Client{}
  13122. data["psn_no"] = his.PsnNo
  13123. data["mdtrt_id"] = his.Number
  13124. data["opter"] = roles.UserName
  13125. data["org_name"] = miConfig.OrgName
  13126. data["med_type"] = strconv.FormatInt(reg_type, 10)
  13127. data["doctor_id"] = doctor_info.DoctorNumber
  13128. data["doctor_name"] = doctor_info.UserName
  13129. data["department"] = department.Name
  13130. data["fixmedins_code"] = miConfig.Code
  13131. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  13132. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13133. data["secret_key"] = miConfig.SecretKey
  13134. data["sick_code"] = sickConfig.CountryCode
  13135. data["sick_name"] = sickConfig.ClassName
  13136. data["dept"] = strconv.FormatInt(department.ID, 10)
  13137. data["config"] = config
  13138. data["begin_time"] = begin_time
  13139. bytesData, _ := json.Marshal(data)
  13140. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  13141. resp, _ := client.Do(req)
  13142. defer resp.Body.Close()
  13143. body, ioErr := ioutil.ReadAll(resp.Body)
  13144. if ioErr != nil {
  13145. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13147. return
  13148. }
  13149. var respJSON map[string]interface{}
  13150. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13153. return
  13154. }
  13155. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13156. userJSONBytes, _ := json.Marshal(respJSON)
  13157. fmt.Println("log")
  13158. fmt.Println(string(userJSONBytes))
  13159. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13160. utils.ErrorLog("解析失败:%v", err)
  13161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13162. return
  13163. }
  13164. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13165. data := make(map[string]interface{})
  13166. client := &http.Client{}
  13167. data["psn_no"] = his.PsnNo
  13168. data["mdtrt_id"] = his.Number
  13169. data["doctor"] = roles.UserName
  13170. data["department"] = department.Name
  13171. data["org_name"] = miConfig.OrgName
  13172. data["med_type"] = strconv.FormatInt(reg_type, 10)
  13173. data["doctor_id"] = doctor_info.DoctorNumber
  13174. data["new_doctor_name"] = doctor_info.UserName
  13175. data["fixmedins_code"] = miConfig.Code
  13176. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  13177. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13178. data["secret_key"] = miConfig.SecretKey
  13179. data["sick_code"] = sickConfig.CountryCode
  13180. data["sick_name"] = sickConfig.ClassName
  13181. data["url"] = miConfig.Url
  13182. data["ak"] = miConfig.AccessKey
  13183. data["begin_time"] = begin_time
  13184. data["cainfo"] = miConfig.Cainfo
  13185. data["dept"] = strconv.FormatInt(department.ID, 10)
  13186. data["config"] = config
  13187. bytesData, _ := json.Marshal(data)
  13188. var req *http.Request
  13189. if miConfig.MdtrtareaAdmvs == "320921" {
  13190. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  13191. //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 +
  13192. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  13193. } else {
  13194. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  13195. }
  13196. resp, _ := client.Do(req)
  13197. defer resp.Body.Close()
  13198. body, ioErr := ioutil.ReadAll(resp.Body)
  13199. if ioErr != nil {
  13200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13202. return
  13203. }
  13204. var respJSON map[string]interface{}
  13205. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13208. return
  13209. }
  13210. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13211. userJSONBytes, _ := json.Marshal(respJSON)
  13212. fmt.Println("log")
  13213. fmt.Println(string(userJSONBytes))
  13214. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  13215. utils.ErrorLog("解析失败:%v", err)
  13216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13217. return
  13218. }
  13219. res2.InfRefmsgid = ressix10265.InfRefmsgid
  13220. res2.Output = ressix10265.Output
  13221. res2.ErrMsg = ressix10265.ErrMsg
  13222. res2.Cainfo = ressix10265.Cainfo
  13223. res2.WarnMsg = ressix10265.WarnMsg
  13224. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  13225. res2.Infcode = infocode
  13226. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13227. data := make(map[string]interface{})
  13228. client := &http.Client{}
  13229. data["psn_no"] = his.PsnNo
  13230. data["mdtrt_id"] = his.Number
  13231. data["doctor"] = roles.UserName
  13232. data["department"] = department.Name
  13233. data["org_name"] = miConfig.OrgName
  13234. data["med_type"] = strconv.FormatInt(reg_type, 10)
  13235. data["doctor_id"] = doctor_info.DoctorNumber
  13236. data["new_doctor_name"] = doctor_info.UserName
  13237. data["fixmedins_code"] = miConfig.Code
  13238. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  13239. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13240. data["secret_key"] = miConfig.SecretKey
  13241. data["sick_code"] = sickConfig.CountryCode
  13242. data["sick_name"] = sickConfig.ClassName
  13243. data["url"] = miConfig.Url
  13244. data["ak"] = miConfig.AccessKey
  13245. data["begin_time"] = begin_time
  13246. data["cainfo"] = miConfig.Cainfo
  13247. data["dept"] = strconv.FormatInt(department.ID, 10)
  13248. data["config"] = config
  13249. bytesData, _ := json.Marshal(data)
  13250. var req *http.Request
  13251. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  13252. resp, _ := client.Do(req)
  13253. defer resp.Body.Close()
  13254. body, ioErr := ioutil.ReadAll(resp.Body)
  13255. if ioErr != nil {
  13256. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13258. return
  13259. }
  13260. var respJSON map[string]interface{}
  13261. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13262. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13264. return
  13265. }
  13266. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13267. userJSONBytes, _ := json.Marshal(respJSON)
  13268. fmt.Println("log")
  13269. fmt.Println(string(userJSONBytes))
  13270. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  13271. utils.ErrorLog("解析失败:%v", err)
  13272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13273. return
  13274. }
  13275. res2.InfRefmsgid = ressix10265.InfRefmsgid
  13276. res2.Output = ressix10265.Output
  13277. res2.ErrMsg = ressix10265.ErrMsg
  13278. res2.Cainfo = ressix10265.Cainfo
  13279. res2.WarnMsg = ressix10265.WarnMsg
  13280. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  13281. res2.Infcode = infocode
  13282. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13283. 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)
  13284. saveLog(result, requestLog, "2203", "上传就诊信息")
  13285. var respJSON2 map[string]interface{}
  13286. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  13287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13289. return
  13290. }
  13291. userJSONBytes2, _ := json.Marshal(respJSON2)
  13292. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13293. utils.ErrorLog("解析失败:%v", err)
  13294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13295. return
  13296. }
  13297. 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)
  13298. fmt.Println(result2)
  13299. fmt.Println(src_request)
  13300. } else {
  13301. if miConfig.MdtrtareaAdmvs == "440781" { //
  13302. 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)
  13303. } else {
  13304. if miConfig.Code == "H15049901371" {
  13305. //赤峰地区国家医保医疗类别
  13306. //职工透析:医疗类别选特殊情况门诊990502
  13307. //居民定额血透门慢: 医疗类别选门诊慢病140104
  13308. var med_type string
  13309. if his.Insutype == "390" {
  13310. if reg_type == 14 {
  13311. med_type = "9933"
  13312. } else if reg_type == 11 {
  13313. med_type = "11"
  13314. }
  13315. } else if his.Insutype == "310" {
  13316. if reg_type == 14 {
  13317. med_type = "990502"
  13318. } else if reg_type == 11 {
  13319. med_type = "11"
  13320. }
  13321. }
  13322. 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)
  13323. } else {
  13324. 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)
  13325. }
  13326. }
  13327. saveLog(result, requestLog, "2203", "上传就诊信息")
  13328. var respJSON2 map[string]interface{}
  13329. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  13330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13332. return
  13333. }
  13334. userJSONBytes2, _ := json.Marshal(respJSON2)
  13335. if miConfig.Code == "H15049901371" {
  13336. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  13337. utils.ErrorLog("解析失败:%v", err)
  13338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13339. return
  13340. }
  13341. res2.InfRefmsgid = ressix10265.InfRefmsgid
  13342. res2.Output = ressix10265.Output
  13343. res2.ErrMsg = ressix10265.ErrMsg
  13344. res2.Cainfo = ressix10265.Cainfo
  13345. res2.WarnMsg = ressix10265.WarnMsg
  13346. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  13347. res2.Infcode = infocode
  13348. } else {
  13349. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  13350. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  13351. utils.ErrorLog("解析失败:%v", err)
  13352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13353. return
  13354. }
  13355. res2.Infcode = res3.Infcode
  13356. } else {
  13357. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13358. utils.ErrorLog("解析失败:%v", err)
  13359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13360. return
  13361. }
  13362. }
  13363. }
  13364. }
  13365. if res2.Infcode != 0 {
  13366. adminUser := c.GetAdminUserInfo()
  13367. errlog := &models.HisOrderError{
  13368. UserOrgId: adminUser.CurrentOrgId,
  13369. Ctime: time.Now().Unix(),
  13370. Mtime: time.Now().Unix(),
  13371. ErrMsg: res2.ErrMsg,
  13372. Status: 1,
  13373. PatientId: id,
  13374. RecordTime: recordDateTime,
  13375. Stage: 3,
  13376. }
  13377. service.CreateErrMsgLog(errlog)
  13378. c.ServeSuccessJSON(map[string]interface{}{
  13379. "failed_code": -10,
  13380. "msg": res2.ErrMsg,
  13381. })
  13382. return
  13383. } else {
  13384. his.Diagnosis = diagnosis_id
  13385. his.SickType = sickConfig.ID
  13386. //var p_type int64
  13387. //if reg_type == 1111 || reg_type == 1112 {
  13388. // p_type = 11
  13389. //
  13390. //}
  13391. his.PType = fmt.Sprintf("%d", reg_type)
  13392. service.UpdateHisPatientThree(&his)
  13393. data := make(map[string]interface{})
  13394. if settle_accounts_type == 1 { //日结
  13395. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  13396. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  13397. } else {
  13398. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  13399. }
  13400. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  13401. data["pre"] = prescriptions
  13402. } else { //月结
  13403. start_time_str := c.GetString("start_time")
  13404. end_time_str := c.GetString("end_time")
  13405. timeLayout := "2006-01-02"
  13406. loc, _ := time.LoadLocation("Local")
  13407. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  13408. if err != nil {
  13409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13410. return
  13411. }
  13412. recordStartTime := theStartTime.Unix()
  13413. start_time = recordStartTime
  13414. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  13415. if err != nil {
  13416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13417. return
  13418. }
  13419. recordEndTime := theEndTime.Unix()
  13420. end_time = recordEndTime
  13421. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  13422. data["pre"] = prescriptions
  13423. }
  13424. timestamp := time.Now().Unix()
  13425. tempTime := time.Unix(timestamp, 0)
  13426. timeFormat := tempTime.Format("20060102150405")
  13427. chrgBchno := rand.Intn(100000) + 10000
  13428. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  13429. strconv.FormatInt(his.PatientId, 10)
  13430. client := &http.Client{}
  13431. data["psn_no"] = his.PsnNo
  13432. data["mdtrt_id"] = his.Number
  13433. data["chrg_bchno"] = chrg_bchno
  13434. data["org_name"] = miConfig.OrgName
  13435. data["doctor"] = doctor_info.UserName
  13436. data["doctor_id"] = doctor_info.DoctorNumber
  13437. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  13438. data["fixmedins_code"] = miConfig.Code
  13439. data["opter"] = roles.UserName
  13440. data["dept_code"] = department.Number
  13441. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  13442. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13443. data["secret_key"] = miConfig.SecretKey
  13444. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  13445. data["url"] = miConfig.Url
  13446. data["ak"] = miConfig.AccessKey
  13447. data["new_doctor_name"] = patientPrescription.Doctor
  13448. data["diag_code"] = sickConfig.CountryCode
  13449. data["cainfo"] = miConfig.Cainfo
  13450. data["opter"] = roles.UserName
  13451. var ids []int64
  13452. for _, item := range prescriptions {
  13453. ids = append(ids, item.ID)
  13454. }
  13455. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13456. if config.IsOpen == 1 { //对接了医保,走医保流程
  13457. var res ResultFour
  13458. var resFour10265 ResultFour10265
  13459. if miConfig.MdtrtareaAdmvs == "421300" {
  13460. bytesData, _ := json.Marshal(data)
  13461. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  13462. resp, _ := client.Do(req)
  13463. defer resp.Body.Close()
  13464. body, ioErr := ioutil.ReadAll(resp.Body)
  13465. if ioErr != nil {
  13466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13468. return
  13469. }
  13470. var respJSON map[string]interface{}
  13471. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13474. return
  13475. }
  13476. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13477. userJSONBytes, _ := json.Marshal(respJSON)
  13478. fmt.Println("log")
  13479. fmt.Println(string(userJSONBytes))
  13480. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13481. utils.ErrorLog("解析失败:%v", err)
  13482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13483. return
  13484. }
  13485. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13486. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  13487. if result3101.Infcode == "0" {
  13488. if len(result3101.Output.Result) > 0 {
  13489. var errMsgs []string
  13490. for _, item := range result3101.Output.Result {
  13491. errMsgs = append(errMsgs, item.VolaCont)
  13492. }
  13493. c.ServeSuccessJSON(map[string]interface{}{
  13494. "failed_code": -10,
  13495. "msg": errMsgs,
  13496. })
  13497. return
  13498. }
  13499. }
  13500. if miConfig.MdtrtareaAdmvs == "320921" {
  13501. data["doctor_id"] = doctor_info.DoctorNumber
  13502. } else {
  13503. data["doctor_id"] = doctor_info.DoctorNumber
  13504. }
  13505. bytesData, _ := json.Marshal(data)
  13506. var req *http.Request
  13507. if miConfig.MdtrtareaAdmvs == "320921" {
  13508. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13509. } else {
  13510. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13511. }
  13512. resp, _ := client.Do(req)
  13513. defer resp.Body.Close()
  13514. body, ioErr := ioutil.ReadAll(resp.Body)
  13515. if ioErr != nil {
  13516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13518. return
  13519. }
  13520. var respJSON map[string]interface{}
  13521. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13524. return
  13525. }
  13526. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13527. userJSONBytes, _ := json.Marshal(respJSON)
  13528. fmt.Println("log")
  13529. fmt.Println(string(userJSONBytes))
  13530. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  13531. utils.ErrorLog("解析失败:%v", err)
  13532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13533. return
  13534. }
  13535. res.InfRefmsgid = resFour10265.InfRefmsgid
  13536. res.Output = resFour10265.Output
  13537. res.ErrMsg = resFour10265.ErrMsg
  13538. res.Cainfo = resFour10265.Cainfo
  13539. res.WarnMsg = resFour10265.WarnMsg
  13540. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  13541. res.Infcode = infocode
  13542. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13543. var pagesize int = 2
  13544. var start int = 1
  13545. var stop int
  13546. var pagecount int
  13547. var curpage int
  13548. var isSuccess bool = true
  13549. data["doctor_id"] = doctor_info.DoctorNumber
  13550. //总页数,向上取整,注意除之前要先转换类型为float64
  13551. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  13552. for curpage = 1; curpage <= pagecount; curpage++ {
  13553. if curpage == 1 {
  13554. start = 1
  13555. } else {
  13556. start = (curpage-1)*pagesize + 1
  13557. }
  13558. stop = curpage * pagesize
  13559. if stop > len(prescriptions) {
  13560. stop = len(prescriptions)
  13561. }
  13562. //var requestLog string
  13563. data["pre"] = prescriptions[start-1 : stop]
  13564. fmt.Println(data["pre"])
  13565. bytesData, _ := json.Marshal(data)
  13566. var req *http.Request
  13567. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  13568. resp, _ := client.Do(req)
  13569. defer resp.Body.Close()
  13570. body, ioErr := ioutil.ReadAll(resp.Body)
  13571. if ioErr != nil {
  13572. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13574. return
  13575. }
  13576. var respJSON map[string]interface{}
  13577. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13578. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13580. return
  13581. }
  13582. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13583. userJSONBytes, _ := json.Marshal(respJSON)
  13584. fmt.Println("log")
  13585. fmt.Println(string(userJSONBytes))
  13586. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  13587. utils.ErrorLog("解析失败:%v", err)
  13588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13589. return
  13590. }
  13591. res.InfRefmsgid = resFour10265.InfRefmsgid
  13592. res.Output = resFour10265.Output
  13593. res.ErrMsg = resFour10265.ErrMsg
  13594. res.Cainfo = resFour10265.Cainfo
  13595. res.WarnMsg = resFour10265.WarnMsg
  13596. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  13597. res.Infcode = infocode
  13598. if infocode == 0 {
  13599. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  13600. } else {
  13601. isSuccess = false
  13602. errlog := &models.HisOrderError{
  13603. UserOrgId: adminUser.CurrentOrgId,
  13604. Ctime: time.Now().Unix(),
  13605. Mtime: time.Now().Unix(),
  13606. Number: chrg_bchno,
  13607. ErrMsg: "",
  13608. Status: 1,
  13609. PatientId: id,
  13610. RecordTime: recordDateTime,
  13611. Stage: 4,
  13612. }
  13613. service.CreateErrMsgLog(errlog)
  13614. c.ServeSuccessJSON(map[string]interface{}{
  13615. "failed_code": -10,
  13616. "msg": res.ErrMsg,
  13617. })
  13618. return
  13619. }
  13620. }
  13621. if isSuccess {
  13622. res.Infcode = 0
  13623. }
  13624. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13625. 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)
  13626. var dat map[string]interface{}
  13627. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13628. fmt.Println(dat)
  13629. } else {
  13630. fmt.Println(err)
  13631. }
  13632. saveLog(result, request_log, "2204", "上传费用明细")
  13633. userJSONBytes, _ := json.Marshal(dat)
  13634. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  13635. utils.ErrorLog("解析失败:%v", err)
  13636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13637. return
  13638. }
  13639. res.InfRefmsgid = resFour10265.InfRefmsgid
  13640. res.Output = resFour10265.Output
  13641. res.ErrMsg = resFour10265.ErrMsg
  13642. res.Cainfo = resFour10265.Cainfo
  13643. res.WarnMsg = resFour10265.WarnMsg
  13644. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  13645. res.Infcode = infocode
  13646. } else {
  13647. if miConfig.Code == "H15049901371" {
  13648. 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)
  13649. var dat map[string]interface{}
  13650. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13651. fmt.Println(dat)
  13652. } else {
  13653. fmt.Println(err)
  13654. }
  13655. saveLog(result, request_log, "2204", "上传费用明细")
  13656. userJSONBytes, _ := json.Marshal(dat)
  13657. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  13658. utils.ErrorLog("解析失败:%v", err)
  13659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13660. return
  13661. }
  13662. res.InfRefmsgid = resFour10265.InfRefmsgid
  13663. res.Output = resFour10265.Output
  13664. res.ErrMsg = resFour10265.ErrMsg
  13665. res.Cainfo = resFour10265.Cainfo
  13666. res.WarnMsg = resFour10265.WarnMsg
  13667. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  13668. res.Infcode = infocode
  13669. } else {
  13670. 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)
  13671. var dat map[string]interface{}
  13672. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13673. fmt.Println(dat)
  13674. } else {
  13675. fmt.Println(err)
  13676. }
  13677. saveLog(result, request_log, "2204", "上传费用明细")
  13678. userJSONBytes, _ := json.Marshal(dat)
  13679. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13680. utils.ErrorLog("解析失败:%v", err)
  13681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13682. return
  13683. }
  13684. }
  13685. }
  13686. if res.Infcode == 0 {
  13687. order := &models.HisOrder{
  13688. UserOrgId: adminUser.CurrentOrgId,
  13689. HisPatientId: his.ID,
  13690. PatientId: his.PatientId,
  13691. SettleAccountsDate: recordDateTime,
  13692. MdtrtId: his.Number,
  13693. PsnNo: his.PsnNo,
  13694. MedType: strconv.FormatInt(reg_type, 10),
  13695. Ctime: time.Now().Unix(),
  13696. Mtime: time.Now().Unix(),
  13697. Status: 1,
  13698. Number: chrg_bchno,
  13699. Infcode: res.Infcode,
  13700. WarnMsg: res.WarnMsg,
  13701. Cainfo: res.Cainfo,
  13702. ErrMsg: res.ErrMsg,
  13703. RespondTime: res.RefmsgTime,
  13704. InfRefmsgid: res.InfRefmsgid,
  13705. OrderStatus: 1,
  13706. PayWay: pay_way,
  13707. PayWays: pay_ways,
  13708. OthDesc: oth_desc,
  13709. PayPrice: pay_price,
  13710. PayCardNo: pay_card_no,
  13711. DiscountPrice: discount_price,
  13712. PreferentialPrice: preferential_price,
  13713. RealityPrice: reality_price,
  13714. FoundPrice: found_price,
  13715. MedicalInsurancePrice: medical_insurance_price,
  13716. PrivatePrice: private_price,
  13717. IsMedicineInsurance: 1,
  13718. SettleType: settle_accounts_type,
  13719. SettleStartTime: start_time,
  13720. SettleEndTime: end_time,
  13721. Creator: roles.AdminUserId,
  13722. Modify: roles.AdminUserId,
  13723. FaPiaoNumber: fapiao_number,
  13724. FaPiaoCode: fapiao_code,
  13725. PType: 2,
  13726. Diagnosis: diagnosis_id,
  13727. CashPay: cash_pay,
  13728. WechatPay: wechat_pay,
  13729. AliPay: ali_pay,
  13730. JifenPay: jifen_pay,
  13731. BandCardPay: band_card_pay,
  13732. }
  13733. err = service.CreateOrder(order)
  13734. if err != nil {
  13735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  13736. return
  13737. }
  13738. for _, item := range res.Output.Result {
  13739. temp := strings.Split(item.FeedetlSn, "-")
  13740. var advice_id int64 = 0
  13741. var project_id int64 = 0
  13742. var types int64 = 0
  13743. id, _ := strconv.ParseInt(temp[2], 10, 64)
  13744. types, _ = strconv.ParseInt(temp[1], 10, 64)
  13745. if temp[1] == "1" {
  13746. advice_id = id
  13747. project_id = 0
  13748. } else if temp[1] == "2" {
  13749. advice_id = 0
  13750. project_id = id
  13751. }
  13752. if item.MedChrgitmType == "9" {
  13753. item.MedChrgitmType = "09"
  13754. }
  13755. info := &models.HisOrderInfo{
  13756. OrderNumber: order.Number,
  13757. FeedetlSn: item.FeedetlSn,
  13758. UploadDate: time.Now().Unix(),
  13759. AdviceId: advice_id,
  13760. DetItemFeeSumamt: item.DetItemFeeSumamt,
  13761. Cnt: item.Cnt,
  13762. Pric: float64(item.Pric),
  13763. PatientId: his.PatientId,
  13764. PricUplmtAmt: item.PricUplmtAmt,
  13765. SelfpayProp: item.SelfpayProp,
  13766. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  13767. OverlmtAmt: item.OverlmtAmt,
  13768. PreselfpayAmt: item.PreselfpayAmt,
  13769. BasMednFlag: item.BasMednFlag,
  13770. MedChrgitmType: item.MedChrgitmType,
  13771. HiNegoDrugFlag: item.HiNegoDrugFlag,
  13772. Status: 1,
  13773. Memo: item.Memo,
  13774. Mtime: time.Now().Unix(),
  13775. InscpScpAmt: item.InscpScpAmt,
  13776. DrtReimFlag: item.DrtReimFlag,
  13777. Ctime: time.Now().Unix(),
  13778. ListSpItemFlag: item.ListSpItemFlag,
  13779. ChldMedcFlag: item.ChldMedcFlag,
  13780. LmtUsedFlag: item.LmtUsedFlag,
  13781. ChrgitmLv: item.ChrgitmLv,
  13782. UserOrgId: adminUser.CurrentOrgId,
  13783. HisPatientId: his.ID,
  13784. OrderId: order.ID,
  13785. ProjectId: project_id,
  13786. Type: types,
  13787. }
  13788. service.CreateOrderInfo(info)
  13789. }
  13790. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  13791. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  13792. var total float64
  13793. for _, item := range prescriptions {
  13794. if item.Type == 1 { //药品
  13795. for _, subItem := range item.HisDoctorAdviceInfo {
  13796. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  13797. total_one := price * subItem.PrescribingNumber
  13798. total = total + total_one
  13799. }
  13800. }
  13801. if item.Type == 2 { //项目
  13802. for _, subItem := range item.HisPrescriptionProject {
  13803. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  13804. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  13805. total_one := price * cnt
  13806. total = total + total_one
  13807. }
  13808. }
  13809. }
  13810. allTotal := fmt.Sprintf("%f", total)
  13811. //if adminUser.CurrentOrgId == 9919 {
  13812. //
  13813. // allTotal = fmt.Sprintf("%.2f", total)
  13814. //
  13815. //} else {
  13816. //
  13817. // allTotal = fmt.Sprintf("%.2f", total)
  13818. //
  13819. //}
  13820. if res.Infcode == 0 {
  13821. var rf []*ResultFive
  13822. json.Unmarshal([]byte(his.Iinfo), &rf)
  13823. chrg_bchno := chrg_bchno
  13824. cert_no := his.Certno
  13825. var insutypes []string
  13826. var insutype string
  13827. var is390 int = 0
  13828. var is310 int = 0
  13829. for _, item := range rf {
  13830. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13831. insutypes = append(insutypes, item.Insutype)
  13832. }
  13833. }
  13834. if len(insutypes) == 1 {
  13835. insutype = insutypes[0]
  13836. } else {
  13837. for _, i := range insutypes {
  13838. if i == "390" {
  13839. is390 = 1
  13840. }
  13841. if i == "310" {
  13842. is310 = 1
  13843. }
  13844. }
  13845. }
  13846. if is390 == 1 {
  13847. insutype = "390"
  13848. }
  13849. if is310 == 1 {
  13850. insutype = "310"
  13851. }
  13852. if len(insutypes) == 0 {
  13853. insutype = "310"
  13854. }
  13855. if len(insutypes) == 2 {
  13856. insutype = strconv.FormatInt(his.SocialType, 10)
  13857. }
  13858. insutype = strconv.FormatInt(his.SocialType, 10)
  13859. //insutype = "390"
  13860. if his.IdCardType == 1 {
  13861. // cert_no = his.MedicalInsuranceNumber
  13862. cert_no = his.Certno
  13863. } else {
  13864. cert_no = his.Certno
  13865. }
  13866. var res ResultSeven
  13867. var resSeven10265 ResultSeven10265
  13868. var gzresSeven10265Two GZResultSeven10265Two
  13869. var src_resquest string
  13870. var result2 string
  13871. if miConfig.MdtrtareaAdmvs == "421300" {
  13872. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  13873. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  13874. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13875. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13876. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  13877. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  13878. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  13879. resp, requestErr := http.Get(api)
  13880. if requestErr != nil {
  13881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13882. return
  13883. }
  13884. body, ioErr := ioutil.ReadAll(resp.Body)
  13885. if ioErr != nil {
  13886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13888. return
  13889. }
  13890. var respJSON map[string]interface{}
  13891. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13894. return
  13895. }
  13896. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13897. result, _ := json.Marshal(respJSON)
  13898. if miConfig.Code == "H15049901371" {
  13899. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  13900. utils.ErrorLog("解析失败:%v", err)
  13901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13902. return
  13903. }
  13904. res.InfRefmsgid = resSeven10265.InfRefmsgid
  13905. res.Output = resSeven10265.Output
  13906. res.ErrMsg = resSeven10265.ErrMsg
  13907. res.Cainfo = resSeven10265.Cainfo
  13908. res.WarnMsg = resSeven10265.WarnMsg
  13909. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  13910. res.Infcode = infocode
  13911. } else {
  13912. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13913. utils.ErrorLog("解析失败:%v", err)
  13914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13915. return
  13916. }
  13917. }
  13918. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13919. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  13920. if result3101.Infcode == "0" {
  13921. if len(result3101.Output.Result) > 0 {
  13922. var errMsgs []string
  13923. for _, item := range result3101.Output.Result {
  13924. errMsgs = append(errMsgs, item.VolaCont)
  13925. }
  13926. c.ServeSuccessJSON(map[string]interface{}{
  13927. "failed_code": -10,
  13928. "msg": errMsgs,
  13929. })
  13930. return
  13931. } else {
  13932. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  13933. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  13934. bas := strings.Split(psn_info.CardInfo, "|")
  13935. if his.IdCardType == 1 {
  13936. cert_no = bas[2]
  13937. } else if his.IdCardType == 3 {
  13938. cert_no = his.Certno
  13939. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  13940. } else if his.IdCardType == 4 {
  13941. cert_no = his.Certno
  13942. psn_info.VerifyNumber = psn_info.VerifyNumber
  13943. }
  13944. var api string
  13945. if miConfig.MdtrtareaAdmvs == "320921" {
  13946. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  13947. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  13948. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13949. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13950. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  13951. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  13952. "&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
  13953. } else {
  13954. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  13955. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  13956. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13957. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13958. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  13959. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  13960. "&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
  13961. }
  13962. resp, requestErr := http.Get(api)
  13963. if requestErr != nil {
  13964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13965. return
  13966. }
  13967. body, ioErr := ioutil.ReadAll(resp.Body)
  13968. if ioErr != nil {
  13969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13971. return
  13972. }
  13973. var respJSON map[string]interface{}
  13974. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13977. return
  13978. }
  13979. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13980. result, _ := json.Marshal(respJSON)
  13981. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  13982. utils.ErrorLog("解析失败:%v", err)
  13983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13984. return
  13985. }
  13986. res.InfRefmsgid = resSeven10265.InfRefmsgid
  13987. res.Output = resSeven10265.Output
  13988. res.ErrMsg = resSeven10265.ErrMsg
  13989. res.Cainfo = resSeven10265.Cainfo
  13990. res.WarnMsg = resSeven10265.WarnMsg
  13991. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  13992. res.Infcode = infocode
  13993. }
  13994. }
  13995. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13996. psn_info, _ := service.GetPsnByPatientId(id)
  13997. var verify_number string
  13998. if psn_info.IdCardType == 4 {
  13999. verify_number = psn_info.VerifyNumber
  14000. } else if psn_info.IdCardType == 1 {
  14001. bas := strings.Split(psn_info.CardInfo, "|")
  14002. cardNumber := bas[2]
  14003. verify_number = cardNumber
  14004. } else {
  14005. psn_info.IdCardType = 2
  14006. verify_number = psn_info.Certno
  14007. }
  14008. var api string
  14009. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  14010. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  14011. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14012. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14013. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  14014. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  14015. "&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
  14016. resp, requestErr := http.Get(api)
  14017. if requestErr != nil {
  14018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14019. return
  14020. }
  14021. body, ioErr := ioutil.ReadAll(resp.Body)
  14022. if ioErr != nil {
  14023. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14025. return
  14026. }
  14027. var respJSON map[string]interface{}
  14028. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14031. return
  14032. }
  14033. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14034. result, _ := json.Marshal(respJSON)
  14035. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  14036. utils.ErrorLog("解析失败:%v", err)
  14037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14038. return
  14039. }
  14040. res.InfRefmsgid = resSeven10265.InfRefmsgid
  14041. res.Output = resSeven10265.Output
  14042. res.ErrMsg = resSeven10265.ErrMsg
  14043. res.Cainfo = resSeven10265.Cainfo
  14044. res.WarnMsg = resSeven10265.WarnMsg
  14045. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  14046. res.Infcode = infocode
  14047. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14048. var cert_no string
  14049. if his.IdCardType == 4 {
  14050. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14051. cert_no = psn_info.VerifyNumber
  14052. 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)
  14053. } else if his.IdCardType == 1 {
  14054. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14055. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  14056. 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)
  14057. }
  14058. //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)
  14059. var dat map[string]interface{}
  14060. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14061. fmt.Println(dat)
  14062. } else {
  14063. fmt.Println(err)
  14064. }
  14065. saveLog(result2, src_resquest, "2207", "结算")
  14066. userJSONBytes, _ := json.Marshal(dat)
  14067. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  14068. utils.ErrorLog("解析失败:%v", err)
  14069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14070. return
  14071. }
  14072. res.InfRefmsgid = resSeven10265.InfRefmsgid
  14073. res.Output = resSeven10265.Output
  14074. res.ErrMsg = resSeven10265.ErrMsg
  14075. res.Cainfo = resSeven10265.Cainfo
  14076. res.WarnMsg = resSeven10265.WarnMsg
  14077. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  14078. res.Infcode = infocode
  14079. } else {
  14080. if miConfig.Code == "H15049901371" {
  14081. //赤峰地区国家医保医疗类别
  14082. //职工透析:医疗类别选特殊情况门诊990502
  14083. //居民定额血透门慢: 医疗类别选门诊慢病140104
  14084. var med_type string
  14085. if his.Insutype == "390" {
  14086. if reg_type == 14 {
  14087. med_type = "9933"
  14088. } else if reg_type == 11 {
  14089. med_type = "11"
  14090. }
  14091. } else if his.Insutype == "310" {
  14092. if reg_type == 14 {
  14093. med_type = "990502"
  14094. } else if reg_type == 11 {
  14095. med_type = "11"
  14096. }
  14097. }
  14098. 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, "")
  14099. } else {
  14100. if his.IdCardType == 4 {
  14101. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14102. var token string
  14103. token = psn_info.VerifyNumber
  14104. 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)
  14105. } else {
  14106. 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, "")
  14107. }
  14108. }
  14109. //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)
  14110. var dat map[string]interface{}
  14111. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14112. fmt.Println(dat)
  14113. } else {
  14114. fmt.Println(err)
  14115. }
  14116. saveLog(result2, src_resquest, "2207", "结算")
  14117. userJSONBytes, _ := json.Marshal(dat)
  14118. if miConfig.Code == "H15049901371" {
  14119. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  14120. utils.ErrorLog("解析失败:%v", err)
  14121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14122. return
  14123. }
  14124. res.InfRefmsgid = resSeven10265.InfRefmsgid
  14125. res.Output = resSeven10265.Output
  14126. res.ErrMsg = resSeven10265.ErrMsg
  14127. res.Cainfo = resSeven10265.Cainfo
  14128. res.WarnMsg = resSeven10265.WarnMsg
  14129. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  14130. res.Infcode = infocode
  14131. } else {
  14132. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  14133. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  14134. utils.ErrorLog("解析失败:%v", err)
  14135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14136. return
  14137. }
  14138. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  14139. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  14140. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  14141. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  14142. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  14143. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  14144. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  14145. res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  14146. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  14147. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  14148. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  14149. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  14150. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  14151. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  14152. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  14153. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  14154. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  14155. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  14156. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  14157. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  14158. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  14159. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  14160. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  14161. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  14162. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  14163. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  14164. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  14165. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  14166. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  14167. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  14168. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  14169. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  14170. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  14171. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  14172. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  14173. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  14174. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  14175. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  14176. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  14177. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  14178. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  14179. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  14180. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  14181. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  14182. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  14183. res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  14184. res.ErrMsg = gzresSeven10265Two.ErrMsg
  14185. res.Cainfo = gzresSeven10265Two.Cainfo
  14186. res.WarnMsg = gzresSeven10265Two.WarnMsg
  14187. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  14188. //res.Infcode = infocode
  14189. } else {
  14190. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14191. utils.ErrorLog("解析失败:%v", err)
  14192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14193. return
  14194. }
  14195. }
  14196. }
  14197. }
  14198. if res.Infcode != 0 {
  14199. errlog := &models.HisOrderError{
  14200. UserOrgId: adminUser.CurrentOrgId,
  14201. Ctime: time.Now().Unix(),
  14202. Mtime: time.Now().Unix(),
  14203. Number: chrg_bchno,
  14204. ErrMsg: res.ErrMsg,
  14205. Status: 1,
  14206. PatientId: id,
  14207. RecordTime: recordDateTime,
  14208. Stage: 6,
  14209. }
  14210. service.CreateErrMsgLog(errlog)
  14211. c.ServeSuccessJSON(map[string]interface{}{
  14212. "failed_code": -10,
  14213. "msg": res.ErrMsg,
  14214. })
  14215. return
  14216. } else {
  14217. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  14218. order.OrderStatus = 2
  14219. order.Status = 1
  14220. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  14221. order.SetlId = res.Output.Setlinfo.SetlID
  14222. order.PsnNo = res.Output.Setlinfo.PsnNo
  14223. order.PsnName = res.Output.Setlinfo.PsnName
  14224. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  14225. order.Certno = res.Output.Setlinfo.Certno
  14226. order.Gend = res.Output.Setlinfo.Gend
  14227. order.Naty = res.Output.Setlinfo.Naty
  14228. order.Age = res.Output.Setlinfo.Age
  14229. order.Insutype = res.Output.Setlinfo.Insutype
  14230. order.PsnType = res.Output.Setlinfo.PsnType
  14231. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  14232. order.SetlTime = res.Output.Setlinfo.SetlTime
  14233. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  14234. if res.Output.Setlinfo.MedType == "140101" {
  14235. order.MedType = "14"
  14236. } else {
  14237. order.MedType = res.Output.Setlinfo.MedType
  14238. }
  14239. if reg_type == 1112 {
  14240. order.MedType = "1112"
  14241. }
  14242. if reg_type == 1111 {
  14243. order.MedType = "1111"
  14244. }
  14245. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  14246. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  14247. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  14248. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  14249. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  14250. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  14251. order.HifpPay = res.Output.Setlinfo.HifpPay
  14252. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  14253. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  14254. order.HifesPay = res.Output.Setlinfo.HifesPay
  14255. order.HifobPay = res.Output.Setlinfo.HifobPay
  14256. order.MafPay = res.Output.Setlinfo.MafPay
  14257. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  14258. order.OthPay = res.Output.Setlinfo.OthPay
  14259. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  14260. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  14261. order.AcctPay = res.Output.Setlinfo.AcctPay
  14262. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  14263. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  14264. order.Balc = res.Output.Setlinfo.Balc
  14265. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  14266. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  14267. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  14268. order.ClrType = res.Output.Setlinfo.ClrType
  14269. order.ClrWay = res.Output.Setlinfo.ClrWay
  14270. order.Creator = order.Creator
  14271. order.Modify = roles.AdminUserId
  14272. order.RequestLog = src_resquest
  14273. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  14274. detailStr := string(setlDetail)
  14275. order.SetlDetail = detailStr
  14276. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  14277. err = service.UpDateOrder(order)
  14278. if err == nil {
  14279. //判断是否使用了押金
  14280. if dec_way == "true" {
  14281. tmpstring := strconv.FormatInt(order.ID, 10)
  14282. order.Decimal = decimal
  14283. service.UpDateOrder(order)
  14284. //扣押金
  14285. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  14286. if errmsg != nil {
  14287. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  14288. return
  14289. }
  14290. }
  14291. c.ServeSuccessJSON(map[string]interface{}{
  14292. "msg": "结算成功",
  14293. })
  14294. } else {
  14295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  14296. return
  14297. }
  14298. }
  14299. } else {
  14300. adminUser := c.GetAdminUserInfo()
  14301. errlog := &models.HisOrderError{
  14302. UserOrgId: adminUser.CurrentOrgId,
  14303. Ctime: time.Now().Unix(),
  14304. Mtime: time.Now().Unix(),
  14305. ErrMsg: res.ErrMsg,
  14306. Status: 1,
  14307. PatientId: id,
  14308. RecordTime: recordDateTime,
  14309. Stage: 4,
  14310. }
  14311. service.CreateErrMsgLog(errlog)
  14312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  14313. return
  14314. }
  14315. } else {
  14316. adminUser := c.GetAdminUserInfo()
  14317. errlog := &models.HisOrderError{
  14318. UserOrgId: adminUser.CurrentOrgId,
  14319. Ctime: time.Now().Unix(),
  14320. Mtime: time.Now().Unix(),
  14321. ErrMsg: res.ErrMsg,
  14322. Status: 1,
  14323. PatientId: id,
  14324. RecordTime: recordDateTime,
  14325. Stage: 4,
  14326. }
  14327. service.CreateErrMsgLog(errlog)
  14328. c.ServeSuccessJSON(map[string]interface{}{
  14329. "failed_code": -10,
  14330. "msg": res.ErrMsg,
  14331. })
  14332. return
  14333. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  14334. //return
  14335. }
  14336. }
  14337. }
  14338. } else if tempOrder.ID > 0 {
  14339. if tempOrder.IsPre == 1 {
  14340. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  14341. var rf []*ResultFive
  14342. json.Unmarshal([]byte(his.Iinfo), &rf)
  14343. chrg_bchno := tempOrder.Number
  14344. cert_no := his.Certno
  14345. var insutypes []string
  14346. var insutype string
  14347. var is390 int = 0
  14348. var is310 int = 0
  14349. for _, item := range rf {
  14350. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14351. insutypes = append(insutypes, item.Insutype)
  14352. }
  14353. }
  14354. if len(insutypes) == 1 {
  14355. insutype = insutypes[0]
  14356. } else {
  14357. for _, i := range insutypes {
  14358. if i == "390" {
  14359. is390 = 1
  14360. }
  14361. if i == "310" {
  14362. is310 = 1
  14363. }
  14364. }
  14365. }
  14366. if is390 == 1 {
  14367. insutype = "390"
  14368. }
  14369. if is310 == 1 {
  14370. insutype = "310"
  14371. }
  14372. if len(insutypes) == 0 {
  14373. insutype = "310"
  14374. }
  14375. if len(insutypes) == 2 {
  14376. insutype = strconv.FormatInt(his.SocialType, 10)
  14377. }
  14378. //insutype = "390"
  14379. if his.IdCardType == 1 {
  14380. // cert_no = his.MedicalInsuranceNumber
  14381. cert_no = his.Certno
  14382. } else {
  14383. cert_no = his.Certno
  14384. }
  14385. var res ResultSeven
  14386. var resSeven10265 ResultSeven10265
  14387. var gzresSeven10265Two GZResultSeven10265Two
  14388. var src_resquest string
  14389. var result2 string
  14390. if miConfig.MdtrtareaAdmvs == "421300" {
  14391. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  14392. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  14393. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14394. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14395. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  14396. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  14397. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  14398. resp, requestErr := http.Get(api)
  14399. if requestErr != nil {
  14400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14401. return
  14402. }
  14403. body, ioErr := ioutil.ReadAll(resp.Body)
  14404. if ioErr != nil {
  14405. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14407. return
  14408. }
  14409. var respJSON map[string]interface{}
  14410. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14413. return
  14414. }
  14415. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14416. result, _ := json.Marshal(respJSON)
  14417. fmt.Println("log")
  14418. fmt.Println(string(result))
  14419. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14420. utils.ErrorLog("解析失败:%v", err)
  14421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14422. return
  14423. }
  14424. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14425. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  14426. if result3101.Infcode == "0" {
  14427. if len(result3101.Output.Result) > 0 {
  14428. var errMsgs []string
  14429. for _, item := range result3101.Output.Result {
  14430. errMsgs = append(errMsgs, item.VolaCont)
  14431. }
  14432. c.ServeSuccessJSON(map[string]interface{}{
  14433. "failed_code": -10,
  14434. "msg": errMsgs,
  14435. })
  14436. return
  14437. } else {
  14438. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14439. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  14440. bas := strings.Split(psn_info.CardInfo, "|")
  14441. if his.IdCardType == 1 {
  14442. cert_no = bas[2]
  14443. } else if his.IdCardType == 3 {
  14444. cert_no = his.Certno
  14445. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  14446. } else if his.IdCardType == 4 {
  14447. cert_no = his.Certno
  14448. psn_info.VerifyNumber = psn_info.VerifyNumber
  14449. }
  14450. //江苏地区国家医保医疗类别
  14451. //职工透析:医疗类别选特殊情况门诊9933
  14452. //居民血透门慢: 医疗类别选门诊慢病1402
  14453. //var med_type string
  14454. //if his.Insutype == "310" {
  14455. // if reg_type == 14 {
  14456. // med_type = "9933"
  14457. // } else if reg_type == 11 {
  14458. // med_type = "11"
  14459. //
  14460. // }
  14461. //} else if his.Insutype == "390" {
  14462. // if reg_type == 14 {
  14463. // med_type = "1402"
  14464. // } else if reg_type == 11 {
  14465. // med_type = "11"
  14466. // }
  14467. //}
  14468. var api string
  14469. if miConfig.MdtrtareaAdmvs == "320921" {
  14470. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  14471. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  14472. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14473. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14474. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  14475. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  14476. "&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
  14477. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14478. } else {
  14479. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14480. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  14481. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  14482. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14483. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14484. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  14485. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  14486. "&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
  14487. }
  14488. resp, requestErr := http.Get(api)
  14489. if requestErr != nil {
  14490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14491. return
  14492. }
  14493. body, ioErr := ioutil.ReadAll(resp.Body)
  14494. if ioErr != nil {
  14495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14497. return
  14498. }
  14499. var respJSON map[string]interface{}
  14500. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14503. return
  14504. }
  14505. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14506. result, _ := json.Marshal(respJSON)
  14507. fmt.Println("log")
  14508. fmt.Println(string(result))
  14509. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  14510. utils.ErrorLog("解析失败:%v", err)
  14511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14512. return
  14513. }
  14514. res.InfRefmsgid = resSeven10265.InfRefmsgid
  14515. res.Output = resSeven10265.Output
  14516. res.InfRefmsgid = resSeven10265.InfRefmsgid
  14517. res.ErrMsg = resSeven10265.ErrMsg
  14518. res.Cainfo = resSeven10265.Cainfo
  14519. res.WarnMsg = resSeven10265.WarnMsg
  14520. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  14521. res.Infcode = infocode
  14522. }
  14523. }
  14524. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14525. psn_info, _ := service.GetPsnByPatientId(id)
  14526. var verify_number string
  14527. if psn_info.IdCardType == 4 {
  14528. verify_number = psn_info.VerifyNumber
  14529. } else if psn_info.IdCardType == 1 {
  14530. bas := strings.Split(psn_info.CardInfo, "|")
  14531. cardNumber := bas[2]
  14532. verify_number = cardNumber
  14533. } else {
  14534. verify_number = psn_info.Certno
  14535. psn_info.IdCardType = 2
  14536. }
  14537. var api string
  14538. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  14539. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  14540. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14541. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14542. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  14543. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  14544. "&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
  14545. resp, requestErr := http.Get(api)
  14546. if requestErr != nil {
  14547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14548. return
  14549. }
  14550. body, ioErr := ioutil.ReadAll(resp.Body)
  14551. if ioErr != nil {
  14552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14554. return
  14555. }
  14556. var respJSON map[string]interface{}
  14557. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14560. return
  14561. }
  14562. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14563. result, _ := json.Marshal(respJSON)
  14564. fmt.Println("log")
  14565. fmt.Println(string(result))
  14566. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  14567. utils.ErrorLog("解析失败:%v", err)
  14568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14569. return
  14570. }
  14571. res.InfRefmsgid = resSeven10265.InfRefmsgid
  14572. res.Output = resSeven10265.Output
  14573. res.InfRefmsgid = resSeven10265.InfRefmsgid
  14574. res.ErrMsg = resSeven10265.ErrMsg
  14575. res.Cainfo = resSeven10265.Cainfo
  14576. res.WarnMsg = resSeven10265.WarnMsg
  14577. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  14578. res.Infcode = infocode
  14579. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14580. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14581. var cert_no string
  14582. if his.IdCardType == 1 {
  14583. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  14584. } else {
  14585. cert_no = psn_info.VerifyNumber
  14586. }
  14587. 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)
  14588. var dat map[string]interface{}
  14589. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14590. fmt.Println(dat)
  14591. } else {
  14592. fmt.Println(err)
  14593. }
  14594. saveLog(result2, src_resquest, "2207", "结算")
  14595. userJSONBytes, _ := json.Marshal(dat)
  14596. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14597. utils.ErrorLog("解析失败:%v", err)
  14598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14599. return
  14600. }
  14601. } else if miConfig.MdtrtareaAdmvs == "360399" {
  14602. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14603. var cert_no string
  14604. if his.IdCardType == 1 {
  14605. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  14606. } else if his.IdCardType == 2 {
  14607. cert_no = his.IdCardNo
  14608. } else {
  14609. cert_no = psn_info.VerifyNumber
  14610. }
  14611. 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, "")
  14612. var dat map[string]interface{}
  14613. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14614. fmt.Println(dat)
  14615. } else {
  14616. fmt.Println(err)
  14617. }
  14618. saveLog(result2, src_resquest, "2207", "结算")
  14619. userJSONBytes, _ := json.Marshal(dat)
  14620. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14621. utils.ErrorLog("解析失败:%v", err)
  14622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14623. return
  14624. }
  14625. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14626. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14627. var cert_no string
  14628. if his.IdCardType == 1 {
  14629. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  14630. } else if his.IdCardType == 2 {
  14631. cert_no = his.IdCardNo
  14632. } else {
  14633. cert_no = psn_info.VerifyNumber
  14634. }
  14635. 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, "")
  14636. var dat map[string]interface{}
  14637. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14638. fmt.Println(dat)
  14639. } else {
  14640. fmt.Println(err)
  14641. }
  14642. saveLog(result2, src_resquest, "2207", "结算")
  14643. userJSONBytes, _ := json.Marshal(dat)
  14644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14645. utils.ErrorLog("解析失败:%v", err)
  14646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14647. return
  14648. }
  14649. } else {
  14650. var src_resquest string
  14651. if miConfig.Code == "H15049901371" {
  14652. //赤峰地区国家医保医疗类别
  14653. //职工透析:医疗类别选特殊情况门诊990502
  14654. //居民定额血透门慢: 医疗类别选门诊慢病140104
  14655. var med_type string
  14656. if his.Insutype == "390" {
  14657. if reg_type == 14 {
  14658. med_type = "9933"
  14659. } else if reg_type == 11 {
  14660. med_type = "11"
  14661. }
  14662. } else if his.Insutype == "310" {
  14663. if reg_type == 14 {
  14664. med_type = "990502"
  14665. } else if reg_type == 11 {
  14666. med_type = "11"
  14667. }
  14668. }
  14669. 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, "")
  14670. } else {
  14671. if his.IdCardType == 4 {
  14672. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14673. token := psn_info.VerifyNumber
  14674. 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)
  14675. } else {
  14676. 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, "")
  14677. }
  14678. }
  14679. var dat map[string]interface{}
  14680. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14681. fmt.Println(dat)
  14682. } else {
  14683. fmt.Println(err)
  14684. }
  14685. saveLog(result2, src_resquest, "2207", "结算")
  14686. userJSONBytes, _ := json.Marshal(dat)
  14687. if miConfig.Code == "H15049901371" {
  14688. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  14689. utils.ErrorLog("解析失败:%v", err)
  14690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14691. return
  14692. }
  14693. res.InfRefmsgid = resSeven10265.InfRefmsgid
  14694. res.Output = resSeven10265.Output
  14695. res.ErrMsg = resSeven10265.ErrMsg
  14696. res.Cainfo = resSeven10265.Cainfo
  14697. res.WarnMsg = resSeven10265.WarnMsg
  14698. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  14699. res.Infcode = infocode
  14700. } else {
  14701. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  14702. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  14703. utils.ErrorLog("解析失败:%v", err)
  14704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14705. return
  14706. }
  14707. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  14708. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  14709. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  14710. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  14711. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  14712. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  14713. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  14714. res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  14715. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  14716. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  14717. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  14718. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  14719. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  14720. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  14721. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  14722. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  14723. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  14724. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  14725. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  14726. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  14727. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  14728. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  14729. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  14730. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  14731. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  14732. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  14733. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  14734. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  14735. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  14736. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  14737. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  14738. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  14739. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  14740. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  14741. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  14742. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  14743. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  14744. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  14745. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  14746. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  14747. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  14748. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  14749. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  14750. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  14751. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  14752. res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  14753. res.ErrMsg = gzresSeven10265Two.ErrMsg
  14754. res.Cainfo = gzresSeven10265Two.Cainfo
  14755. res.WarnMsg = gzresSeven10265Two.WarnMsg
  14756. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  14757. //res.Infcode = infocode
  14758. } else {
  14759. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14760. utils.ErrorLog("解析失败:%v", err)
  14761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14762. return
  14763. }
  14764. }
  14765. }
  14766. }
  14767. if res.Infcode != 0 {
  14768. errlog := &models.HisOrderError{
  14769. UserOrgId: adminUser.CurrentOrgId,
  14770. Ctime: time.Now().Unix(),
  14771. Mtime: time.Now().Unix(),
  14772. Number: chrg_bchno,
  14773. ErrMsg: res.ErrMsg,
  14774. Status: 1,
  14775. PatientId: id,
  14776. RecordTime: recordDateTime,
  14777. Stage: 6,
  14778. }
  14779. service.CreateErrMsgLog(errlog)
  14780. c.ServeSuccessJSON(map[string]interface{}{
  14781. "failed_code": -10,
  14782. "msg": res.ErrMsg,
  14783. })
  14784. return
  14785. } else {
  14786. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  14787. order.OrderStatus = 2
  14788. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  14789. order.SetlId = res.Output.Setlinfo.SetlID
  14790. order.PsnNo = res.Output.Setlinfo.PsnNo
  14791. order.PsnName = res.Output.Setlinfo.PsnName
  14792. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  14793. order.Certno = res.Output.Setlinfo.Certno
  14794. order.Gend = res.Output.Setlinfo.Gend
  14795. order.Naty = res.Output.Setlinfo.Naty
  14796. order.Age = res.Output.Setlinfo.Age
  14797. order.Insutype = res.Output.Setlinfo.Insutype
  14798. order.PsnType = res.Output.Setlinfo.PsnType
  14799. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  14800. order.SetlTime = res.Output.Setlinfo.SetlTime
  14801. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  14802. order.PayWays = pay_ways
  14803. order.AcctUsedFlag = acct_used_flag
  14804. order.WechatPay = wechat_pay
  14805. order.AliPay = ali_pay
  14806. order.JifenPay = jifen_pay
  14807. order.BandCardPay = band_card_pay
  14808. order.CashPay = cash_pay
  14809. order.OthDesc = oth_desc
  14810. //order.MedType = res.Output.Setlinfo.MedType
  14811. if reg_type == 1112 {
  14812. order.MedType = "1112"
  14813. }
  14814. if reg_type == 1111 {
  14815. order.MedType = "1111"
  14816. }
  14817. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  14818. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  14819. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  14820. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  14821. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  14822. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  14823. order.HifpPay = res.Output.Setlinfo.HifpPay
  14824. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  14825. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  14826. order.HifesPay = res.Output.Setlinfo.HifesPay
  14827. order.HifobPay = res.Output.Setlinfo.HifobPay
  14828. order.MafPay = res.Output.Setlinfo.MafPay
  14829. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  14830. order.OthPay = res.Output.Setlinfo.OthPay
  14831. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  14832. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  14833. order.AcctPay = res.Output.Setlinfo.AcctPay
  14834. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  14835. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  14836. order.Balc = res.Output.Setlinfo.Balc
  14837. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  14838. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  14839. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  14840. order.ClrWay = res.Output.Setlinfo.ClrWay
  14841. order.Creator = order.Creator
  14842. order.Modify = roles.AdminUserId
  14843. order.RequestLog = src_resquest
  14844. order.Diagnosis = diagnosis_id
  14845. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  14846. detailStr := string(setlDetail)
  14847. order.SetlDetail = detailStr
  14848. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  14849. err = service.UpDateOrder(order)
  14850. if err == nil {
  14851. //判断是否使用了押金
  14852. if dec_way == "true" {
  14853. tmpstring := strconv.FormatInt(order.ID, 10)
  14854. //扣押金
  14855. order.Decimal = decimal
  14856. service.UpDateOrder(order)
  14857. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  14858. if errmsg != nil {
  14859. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  14860. return
  14861. }
  14862. }
  14863. c.ServeSuccessJSON(map[string]interface{}{
  14864. "msg": "结算成功",
  14865. })
  14866. } else {
  14867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  14868. return
  14869. }
  14870. }
  14871. }
  14872. }
  14873. }
  14874. //func (c *HisApiController) GetPreUploadInfo() {
  14875. // id, _ := c.GetInt64("id")
  14876. // record_time := c.GetString("record_time")
  14877. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  14878. // admin_user_id, _ := c.GetInt64("admin_user_id")
  14879. //
  14880. // timeLayout := "2006-01-02"
  14881. // loc, _ := time.LoadLocation("Local")
  14882. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  14883. // if err != nil {
  14884. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  14885. // return
  14886. // }
  14887. // recordDateTime := theTime.Unix()
  14888. // adminUser := c.GetAdminUserInfo()
  14889. //
  14890. // var prescriptions []*models.HisPrescription
  14891. //
  14892. // var start_time int64
  14893. // var end_time int64
  14894. //
  14895. // data := make(map[string]interface{})
  14896. // if settle_accounts_type == 1 { //日结
  14897. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  14898. // data["pre"] = prescriptions
  14899. //
  14900. // } else { //月结
  14901. // start_time_str := c.GetString("start_time")
  14902. // end_time_str := c.GetString("end_time")
  14903. // timeLayout := "2006-01-02"
  14904. // loc, _ := time.LoadLocation("Local")
  14905. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  14906. // if err != nil {
  14907. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  14908. // return
  14909. // }
  14910. // recordStartTime := theStartTime.Unix()
  14911. // start_time = recordStartTime
  14912. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  14913. // if err != nil {
  14914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  14915. // return
  14916. // }
  14917. // recordEndTime := theEndTime.Unix()
  14918. // end_time = recordEndTime
  14919. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  14920. // data["pre"] = prescriptions
  14921. //
  14922. // }
  14923. //
  14924. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14925. //
  14926. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  14927. // timestamp := time.Now().Unix()
  14928. // tempTime := time.Unix(timestamp, 0)
  14929. // timeFormat := tempTime.Format("20060102150405")
  14930. // chrgBchno := rand.Intn(100000) + 10000
  14931. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  14932. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14933. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  14934. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  14935. // strconv.FormatInt(his.PatientId, 10)
  14936. // client := &http.Client{}
  14937. // data["psn_no"] = his.PsnNo
  14938. // data["mdtrt_id"] = his.Number
  14939. // data["chrg_bchno"] = chrg_bchno
  14940. // data["org_name"] = miConfig.OrgName
  14941. // data["doctor"] = roles.UserName
  14942. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  14943. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  14944. // data["fixmedins_code"] = miConfig.Code
  14945. // data["dept_code"] = department.Number
  14946. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14947. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14948. // data["secret_key"] = miConfig.SecretKey
  14949. // var ids []int64
  14950. //
  14951. // for _, item := range prescriptions {
  14952. // ids = append(ids, item.ID)
  14953. // }
  14954. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14955. // if config.IsOpen == 1 { //对接了医保,走医保流程
  14956. // bytesData, _ := json.Marshal(data)
  14957. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  14958. // resp, _ := client.Do(req)
  14959. // defer resp.Body.Close()
  14960. // body, ioErr := ioutil.ReadAll(resp.Body)
  14961. // if ioErr != nil {
  14962. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14963. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14964. // return
  14965. // }
  14966. // var respJSON map[string]interface{}
  14967. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14968. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14969. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14970. // return
  14971. // }
  14972. //
  14973. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14974. // userJSONBytes, _ := json.Marshal(respJSON)
  14975. // var res ResultFour
  14976. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14977. // utils.ErrorLog("解析失败:%v", err)
  14978. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14979. // return
  14980. // }
  14981. //
  14982. // if res.Infcode == 0 {
  14983. // order := &models.HisOrder{
  14984. // UserOrgId: adminUser.CurrentOrgId,
  14985. // HisPatientId: his.ID,
  14986. // PatientId: his.PatientId,
  14987. // SettleAccountsDate: recordDateTime,
  14988. // Ctime: time.Now().Unix(),
  14989. // Mtime: time.Now().Unix(),
  14990. // Status: 1,
  14991. // Number: chrg_bchno,
  14992. // Infcode: res.Infcode,
  14993. // WarnMsg: res.WarnMsg,
  14994. // Cainfo: res.Cainfo,
  14995. // ErrMsg: res.ErrMsg,
  14996. // RespondTime: res.RefmsgTime,
  14997. // InfRefmsgid: res.InfRefmsgid,
  14998. // OrderStatus: 1,
  14999. // IsMedicineInsurance: 1,
  15000. // SettleType: settle_accounts_type,
  15001. // SettleStartTime: start_time,
  15002. // SettleEndTime: end_time,
  15003. // Creator: roles.ID,
  15004. // Modify: roles.ID,
  15005. // PType: 2,
  15006. // }
  15007. // err = service.CreateOrder(order)
  15008. // if err != nil {
  15009. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  15010. // return
  15011. // }
  15012. //
  15013. // for _, item := range res.Output.Result {
  15014. // temp := strings.Split(item.FeedetlSn, "-")
  15015. // var advice_id int64 = 0
  15016. // var project_id int64 = 0
  15017. // var types int64 = 0
  15018. //
  15019. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  15020. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  15021. //
  15022. // if temp[1] == "1" {
  15023. // advice_id = id
  15024. // project_id = 0
  15025. // } else if temp[1] == "2" {
  15026. // advice_id = 0
  15027. // project_id = id
  15028. // }
  15029. //
  15030. // info := &models.HisOrderInfo{
  15031. // OrderNumber: order.Number,
  15032. // FeedetlSn: item.FeedetlSn,
  15033. // UploadDate: time.Now().Unix(),
  15034. // AdviceId: advice_id,
  15035. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  15036. // Cnt: item.Cnt,
  15037. // Pric: float64(item.Pric),
  15038. // PatientId: his.PatientId,
  15039. // PricUplmtAmt: item.PricUplmtAmt,
  15040. // SelfpayProp: item.SelfpayProp,
  15041. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  15042. // OverlmtAmt: item.OverlmtAmt,
  15043. // PreselfpayAmt: item.PreselfpayAmt,
  15044. // BasMednFlag: item.BasMednFlag,
  15045. // MedChrgitmType: item.MedChrgitmType,
  15046. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  15047. // Status: 1,
  15048. // Memo: item.Memo,
  15049. // Mtime: time.Now().Unix(),
  15050. // InscpScpAmt: item.InscpScpAmt,
  15051. // DrtReimFlag: item.DrtReimFlag,
  15052. // Ctime: time.Now().Unix(),
  15053. // ListSpItemFlag: item.ListSpItemFlag,
  15054. // ChldMedcFlag: item.ChldMedcFlag,
  15055. // LmtUsedFlag: item.LmtUsedFlag,
  15056. // ChrgitmLv: item.ChrgitmLv,
  15057. // UserOrgId: adminUser.CurrentOrgId,
  15058. // HisPatientId: his.ID,
  15059. // OrderId: order.ID,
  15060. // ProjectId: project_id,
  15061. // Type: types,
  15062. // }
  15063. // service.CreateOrderInfo(info)
  15064. //
  15065. // }
  15066. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  15067. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  15068. //
  15069. // var total float64
  15070. // for _, item := range prescriptions {
  15071. // if item.Type == 1 { //药品
  15072. // for _, subItem := range item.HisDoctorAdviceInfo {
  15073. // total = total + (subItem.Price * subItem.PrescribingNumber)
  15074. // }
  15075. // }
  15076. // if item.Type == 2 { //项目
  15077. // for _, subItem := range item.HisPrescriptionProject {
  15078. // total = total + (subItem.Price * float64(subItem.Count))
  15079. // }
  15080. // }
  15081. // }
  15082. //
  15083. // for _, item := range prescriptions {
  15084. // for _, subItem := range item.HisAdditionalCharge {
  15085. // total = total + (subItem.Price * float64(subItem.Count))
  15086. // }
  15087. // }
  15088. //
  15089. // allTotal := fmt.Sprintf("%.2f", total)
  15090. // if res.Infcode == 0 {
  15091. // var rf []*ResultFive
  15092. // json.Unmarshal([]byte(his.Iinfo), &rf)
  15093. // psn_no := his.PsnNo
  15094. // mdtrt_id := his.Number
  15095. // chrg_bchno := chrg_bchno
  15096. // cert_no := his.Certno
  15097. // insutype := rf[0].Insutype
  15098. //
  15099. // if his.IdCardType == 1 {
  15100. // cert_no = his.MedicalInsuranceNumber
  15101. //
  15102. // } else {
  15103. //
  15104. // cert_no = his.Certno
  15105. //
  15106. // }
  15107. //
  15108. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  15109. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  15110. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  15111. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  15112. // resp, requestErr := http.Get(api)
  15113. // if requestErr != nil {
  15114. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15115. // return
  15116. // }
  15117. // defer resp.Body.Close()
  15118. // body, ioErr := ioutil.ReadAll(resp.Body)
  15119. // if ioErr != nil {
  15120. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15121. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15122. // return
  15123. // }
  15124. // var respJSON map[string]interface{}
  15125. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15126. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15127. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15128. // return
  15129. // }
  15130. // fmt.Println(respJSON)
  15131. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15132. // userJSONBytes, _ := json.Marshal(respJSON)
  15133. // var res ResultSeven
  15134. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15135. // utils.ErrorLog("解析失败:%v", err)
  15136. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15137. // return
  15138. // }
  15139. // if res.Infcode != 0 {
  15140. // errlog := &models.HisOrderError{
  15141. // UserOrgId: adminUser.CurrentOrgId,
  15142. // Ctime: time.Now().Unix(),
  15143. // Mtime: time.Now().Unix(),
  15144. // Number: chrg_bchno,
  15145. // ErrMsg: res.ErrMsg,
  15146. // Status: 1,
  15147. // PatientId: id,
  15148. // RecordTime: recordDateTime,
  15149. // Stage: 7,
  15150. // }
  15151. // service.CreateErrMsgLog(errlog)
  15152. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  15153. // return
  15154. // } else {
  15155. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  15156. // order.OrderStatus = 1
  15157. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  15158. // order.SetlId = res.Output.Setlinfo.SetlID
  15159. // order.PsnNo = res.Output.Setlinfo.PsnNo
  15160. // order.PsnName = res.Output.Setlinfo.PsnName
  15161. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  15162. // order.Certno = res.Output.Setlinfo.Certno
  15163. // order.Gend = res.Output.Setlinfo.Gend
  15164. // order.Naty = res.Output.Setlinfo.Naty
  15165. // order.Age = res.Output.Setlinfo.Age
  15166. // order.Insutype = res.Output.Setlinfo.Insutype
  15167. // order.PsnType = res.Output.Setlinfo.PsnType
  15168. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  15169. // order.SetlTime = res.Output.Setlinfo.SetlTime
  15170. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  15171. // order.MedType = res.Output.Setlinfo.MedType
  15172. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  15173. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  15174. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  15175. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  15176. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  15177. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  15178. // order.HifpPay = res.Output.Setlinfo.HifpPay
  15179. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  15180. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  15181. // order.HifesPay = res.Output.Setlinfo.HifesPay
  15182. // order.HifobPay = res.Output.Setlinfo.HifobPay
  15183. // order.MafPay = res.Output.Setlinfo.MafPay
  15184. // order.OthPay = res.Output.Setlinfo.OthPay
  15185. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  15186. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  15187. // order.AcctPay = res.Output.Setlinfo.AcctPay
  15188. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  15189. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  15190. // order.Balc = res.Output.Setlinfo.Balc
  15191. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  15192. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  15193. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  15194. // order.ClrWay = res.Output.Setlinfo.ClrWay
  15195. // order.Creator = order.Creator
  15196. // order.Modify = roles.ID
  15197. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  15198. // detailStr := string(setlDetail)
  15199. // order.SetlDetail = detailStr
  15200. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  15201. // err = service.UpDateOrder(order)
  15202. // if err == nil {
  15203. // c.ServeSuccessJSON(map[string]interface{}{
  15204. // "msg": "预结算成功",
  15205. // })
  15206. // } else {
  15207. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  15208. // return
  15209. // }
  15210. // }
  15211. // } else {
  15212. // adminUser := c.GetAdminUserInfo()
  15213. // errlog := &models.HisOrderError{
  15214. // UserOrgId: adminUser.CurrentOrgId,
  15215. // Ctime: time.Now().Unix(),
  15216. // Mtime: time.Now().Unix(),
  15217. // ErrMsg: res.ErrMsg,
  15218. // Status: 1,
  15219. // PatientId: id,
  15220. // RecordTime: recordDateTime,
  15221. // Stage: 4,
  15222. // }
  15223. // service.CreateErrMsgLog(errlog)
  15224. //
  15225. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  15226. // return
  15227. // }
  15228. // } else {
  15229. // adminUser := c.GetAdminUserInfo()
  15230. // errlog := &models.HisOrderError{
  15231. // UserOrgId: adminUser.CurrentOrgId,
  15232. // Ctime: time.Now().Unix(),
  15233. // Mtime: time.Now().Unix(),
  15234. // ErrMsg: res.ErrMsg,
  15235. // Status: 1,
  15236. // PatientId: id,
  15237. // RecordTime: recordDateTime,
  15238. // Stage: 4,
  15239. // }
  15240. // service.CreateErrMsgLog(errlog)
  15241. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  15242. // return
  15243. // }
  15244. //
  15245. // } else {
  15246. // var total float64
  15247. // for _, item := range prescriptions {
  15248. // if item.Type == 1 { //药品
  15249. // for _, subItem := range item.HisDoctorAdviceInfo {
  15250. // total = total + (subItem.Price * subItem.PrescribingNumber)
  15251. // }
  15252. // }
  15253. // if item.Type == 2 { //项目
  15254. // for _, subItem := range item.HisPrescriptionProject {
  15255. // total = total + (subItem.Price * float64(subItem.Count))
  15256. // }
  15257. // }
  15258. //
  15259. // for _, subItem := range item.HisAdditionalCharge {
  15260. // total = total + (subItem.Price * float64(subItem.Count))
  15261. // }
  15262. // }
  15263. //
  15264. // allTotal := fmt.Sprintf("%.2f", total)
  15265. // totals, _ := strconv.ParseFloat(allTotal, 64)
  15266. // order := &models.HisOrder{
  15267. // UserOrgId: adminUser.CurrentOrgId,
  15268. // HisPatientId: his.ID,
  15269. // PatientId: id,
  15270. // SettleAccountsDate: recordDateTime,
  15271. // Ctime: time.Now().Unix(),
  15272. // Mtime: time.Now().Unix(),
  15273. // Status: 1,
  15274. // OrderStatus: 2,
  15275. // Number: chrg_bchno,
  15276. // MedfeeSumamt: totals,
  15277. // }
  15278. // err = service.CreateOrder(order)
  15279. // if err != nil {
  15280. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  15281. // return
  15282. // }
  15283. //
  15284. // var customs []*Custom
  15285. // for _, item := range prescriptions {
  15286. //
  15287. // if item.Type == 1 { //药品
  15288. // for _, subItem := range item.HisDoctorAdviceInfo {
  15289. // cus := &Custom{
  15290. // AdviceId: subItem.ID,
  15291. // ProjectId: 0,
  15292. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  15293. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  15294. // FeedetlSn: subItem.FeedetlSn,
  15295. // Price: fmt.Sprintf("%.2f", subItem.Price),
  15296. // MedListCodg: subItem.MedListCodg,
  15297. // Type: 1,
  15298. // }
  15299. // customs = append(customs, cus)
  15300. // }
  15301. // }
  15302. //
  15303. // if item.Type == 2 { //项目
  15304. // for _, subItem := range item.HisPrescriptionProject {
  15305. //
  15306. // cus := &Custom{
  15307. // AdviceId: 0,
  15308. // ProjectId: subItem.ID,
  15309. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  15310. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  15311. // FeedetlSn: subItem.FeedetlSn,
  15312. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  15313. // MedListCodg: subItem.MedListCodg,
  15314. // Type: 2,
  15315. // }
  15316. //
  15317. // customs = append(customs, cus)
  15318. // }
  15319. // }
  15320. //
  15321. // for _, item := range item.HisAdditionalCharge {
  15322. // cus := &Custom{
  15323. // ItemId: item.ID,
  15324. // AdviceId: 0,
  15325. // ProjectId: 0,
  15326. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  15327. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  15328. // FeedetlSn: item.FeedetlSn,
  15329. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  15330. // MedListCodg: item.XtHisAddtionConfig.Code,
  15331. // Type: 3,
  15332. // }
  15333. //
  15334. // customs = append(customs, cus)
  15335. // }
  15336. //
  15337. // }
  15338. //
  15339. // for _, item := range customs {
  15340. // var advice_id int64 = 0
  15341. // var project_id int64 = 0
  15342. // var item_id int64 = 0
  15343. //
  15344. // var types int64 = 0
  15345. //
  15346. // if item.Type == 1 {
  15347. // advice_id = item.AdviceId
  15348. // project_id = 0
  15349. // item_id = 0
  15350. // } else if item.Type == 2 {
  15351. // advice_id = 0
  15352. // item_id = 0
  15353. //
  15354. // project_id = item.ProjectId
  15355. // } else if item.Type == 3 {
  15356. // advice_id = 0
  15357. // item_id = item.ItemId
  15358. // project_id = 0
  15359. // }
  15360. //
  15361. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  15362. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  15363. // pric, _ := strconv.ParseFloat(item.Price, 32)
  15364. //
  15365. // info := &models.HisOrderInfo{
  15366. // OrderNumber: order.Number,
  15367. // UploadDate: time.Now().Unix(),
  15368. // AdviceId: advice_id,
  15369. // DetItemFeeSumamt: detItemFeeSumamt,
  15370. // Cnt: cut,
  15371. // Pric: pric,
  15372. // PatientId: id,
  15373. // Status: 1,
  15374. // Mtime: time.Now().Unix(),
  15375. // Ctime: time.Now().Unix(),
  15376. // UserOrgId: adminUser.CurrentOrgId,
  15377. // HisPatientId: his.ID,
  15378. // OrderId: order.ID,
  15379. // ProjectId: project_id,
  15380. // Type: types,
  15381. // ItemId: item_id,
  15382. // }
  15383. // service.CreateOrderInfo(info)
  15384. // }
  15385. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  15386. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  15387. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  15388. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  15389. // if err == nil {
  15390. // c.ServeSuccessJSON(map[string]interface{}{
  15391. // "msg": "结算成功",
  15392. // })
  15393. // } else {
  15394. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  15395. // return
  15396. // }
  15397. // }
  15398. //}
  15399. // 上传明细-预结算-
  15400. func (c *HisApiController) GetPreUploadInfo() {
  15401. id, _ := c.GetInt64("id")
  15402. record_time := c.GetString("record_time")
  15403. his_patient_id, _ := c.GetInt64("his_patient_id")
  15404. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  15405. admin_user_id, _ := c.GetInt64("admin_user_id")
  15406. diagnosis_id := c.GetString("diagnosis")
  15407. sick_type, _ := c.GetInt64("sick_type")
  15408. reg_type, _ := c.GetInt64("p_type")
  15409. begin_time := c.GetString("begin_time")
  15410. acct_used_flag := c.GetString("acct_used_flag")
  15411. id_str := c.GetString("ids")
  15412. ids_arr := strings.Split(id_str, ",")
  15413. timeLayout := "2006-01-02"
  15414. loc, _ := time.LoadLocation("Local")
  15415. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  15416. if err != nil {
  15417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  15418. return
  15419. }
  15420. recordDateTime := theTime.Unix()
  15421. adminUser := c.GetAdminUserInfo()
  15422. diagnosis_ids := strings.Split(diagnosis_id, ",")
  15423. var config []*models.HisXtDiagnoseConfig
  15424. for _, item := range diagnosis_ids {
  15425. id, _ := strconv.ParseInt(item, 10, 64)
  15426. diagnosisConfig, _ := service.FindDiagnoseById(id)
  15427. config = append(config, &diagnosisConfig)
  15428. }
  15429. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  15430. sickConfig, _ := service.FindSickById(sick_type)
  15431. var prescriptions []*models.HisPrescription
  15432. var start_time int64
  15433. var end_time int64
  15434. var isSuccess bool = true
  15435. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15436. fmt.Println(his_patient_id)
  15437. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  15438. timestamp := time.Now().Unix()
  15439. tempTime := time.Unix(timestamp, 0)
  15440. timeFormat := tempTime.Format("20060102150405")
  15441. chrgBchno := rand.Intn(100000) + 10000
  15442. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  15443. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15444. var patientPrescription models.HisPrescriptionInfo
  15445. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  15446. if patientPrescription.ID == 0 {
  15447. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  15448. }
  15449. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15450. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  15451. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  15452. strconv.FormatInt(his.PatientId, 10)
  15453. var res2 ResultSix
  15454. var res3 GZResultSix
  15455. var resSix10265 ResultSix10265
  15456. //var time_stamp string
  15457. if miConfig.MdtrtareaAdmvs == "421300" {
  15458. data := make(map[string]interface{})
  15459. client := &http.Client{}
  15460. data["psn_no"] = his.PsnNo
  15461. data["mdtrt_id"] = his.Number
  15462. data["department"] = department.Name
  15463. data["org_name"] = miConfig.OrgName
  15464. data["med_type"] = strconv.FormatInt(reg_type, 10)
  15465. data["doctor_id"] = doctor_info.DoctorNumber
  15466. data["doctor_name"] = roles.UserName
  15467. data["fixmedins_code"] = miConfig.Code
  15468. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15469. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15470. data["secret_key"] = miConfig.SecretKey
  15471. data["sick_code"] = sickConfig.CountryCode
  15472. data["sick_name"] = sickConfig.ClassName
  15473. data["begin_time"] = begin_time
  15474. data["dept"] = strconv.FormatInt(department.ID, 10)
  15475. data["config"] = config
  15476. data["opter"] = roles.UserName
  15477. fmt.Println(data)
  15478. bytesData, _ := json.Marshal(data)
  15479. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  15480. resp, _ := client.Do(req)
  15481. defer resp.Body.Close()
  15482. body, ioErr := ioutil.ReadAll(resp.Body)
  15483. if ioErr != nil {
  15484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15486. return
  15487. }
  15488. var respJSON map[string]interface{}
  15489. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15492. return
  15493. }
  15494. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15495. userJSONBytes, _ := json.Marshal(respJSON)
  15496. fmt.Println("log")
  15497. fmt.Println(string(userJSONBytes))
  15498. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15499. utils.ErrorLog("解析失败:%v", err)
  15500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15501. return
  15502. }
  15503. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15504. data := make(map[string]interface{})
  15505. client := &http.Client{}
  15506. data["psn_no"] = his.PsnNo
  15507. data["mdtrt_id"] = his.Number
  15508. data["doctor"] = roles.UserName
  15509. data["department"] = department.Name
  15510. data["org_name"] = miConfig.OrgName
  15511. data["med_type"] = strconv.FormatInt(reg_type, 10)
  15512. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  15513. data["fixmedins_code"] = miConfig.Code
  15514. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  15515. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15516. data["secret_key"] = miConfig.SecretKey
  15517. data["sick_code"] = sickConfig.CountryCode
  15518. data["sick_name"] = sickConfig.ClassName
  15519. data["begin_time"] = begin_time
  15520. data["dept"] = strconv.FormatInt(department.ID, 10)
  15521. data["config"] = config
  15522. data["url"] = miConfig.Url
  15523. data["ak"] = miConfig.AccessKey
  15524. data["cainfo"] = miConfig.Cainfo
  15525. bytesData, _ := json.Marshal(data)
  15526. var req *http.Request
  15527. if miConfig.MdtrtareaAdmvs == "320921" {
  15528. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  15529. } else {
  15530. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  15531. }
  15532. resp, _ := client.Do(req)
  15533. defer resp.Body.Close()
  15534. body, ioErr := ioutil.ReadAll(resp.Body)
  15535. if ioErr != nil {
  15536. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15538. return
  15539. }
  15540. var respJSON map[string]interface{}
  15541. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15544. return
  15545. }
  15546. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  15547. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  15548. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  15549. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15550. userJSONBytes, _ := json.Marshal(respJSON)
  15551. fmt.Println("log")
  15552. fmt.Println(string(userJSONBytes))
  15553. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  15554. utils.ErrorLog("解析失败:%v", err)
  15555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15556. return
  15557. }
  15558. res2.InfRefmsgid = resSix10265.InfRefmsgid
  15559. res2.Output = resSix10265.Output
  15560. res2.ErrMsg = resSix10265.ErrMsg
  15561. res2.Cainfo = resSix10265.Cainfo
  15562. res2.WarnMsg = resSix10265.WarnMsg
  15563. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15564. res2.Infcode = infocode
  15565. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15566. data := make(map[string]interface{})
  15567. client := &http.Client{}
  15568. data["psn_no"] = his.PsnNo
  15569. data["mdtrt_id"] = his.Number
  15570. data["doctor"] = roles.UserName
  15571. data["department"] = department.Name
  15572. data["org_name"] = miConfig.OrgName
  15573. data["med_type"] = strconv.FormatInt(reg_type, 10)
  15574. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  15575. data["fixmedins_code"] = miConfig.Code
  15576. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  15577. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15578. data["secret_key"] = miConfig.SecretKey
  15579. data["sick_code"] = sickConfig.CountryCode
  15580. data["sick_name"] = sickConfig.ClassName
  15581. data["begin_time"] = begin_time
  15582. data["dept"] = strconv.FormatInt(department.ID, 10)
  15583. data["config"] = config
  15584. //data["url"] = miConfig.Url
  15585. //data["ak"] = miConfig.AccessKey
  15586. data["cainfo"] = miConfig.Cainfo
  15587. fmt.Println(data)
  15588. bytesData, _ := json.Marshal(data)
  15589. var req *http.Request
  15590. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  15591. resp, _ := client.Do(req)
  15592. defer resp.Body.Close()
  15593. body, ioErr := ioutil.ReadAll(resp.Body)
  15594. if ioErr != nil {
  15595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15597. return
  15598. }
  15599. var respJSON map[string]interface{}
  15600. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15603. return
  15604. }
  15605. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  15606. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  15607. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  15608. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15609. userJSONBytes, _ := json.Marshal(respJSON)
  15610. fmt.Println("log")
  15611. fmt.Println(string(userJSONBytes))
  15612. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  15613. utils.ErrorLog("解析失败:%v", err)
  15614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15615. return
  15616. }
  15617. res2.InfRefmsgid = resSix10265.InfRefmsgid
  15618. res2.Output = resSix10265.Output
  15619. res2.ErrMsg = resSix10265.ErrMsg
  15620. res2.Cainfo = resSix10265.Cainfo
  15621. res2.WarnMsg = resSix10265.WarnMsg
  15622. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15623. res2.Infcode = infocode
  15624. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15625. 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)
  15626. saveLog(result, requestLog, "2203", "上传就诊信息")
  15627. var respJSON2 map[string]interface{}
  15628. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  15629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15631. return
  15632. }
  15633. userJSONBytes2, _ := json.Marshal(respJSON2)
  15634. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  15635. utils.ErrorLog("解析失败:%v", err)
  15636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15637. return
  15638. }
  15639. } else if miConfig.MdtrtareaAdmvs == "360399" {
  15640. var result string
  15641. var requestLog string
  15642. 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, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, miConfig.Url, miConfig.AccessKey, "")
  15643. saveLog(result, requestLog, "2203", "上传就诊信息")
  15644. var respJSON2 map[string]interface{}
  15645. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  15646. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15648. return
  15649. }
  15650. userJSONBytes2, _ := json.Marshal(respJSON2)
  15651. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  15652. utils.ErrorLog("解析失败:%v", err)
  15653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15654. return
  15655. }
  15656. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15657. var result string
  15658. var requestLog string
  15659. 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, "")
  15660. saveLog(result, requestLog, "2203", "上传就诊信息")
  15661. var respJSON2 map[string]interface{}
  15662. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  15663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15665. return
  15666. }
  15667. userJSONBytes2, _ := json.Marshal(respJSON2)
  15668. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  15669. utils.ErrorLog("解析失败:%v", err)
  15670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15671. return
  15672. }
  15673. } else {
  15674. var result string
  15675. var requestLog string
  15676. if miConfig.MdtrtareaAdmvs == "440781" { //
  15677. 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)
  15678. } else {
  15679. if miConfig.Code == "H15049901371" {
  15680. //赤峰地区国家医保医疗类别
  15681. //职工透析:医疗类别选特殊情况门诊990502
  15682. //居民定额血透门慢: 医疗类别选门诊慢病140104
  15683. var med_type string
  15684. if his.Insutype == "390" {
  15685. if reg_type == 14 {
  15686. med_type = "9933"
  15687. } else if reg_type == 11 {
  15688. med_type = "11"
  15689. }
  15690. } else if his.Insutype == "310" {
  15691. if reg_type == 14 {
  15692. med_type = "990502"
  15693. } else if reg_type == 11 {
  15694. med_type = "11"
  15695. }
  15696. }
  15697. 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)
  15698. } else {
  15699. 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)
  15700. }
  15701. saveLog(result, requestLog, "2203", "上传就诊信息")
  15702. var respJSON2 map[string]interface{}
  15703. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  15704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15706. return
  15707. }
  15708. userJSONBytes2, _ := json.Marshal(respJSON2)
  15709. if miConfig.Code == "H15049901371" {
  15710. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  15711. utils.ErrorLog("解析失败:%v", err)
  15712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15713. return
  15714. }
  15715. res2.InfRefmsgid = resSix10265.InfRefmsgid
  15716. res2.Output = resSix10265.Output
  15717. res2.ErrMsg = resSix10265.ErrMsg
  15718. res2.Cainfo = resSix10265.Cainfo
  15719. res2.WarnMsg = resSix10265.WarnMsg
  15720. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15721. res2.Infcode = infocode
  15722. } else {
  15723. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  15724. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  15725. utils.ErrorLog("解析失败:%v", err)
  15726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15727. return
  15728. }
  15729. res2.Infcode = res3.Infcode
  15730. } else {
  15731. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  15732. utils.ErrorLog("解析失败:%v", err)
  15733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15734. return
  15735. }
  15736. }
  15737. }
  15738. }
  15739. }
  15740. if res2.Infcode != 0 {
  15741. adminUser := c.GetAdminUserInfo()
  15742. errlog := &models.HisOrderError{
  15743. UserOrgId: adminUser.CurrentOrgId,
  15744. Ctime: time.Now().Unix(),
  15745. Mtime: time.Now().Unix(),
  15746. ErrMsg: res2.ErrMsg,
  15747. Status: 1,
  15748. PatientId: id,
  15749. RecordTime: recordDateTime,
  15750. Stage: 3,
  15751. }
  15752. service.CreateErrMsgLog(errlog)
  15753. c.ServeSuccessJSON(map[string]interface{}{
  15754. "failed_code": -10,
  15755. "msg": res2.ErrMsg,
  15756. })
  15757. return
  15758. } else {
  15759. his.Diagnosis = diagnosis_id
  15760. his.SickType = sickConfig.ID
  15761. his.PType = fmt.Sprintf("%d", reg_type)
  15762. service.UpdateHisPatientThree(&his)
  15763. data := make(map[string]interface{})
  15764. if settle_accounts_type == 1 { //日结
  15765. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  15766. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  15767. } else {
  15768. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  15769. }
  15770. data["pre"] = prescriptions
  15771. } else { //月结
  15772. start_time_str := c.GetString("start_time")
  15773. end_time_str := c.GetString("end_time")
  15774. timeLayout := "2006-01-02"
  15775. loc, _ := time.LoadLocation("Local")
  15776. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  15777. if err != nil {
  15778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  15779. return
  15780. }
  15781. recordStartTime := theStartTime.Unix()
  15782. start_time = recordStartTime
  15783. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  15784. if err != nil {
  15785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  15786. return
  15787. }
  15788. recordEndTime := theEndTime.Unix()
  15789. end_time = recordEndTime
  15790. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  15791. data["pre"] = prescriptions
  15792. }
  15793. client := &http.Client{}
  15794. data["psn_no"] = his.PsnNo
  15795. data["mdtrt_id"] = his.Number
  15796. data["chrg_bchno"] = chrg_bchno
  15797. data["org_name"] = miConfig.OrgName
  15798. data["doctor"] = doctor_info.UserName
  15799. data["doctor_id"] = doctor_info.DoctorNumber
  15800. data["dept"] = department.Name
  15801. data["fixmedins_code"] = miConfig.Code
  15802. data["opter"] = roles.UserName
  15803. data["dept_code"] = department.Number
  15804. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  15805. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15806. data["secret_key"] = miConfig.SecretKey
  15807. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  15808. data["url"] = miConfig.Url
  15809. data["ak"] = miConfig.AccessKey
  15810. data["new_doctor_name"] = patientPrescription.Doctor
  15811. data["diag_code"] = sickConfig.CountryCode
  15812. data["cainfo"] = miConfig.Cainfo
  15813. data["opter"] = roles.UserName
  15814. var ids []int64
  15815. for _, item := range prescriptions {
  15816. ids = append(ids, item.ID)
  15817. }
  15818. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15819. if config.IsOpen == 1 { //对接了医保,走医保流程
  15820. var res ResultFour
  15821. var resFour10265 ResultFour10265
  15822. if miConfig.MdtrtareaAdmvs == "421300" {
  15823. bytesData, _ := json.Marshal(data)
  15824. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  15825. resp, _ := client.Do(req)
  15826. defer resp.Body.Close()
  15827. body, ioErr := ioutil.ReadAll(resp.Body)
  15828. if ioErr != nil {
  15829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15831. return
  15832. }
  15833. var respJSON map[string]interface{}
  15834. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15837. return
  15838. }
  15839. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15840. userJSONBytes, _ := json.Marshal(respJSON)
  15841. fmt.Println("log")
  15842. fmt.Println(string(userJSONBytes))
  15843. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15844. utils.ErrorLog("解析失败:%v", err)
  15845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15846. return
  15847. }
  15848. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15849. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  15850. if result3101.Infcode == "0" {
  15851. if len(result3101.Output.Result) > 0 {
  15852. var errMsgs []string
  15853. for _, item := range result3101.Output.Result {
  15854. errMsgs = append(errMsgs, item.VolaCont)
  15855. }
  15856. c.ServeSuccessJSON(map[string]interface{}{
  15857. "failed_code": -10,
  15858. "msg": errMsgs,
  15859. })
  15860. return
  15861. } else {
  15862. if miConfig.MdtrtareaAdmvs == "320921" {
  15863. data["doctor_id"] = "D320923012139"
  15864. } else {
  15865. data["doctor_id"] = "D371621008686"
  15866. }
  15867. bytesData, _ := json.Marshal(data)
  15868. var req *http.Request
  15869. if miConfig.MdtrtareaAdmvs == "320921" {
  15870. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  15871. } else {
  15872. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  15873. }
  15874. resp, _ := client.Do(req)
  15875. defer resp.Body.Close()
  15876. body, ioErr := ioutil.ReadAll(resp.Body)
  15877. if ioErr != nil {
  15878. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15880. return
  15881. }
  15882. var respJSON map[string]interface{}
  15883. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15886. return
  15887. }
  15888. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15889. userJSONBytes, _ := json.Marshal(respJSON)
  15890. fmt.Println("log")
  15891. fmt.Println(string(userJSONBytes))
  15892. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  15893. utils.ErrorLog("解析失败:%v", err)
  15894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15895. return
  15896. }
  15897. res.InfRefmsgid = resFour10265.InfRefmsgid
  15898. res.Output = resFour10265.Output
  15899. res.ErrMsg = resFour10265.ErrMsg
  15900. res.Cainfo = resFour10265.Cainfo
  15901. res.WarnMsg = resFour10265.WarnMsg
  15902. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  15903. res.Infcode = infocode
  15904. }
  15905. }
  15906. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15907. var pagesize int = 5
  15908. var start int = 1
  15909. var stop int
  15910. var pagecount int
  15911. var curpage int
  15912. data["doctor_id"] = doctor_info.DoctorNumber
  15913. var res2 ResultFour
  15914. //var result res.
  15915. //总页数,向上取整,注意除之前要先转换类型为float64
  15916. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  15917. for curpage = 1; curpage <= pagecount; curpage++ {
  15918. if curpage == 1 {
  15919. start = 1
  15920. } else {
  15921. start = (curpage-1)*pagesize + 1
  15922. }
  15923. stop = curpage * pagesize
  15924. if stop > len(prescriptions) {
  15925. stop = len(prescriptions)
  15926. }
  15927. //var requestLog string
  15928. data["pre"] = prescriptions[start-1 : stop]
  15929. fmt.Println(data["pre"])
  15930. bytesData, _ := json.Marshal(data)
  15931. var req *http.Request
  15932. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  15933. resp, _ := client.Do(req)
  15934. defer resp.Body.Close()
  15935. body, ioErr := ioutil.ReadAll(resp.Body)
  15936. if ioErr != nil {
  15937. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15939. return
  15940. }
  15941. var respJSON map[string]interface{}
  15942. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15945. return
  15946. }
  15947. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15948. userJSONBytes, _ := json.Marshal(respJSON)
  15949. fmt.Println("log")
  15950. fmt.Println(string(userJSONBytes))
  15951. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  15952. utils.ErrorLog("解析失败:%v", err)
  15953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15954. return
  15955. }
  15956. res.InfRefmsgid = resFour10265.InfRefmsgid
  15957. res.Output = resFour10265.Output
  15958. res.ErrMsg = resFour10265.ErrMsg
  15959. res.Cainfo = resFour10265.Cainfo
  15960. res.WarnMsg = resFour10265.WarnMsg
  15961. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  15962. res.Infcode = infocode
  15963. if infocode == 0 {
  15964. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  15965. } else {
  15966. isSuccess = false
  15967. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  15968. res.Infcode = -1
  15969. res.ErrMsg = resFour10265.ErrMsg
  15970. errlog := &models.HisOrderError{
  15971. UserOrgId: adminUser.CurrentOrgId,
  15972. Ctime: time.Now().Unix(),
  15973. Mtime: time.Now().Unix(),
  15974. Number: chrg_bchno,
  15975. ErrMsg: "",
  15976. Status: 1,
  15977. PatientId: id,
  15978. RecordTime: recordDateTime,
  15979. Stage: 4,
  15980. }
  15981. service.CreateErrMsgLog(errlog)
  15982. }
  15983. }
  15984. if isSuccess {
  15985. res.Infcode = 0
  15986. res.Output.Result = res2.Output.Result
  15987. } else {
  15988. order := &models.HisOrder{
  15989. UserOrgId: adminUser.CurrentOrgId,
  15990. HisPatientId: his.ID,
  15991. PatientId: his.PatientId,
  15992. SettleAccountsDate: recordDateTime,
  15993. Ctime: time.Now().Unix(),
  15994. Mtime: time.Now().Unix(),
  15995. MdtrtId: his.Number,
  15996. PsnNo: his.PsnNo,
  15997. MedType: strconv.FormatInt(reg_type, 10),
  15998. Status: 1,
  15999. Number: chrg_bchno,
  16000. Infcode: res.Infcode,
  16001. WarnMsg: res.WarnMsg,
  16002. Cainfo: res.Cainfo,
  16003. ErrMsg: res.ErrMsg,
  16004. RespondTime: res.RefmsgTime,
  16005. InfRefmsgid: res.InfRefmsgid,
  16006. OrderStatus: 1,
  16007. IsMedicineInsurance: 1,
  16008. SettleType: settle_accounts_type,
  16009. SettleStartTime: start_time,
  16010. SettleEndTime: end_time,
  16011. Creator: roles.AdminUserId,
  16012. Modify: roles.AdminUserId,
  16013. PType: 2,
  16014. Diagnosis: diagnosis_id,
  16015. }
  16016. err = service.CreateOrder(order)
  16017. if err != nil {
  16018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  16019. return
  16020. }
  16021. c.ServeSuccessJSON(map[string]interface{}{
  16022. "failed_code": -10,
  16023. "msg": res2.ErrMsg,
  16024. })
  16025. return
  16026. }
  16027. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16028. 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)
  16029. var dat map[string]interface{}
  16030. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16031. fmt.Println(dat)
  16032. } else {
  16033. fmt.Println(err)
  16034. }
  16035. saveLog(result, request_log, "2204", "上传费用明细")
  16036. userJSONBytes, _ := json.Marshal(dat)
  16037. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16038. utils.ErrorLog("解析失败:%v", err)
  16039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16040. return
  16041. }
  16042. } else if miConfig.MdtrtareaAdmvs == "360399" {
  16043. 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, "", "")
  16044. var dat map[string]interface{}
  16045. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16046. fmt.Println(dat)
  16047. } else {
  16048. fmt.Println(err)
  16049. }
  16050. saveLog(result, request_log, "2204", "上传费用明细")
  16051. userJSONBytes, _ := json.Marshal(dat)
  16052. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16053. utils.ErrorLog("解析失败:%v", err)
  16054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16055. return
  16056. }
  16057. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16058. 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, "", "")
  16059. var dat map[string]interface{}
  16060. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16061. fmt.Println(dat)
  16062. } else {
  16063. fmt.Println(err)
  16064. }
  16065. saveLog(result, request_log, "2204", "上传费用明细")
  16066. userJSONBytes, _ := json.Marshal(dat)
  16067. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16068. utils.ErrorLog("解析失败:%v", err)
  16069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16070. return
  16071. }
  16072. } else {
  16073. if miConfig.MdtrtareaAdmvs == "441202" {
  16074. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  16075. if result3101.Infcode == 0 {
  16076. if len(result3101.Output.Result) > 0 {
  16077. var errMsgs []string
  16078. for _, item := range result3101.Output.Result {
  16079. errMsgs = append(errMsgs, item.VolaCont)
  16080. }
  16081. c.ServeSuccessJSON(map[string]interface{}{
  16082. "failed_code": -10,
  16083. "msg": errMsgs,
  16084. })
  16085. return
  16086. } else {
  16087. 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)
  16088. var dat map[string]interface{}
  16089. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16090. fmt.Println(dat)
  16091. } else {
  16092. fmt.Println(err)
  16093. }
  16094. saveLog(result, request_log, "2204", "上传费用明细")
  16095. userJSONBytes, _ := json.Marshal(dat)
  16096. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16097. utils.ErrorLog("解析失败:%v", err)
  16098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16099. return
  16100. }
  16101. }
  16102. } else {
  16103. c.ServeSuccessJSON(map[string]interface{}{
  16104. "failed_code": -10,
  16105. "msg": result3101.ErrMsg,
  16106. })
  16107. return
  16108. }
  16109. } else {
  16110. if miConfig.Code == "H15049901371" {
  16111. 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)
  16112. var dat map[string]interface{}
  16113. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16114. fmt.Println(dat)
  16115. } else {
  16116. fmt.Println(err)
  16117. }
  16118. saveLog(result, request_log, "2204", "上传费用明细")
  16119. userJSONBytes, _ := json.Marshal(dat)
  16120. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  16121. utils.ErrorLog("解析失败:%v", err)
  16122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16123. return
  16124. }
  16125. res.InfRefmsgid = resFour10265.InfRefmsgid
  16126. res.Output = resFour10265.Output
  16127. res.ErrMsg = resFour10265.ErrMsg
  16128. res.Cainfo = resFour10265.Cainfo
  16129. res.WarnMsg = resFour10265.WarnMsg
  16130. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  16131. res.Infcode = infocode
  16132. } else {
  16133. 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)
  16134. var dat map[string]interface{}
  16135. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16136. fmt.Println(dat)
  16137. } else {
  16138. fmt.Println(err)
  16139. }
  16140. saveLog(result, request_log, "2204", "上传费用明细")
  16141. userJSONBytes, _ := json.Marshal(dat)
  16142. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16143. utils.ErrorLog("解析失败:%v", err)
  16144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16145. return
  16146. }
  16147. }
  16148. }
  16149. }
  16150. var total_two float64
  16151. if res.Infcode == 0 {
  16152. order := &models.HisOrder{
  16153. UserOrgId: adminUser.CurrentOrgId,
  16154. HisPatientId: his.ID,
  16155. PatientId: his.PatientId,
  16156. SettleAccountsDate: recordDateTime,
  16157. Ctime: time.Now().Unix(),
  16158. Mtime: time.Now().Unix(),
  16159. MdtrtId: his.Number,
  16160. PsnNo: his.PsnNo,
  16161. MedType: strconv.FormatInt(reg_type, 10),
  16162. Status: 1,
  16163. Number: chrg_bchno,
  16164. Infcode: res.Infcode,
  16165. WarnMsg: res.WarnMsg,
  16166. Cainfo: res.Cainfo,
  16167. ErrMsg: res.ErrMsg,
  16168. RespondTime: res.RefmsgTime,
  16169. InfRefmsgid: res.InfRefmsgid,
  16170. OrderStatus: 1,
  16171. IsMedicineInsurance: 1,
  16172. SettleType: settle_accounts_type,
  16173. SettleStartTime: start_time,
  16174. SettleEndTime: end_time,
  16175. Creator: roles.AdminUserId,
  16176. Modify: roles.AdminUserId,
  16177. PType: 2,
  16178. Diagnosis: diagnosis_id,
  16179. }
  16180. err = service.CreateOrder(order)
  16181. if err != nil {
  16182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  16183. return
  16184. }
  16185. for _, item := range res.Output.Result {
  16186. temp := strings.Split(item.FeedetlSn, "-")
  16187. var advice_id int64 = 0
  16188. var project_id int64 = 0
  16189. var types int64 = 0
  16190. id, _ := strconv.ParseInt(temp[2], 10, 64)
  16191. types, _ = strconv.ParseInt(temp[1], 10, 64)
  16192. if temp[1] == "1" {
  16193. advice_id = id
  16194. project_id = 0
  16195. } else if temp[1] == "2" {
  16196. advice_id = 0
  16197. project_id = id
  16198. }
  16199. total_two = total_two + item.DetItemFeeSumamt
  16200. info := &models.HisOrderInfo{
  16201. OrderNumber: order.Number,
  16202. FeedetlSn: item.FeedetlSn,
  16203. UploadDate: time.Now().Unix(),
  16204. AdviceId: advice_id,
  16205. DetItemFeeSumamt: item.DetItemFeeSumamt,
  16206. Cnt: item.Cnt,
  16207. Pric: float64(item.Pric),
  16208. PatientId: his.PatientId,
  16209. PricUplmtAmt: item.PricUplmtAmt,
  16210. SelfpayProp: item.SelfpayProp,
  16211. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  16212. OverlmtAmt: item.OverlmtAmt,
  16213. PreselfpayAmt: item.PreselfpayAmt,
  16214. BasMednFlag: item.BasMednFlag,
  16215. MedChrgitmType: item.MedChrgitmType,
  16216. HiNegoDrugFlag: item.HiNegoDrugFlag,
  16217. Status: 1,
  16218. Memo: item.Memo,
  16219. Mtime: time.Now().Unix(),
  16220. InscpScpAmt: item.InscpScpAmt,
  16221. DrtReimFlag: item.DrtReimFlag,
  16222. Ctime: time.Now().Unix(),
  16223. ListSpItemFlag: item.ListSpItemFlag,
  16224. ChldMedcFlag: item.ChldMedcFlag,
  16225. LmtUsedFlag: item.LmtUsedFlag,
  16226. ChrgitmLv: item.ChrgitmLv,
  16227. UserOrgId: adminUser.CurrentOrgId,
  16228. HisPatientId: his.ID,
  16229. OrderId: order.ID,
  16230. ProjectId: project_id,
  16231. Type: types,
  16232. }
  16233. service.CreateOrderInfo(info)
  16234. }
  16235. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  16236. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  16237. var total float64
  16238. for _, item := range prescriptions {
  16239. if item.Type == 1 { //药品
  16240. for _, subItem := range item.HisDoctorAdviceInfo {
  16241. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  16242. total_one := price * subItem.PrescribingNumber
  16243. fmt.Println("subItem")
  16244. fmt.Println(subItem.Price)
  16245. fmt.Println("price")
  16246. fmt.Println(price)
  16247. fmt.Println("total_one")
  16248. fmt.Println(total_one)
  16249. total = total + total_one
  16250. fmt.Println(total)
  16251. }
  16252. }
  16253. if item.Type == 2 { //项目
  16254. for _, subItem := range item.HisPrescriptionProject {
  16255. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  16256. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  16257. total_one := price * cnt
  16258. total = total + total_one
  16259. }
  16260. }
  16261. }
  16262. allTotal := fmt.Sprintf("%2f", total)
  16263. if res.Infcode == 0 {
  16264. var rf []*ResultFive
  16265. json.Unmarshal([]byte(his.Iinfo), &rf)
  16266. chrg_bchno := chrg_bchno
  16267. cert_no := his.Certno
  16268. var insutypes []string
  16269. var insutype string
  16270. var is390 int = 0
  16271. var is310 int = 0
  16272. for _, item := range rf {
  16273. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16274. insutypes = append(insutypes, item.Insutype)
  16275. }
  16276. }
  16277. if len(insutypes) == 1 {
  16278. insutype = insutypes[0]
  16279. } else {
  16280. for _, i := range insutypes {
  16281. if i == "390" {
  16282. is390 = 1
  16283. }
  16284. if i == "310" {
  16285. is310 = 1
  16286. }
  16287. }
  16288. }
  16289. if is390 == 1 {
  16290. insutype = "390"
  16291. }
  16292. if is310 == 1 {
  16293. insutype = "310"
  16294. }
  16295. if len(insutypes) == 0 {
  16296. insutype = "390"
  16297. }
  16298. if len(insutypes) == 2 {
  16299. insutype = strconv.FormatInt(his.SocialType, 10)
  16300. }
  16301. //insutype = "390"
  16302. if his.IdCardType == 1 {
  16303. cert_no = his.MedicalInsuranceNumber
  16304. } else {
  16305. cert_no = his.Certno
  16306. }
  16307. var res ResultSeven
  16308. var resSeven10265 ResultSeven10265
  16309. var resSeven10265Two ResultSeven10265Two
  16310. var gzresSeven10265Two GZResultSeven10265Two
  16311. if miConfig.MdtrtareaAdmvs == "421300" {
  16312. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  16313. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  16314. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16315. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  16316. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  16317. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  16318. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  16319. resp, requestErr := http.Get(api)
  16320. if requestErr != nil {
  16321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16322. return
  16323. }
  16324. body, ioErr := ioutil.ReadAll(resp.Body)
  16325. if ioErr != nil {
  16326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16328. return
  16329. }
  16330. var respJSON map[string]interface{}
  16331. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16334. return
  16335. }
  16336. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16337. result, _ := json.Marshal(respJSON)
  16338. fmt.Println("log")
  16339. fmt.Println(string(result))
  16340. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16341. utils.ErrorLog("解析失败:%v", err)
  16342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16343. return
  16344. }
  16345. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16346. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  16347. if result3101.Infcode == "0" {
  16348. if len(result3101.Output.Result) > 0 {
  16349. var errMsgs []string
  16350. for _, item := range result3101.Output.Result {
  16351. errMsgs = append(errMsgs, item.VolaCont)
  16352. }
  16353. c.ServeSuccessJSON(map[string]interface{}{
  16354. "failed_code": -10,
  16355. "msg": errMsgs,
  16356. })
  16357. return
  16358. } else {
  16359. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  16360. if his.IdCardType != 4 {
  16361. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  16362. bas := strings.Split(psn_info.CardInfo, "|")
  16363. if his.IdCardType == 1 {
  16364. cert_no = bas[2]
  16365. } else {
  16366. cert_no = bas[1]
  16367. }
  16368. } else {
  16369. cert_no = his.Certno
  16370. }
  16371. //江苏地区国家医保医疗类别
  16372. //职工透析:医疗类别选特殊情况门诊9933
  16373. //居民血透门慢: 医疗类别选门诊慢病1402
  16374. //var med_type string
  16375. //if his.Insutype == "310" {
  16376. // if reg_type == 14 {
  16377. // med_type = "9933"
  16378. // } else if reg_type == 11 {
  16379. // med_type = "11"
  16380. //
  16381. // }
  16382. //} else if his.Insutype == "390" {
  16383. // if reg_type == 14 {
  16384. // med_type = "1402"
  16385. // } else if reg_type == 11 {
  16386. // med_type = "11"
  16387. // }
  16388. //}
  16389. var api string
  16390. if miConfig.MdtrtareaAdmvs == "320921" {
  16391. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  16392. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  16393. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16394. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  16395. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  16396. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  16397. "&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
  16398. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  16399. } else {
  16400. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  16401. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  16402. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  16403. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16404. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  16405. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  16406. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  16407. "&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
  16408. }
  16409. resp, requestErr := http.Get(api)
  16410. if requestErr != nil {
  16411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16412. return
  16413. }
  16414. body, ioErr := ioutil.ReadAll(resp.Body)
  16415. if ioErr != nil {
  16416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16418. return
  16419. }
  16420. var respJSON map[string]interface{}
  16421. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16422. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16424. return
  16425. }
  16426. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16427. result, _ := json.Marshal(respJSON)
  16428. fmt.Println("log")
  16429. fmt.Println(string(result))
  16430. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  16431. utils.ErrorLog("解析失败:%v", err)
  16432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16433. return
  16434. }
  16435. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  16436. res.InfRefmsgid = resSeven10265.InfRefmsgid
  16437. res.Output = resSeven10265.Output
  16438. res.ErrMsg = resSeven10265.ErrMsg
  16439. res.Cainfo = resSeven10265.Cainfo
  16440. res.WarnMsg = resSeven10265.WarnMsg
  16441. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  16442. res.Infcode = infocode
  16443. } else {
  16444. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  16445. AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  16446. res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  16447. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  16448. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  16449. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  16450. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  16451. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  16452. res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  16453. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  16454. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  16455. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  16456. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  16457. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  16458. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  16459. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  16460. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  16461. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  16462. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  16463. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  16464. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  16465. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  16466. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  16467. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  16468. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  16469. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  16470. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  16471. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  16472. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  16473. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  16474. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  16475. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  16476. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  16477. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  16478. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  16479. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  16480. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  16481. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  16482. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  16483. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  16484. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  16485. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  16486. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  16487. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  16488. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  16489. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  16490. res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  16491. res.ErrMsg = resSeven10265Two.ErrMsg
  16492. res.Cainfo = resSeven10265Two.Cainfo
  16493. res.WarnMsg = resSeven10265Two.WarnMsg
  16494. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  16495. res.Infcode = infocode
  16496. }
  16497. }
  16498. }
  16499. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16500. psn_info, _ := service.GetPsnByPatientId(id)
  16501. var verify_number string
  16502. if psn_info.IdCardType == 4 {
  16503. verify_number = psn_info.VerifyNumber
  16504. } else if psn_info.IdCardType == 1 {
  16505. bas := strings.Split(psn_info.CardInfo, "|")
  16506. cardNumber := bas[2]
  16507. verify_number = cardNumber
  16508. } else {
  16509. psn_info.IdCardType = 2
  16510. verify_number = psn_info.Certno
  16511. }
  16512. var api string
  16513. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  16514. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  16515. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16516. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  16517. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  16518. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  16519. "&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
  16520. resp, requestErr := http.Get(api)
  16521. if requestErr != nil {
  16522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16523. return
  16524. }
  16525. body, ioErr := ioutil.ReadAll(resp.Body)
  16526. if ioErr != nil {
  16527. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16529. return
  16530. }
  16531. var respJSON map[string]interface{}
  16532. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16535. return
  16536. }
  16537. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16538. result, _ := json.Marshal(respJSON)
  16539. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  16540. utils.ErrorLog("解析失败:%v", err)
  16541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16542. return
  16543. }
  16544. res.InfRefmsgid = resSeven10265.InfRefmsgid
  16545. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  16546. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  16547. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  16548. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  16549. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  16550. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  16551. res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  16552. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  16553. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  16554. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  16555. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  16556. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  16557. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  16558. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  16559. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  16560. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  16561. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  16562. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  16563. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  16564. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  16565. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  16566. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  16567. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  16568. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  16569. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  16570. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  16571. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  16572. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  16573. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  16574. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  16575. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  16576. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  16577. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  16578. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  16579. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  16580. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  16581. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  16582. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  16583. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  16584. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  16585. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  16586. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  16587. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  16588. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  16589. res.Output.Setldetail = resSeven10265.Output.Setldetail
  16590. res.ErrMsg = resSeven10265.ErrMsg
  16591. res.Cainfo = resSeven10265.Cainfo
  16592. res.WarnMsg = resSeven10265.WarnMsg
  16593. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  16594. res.Infcode = infocode
  16595. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16596. acct_used_flag := "1"
  16597. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  16598. var result string
  16599. var request_log string
  16600. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  16601. 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)
  16602. } else {
  16603. 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)
  16604. }
  16605. var dat map[string]interface{}
  16606. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16607. fmt.Println(dat)
  16608. } else {
  16609. fmt.Println(err)
  16610. }
  16611. saveLog(result, request_log, "2206", "预结算")
  16612. userJSONBytes, _ := json.Marshal(dat)
  16613. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16614. utils.ErrorLog("解析失败:%v", err)
  16615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16616. return
  16617. }
  16618. } else if miConfig.MdtrtareaAdmvs == "360399" {
  16619. var result string
  16620. var request_log string
  16621. if his.IdCardType == 2 {
  16622. 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, "")
  16623. } else if his.IdCardType == 1 {
  16624. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  16625. bas := strings.Split(psn_info.CardInfo, "|")
  16626. basNumber := bas[2]
  16627. card_sn := bas[3]
  16628. 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)
  16629. } else {
  16630. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  16631. 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, "")
  16632. }
  16633. var dat map[string]interface{}
  16634. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16635. fmt.Println(dat)
  16636. } else {
  16637. fmt.Println(err)
  16638. }
  16639. saveLog(result, request_log, "2206", "预结算")
  16640. userJSONBytes, _ := json.Marshal(dat)
  16641. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16642. utils.ErrorLog("解析失败:%v", err)
  16643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16644. return
  16645. }
  16646. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16647. var result string
  16648. var request_log string
  16649. if his.IdCardType == 2 {
  16650. 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")
  16651. } else if his.IdCardType == 1 {
  16652. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  16653. bas := strings.Split(psn_info.CardInfo, "|")
  16654. basNumber := bas[2]
  16655. card_sn := bas[3]
  16656. 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")
  16657. } else {
  16658. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  16659. 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")
  16660. }
  16661. var dat map[string]interface{}
  16662. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16663. fmt.Println(dat)
  16664. } else {
  16665. fmt.Println(err)
  16666. }
  16667. saveLog(result, request_log, "2206", "预结算")
  16668. userJSONBytes, _ := json.Marshal(dat)
  16669. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16670. utils.ErrorLog("解析失败:%v", err)
  16671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16672. return
  16673. }
  16674. } else {
  16675. if miConfig.MdtrtareaAdmvs == "441202" {
  16676. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  16677. if result3101.Infcode == 0 {
  16678. if len(result3101.Output.Result) > 0 {
  16679. var errMsgs []string
  16680. for _, item := range result3101.Output.Result {
  16681. errMsgs = append(errMsgs, item.VolaCont)
  16682. }
  16683. c.ServeSuccessJSON(map[string]interface{}{
  16684. "failed_code": -10,
  16685. "msg": errMsgs,
  16686. })
  16687. return
  16688. } else {
  16689. var result string
  16690. var request_log string
  16691. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  16692. allTotal = fmt.Sprintf("%2f", total_two)
  16693. if his.IdCardType == 4 {
  16694. 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)
  16695. } else {
  16696. 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)
  16697. }
  16698. var dat map[string]interface{}
  16699. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16700. fmt.Println(dat)
  16701. } else {
  16702. fmt.Println(err)
  16703. }
  16704. saveLog(result, request_log, "2206", "预结算")
  16705. //userJSONBytes, _ := json.Marshal(dat)
  16706. //
  16707. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16708. // utils.ErrorLog("解析失败:%v", err)
  16709. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16710. // return
  16711. //}
  16712. userJSONBytes, _ := json.Marshal(dat)
  16713. if miConfig.Code == "H15049901371" {
  16714. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  16715. utils.ErrorLog("解析失败:%v", err)
  16716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16717. return
  16718. }
  16719. res.InfRefmsgid = resSeven10265.InfRefmsgid
  16720. res.Output = resSeven10265.Output
  16721. res.ErrMsg = resSeven10265.ErrMsg
  16722. res.Cainfo = resSeven10265.Cainfo
  16723. res.WarnMsg = resSeven10265.WarnMsg
  16724. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  16725. res.Infcode = infocode
  16726. } else {
  16727. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16728. utils.ErrorLog("解析失败:%v", err)
  16729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16730. return
  16731. }
  16732. }
  16733. }
  16734. } else {
  16735. c.ServeSuccessJSON(map[string]interface{}{
  16736. "failed_code": -10,
  16737. "msg": result3101.ErrMsg,
  16738. })
  16739. return
  16740. }
  16741. } else {
  16742. var result string
  16743. var request_log string
  16744. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  16745. allTotal = fmt.Sprintf("%2f", total_two)
  16746. if his.IdCardType == 4 {
  16747. 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)
  16748. } else {
  16749. 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)
  16750. }
  16751. var dat map[string]interface{}
  16752. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16753. fmt.Println(dat)
  16754. } else {
  16755. fmt.Println(err)
  16756. }
  16757. saveLog(result, request_log, "2206", "预结算")
  16758. //userJSONBytes, _ := json.Marshal(dat)
  16759. //
  16760. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16761. // utils.ErrorLog("解析失败:%v", err)
  16762. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16763. // return
  16764. //}
  16765. userJSONBytes, _ := json.Marshal(dat)
  16766. if miConfig.Code == "H15049901371" {
  16767. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  16768. utils.ErrorLog("解析失败:%v", err)
  16769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16770. return
  16771. }
  16772. res.InfRefmsgid = resSeven10265.InfRefmsgid
  16773. res.Output = resSeven10265.Output
  16774. res.ErrMsg = resSeven10265.ErrMsg
  16775. res.Cainfo = resSeven10265.Cainfo
  16776. res.WarnMsg = resSeven10265.WarnMsg
  16777. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  16778. res.Infcode = infocode
  16779. } else {
  16780. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  16781. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  16782. utils.ErrorLog("解析失败:%v", err)
  16783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16784. return
  16785. }
  16786. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  16787. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  16788. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  16789. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  16790. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  16791. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  16792. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  16793. res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  16794. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  16795. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  16796. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  16797. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  16798. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  16799. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  16800. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  16801. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  16802. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  16803. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  16804. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  16805. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  16806. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  16807. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  16808. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  16809. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  16810. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  16811. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  16812. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  16813. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  16814. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  16815. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  16816. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  16817. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  16818. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  16819. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  16820. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  16821. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  16822. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  16823. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  16824. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  16825. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  16826. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  16827. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  16828. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  16829. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  16830. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  16831. res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  16832. res.ErrMsg = gzresSeven10265Two.ErrMsg
  16833. res.Cainfo = gzresSeven10265Two.Cainfo
  16834. res.WarnMsg = gzresSeven10265Two.WarnMsg
  16835. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  16836. //res.Infcode = infocode
  16837. } else {
  16838. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16839. utils.ErrorLog("解析失败:%v", err)
  16840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16841. return
  16842. }
  16843. }
  16844. }
  16845. }
  16846. }
  16847. if res.Infcode != 0 {
  16848. errlog := &models.HisOrderError{
  16849. UserOrgId: adminUser.CurrentOrgId,
  16850. Ctime: time.Now().Unix(),
  16851. Mtime: time.Now().Unix(),
  16852. Number: chrg_bchno,
  16853. ErrMsg: res.ErrMsg,
  16854. Status: 1,
  16855. PatientId: id,
  16856. RecordTime: recordDateTime,
  16857. Stage: 20,
  16858. }
  16859. service.CreateErrMsgLog(errlog)
  16860. c.ServeSuccessJSON(map[string]interface{}{
  16861. "failed_code": -10,
  16862. "msg": res.ErrMsg,
  16863. })
  16864. return
  16865. } else {
  16866. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  16867. order.OrderStatus = 1
  16868. order.IsPre = 1
  16869. order.Status = 1
  16870. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  16871. order.SetlId = res.Output.Setlinfo.SetlID
  16872. order.PsnNo = res.Output.Setlinfo.PsnNo
  16873. order.PsnName = res.Output.Setlinfo.PsnName
  16874. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  16875. order.Certno = res.Output.Setlinfo.Certno
  16876. order.Gend = res.Output.Setlinfo.Gend
  16877. order.Naty = res.Output.Setlinfo.Naty
  16878. order.Age = res.Output.Setlinfo.Age
  16879. order.Insutype = res.Output.Setlinfo.Insutype
  16880. order.PsnType = res.Output.Setlinfo.PsnType
  16881. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  16882. order.SetlTime = res.Output.Setlinfo.SetlTime
  16883. order.AcctUsedFlag = acct_used_flag
  16884. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  16885. if res.Output.Setlinfo.MedType == "140101" {
  16886. order.MedType = "14"
  16887. } else {
  16888. order.MedType = res.Output.Setlinfo.MedType
  16889. }
  16890. if reg_type == 1112 {
  16891. order.MedType = "1112"
  16892. }
  16893. if reg_type == 1111 {
  16894. order.MedType = "1111"
  16895. }
  16896. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  16897. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  16898. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  16899. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  16900. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  16901. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  16902. order.HifpPay = res.Output.Setlinfo.HifpPay
  16903. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  16904. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  16905. order.HifesPay = res.Output.Setlinfo.HifesPay
  16906. order.HifobPay = res.Output.Setlinfo.HifobPay
  16907. order.MafPay = res.Output.Setlinfo.MafPay
  16908. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  16909. order.OthPay = res.Output.Setlinfo.OthPay
  16910. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  16911. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  16912. order.AcctPay = res.Output.Setlinfo.AcctPay
  16913. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  16914. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  16915. order.Balc = res.Output.Setlinfo.Balc
  16916. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  16917. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  16918. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  16919. order.ClrWay = res.Output.Setlinfo.ClrWay
  16920. order.Creator = order.Creator
  16921. order.Modify = roles.AdminUserId
  16922. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  16923. detailStr := string(setlDetail)
  16924. order.SetlDetail = detailStr
  16925. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  16926. err = service.UpDateOrder(order)
  16927. if err == nil {
  16928. c.ServeSuccessJSON(map[string]interface{}{
  16929. "msg": "预结算成功",
  16930. })
  16931. } else {
  16932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  16933. return
  16934. }
  16935. }
  16936. } else {
  16937. adminUser := c.GetAdminUserInfo()
  16938. errlog := &models.HisOrderError{
  16939. UserOrgId: adminUser.CurrentOrgId,
  16940. Ctime: time.Now().Unix(),
  16941. Mtime: time.Now().Unix(),
  16942. ErrMsg: res.ErrMsg,
  16943. Status: 1,
  16944. PatientId: id,
  16945. RecordTime: recordDateTime,
  16946. Stage: 4,
  16947. }
  16948. service.CreateErrMsgLog(errlog)
  16949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  16950. return
  16951. }
  16952. } else {
  16953. if miConfig.MdtrtareaAdmvs == "150499" {
  16954. order := &models.HisOrder{
  16955. UserOrgId: adminUser.CurrentOrgId,
  16956. HisPatientId: his.ID,
  16957. PatientId: his.PatientId,
  16958. SettleAccountsDate: recordDateTime,
  16959. Ctime: time.Now().Unix(),
  16960. Mtime: time.Now().Unix(),
  16961. MdtrtId: his.Number,
  16962. PsnNo: his.PsnNo,
  16963. MedType: strconv.FormatInt(reg_type, 10),
  16964. Status: 1,
  16965. Number: chrg_bchno,
  16966. Infcode: res.Infcode,
  16967. WarnMsg: res.WarnMsg,
  16968. Cainfo: res.Cainfo,
  16969. ErrMsg: res.ErrMsg,
  16970. RespondTime: res.RefmsgTime,
  16971. InfRefmsgid: res.InfRefmsgid,
  16972. OrderStatus: 1,
  16973. IsMedicineInsurance: 1,
  16974. SettleType: settle_accounts_type,
  16975. SettleStartTime: start_time,
  16976. SettleEndTime: end_time,
  16977. Creator: roles.AdminUserId,
  16978. Modify: roles.AdminUserId,
  16979. PType: 2,
  16980. Diagnosis: diagnosis_id,
  16981. }
  16982. err = service.CreateOrder(order)
  16983. if err != nil {
  16984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  16985. return
  16986. }
  16987. }
  16988. adminUser := c.GetAdminUserInfo()
  16989. errlog := &models.HisOrderError{
  16990. UserOrgId: adminUser.CurrentOrgId,
  16991. Ctime: time.Now().Unix(),
  16992. Mtime: time.Now().Unix(),
  16993. ErrMsg: res.ErrMsg,
  16994. Status: 1,
  16995. PatientId: id,
  16996. RecordTime: recordDateTime,
  16997. Stage: 4,
  16998. }
  16999. service.CreateErrMsgLog(errlog)
  17000. c.ServeSuccessJSON(map[string]interface{}{
  17001. "failed_code": -10,
  17002. "msg": res.ErrMsg,
  17003. })
  17004. return
  17005. }
  17006. }
  17007. }
  17008. }
  17009. // 退款
  17010. func (c *HisApiController) Refund() {
  17011. order_id, _ := c.GetInt64("order_id")
  17012. admin_user_id, _ := c.GetInt64("admin_user_id")
  17013. adminUser := c.GetAdminUserInfo()
  17014. var order models.HisOrder
  17015. order, _ = service.GetHisOrderByID(order_id)
  17016. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17017. if order.ID == 0 {
  17018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17019. return
  17020. }
  17021. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17022. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17023. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17024. if config.IsOpen == 1 { //对接了医保,走医保流程
  17025. var res ResultSixteen
  17026. var resSixteen10265 ResultSixteen10265
  17027. var resSixteen10265Two ResultSixteen10265Two
  17028. var gz ResultgzSixteen10265Two
  17029. var src_resquest string
  17030. var result string
  17031. if miConfig.MdtrtareaAdmvs == "421300" {
  17032. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  17033. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17034. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  17035. resp3, requestErr3 := http.Get(api3)
  17036. if requestErr3 != nil {
  17037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17038. return
  17039. }
  17040. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  17041. if ioErr3 != nil {
  17042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  17043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17044. return
  17045. }
  17046. var respJSON3 map[string]interface{}
  17047. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  17048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17050. return
  17051. }
  17052. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17053. userJSONBytes3, _ := json.Marshal(respJSON3)
  17054. fmt.Println("log")
  17055. fmt.Println(string(userJSONBytes3))
  17056. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  17057. utils.ErrorLog("解析失败:%v", err)
  17058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17059. return
  17060. }
  17061. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17062. var api3 string
  17063. if miConfig.MdtrtareaAdmvs == "320921" {
  17064. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  17065. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17066. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  17067. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  17068. } else {
  17069. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  17070. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  17071. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17072. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  17073. }
  17074. resp3, requestErr3 := http.Get(api3)
  17075. if requestErr3 != nil {
  17076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17077. return
  17078. }
  17079. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  17080. if ioErr3 != nil {
  17081. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  17082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17083. return
  17084. }
  17085. var respJSON3 map[string]interface{}
  17086. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  17087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17089. return
  17090. }
  17091. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17092. userJSONBytes3, _ := json.Marshal(respJSON3)
  17093. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  17094. utils.ErrorLog("解析失败:%v", err)
  17095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17096. return
  17097. }
  17098. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  17099. res.Output = resSixteen10265.Output
  17100. res.ErrMsg = resSixteen10265.ErrMsg
  17101. res.Cainfo = resSixteen10265.Cainfo
  17102. res.WarnMsg = resSixteen10265.WarnMsg
  17103. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  17104. res.Infcode = infocode
  17105. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17106. var api3 string
  17107. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  17108. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17109. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  17110. resp3, requestErr3 := http.Get(api3)
  17111. if requestErr3 != nil {
  17112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17113. return
  17114. }
  17115. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  17116. if ioErr3 != nil {
  17117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  17118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17119. return
  17120. }
  17121. var respJSON3 map[string]interface{}
  17122. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  17123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17125. return
  17126. }
  17127. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17128. userJSONBytes3, _ := json.Marshal(respJSON3)
  17129. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  17130. utils.ErrorLog("解析失败:%v", err)
  17131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17132. return
  17133. }
  17134. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  17135. res.Output = resSixteen10265.Output
  17136. res.ErrMsg = resSixteen10265.ErrMsg
  17137. res.Cainfo = resSixteen10265.Cainfo
  17138. res.WarnMsg = resSixteen10265.WarnMsg
  17139. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  17140. res.Infcode = infocode
  17141. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17142. 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)
  17143. var dat map[string]interface{}
  17144. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17145. fmt.Println(dat)
  17146. } else {
  17147. fmt.Println(err)
  17148. }
  17149. saveLog(result, src_resquest, "2208", "退费")
  17150. userJSONBytes, _ := json.Marshal(dat)
  17151. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17152. utils.ErrorLog("解析失败:%v", err)
  17153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17154. return
  17155. }
  17156. } else if miConfig.MdtrtareaAdmvs == "360399" {
  17157. 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, "")
  17158. var dat map[string]interface{}
  17159. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17160. fmt.Println(dat)
  17161. } else {
  17162. fmt.Println(err)
  17163. }
  17164. saveLog(result, src_resquest, "2208", "退费")
  17165. userJSONBytes, _ := json.Marshal(dat)
  17166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17167. utils.ErrorLog("解析失败:%v", err)
  17168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17169. return
  17170. }
  17171. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17172. 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, "")
  17173. var dat map[string]interface{}
  17174. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17175. fmt.Println(dat)
  17176. } else {
  17177. fmt.Println(err)
  17178. }
  17179. saveLog(result, src_resquest, "2208", "退费")
  17180. userJSONBytes, _ := json.Marshal(dat)
  17181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17182. utils.ErrorLog("解析失败:%v", err)
  17183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17184. return
  17185. }
  17186. } else {
  17187. if miConfig.Code == "H15049901371" {
  17188. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  17189. var dat map[string]interface{}
  17190. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17191. fmt.Println(dat)
  17192. } else {
  17193. fmt.Println(err)
  17194. }
  17195. saveLog(result, src_resquest, "2208", "退费")
  17196. userJSONBytes, _ := json.Marshal(dat)
  17197. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  17198. utils.ErrorLog("解析失败:%v", err)
  17199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17200. return
  17201. }
  17202. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  17203. res.Output = resSixteen10265.Output
  17204. res.ErrMsg = resSixteen10265.ErrMsg
  17205. res.Cainfo = resSixteen10265.Cainfo
  17206. res.WarnMsg = resSixteen10265.WarnMsg
  17207. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  17208. res.Infcode = infocode
  17209. } else {
  17210. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  17211. var dat map[string]interface{}
  17212. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17213. fmt.Println(dat)
  17214. } else {
  17215. fmt.Println(err)
  17216. }
  17217. saveLog(result, src_resquest, "2208", "退费")
  17218. userJSONBytes, _ := json.Marshal(dat)
  17219. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  17220. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  17221. utils.ErrorLog("解析失败:%v", err)
  17222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17223. return
  17224. }
  17225. res.Infcode = gz.Infcode
  17226. } else {
  17227. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17228. utils.ErrorLog("解析失败:%v", err)
  17229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17230. return
  17231. }
  17232. }
  17233. }
  17234. }
  17235. if res.Infcode == 0 {
  17236. var res2 ResultSix
  17237. var resSix10265 ResultSix10265
  17238. if miConfig.MdtrtareaAdmvs == "421300" {
  17239. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  17240. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17241. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  17242. resp3, requestErr3 := http.Get(api3)
  17243. if requestErr3 != nil {
  17244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17245. return
  17246. }
  17247. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  17248. if ioErr3 != nil {
  17249. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  17250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17251. return
  17252. }
  17253. var respJSON3 map[string]interface{}
  17254. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  17255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17257. return
  17258. }
  17259. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17260. userJSONBytes3, _ := json.Marshal(respJSON3)
  17261. fmt.Println("log")
  17262. fmt.Println(string(userJSONBytes3))
  17263. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  17264. utils.ErrorLog("解析失败:%v", err)
  17265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17266. return
  17267. }
  17268. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17269. var api3 string
  17270. if miConfig.MdtrtareaAdmvs == "320921" {
  17271. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  17272. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17273. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  17274. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  17275. } else {
  17276. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  17277. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  17278. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17279. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  17280. }
  17281. resp3, requestErr3 := http.Get(api3)
  17282. if requestErr3 != nil {
  17283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17284. return
  17285. }
  17286. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  17287. if ioErr3 != nil {
  17288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  17289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17290. return
  17291. }
  17292. var respJSON3 map[string]interface{}
  17293. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  17294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17296. return
  17297. }
  17298. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17299. userJSONBytes3, _ := json.Marshal(respJSON3)
  17300. fmt.Println("log")
  17301. fmt.Println(string(userJSONBytes3))
  17302. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  17303. utils.ErrorLog("解析失败:%v", err)
  17304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17305. return
  17306. }
  17307. res2.InfRefmsgid = resSix10265.InfRefmsgid
  17308. res2.Output = resSix10265.Output
  17309. res2.ErrMsg = resSix10265.ErrMsg
  17310. res2.Cainfo = resSix10265.Cainfo
  17311. res2.WarnMsg = resSix10265.WarnMsg
  17312. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17313. res2.Infcode = infocode
  17314. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17315. var api3 string
  17316. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  17317. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17318. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  17319. resp3, requestErr3 := http.Get(api3)
  17320. if requestErr3 != nil {
  17321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17322. return
  17323. }
  17324. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  17325. if ioErr3 != nil {
  17326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  17327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17328. return
  17329. }
  17330. var respJSON3 map[string]interface{}
  17331. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  17332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17334. return
  17335. }
  17336. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17337. userJSONBytes3, _ := json.Marshal(respJSON3)
  17338. fmt.Println("log")
  17339. fmt.Println(string(userJSONBytes3))
  17340. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  17341. utils.ErrorLog("解析失败:%v", err)
  17342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17343. return
  17344. }
  17345. res2.InfRefmsgid = resSix10265.InfRefmsgid
  17346. res2.Output = resSix10265.Output
  17347. res2.ErrMsg = resSix10265.ErrMsg
  17348. res2.Cainfo = resSix10265.Cainfo
  17349. res2.WarnMsg = resSix10265.WarnMsg
  17350. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17351. res2.Infcode = infocode
  17352. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17353. 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)
  17354. var dat map[string]interface{}
  17355. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  17356. fmt.Println(dat)
  17357. } else {
  17358. fmt.Println(err)
  17359. }
  17360. saveLog(result2, src_request, "2205", "撤销明细")
  17361. userJSONBytes, _ := json.Marshal(dat)
  17362. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17363. utils.ErrorLog("解析失败:%v", err)
  17364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17365. return
  17366. }
  17367. } else if miConfig.MdtrtareaAdmvs == "360399" {
  17368. 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, "")
  17369. var dat map[string]interface{}
  17370. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  17371. fmt.Println(dat)
  17372. } else {
  17373. fmt.Println(err)
  17374. }
  17375. saveLog(result2, src_request, "2205", "撤销明细")
  17376. userJSONBytes, _ := json.Marshal(dat)
  17377. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17378. utils.ErrorLog("解析失败:%v", err)
  17379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17380. return
  17381. }
  17382. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17383. 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, "")
  17384. var dat map[string]interface{}
  17385. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  17386. fmt.Println(dat)
  17387. } else {
  17388. fmt.Println(err)
  17389. }
  17390. saveLog(result2, src_request, "2205", "撤销明细")
  17391. userJSONBytes, _ := json.Marshal(dat)
  17392. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17393. utils.ErrorLog("解析失败:%v", err)
  17394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17395. return
  17396. }
  17397. } else {
  17398. if miConfig.Code == "H15049901371" {
  17399. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  17400. var dat map[string]interface{}
  17401. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  17402. fmt.Println(dat)
  17403. } else {
  17404. fmt.Println(err)
  17405. }
  17406. saveLog(result2, src_request, "2205", "撤销明细")
  17407. userJSONBytes, _ := json.Marshal(dat)
  17408. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  17409. utils.ErrorLog("解析失败:%v", err)
  17410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17411. return
  17412. }
  17413. res2.InfRefmsgid = resSix10265.InfRefmsgid
  17414. res2.Output = resSix10265.Output
  17415. res2.ErrMsg = resSix10265.ErrMsg
  17416. res2.Cainfo = resSix10265.Cainfo
  17417. res2.WarnMsg = resSix10265.WarnMsg
  17418. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17419. res2.Infcode = infocode
  17420. } else {
  17421. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  17422. res2.Infcode = 0
  17423. } else {
  17424. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  17425. var dat map[string]interface{}
  17426. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  17427. fmt.Println(dat)
  17428. } else {
  17429. fmt.Println(err)
  17430. }
  17431. saveLog(result2, src_request, "2205", "撤销明细")
  17432. userJSONBytes, _ := json.Marshal(dat)
  17433. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17434. utils.ErrorLog("解析失败:%v", err)
  17435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17436. return
  17437. }
  17438. }
  17439. }
  17440. }
  17441. if res2.Infcode == 0 {
  17442. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  17443. if err == nil {
  17444. //当押金不为零时产生退费记录
  17445. if order.Decimal != 0 {
  17446. tmp := strconv.FormatInt(order.ID, 10)
  17447. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  17448. if err != nil {
  17449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17450. return
  17451. }
  17452. }
  17453. c.ServeSuccessJSON(map[string]interface{}{
  17454. "msg": "退费成功",
  17455. })
  17456. } else {
  17457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17458. return
  17459. }
  17460. } else {
  17461. c.ServeSuccessJSON(map[string]interface{}{
  17462. "code": -10,
  17463. "msg": res2.ErrMsg,
  17464. })
  17465. }
  17466. } else {
  17467. c.ServeSuccessJSON(map[string]interface{}{
  17468. "code": -10,
  17469. "msg": res.ErrMsg,
  17470. })
  17471. }
  17472. }
  17473. }
  17474. func (c *HisApiController) RefundNumber() {
  17475. record_time := c.GetString("record_time")
  17476. //patient_id, _ := c.GetInt64("patient_id")
  17477. admin_user_id, _ := c.GetInt64("admin_user_id")
  17478. his_patient_id, _ := c.GetInt64("id")
  17479. timeLayout := "2006-01-02"
  17480. loc, _ := time.LoadLocation("Local")
  17481. adminUser := c.GetAdminUserInfo()
  17482. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17483. fmt.Println(err)
  17484. if err != nil {
  17485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17486. return
  17487. }
  17488. recordDateTime := theTime.Unix()
  17489. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  17490. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  17491. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  17492. //order, _ := service.GetHisOrderByID(order_id)
  17493. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17494. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17495. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17496. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  17497. if count > 0 {
  17498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  17499. return
  17500. }
  17501. if config.IsOpen == 1 { //对接了医保,走医保流程
  17502. var res2 ResultSix
  17503. var res3 GZResultSix
  17504. var resSix10265 ResultSix10265
  17505. if miConfig.MdtrtareaAdmvs == "421300" {
  17506. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  17507. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17508. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  17509. resp3, requestErr3 := http.Get(api3)
  17510. if requestErr3 != nil {
  17511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17512. return
  17513. }
  17514. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  17515. if ioErr3 != nil {
  17516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  17517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17518. return
  17519. }
  17520. var respJSON3 map[string]interface{}
  17521. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  17522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17524. return
  17525. }
  17526. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17527. userJSONBytes3, _ := json.Marshal(respJSON3)
  17528. fmt.Println("log")
  17529. fmt.Println(string(userJSONBytes3))
  17530. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  17531. utils.ErrorLog("解析失败:%v", err)
  17532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17533. return
  17534. }
  17535. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17536. var api3 string
  17537. if miConfig.MdtrtareaAdmvs == "320921" {
  17538. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  17539. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17540. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  17541. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  17542. } else {
  17543. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  17544. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  17545. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17546. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  17547. }
  17548. resp3, requestErr3 := http.Get(api3)
  17549. if requestErr3 != nil {
  17550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17551. return
  17552. }
  17553. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  17554. if ioErr3 != nil {
  17555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  17556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17557. return
  17558. }
  17559. var respJSON3 map[string]interface{}
  17560. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  17561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17563. return
  17564. }
  17565. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17566. userJSONBytes3, _ := json.Marshal(respJSON3)
  17567. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  17568. utils.ErrorLog("解析失败:%v", err)
  17569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17570. return
  17571. }
  17572. res2.InfRefmsgid = resSix10265.InfRefmsgid
  17573. res2.Output = resSix10265.Output
  17574. res2.ErrMsg = resSix10265.ErrMsg
  17575. res2.Cainfo = resSix10265.Cainfo
  17576. res2.WarnMsg = resSix10265.WarnMsg
  17577. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17578. res2.Infcode = infocode
  17579. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17580. var api3 string
  17581. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  17582. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17583. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  17584. resp3, requestErr3 := http.Get(api3)
  17585. if requestErr3 != nil {
  17586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17587. return
  17588. }
  17589. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  17590. if ioErr3 != nil {
  17591. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  17592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17593. return
  17594. }
  17595. var respJSON3 map[string]interface{}
  17596. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  17597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17599. return
  17600. }
  17601. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17602. userJSONBytes3, _ := json.Marshal(respJSON3)
  17603. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  17604. utils.ErrorLog("解析失败:%v", err)
  17605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17606. return
  17607. }
  17608. res2.InfRefmsgid = resSix10265.InfRefmsgid
  17609. res2.Output = resSix10265.Output
  17610. res2.ErrMsg = resSix10265.ErrMsg
  17611. res2.Cainfo = resSix10265.Cainfo
  17612. res2.WarnMsg = resSix10265.WarnMsg
  17613. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17614. res2.Infcode = infocode
  17615. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17616. 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)
  17617. var dat map[string]interface{}
  17618. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17619. fmt.Println(dat)
  17620. } else {
  17621. fmt.Println(err)
  17622. }
  17623. saveLog(result, request, "2202", "退号")
  17624. userJSONBytes, _ := json.Marshal(dat)
  17625. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17626. utils.ErrorLog("解析失败:%v", err)
  17627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17628. return
  17629. }
  17630. } else if miConfig.MdtrtareaAdmvs == "360399" {
  17631. 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, "")
  17632. var dat map[string]interface{}
  17633. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17634. fmt.Println(dat)
  17635. } else {
  17636. fmt.Println(err)
  17637. }
  17638. saveLog(result, request, "2202", "退号")
  17639. userJSONBytes, _ := json.Marshal(dat)
  17640. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17641. utils.ErrorLog("解析失败:%v", err)
  17642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17643. return
  17644. }
  17645. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17646. 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, "")
  17647. var dat map[string]interface{}
  17648. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17649. fmt.Println(dat)
  17650. } else {
  17651. fmt.Println(err)
  17652. }
  17653. saveLog(result, request, "2202", "退号")
  17654. userJSONBytes, _ := json.Marshal(dat)
  17655. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17656. utils.ErrorLog("解析失败:%v", err)
  17657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17658. return
  17659. }
  17660. } else {
  17661. var api3 string
  17662. if miConfig.Code == "H15049901371" {
  17663. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  17664. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17665. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  17666. } else {
  17667. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  17668. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17669. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  17670. }
  17671. resp3, requestErr3 := http.Get(api3)
  17672. if requestErr3 != nil {
  17673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17674. return
  17675. }
  17676. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  17677. if ioErr3 != nil {
  17678. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  17679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17680. return
  17681. }
  17682. var respJSON3 map[string]interface{}
  17683. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  17684. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17686. return
  17687. }
  17688. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17689. userJSONBytes3, _ := json.Marshal(respJSON3)
  17690. if miConfig.Code == "H15049901371" {
  17691. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  17692. utils.ErrorLog("解析失败:%v", err)
  17693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17694. return
  17695. }
  17696. res2.InfRefmsgid = resSix10265.InfRefmsgid
  17697. res2.Output = resSix10265.Output
  17698. res2.ErrMsg = resSix10265.ErrMsg
  17699. res2.Cainfo = resSix10265.Cainfo
  17700. res2.WarnMsg = resSix10265.WarnMsg
  17701. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17702. res2.Infcode = infocode
  17703. } else {
  17704. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  17705. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  17706. utils.ErrorLog("解析失败:%v", err)
  17707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17708. return
  17709. }
  17710. res2.Infcode = res3.Infcode
  17711. } else {
  17712. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  17713. utils.ErrorLog("解析失败:%v", err)
  17714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17715. return
  17716. }
  17717. }
  17718. }
  17719. }
  17720. if res2.Infcode == 0 {
  17721. if err == nil {
  17722. c.ServeSuccessJSON(map[string]interface{}{
  17723. "msg": "退号成功",
  17724. })
  17725. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  17726. } else {
  17727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17728. return
  17729. }
  17730. } else {
  17731. c.ServeSuccessJSON(map[string]interface{}{
  17732. "code": -10,
  17733. "msg": res2.ErrMsg,
  17734. })
  17735. }
  17736. } else {
  17737. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  17738. //if err == nil {
  17739. // c.ServeSuccessJSON(map[string]interface{}{
  17740. // "msg": "退费成功",
  17741. // })
  17742. //} else {
  17743. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17744. // return
  17745. //}
  17746. }
  17747. }
  17748. func (c *HisApiController) RefundDetail() {
  17749. order_id, _ := c.GetInt64("order_id")
  17750. admin_user_id, _ := c.GetInt64("admin_user_id")
  17751. //his_patient_id, _ := c.GetInt64("his_patient_id")
  17752. number := c.GetString("number")
  17753. record_time := c.GetString("record_time")
  17754. patient_id, _ := c.GetInt64("patient_id")
  17755. //med_type, _ := c.GetInt64("med_type")
  17756. timeLayout := "2006-01-02"
  17757. loc, _ := time.LoadLocation("Local")
  17758. adminUser := c.GetAdminUserInfo()
  17759. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17760. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17761. fmt.Println(err)
  17762. if err != nil {
  17763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17764. return
  17765. }
  17766. recordDateTime := theTime.Unix()
  17767. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  17768. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  17769. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17770. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17771. var order models.HisOrder
  17772. order, _ = service.GetHisOrderByID(order_id)
  17773. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17774. if config.IsOpen == 1 { //对接了医保,走医保流程
  17775. var res2 ResultSix
  17776. if miConfig.MdtrtareaAdmvs == "421300" {
  17777. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  17778. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17779. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  17780. resp3, requestErr3 := http.Get(api3)
  17781. if requestErr3 != nil {
  17782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17783. return
  17784. }
  17785. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  17786. if ioErr3 != nil {
  17787. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  17788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17789. return
  17790. }
  17791. var respJSON3 map[string]interface{}
  17792. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  17793. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17795. return
  17796. }
  17797. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17798. userJSONBytes3, _ := json.Marshal(respJSON3)
  17799. fmt.Println("log")
  17800. fmt.Println(string(userJSONBytes3))
  17801. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  17802. utils.ErrorLog("解析失败:%v", err)
  17803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17804. return
  17805. }
  17806. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  17807. if err == nil {
  17808. c.ServeSuccessJSON(map[string]interface{}{
  17809. "msg": "撤销明细成功",
  17810. })
  17811. return
  17812. } else {
  17813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17814. return
  17815. }
  17816. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17817. var resSix10265 ResultSix10265
  17818. var api3 string
  17819. if miConfig.MdtrtareaAdmvs == "320921" {
  17820. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  17821. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17822. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  17823. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  17824. } else {
  17825. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  17826. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  17827. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17828. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  17829. }
  17830. resp3, requestErr3 := http.Get(api3)
  17831. if requestErr3 != nil {
  17832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17833. return
  17834. }
  17835. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  17836. if ioErr3 != nil {
  17837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  17838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17839. return
  17840. }
  17841. var respJSON3 map[string]interface{}
  17842. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  17843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17845. return
  17846. }
  17847. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17848. userJSONBytes3, _ := json.Marshal(respJSON3)
  17849. fmt.Println("log")
  17850. fmt.Println(string(userJSONBytes3))
  17851. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  17852. utils.ErrorLog("解析失败:%v", err)
  17853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17854. return
  17855. }
  17856. res2.InfRefmsgid = resSix10265.InfRefmsgid
  17857. res2.Output = resSix10265.Output
  17858. res2.ErrMsg = resSix10265.ErrMsg
  17859. res2.Cainfo = resSix10265.Cainfo
  17860. res2.WarnMsg = resSix10265.WarnMsg
  17861. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17862. res2.Infcode = infocode
  17863. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  17864. if err == nil {
  17865. c.ServeSuccessJSON(map[string]interface{}{
  17866. "msg": "撤销明细成功",
  17867. })
  17868. return
  17869. } else {
  17870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17871. return
  17872. }
  17873. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17874. var resSix10265 ResultSix10265
  17875. var api3 string
  17876. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  17877. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  17878. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  17879. resp3, requestErr3 := http.Get(api3)
  17880. if requestErr3 != nil {
  17881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17882. return
  17883. }
  17884. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  17885. if ioErr3 != nil {
  17886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  17887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17888. return
  17889. }
  17890. var respJSON3 map[string]interface{}
  17891. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  17892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17894. return
  17895. }
  17896. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17897. userJSONBytes3, _ := json.Marshal(respJSON3)
  17898. fmt.Println("log")
  17899. fmt.Println(string(userJSONBytes3))
  17900. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  17901. utils.ErrorLog("解析失败:%v", err)
  17902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17903. return
  17904. }
  17905. res2.InfRefmsgid = resSix10265.InfRefmsgid
  17906. res2.Output = resSix10265.Output
  17907. res2.ErrMsg = resSix10265.ErrMsg
  17908. res2.Cainfo = resSix10265.Cainfo
  17909. res2.WarnMsg = resSix10265.WarnMsg
  17910. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17911. res2.Infcode = infocode
  17912. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  17913. if err == nil {
  17914. c.ServeSuccessJSON(map[string]interface{}{
  17915. "msg": "撤销明细成功",
  17916. })
  17917. return
  17918. } else {
  17919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17920. return
  17921. }
  17922. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17923. 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)
  17924. var dat map[string]interface{}
  17925. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  17926. fmt.Println(dat)
  17927. } else {
  17928. fmt.Println(err)
  17929. }
  17930. saveLog(result2, src_request, "2205", "撤销明细")
  17931. userJSONBytes, _ := json.Marshal(dat)
  17932. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17933. utils.ErrorLog("解析失败:%v", err)
  17934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17935. return
  17936. }
  17937. if res2.Infcode == 0 {
  17938. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  17939. if err == nil {
  17940. c.ServeSuccessJSON(map[string]interface{}{
  17941. "msg": "撤销明细成功",
  17942. })
  17943. return
  17944. } else {
  17945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17946. return
  17947. }
  17948. } else {
  17949. c.ServeSuccessJSON(map[string]interface{}{
  17950. "code": -10,
  17951. "msg": res2.ErrMsg,
  17952. })
  17953. }
  17954. } else if miConfig.MdtrtareaAdmvs == "360399" {
  17955. 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, "")
  17956. var dat map[string]interface{}
  17957. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  17958. fmt.Println(dat)
  17959. } else {
  17960. fmt.Println(err)
  17961. }
  17962. saveLog(result2, src_request, "2205", "撤销明细")
  17963. userJSONBytes, _ := json.Marshal(dat)
  17964. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17965. utils.ErrorLog("解析失败:%v", err)
  17966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17967. return
  17968. }
  17969. if res2.Infcode == 0 {
  17970. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  17971. if err == nil {
  17972. c.ServeSuccessJSON(map[string]interface{}{
  17973. "msg": "撤销明细成功",
  17974. })
  17975. return
  17976. } else {
  17977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17978. return
  17979. }
  17980. } else {
  17981. c.ServeSuccessJSON(map[string]interface{}{
  17982. "code": -10,
  17983. "msg": res2.ErrMsg,
  17984. })
  17985. }
  17986. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17987. 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, "")
  17988. var dat map[string]interface{}
  17989. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  17990. fmt.Println(dat)
  17991. } else {
  17992. fmt.Println(err)
  17993. }
  17994. saveLog(result2, src_request, "2205", "撤销明细")
  17995. userJSONBytes, _ := json.Marshal(dat)
  17996. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17997. utils.ErrorLog("解析失败:%v", err)
  17998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17999. return
  18000. }
  18001. if res2.Infcode == 0 {
  18002. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  18003. if err == nil {
  18004. c.ServeSuccessJSON(map[string]interface{}{
  18005. "msg": "撤销明细成功",
  18006. })
  18007. return
  18008. } else {
  18009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18010. return
  18011. }
  18012. } else {
  18013. c.ServeSuccessJSON(map[string]interface{}{
  18014. "code": -10,
  18015. "msg": res2.ErrMsg,
  18016. })
  18017. }
  18018. } else {
  18019. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  18020. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  18021. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  18022. resp2, requestErr2 := http.Get(api2)
  18023. if requestErr2 != nil {
  18024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18025. return
  18026. }
  18027. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  18028. if ioErr2 != nil {
  18029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  18030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18031. return
  18032. }
  18033. var respJSON2 map[string]interface{}
  18034. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  18035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18037. return
  18038. }
  18039. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  18040. if err == nil {
  18041. c.ServeSuccessJSON(map[string]interface{}{
  18042. "msg": "撤销明细成功",
  18043. })
  18044. return
  18045. } else {
  18046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18047. return
  18048. }
  18049. }
  18050. } else {
  18051. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  18052. if err == nil {
  18053. c.ServeSuccessJSON(map[string]interface{}{
  18054. "msg": "退费成功",
  18055. })
  18056. } else {
  18057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18058. return
  18059. }
  18060. }
  18061. }
  18062. // 对账
  18063. func (c *HisApiController) GetCheckAccount() {
  18064. start_time := c.GetString("start_time")
  18065. end_time := c.GetString("end_time")
  18066. insutype := c.GetString("insutype")
  18067. clr_type := c.GetString("clr_type")
  18068. clr_org := c.GetString("clr_optins")
  18069. admin_user_id, _ := c.GetInt64("admin_user_id")
  18070. adminUser := c.GetAdminUserInfo()
  18071. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18072. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  18073. if len(clr_org) == 0 {
  18074. clr_org = miConfig.MdtrtareaAdmvs
  18075. }
  18076. timeLayout := "2006-01-02"
  18077. loc, _ := time.LoadLocation("Local")
  18078. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  18079. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  18080. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  18081. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  18082. fixmedins_setl_cnt := int64(len(orders))
  18083. var medfee_sumamt float64
  18084. var acct_pay float64
  18085. var fund_pay_sumamt float64
  18086. for _, item := range orders {
  18087. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  18088. acct_pay = acct_pay + item.AcctPay
  18089. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  18090. }
  18091. var user_name string
  18092. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18093. if role.ID == 0 {
  18094. user_name = "xxx"
  18095. } else {
  18096. user_name = role.UserName
  18097. }
  18098. var res ResultEight
  18099. var res10188 ResultEightFor10188
  18100. if config.IsOpen == 1 {
  18101. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18102. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  18103. "insutype=" + insutype +
  18104. "&clr_type=" + clr_type +
  18105. "&setl_optins=" + clr_org +
  18106. "&stmt_begndate=" + start_time +
  18107. "&stm_enddate=" + end_time +
  18108. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  18109. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  18110. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  18111. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  18112. "&fixmedins_code=" + miConfig.Code +
  18113. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  18114. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18115. "&secret_key=" + miConfig.SecretKey +
  18116. "&org_name=" + miConfig.OrgName +
  18117. "&doctor=" + user_name +
  18118. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  18119. fmt.Println(api)
  18120. resp, requestErr := http.Get(api)
  18121. if requestErr != nil {
  18122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18123. return
  18124. }
  18125. body, ioErr := ioutil.ReadAll(resp.Body)
  18126. fmt.Println(body)
  18127. if ioErr != nil {
  18128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18130. return
  18131. }
  18132. var respJSON map[string]interface{}
  18133. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18136. return
  18137. }
  18138. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18139. userJSONBytes, _ := json.Marshal(respJSON)
  18140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18141. utils.ErrorLog("解析失败:%v", err)
  18142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18143. return
  18144. }
  18145. res.InfRefmsgid = res10188.InfRefmsgid
  18146. res.Output = res10188.Output
  18147. res.ErrMsg = res10188.ErrMsg
  18148. res.Cainfo = res10188.Cainfo
  18149. res.WarnMsg = res10188.WarnMsg
  18150. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  18151. res.Infcode = infocode
  18152. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18153. if clr_type != "9903" {
  18154. clr_type = "51" // 就诊 ID(来自2201接口返回)
  18155. } else {
  18156. clr_type = "99" // 就诊 ID(来自2201接口返回)
  18157. }
  18158. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  18159. "insutype=" + insutype +
  18160. "&clr_type=" + clr_type +
  18161. "&setl_optins=" + clr_org +
  18162. "&stmt_begndate=" + start_time +
  18163. "&stm_enddate=" + end_time +
  18164. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  18165. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  18166. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  18167. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  18168. "&fixmedins_code=" + miConfig.Code +
  18169. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  18170. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18171. "&secret_key=" + miConfig.SecretKey +
  18172. "&org_name=" + miConfig.OrgName +
  18173. "&doctor=" + user_name
  18174. resp, requestErr := http.Get(api)
  18175. if requestErr != nil {
  18176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18177. return
  18178. }
  18179. body, ioErr := ioutil.ReadAll(resp.Body)
  18180. if ioErr != nil {
  18181. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18183. return
  18184. }
  18185. var respJSON map[string]interface{}
  18186. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18187. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18189. return
  18190. }
  18191. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18192. result, _ := json.Marshal(respJSON)
  18193. fmt.Println("log")
  18194. fmt.Println(string(result))
  18195. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  18196. utils.ErrorLog("解析失败:%v", err)
  18197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18198. return
  18199. }
  18200. res.InfRefmsgid = res10188.InfRefmsgid
  18201. res.Output = res10188.Output
  18202. res.ErrMsg = res10188.ErrMsg
  18203. res.Cainfo = res10188.Cainfo
  18204. res.WarnMsg = res10188.WarnMsg
  18205. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  18206. res.Infcode = infocode
  18207. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18208. var baseParams models.BaseParams
  18209. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18210. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18211. baseParams.SecretKey = miConfig.SecretKey
  18212. baseParams.OrgName = miConfig.OrgName
  18213. baseParams.FixmedinsCode = miConfig.Code
  18214. baseParams.EncKey = miConfig.EncKey
  18215. baseParams.AppSecret = miConfig.AppSecret
  18216. baseParams.SignKey = miConfig.SignKey
  18217. baseParams.AppID = miConfig.Code
  18218. baseParams.Doctor = role.UserName
  18219. baseParams.RequestUrl = miConfig.Url
  18220. businessParams := models.BusinessParams{
  18221. Insutype: insutype,
  18222. ClrType: clr_type,
  18223. SetlOptins: clr_org,
  18224. StmtBegndate: start_time,
  18225. StmtEnddate: end_time,
  18226. MedfeeSumamt: medfee_sumamt,
  18227. FundPaySumamt: fund_pay_sumamt,
  18228. AcctPay: acct_pay,
  18229. FixmedinsSetlCnt: fixmedins_setl_cnt,
  18230. }
  18231. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  18232. fmt.Println(requestLog)
  18233. fmt.Println(result)
  18234. fmt.Println(err_msg)
  18235. var dat map[string]interface{}
  18236. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18237. fmt.Println(dat)
  18238. } else {
  18239. fmt.Println(err)
  18240. }
  18241. userJSONBytes, _ := json.Marshal(dat)
  18242. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18243. utils.ErrorLog("解析失败:%v", err)
  18244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18245. return
  18246. }
  18247. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18248. var baseParams models.BaseParams
  18249. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18250. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18251. baseParams.SecretKey = miConfig.SecretKey
  18252. baseParams.OrgName = miConfig.OrgName
  18253. baseParams.FixmedinsCode = miConfig.Code
  18254. baseParams.EncKey = miConfig.EncKey
  18255. baseParams.AppSecret = miConfig.AppSecret
  18256. baseParams.SignKey = miConfig.SignKey
  18257. baseParams.AppID = miConfig.Code
  18258. baseParams.Doctor = role.UserName
  18259. baseParams.RequestUrl = miConfig.Url
  18260. baseParams.AccessKey = miConfig.AccessKey
  18261. businessParams := models.BusinessParams{
  18262. Insutype: insutype,
  18263. ClrType: clr_type,
  18264. SetlOptins: "430822",
  18265. StmtBegndate: start_time,
  18266. StmtEnddate: end_time,
  18267. MedfeeSumamt: medfee_sumamt,
  18268. FundPaySumamt: fund_pay_sumamt,
  18269. AcctPay: acct_pay,
  18270. FixmedinsSetlCnt: fixmedins_setl_cnt,
  18271. }
  18272. 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)
  18273. fmt.Println(requestLog)
  18274. fmt.Println(result)
  18275. var dat map[string]interface{}
  18276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18277. fmt.Println(dat)
  18278. } else {
  18279. fmt.Println(err)
  18280. }
  18281. userJSONBytes, _ := json.Marshal(dat)
  18282. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18283. utils.ErrorLog("解析失败:%v", err)
  18284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18285. return
  18286. }
  18287. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18288. var baseParams models.BaseParams
  18289. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18290. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18291. baseParams.SecretKey = miConfig.SecretKey
  18292. baseParams.OrgName = miConfig.OrgName
  18293. baseParams.FixmedinsCode = miConfig.Code
  18294. baseParams.EncKey = miConfig.EncKey
  18295. baseParams.AppSecret = miConfig.AppSecret
  18296. baseParams.SignKey = miConfig.SignKey
  18297. baseParams.AppID = miConfig.Code
  18298. baseParams.Doctor = role.UserName
  18299. baseParams.RequestUrl = miConfig.Url
  18300. businessParams := models.BusinessParams{
  18301. Insutype: insutype,
  18302. ClrType: clr_type,
  18303. SetlOptins: clr_org,
  18304. StmtBegndate: start_time,
  18305. StmtEnddate: end_time,
  18306. MedfeeSumamt: medfee_sumamt,
  18307. FundPaySumamt: fund_pay_sumamt,
  18308. AcctPay: acct_pay,
  18309. FixmedinsSetlCnt: fixmedins_setl_cnt,
  18310. }
  18311. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  18312. fmt.Println(requestLog)
  18313. fmt.Println(result)
  18314. fmt.Println(err_msg)
  18315. var dat map[string]interface{}
  18316. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18317. fmt.Println(dat)
  18318. } else {
  18319. fmt.Println(err)
  18320. }
  18321. userJSONBytes, _ := json.Marshal(dat)
  18322. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18323. utils.ErrorLog("解析失败:%v", err)
  18324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18325. return
  18326. }
  18327. } else {
  18328. if len(clr_type) == 0 {
  18329. clr_type = "11"
  18330. }
  18331. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  18332. "insutype=" + insutype +
  18333. "&clr_type=" + clr_type +
  18334. "&setl_optins=" + clr_org +
  18335. "&stmt_begndate=" + start_time +
  18336. "&stm_enddate=" + end_time +
  18337. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  18338. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  18339. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  18340. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  18341. "&fixmedins_code=" + miConfig.Code +
  18342. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  18343. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18344. "&secret_key=" + miConfig.SecretKey +
  18345. "&org_name=" + miConfig.OrgName +
  18346. "&doctor=" + user_name
  18347. fmt.Println(api)
  18348. resp, requestErr := http.Get(api)
  18349. if requestErr != nil {
  18350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18351. return
  18352. }
  18353. body, ioErr := ioutil.ReadAll(resp.Body)
  18354. fmt.Println(body)
  18355. if ioErr != nil {
  18356. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18358. return
  18359. }
  18360. var respJSON map[string]interface{}
  18361. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18362. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18364. return
  18365. }
  18366. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18367. userJSONBytes, _ := json.Marshal(respJSON)
  18368. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18369. utils.ErrorLog("解析失败:%v", err)
  18370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18371. return
  18372. }
  18373. }
  18374. if res.Infcode == 0 {
  18375. if res.Output.Stmtinfo.StmtRslt == "0" {
  18376. micc := &models.MedicalInsuranceCostCompare{
  18377. StartTime: startime.Unix(),
  18378. EndTime: endtime.Unix(),
  18379. Insutype: insutype,
  18380. CheckType: 1,
  18381. Num: fixmedins_setl_cnt,
  18382. Mtime: time.Now().Unix(),
  18383. Status: 1,
  18384. UserOrgId: adminUser.CurrentOrgId,
  18385. CostTotal: medfee_sumamt,
  18386. FuncTotal: fund_pay_sumamt,
  18387. PsnPay: acct_pay,
  18388. Creator: admin_user_id,
  18389. Ctime: time.Now().Unix(),
  18390. ClrType: clr_type,
  18391. }
  18392. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  18393. if err == nil {
  18394. c.ServeSuccessJSON(map[string]interface{}{
  18395. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  18396. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  18397. })
  18398. } else {
  18399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18400. }
  18401. } else {
  18402. c.ServeSuccessJSON(map[string]interface{}{
  18403. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  18404. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  18405. })
  18406. }
  18407. } else {
  18408. c.ServeSuccessJSON(map[string]interface{}{
  18409. "code": -10,
  18410. "msg": res.ErrMsg,
  18411. })
  18412. }
  18413. }
  18414. }
  18415. func (c *HisApiController) Check310() {
  18416. adminUser := c.GetAdminUserInfo()
  18417. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18418. var user_name string
  18419. user_name = "高慧裕"
  18420. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  18421. "insutype=" + "310" +
  18422. "&clr_type=" + "" +
  18423. "&setl_optins=" + "441202" +
  18424. "&stmt_begndate=" + "2022-03-01" +
  18425. "&stm_enddate=" + "2022-03-31" +
  18426. "&medfee_sumamt=" + "194930.12" +
  18427. "&fund_pay_sumamt=" + "188741.46" +
  18428. "&acct_pay=" + "0" +
  18429. "&fixmedins_setl_cnt=" + "452" +
  18430. "&fixmedins_code=" + miConfig.Code +
  18431. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  18432. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18433. "&secret_key=" + miConfig.SecretKey +
  18434. "&org_name=" + miConfig.OrgName +
  18435. "&doctor=" + user_name
  18436. fmt.Println(api)
  18437. resp, requestErr := http.Get(api)
  18438. if requestErr != nil {
  18439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18440. return
  18441. }
  18442. body, ioErr := ioutil.ReadAll(resp.Body)
  18443. fmt.Println(body)
  18444. if ioErr != nil {
  18445. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18447. return
  18448. }
  18449. var respJSON map[string]interface{}
  18450. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18453. return
  18454. }
  18455. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18456. userJSONBytes, _ := json.Marshal(respJSON)
  18457. var res ResultEight
  18458. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18459. utils.ErrorLog("解析失败:%v", err)
  18460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18461. return
  18462. }
  18463. }
  18464. func (c *HisApiController) Check390() {
  18465. adminUser := c.GetAdminUserInfo()
  18466. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18467. var user_name string
  18468. user_name = "高慧裕"
  18469. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  18470. "insutype=" + "390" +
  18471. "&clr_type=" + "" +
  18472. "&setl_optins=" + "441202" +
  18473. "&stmt_begndate=" + "2022-03-01" +
  18474. "&stm_enddate=" + "2022-03-31" +
  18475. "&medfee_sumamt=" + "1068448.89" +
  18476. "&fund_pay_sumamt=" + "1014677.62" +
  18477. "&acct_pay=" + "0" +
  18478. "&fixmedins_setl_cnt=" + "1950" +
  18479. "&fixmedins_code=" + miConfig.Code +
  18480. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  18481. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18482. "&secret_key=" + miConfig.SecretKey +
  18483. "&org_name=" + miConfig.OrgName +
  18484. "&doctor=" + user_name
  18485. fmt.Println(api)
  18486. resp, requestErr := http.Get(api)
  18487. if requestErr != nil {
  18488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18489. return
  18490. }
  18491. body, ioErr := ioutil.ReadAll(resp.Body)
  18492. fmt.Println(body)
  18493. if ioErr != nil {
  18494. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18496. return
  18497. }
  18498. var respJSON map[string]interface{}
  18499. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18500. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18502. return
  18503. }
  18504. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18505. userJSONBytes, _ := json.Marshal(respJSON)
  18506. var res ResultEight
  18507. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18508. utils.ErrorLog("解析失败:%v", err)
  18509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18510. return
  18511. }
  18512. }
  18513. // 对账明细
  18514. func (c *HisApiController) GetCheckDetailAccount() {
  18515. start_time := c.GetString("start_time")
  18516. end_time := c.GetString("end_time")
  18517. admin_user_id, _ := c.GetInt64("admin_user_id")
  18518. adminUser := c.GetAdminUserInfo()
  18519. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18520. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  18521. timeLayout := "2006-01-02"
  18522. loc, _ := time.LoadLocation("Local")
  18523. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  18524. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  18525. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  18526. rand.Seed(time.Now().UnixNano())
  18527. num := rand.Intn(30000)
  18528. Mkdir(miConfig.OrgName)
  18529. file := strconv.FormatInt(int64(num), 10)
  18530. file_name := file + ".txt"
  18531. zip_name := file + ".zip"
  18532. zip_path := miConfig.OrgName + "/" + zip_name
  18533. file_path := miConfig.OrgName + "/" + file_name
  18534. decimal.DivisionPrecision = 2
  18535. var medfee_sumamt float64
  18536. var psn_cash_pay float64
  18537. var fund_pay_sumamt float64
  18538. fixmedins_setl_cnt := int64(len(orders))
  18539. for _, item := range orders {
  18540. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  18541. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  18542. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  18543. }
  18544. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  18545. defer f.Close()
  18546. if err != nil {
  18547. fmt.Println(err.Error())
  18548. } else {
  18549. for _, item := range orders {
  18550. var refd_setl_flag string
  18551. if item.OrderStatus == 2 {
  18552. refd_setl_flag = "0"
  18553. var str string
  18554. str = item.SetlId + " " +
  18555. item.MdtrtId + " " +
  18556. item.PsnNo + " " +
  18557. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  18558. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  18559. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  18560. _, err = f.Write([]byte(str))
  18561. }
  18562. if item.OrderStatus == 3 {
  18563. var str string
  18564. str = item.SetlId + " " +
  18565. item.MdtrtId + " " +
  18566. item.PsnNo + " " +
  18567. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  18568. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  18569. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  18570. _, err = f.Write([]byte(str))
  18571. var str2 string
  18572. str2 = item.SetlId + " " +
  18573. item.MdtrtId + " " +
  18574. item.PsnNo + " " +
  18575. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  18576. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  18577. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  18578. _, err = f.Write([]byte(str2))
  18579. }
  18580. }
  18581. }
  18582. Zip(file_path, zip_path)
  18583. fmt.Println(ReadFile(zip_path))
  18584. fmt.Println(string(ReadFile(zip_path)))
  18585. if config.IsOpen == 1 {
  18586. var user_name string
  18587. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18588. if role.ID == 0 {
  18589. user_name = "管理员"
  18590. } else {
  18591. user_name = role.UserName
  18592. }
  18593. baseParams := models.BaseParams{
  18594. SecretKey: miConfig.SecretKey,
  18595. FixmedinsCode: miConfig.Code,
  18596. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  18597. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  18598. OrgName: miConfig.OrgName,
  18599. Doctor: user_name,
  18600. }
  18601. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  18602. var dat map[string]interface{}
  18603. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18604. fmt.Println(dat)
  18605. } else {
  18606. fmt.Println(err)
  18607. }
  18608. userJSONBytes, _ := json.Marshal(dat)
  18609. var res ResultNine
  18610. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18611. utils.ErrorLog("解析失败:%v", err)
  18612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18613. return
  18614. }
  18615. if res.Infcode == 0 {
  18616. fileNo := res.Output.FileQuryNo
  18617. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  18618. "file_qury_no=" + fileNo +
  18619. "&setl_optins=" + "定点医保中心" +
  18620. "&stmt_begndate=" + start_time +
  18621. "&stm_enddate=" + end_time +
  18622. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  18623. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  18624. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  18625. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  18626. "&fixmedins_code=" + miConfig.Code +
  18627. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  18628. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18629. "&secret_key=" + miConfig.SecretKey +
  18630. "&org_name=" + miConfig.OrgName +
  18631. "&doctor=" + user_name
  18632. resp, requestErr := http.Get(api)
  18633. if requestErr != nil {
  18634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18635. return
  18636. }
  18637. body, ioErr := ioutil.ReadAll(resp.Body)
  18638. if ioErr != nil {
  18639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18641. return
  18642. }
  18643. var respJSON map[string]interface{}
  18644. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18647. return
  18648. }
  18649. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18650. userJSONBytes, _ := json.Marshal(respJSON)
  18651. var res ResultTen
  18652. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18653. utils.ErrorLog("解析失败:%v", err)
  18654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18655. return
  18656. }
  18657. if res.Infcode == 0 {
  18658. service.Gdyb9102(baseParams, zip_name, fileNo)
  18659. micc := &models.MedicalInsuranceCostCompare{
  18660. StartTime: startime.Unix(),
  18661. EndTime: endtime.Unix(),
  18662. Insutype: "0",
  18663. CheckType: 2,
  18664. Num: fixmedins_setl_cnt,
  18665. Mtime: time.Now().Unix(),
  18666. Status: 1,
  18667. UserOrgId: adminUser.CurrentOrgId,
  18668. CostTotal: medfee_sumamt,
  18669. FuncTotal: fund_pay_sumamt,
  18670. PsnPay: psn_cash_pay,
  18671. Creator: admin_user_id,
  18672. Ctime: time.Now().Unix(),
  18673. }
  18674. service.CreateMedicalInsuranceCostCompareRecord(micc)
  18675. c.ServeSuccessJSON(map[string]interface{}{
  18676. "msg": "明细对账成功",
  18677. })
  18678. }
  18679. } else {
  18680. }
  18681. }
  18682. }
  18683. type CustomOrderInfo struct {
  18684. Name string
  18685. Spec string
  18686. Unit string
  18687. Count float64
  18688. Price float64
  18689. Total float64
  18690. }
  18691. func (c *HisApiController) GetBatchSettleAccounts() {
  18692. admin_user_id, _ := c.GetInt64("admin_user_id")
  18693. order_ids := c.GetString("order_ids")
  18694. order_ids_arr := strings.Split(order_ids, ",")
  18695. data3 := []map[string]interface{}{}
  18696. for _, item := range order_ids_arr {
  18697. id, _ := strconv.ParseInt(item, 10, 64)
  18698. order_id := id
  18699. adminUser := c.GetAdminUserInfo()
  18700. order, _ := service.GetHisOrderByID(order_id)
  18701. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18702. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  18703. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  18704. orderInfos = append(orderInfos, orderInfos_two...)
  18705. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  18706. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  18707. var diagnosis_ids []string
  18708. if his.ID > 0 {
  18709. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  18710. } else {
  18711. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  18712. }
  18713. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  18714. var dia_config []*models.HisXtDiagnoseConfig
  18715. var name string
  18716. for _, item := range diagnosis_ids {
  18717. id, _ := strconv.ParseInt(item, 10, 64)
  18718. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18719. dia_config = append(dia_config, &diagnosisConfig)
  18720. if len(name) == 0 {
  18721. name = diagnosisConfig.ClassName
  18722. }
  18723. //} else {
  18724. // name = name + "," + diagnosisConfig.ClassName
  18725. //}
  18726. }
  18727. var bedCostTotal float64 = 0 //床位总费
  18728. var bedCostSelfTotal float64 = 0 //床位自费
  18729. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18730. var bedSelfTotal float64 = 0 //床位部分项目自费
  18731. var bedInscpTotal float64 = 0 //床位部分项目自费
  18732. var operationCostTotal float64 = 0 //手术费
  18733. var operationCostSelfTotal float64 = 0 //手术费
  18734. var operationCostPartSelfTotal float64 = 0 //手术费
  18735. var operationSelfTotal float64 = 0 //床位部分项目自费
  18736. var operationInscpTotal float64 = 0 //床位部分项目自费
  18737. var otherCostTotal float64 = 0 //其他费用
  18738. var otherCostSelfTotal float64 = 0 //其他费用
  18739. var otherCostPartSelfTotal float64 = 0 //其他费用
  18740. var otherSelfTotal float64 = 0 //床位部分项目自费
  18741. var otherInscpTotal float64 = 0 //床位部分项目自费
  18742. var materialCostTotal float64 = 0 //材料费
  18743. var materialCostSelfTotal float64 = 0 //材料费
  18744. var materialCostPartSelfTotal float64 = 0 //材料费
  18745. var materialSelfTotal float64 = 0 //床位部分项目自费
  18746. var materialInscpTotal float64 = 0 //床位部分项目自费
  18747. var westernMedicineCostTotal float64 = 0 //西药费
  18748. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18749. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18750. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  18751. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  18752. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18753. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18754. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18755. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  18756. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  18757. var checkCostTotal float64 = 0 //检查费
  18758. var checkCostSelfTotal float64 = 0 //检查费
  18759. var checkCostPartSelfTotal float64 = 0 //检查费
  18760. var checkSelfTotal float64 = 0 //床位部分项目自费
  18761. var checkInscpTotal float64 = 0 //床位部分项目自费
  18762. var laboratoryCostTotal float64 = 0 //化验费
  18763. var laboratoryCostSelfTotal float64 = 0 //化验费
  18764. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18765. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  18766. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  18767. var treatCostTotal float64 = 0 //治疗费用
  18768. var treatCostSelfTotal float64 = 0 //治疗费用
  18769. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18770. var treatSelfTotal float64 = 0 //床位部分项目自费
  18771. var treatInscpTotal float64 = 0 //床位部分项目自费
  18772. decimal.DivisionPrecision = 2
  18773. for _, item := range orderInfos {
  18774. if item.MedChrgitmType == "01" { //床位费
  18775. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18776. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18777. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18778. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18779. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  18780. }
  18781. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  18782. if item.MedChrgitmType == "03" { //检查费
  18783. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18784. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18785. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18786. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18787. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  18788. }
  18789. } else {
  18790. if item.MedChrgitmType == "03" { //检查费
  18791. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18792. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18793. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18794. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18795. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  18796. }
  18797. }
  18798. if item.MedChrgitmType == "04" { //化验费
  18799. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18800. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18801. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18802. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18803. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  18804. }
  18805. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  18806. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18807. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18808. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18809. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18810. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  18811. }
  18812. if item.MedChrgitmType == "06" { //手术费
  18813. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18814. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18815. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18816. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18817. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  18818. }
  18819. if item.MedChrgitmType == "08" { //材料费
  18820. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18821. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18822. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18823. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18824. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  18825. }
  18826. if item.MedChrgitmType == "09" { //西药费
  18827. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18828. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18829. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18830. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18831. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  18832. }
  18833. if item.MedChrgitmType == "11" { //中成费
  18834. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18835. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18836. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18837. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18838. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  18839. }
  18840. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  18841. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18842. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18843. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18844. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18845. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  18846. }
  18847. }
  18848. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18849. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  18850. var user_name string
  18851. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18852. if role.ID == 0 {
  18853. user_name = "管理员"
  18854. } else {
  18855. user_name = role.UserName
  18856. }
  18857. baseParams := models.BaseParams{
  18858. SecretKey: miConfig.SecretKey,
  18859. FixmedinsCode: miConfig.Code,
  18860. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  18861. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  18862. OrgName: miConfig.OrgName,
  18863. Doctor: user_name,
  18864. RequestUrl: miConfig.Url,
  18865. AccessKey: miConfig.AccessKey,
  18866. }
  18867. businessParams := models.BusinessParams{
  18868. PsnNo: order.PsnNo,
  18869. MdtrtId: order.MdtrtId,
  18870. SetlId: order.SetlId,
  18871. }
  18872. var res ResultEleven
  18873. var resEleven10265 ResultEleven10265
  18874. if config.IsOpen == 1 {
  18875. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  18876. result := service.Gdyb5203(baseParams, businessParams)
  18877. service.Gdyb5204(baseParams, businessParams)
  18878. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  18879. var dat map[string]interface{}
  18880. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18881. fmt.Println(dat)
  18882. } else {
  18883. fmt.Println(err)
  18884. }
  18885. userJSONBytes, _ := json.Marshal(dat)
  18886. if miConfig.Code == "H15049901371" {
  18887. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  18888. utils.ErrorLog("解析失败:%v", err)
  18889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18890. return
  18891. }
  18892. res.InfRefmsgid = resEleven10265.InfRefmsgid
  18893. res.Output = resEleven10265.Output
  18894. res.ErrMsg = resEleven10265.ErrMsg
  18895. res.Cainfo = resEleven10265.Cainfo
  18896. res.WarnMsg = resEleven10265.WarnMsg
  18897. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  18898. res.Infcode = infocode
  18899. } else {
  18900. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18901. utils.ErrorLog("解析失败:%v", err)
  18902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18903. return
  18904. }
  18905. }
  18906. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18907. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  18908. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  18909. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  18910. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  18911. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18912. var doctor_name string
  18913. if roles.ID == 0 {
  18914. doctor_name = "管理员"
  18915. } else {
  18916. doctor_name = roles.UserName
  18917. }
  18918. yiliao_leibie := ""
  18919. switch order.MedType {
  18920. case "11":
  18921. yiliao_leibie = "普通门诊"
  18922. break
  18923. case "12":
  18924. yiliao_leibie = "门诊挂号"
  18925. break
  18926. case "13":
  18927. yiliao_leibie = "急诊"
  18928. break
  18929. case "14":
  18930. yiliao_leibie = "门诊特殊病"
  18931. break
  18932. case "15":
  18933. yiliao_leibie = "门诊统筹"
  18934. break
  18935. case "16":
  18936. yiliao_leibie = "门诊慢性病"
  18937. break
  18938. case "21":
  18939. yiliao_leibie = "普通住院"
  18940. break
  18941. }
  18942. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  18943. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  18944. if res.Infcode == 0 {
  18945. data2 := map[string]interface{}{
  18946. "diagnosis": name,
  18947. "order_infos": orderInfos,
  18948. "number": order.MdtrtId,
  18949. "date": order.SettleAccountsDate,
  18950. "charge_admin": charge_admin,
  18951. "printor_admin": printor_admin,
  18952. "info": res.Output.Setlinfo,
  18953. "order": order,
  18954. "bedCostTotal": bedCostTotal,
  18955. "bedCostSelfTotal": bedCostSelfTotal,
  18956. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  18957. "bedSelfTotal": bedSelfTotal,
  18958. "bedInscpTotal": bedInscpTotal,
  18959. "operationCostTotal": operationCostTotal,
  18960. "operationCostSelfTotal": operationCostSelfTotal,
  18961. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  18962. "operationSelfTotal": operationSelfTotal,
  18963. "operationInscpTotal": operationInscpTotal,
  18964. "otherCostTotal": otherCostTotal,
  18965. "otherCostSelfTotal": otherCostSelfTotal,
  18966. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  18967. "otherSelfTotal": otherSelfTotal,
  18968. "otherInscpTotal": otherInscpTotal,
  18969. "materialCostTotal": materialCostTotal,
  18970. "materialCostSelfTotal": materialCostSelfTotal,
  18971. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  18972. "materialSelfTotal": materialSelfTotal,
  18973. "materialInscpTotal": materialInscpTotal,
  18974. "westernMedicineCostTotal": westernMedicineCostTotal,
  18975. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  18976. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  18977. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  18978. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  18979. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  18980. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  18981. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  18982. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  18983. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  18984. "checkCostTotal": checkCostTotal,
  18985. "checkCostSelfTotal": checkCostSelfTotal,
  18986. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  18987. "checkSelfTotal": checkSelfTotal,
  18988. "checkInscpTotal": checkInscpTotal,
  18989. "laboratoryCostTotal": laboratoryCostTotal,
  18990. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  18991. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  18992. "laboratorySelfTotal": laboratorySelfTotal,
  18993. "laboratoryInscpTotal": laboratoryInscpTotal,
  18994. "treatCostTotal": treatCostTotal,
  18995. "treatCostSelfTotal": treatCostSelfTotal,
  18996. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  18997. "treatSelfTotal": treatSelfTotal,
  18998. "treatInscpTotal": treatInscpTotal,
  18999. "doctor_info": doctor_info,
  19000. "doctor_code": adminRole_two.DoctorCode,
  19001. "doctor_name": doctor_name,
  19002. "health_card_no": order.PsnNo,
  19003. "department": departments.Name,
  19004. "yiliao_leibie": yiliao_leibie,
  19005. "after_money": order.AccountPrice,
  19006. "patient": patient,
  19007. "org_name": miConfig.OrgName,
  19008. "org_code": miConfig.Code,
  19009. "order_number": order.Number,
  19010. "his_hospital": his_hospital,
  19011. "his": his,
  19012. "dia_config": dia_config,
  19013. "psn_cash_pay": order.PsnCashPay,
  19014. //"check_order_info": cus_slice,
  19015. }
  19016. data3 = append(data3, data2)
  19017. }
  19018. }
  19019. }
  19020. c.ServeSuccessJSON(map[string]interface{}{
  19021. "infos": data3,
  19022. })
  19023. }
  19024. func (c *HisApiController) GetSettleAccounts() {
  19025. //id, _ := c.GetInt64("id")
  19026. //record_time := c.GetString("record_time")
  19027. order_id, _ := c.GetInt64("order_id")
  19028. admin_user_id, _ := c.GetInt64("admin_user_id")
  19029. //timeLayout := "2006-01-02"
  19030. //loc, _ := time.LoadLocation("Local")
  19031. //
  19032. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  19033. //if err != nil {
  19034. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19035. // return
  19036. //}
  19037. //recordDateTime := theTime.Unix()
  19038. adminUser := c.GetAdminUserInfo()
  19039. order, _ := service.GetHisOrderByID(order_id)
  19040. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19041. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  19042. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  19043. orderInfos = append(orderInfos, orderInfos_two...)
  19044. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  19045. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  19046. var diagnosis_ids []string
  19047. if his.ID > 0 {
  19048. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  19049. } else {
  19050. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  19051. }
  19052. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  19053. var dia_config []*models.HisXtDiagnoseConfig
  19054. var name string
  19055. for _, item := range diagnosis_ids {
  19056. id, _ := strconv.ParseInt(item, 10, 64)
  19057. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19058. dia_config = append(dia_config, &diagnosisConfig)
  19059. if len(name) == 0 {
  19060. name = diagnosisConfig.ClassName
  19061. } else {
  19062. name = name + "," + diagnosisConfig.ClassName
  19063. }
  19064. }
  19065. if patient.UserOrgId == 10215 {
  19066. name = "慢性肾功能不全(血透治疗)"
  19067. }
  19068. var bedCostTotal float64 = 0 //床位总费
  19069. var bedCostSelfTotal float64 = 0 //床位自费
  19070. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19071. var bedSelfTotal float64 = 0 //床位部分项目自费
  19072. var bedInscpTotal float64 = 0 //床位部分项目自费
  19073. var operationCostTotal float64 = 0 //手术费
  19074. var operationCostSelfTotal float64 = 0 //手术费
  19075. var operationCostPartSelfTotal float64 = 0 //手术费
  19076. var operationSelfTotal float64 = 0 //床位部分项目自费
  19077. var operationInscpTotal float64 = 0 //床位部分项目自费
  19078. var otherCostTotal float64 = 0 //其他费用
  19079. var otherCostSelfTotal float64 = 0 //其他费用
  19080. var otherCostPartSelfTotal float64 = 0 //其他费用
  19081. var otherSelfTotal float64 = 0 //床位部分项目自费
  19082. var otherInscpTotal float64 = 0 //床位部分项目自费
  19083. var materialCostTotal float64 = 0 //材料费
  19084. var materialCostSelfTotal float64 = 0 //材料费
  19085. var materialCostPartSelfTotal float64 = 0 //材料费
  19086. var materialSelfTotal float64 = 0 //床位部分项目自费
  19087. var materialInscpTotal float64 = 0 //床位部分项目自费
  19088. var westernMedicineCostTotal float64 = 0 //西药费
  19089. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19090. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19091. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  19092. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  19093. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19094. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19095. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19096. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  19097. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  19098. var checkCostTotal float64 = 0 //检查费
  19099. var checkCostSelfTotal float64 = 0 //检查费
  19100. var checkCostPartSelfTotal float64 = 0 //检查费
  19101. var checkSelfTotal float64 = 0 //床位部分项目自费
  19102. var checkInscpTotal float64 = 0 //床位部分项目自费
  19103. var laboratoryCostTotal float64 = 0 //化验费
  19104. var laboratoryCostSelfTotal float64 = 0 //化验费
  19105. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19106. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  19107. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  19108. var treatCostTotal float64 = 0 //治疗费用
  19109. var treatCostSelfTotal float64 = 0 //治疗费用
  19110. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19111. var treatSelfTotal float64 = 0 //床位部分项目自费
  19112. var treatInscpTotal float64 = 0 //床位部分项目自费
  19113. decimal.DivisionPrecision = 2
  19114. for _, item := range orderInfos {
  19115. if item.MedChrgitmType == "01" { //床位费
  19116. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19117. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19118. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19119. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19120. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  19121. }
  19122. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  19123. if item.MedChrgitmType == "03" { //检查费
  19124. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19125. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19126. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19127. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19128. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  19129. }
  19130. } else {
  19131. if item.MedChrgitmType == "03" { //检查费
  19132. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19133. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19134. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19135. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19136. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  19137. }
  19138. }
  19139. if item.MedChrgitmType == "04" { //化验费
  19140. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19141. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19142. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19143. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19144. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  19145. }
  19146. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  19147. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19148. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19149. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19150. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19151. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  19152. }
  19153. if item.MedChrgitmType == "06" { //手术费
  19154. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19155. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19156. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19157. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19158. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  19159. }
  19160. if item.MedChrgitmType == "08" { //材料费
  19161. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19162. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19163. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19164. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19165. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  19166. }
  19167. if item.MedChrgitmType == "09" { //西药费
  19168. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19169. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19170. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19171. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19172. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  19173. }
  19174. if item.MedChrgitmType == "11" { //中成费
  19175. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19176. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19177. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19178. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19179. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  19180. }
  19181. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  19182. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19183. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19184. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19185. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19186. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  19187. }
  19188. }
  19189. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  19190. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  19191. var user_name string
  19192. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  19193. if role.ID == 0 {
  19194. user_name = "管理员"
  19195. } else {
  19196. user_name = role.UserName
  19197. }
  19198. baseParams := models.BaseParams{
  19199. SecretKey: miConfig.SecretKey,
  19200. FixmedinsCode: miConfig.Code,
  19201. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  19202. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  19203. OrgName: miConfig.OrgName,
  19204. Doctor: user_name,
  19205. RequestUrl: miConfig.Url,
  19206. AccessKey: miConfig.AccessKey,
  19207. }
  19208. businessParams := models.BusinessParams{
  19209. PsnNo: order.PsnNo,
  19210. MdtrtId: order.MdtrtId,
  19211. SetlId: order.SetlId,
  19212. }
  19213. var res ResultEleven
  19214. var resEleven10265 ResultEleven10265
  19215. if config.IsOpen == 1 {
  19216. if miConfig.MdtrtareaAdmvs == "421300" {
  19217. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  19218. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  19219. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  19220. resp, requestErr := http.Get(api)
  19221. if requestErr != nil {
  19222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19223. return
  19224. }
  19225. body, ioErr := ioutil.ReadAll(resp.Body)
  19226. if ioErr != nil {
  19227. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19229. return
  19230. }
  19231. var respJSON map[string]interface{}
  19232. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19233. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19235. return
  19236. }
  19237. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19238. result, _ := json.Marshal(respJSON)
  19239. fmt.Println("log")
  19240. fmt.Println(string(result))
  19241. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19242. utils.ErrorLog("解析失败:%v", err)
  19243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19244. return
  19245. }
  19246. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19247. var api string
  19248. if miConfig.MdtrtareaAdmvs == "320921" {
  19249. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  19250. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  19251. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  19252. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19253. } else {
  19254. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19255. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  19256. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  19257. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  19258. }
  19259. resp, requestErr := http.Get(api)
  19260. if requestErr != nil {
  19261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19262. return
  19263. }
  19264. body, ioErr := ioutil.ReadAll(resp.Body)
  19265. if ioErr != nil {
  19266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19268. return
  19269. }
  19270. var respJSON map[string]interface{}
  19271. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19274. return
  19275. }
  19276. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19277. result, _ := json.Marshal(respJSON)
  19278. fmt.Println("log")
  19279. fmt.Println(string(result))
  19280. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  19281. utils.ErrorLog("解析失败:%v", err)
  19282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19283. return
  19284. }
  19285. res.InfRefmsgid = resEleven10265.InfRefmsgid
  19286. res.Output = resEleven10265.Output
  19287. res.ErrMsg = resEleven10265.ErrMsg
  19288. res.Cainfo = resEleven10265.Cainfo
  19289. res.WarnMsg = resEleven10265.WarnMsg
  19290. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  19291. res.Infcode = infocode
  19292. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19293. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  19294. saveLog(result, requestLog, "5203", "结算单")
  19295. var dat map[string]interface{}
  19296. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19297. fmt.Println(dat)
  19298. } else {
  19299. fmt.Println(err)
  19300. }
  19301. userJSONBytes, _ := json.Marshal(dat)
  19302. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19303. utils.ErrorLog("解析失败:%v", err)
  19304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19305. return
  19306. }
  19307. } else if miConfig.MdtrtareaAdmvs == "360399" {
  19308. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  19309. fmt.Println(result3)
  19310. fmt.Println(requestLog3)
  19311. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  19312. fmt.Println(result2)
  19313. fmt.Println(requestLog2)
  19314. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  19315. saveLog(result, requestLog, "5203", "结算单")
  19316. var dat map[string]interface{}
  19317. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19318. fmt.Println(dat)
  19319. } else {
  19320. fmt.Println(err)
  19321. }
  19322. userJSONBytes, _ := json.Marshal(dat)
  19323. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19324. utils.ErrorLog("解析失败:%v", err)
  19325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19326. return
  19327. }
  19328. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19329. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  19330. saveLog(result, requestLog, "5203", "结算单")
  19331. var dat map[string]interface{}
  19332. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19333. fmt.Println(dat)
  19334. } else {
  19335. fmt.Println(err)
  19336. }
  19337. userJSONBytes, _ := json.Marshal(dat)
  19338. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19339. utils.ErrorLog("解析失败:%v", err)
  19340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19341. return
  19342. }
  19343. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19344. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  19345. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  19346. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  19347. resp, requestErr := http.Get(api)
  19348. if requestErr != nil {
  19349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19350. return
  19351. }
  19352. body, ioErr := ioutil.ReadAll(resp.Body)
  19353. if ioErr != nil {
  19354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19356. return
  19357. }
  19358. var respJSON map[string]interface{}
  19359. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19362. return
  19363. }
  19364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19365. result, _ := json.Marshal(respJSON)
  19366. fmt.Println("log")
  19367. fmt.Println(string(result))
  19368. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  19369. utils.ErrorLog("解析失败:%v", err)
  19370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19371. return
  19372. }
  19373. res.InfRefmsgid = resEleven10265.InfRefmsgid
  19374. res.Output = resEleven10265.Output
  19375. res.ErrMsg = resEleven10265.ErrMsg
  19376. res.Cainfo = resEleven10265.Cainfo
  19377. res.WarnMsg = resEleven10265.WarnMsg
  19378. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  19379. res.Infcode = infocode
  19380. } else {
  19381. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  19382. result := service.Gdyb5203(baseParams, businessParams)
  19383. //service.Gdyb5204(baseParams, businessParams)
  19384. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  19385. var dat map[string]interface{}
  19386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19387. fmt.Println(dat)
  19388. } else {
  19389. fmt.Println(err)
  19390. }
  19391. userJSONBytes, _ := json.Marshal(dat)
  19392. if miConfig.Code == "H15049901371" {
  19393. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  19394. utils.ErrorLog("解析失败:%v", err)
  19395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19396. return
  19397. }
  19398. res.InfRefmsgid = resEleven10265.InfRefmsgid
  19399. res.Output = resEleven10265.Output
  19400. res.ErrMsg = resEleven10265.ErrMsg
  19401. res.Cainfo = resEleven10265.Cainfo
  19402. res.WarnMsg = resEleven10265.WarnMsg
  19403. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  19404. res.Infcode = infocode
  19405. } else {
  19406. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19407. utils.ErrorLog("解析失败:%v", err)
  19408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19409. return
  19410. }
  19411. }
  19412. }
  19413. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  19414. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  19415. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  19416. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  19417. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  19418. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  19419. var doctor_name string
  19420. if roles.ID == 0 {
  19421. doctor_name = "管理员"
  19422. } else {
  19423. doctor_name = roles.UserName
  19424. }
  19425. yiliao_leibie := ""
  19426. switch order.MedType {
  19427. case "11":
  19428. yiliao_leibie = "普通门诊"
  19429. break
  19430. case "12":
  19431. yiliao_leibie = "门诊挂号"
  19432. break
  19433. case "13":
  19434. yiliao_leibie = "急诊"
  19435. break
  19436. case "14":
  19437. yiliao_leibie = "门诊特殊病"
  19438. break
  19439. case "15":
  19440. yiliao_leibie = "门诊统筹"
  19441. break
  19442. case "16":
  19443. yiliao_leibie = "门诊慢性病"
  19444. break
  19445. case "21":
  19446. yiliao_leibie = "普通住院"
  19447. break
  19448. }
  19449. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  19450. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  19451. if res.Infcode == 0 {
  19452. c.ServeSuccessJSON(map[string]interface{}{
  19453. "diagnosis": name,
  19454. "order_infos": orderInfos,
  19455. "number": order.MdtrtId,
  19456. "date": order.SettleAccountsDate,
  19457. "charge_admin": charge_admin,
  19458. "printor_admin": printor_admin,
  19459. "info": res.Output.Setlinfo,
  19460. "order": order,
  19461. "bedCostTotal": bedCostTotal,
  19462. "bedCostSelfTotal": bedCostSelfTotal,
  19463. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  19464. "bedSelfTotal": bedSelfTotal,
  19465. "bedInscpTotal": bedInscpTotal,
  19466. "operationCostTotal": operationCostTotal,
  19467. "operationCostSelfTotal": operationCostSelfTotal,
  19468. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  19469. "operationSelfTotal": operationSelfTotal,
  19470. "operationInscpTotal": operationInscpTotal,
  19471. "otherCostTotal": otherCostTotal,
  19472. "otherCostSelfTotal": otherCostSelfTotal,
  19473. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  19474. "otherSelfTotal": otherSelfTotal,
  19475. "otherInscpTotal": otherInscpTotal,
  19476. "materialCostTotal": materialCostTotal,
  19477. "materialCostSelfTotal": materialCostSelfTotal,
  19478. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  19479. "materialSelfTotal": materialSelfTotal,
  19480. "materialInscpTotal": materialInscpTotal,
  19481. "westernMedicineCostTotal": westernMedicineCostTotal,
  19482. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  19483. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  19484. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  19485. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  19486. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  19487. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  19488. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  19489. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  19490. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  19491. "checkCostTotal": checkCostTotal,
  19492. "checkCostSelfTotal": checkCostSelfTotal,
  19493. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  19494. "checkSelfTotal": checkSelfTotal,
  19495. "checkInscpTotal": checkInscpTotal,
  19496. "laboratoryCostTotal": laboratoryCostTotal,
  19497. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  19498. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  19499. "laboratorySelfTotal": laboratorySelfTotal,
  19500. "laboratoryInscpTotal": laboratoryInscpTotal,
  19501. "treatCostTotal": treatCostTotal,
  19502. "treatCostSelfTotal": treatCostSelfTotal,
  19503. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  19504. "treatSelfTotal": treatSelfTotal,
  19505. "treatInscpTotal": treatInscpTotal,
  19506. "doctor_info": doctor_info,
  19507. "doctor_code": adminRole_two.DoctorCode,
  19508. "doctor_name": doctor_name,
  19509. "health_card_no": order.PsnNo,
  19510. "department": departments.Name,
  19511. "yiliao_leibie": yiliao_leibie,
  19512. "after_money": order.AccountPrice,
  19513. "patient": patient,
  19514. "org_name": miConfig.OrgName,
  19515. "org_code": miConfig.Code,
  19516. "order_number": order.Number,
  19517. "his_hospital": his_hospital,
  19518. "his": his,
  19519. "dia_config": dia_config,
  19520. "psn_cash_pay": order.PsnCashPay,
  19521. //"check_order_info": cus_slice,
  19522. })
  19523. }
  19524. }
  19525. }
  19526. //func (c *HisApiController) CheckTreatment() {
  19527. // patient_id, _ := c.GetInt64("patient_id")
  19528. // id_card_no := c.GetString("id_card_no")
  19529. // insutype := c.GetString("insutype")
  19530. // med_type := c.GetString("med_type")
  19531. // admin_user_id, _ := c.GetInt64("admin_user_id")
  19532. //
  19533. // adminUser := c.GetAdminUserInfo()
  19534. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  19535. //
  19536. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  19537. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  19538. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  19539. //
  19540. // if miConfig.MdtrtareaAdmvs == "421300" {
  19541. // var res ResultTwo
  19542. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  19543. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19544. // "&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)
  19545. // resp, requestErr := http.Get(api)
  19546. // if requestErr != nil {
  19547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19548. // return
  19549. // }
  19550. //
  19551. // body, ioErr := ioutil.ReadAll(resp.Body)
  19552. // if ioErr != nil {
  19553. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19554. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19555. // return
  19556. // }
  19557. // var respJSON map[string]interface{}
  19558. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19559. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19560. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19561. // return
  19562. // }
  19563. //
  19564. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19565. // result, _ := json.Marshal(respJSON)
  19566. //
  19567. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  19568. // utils.ErrorLog("解析失败:%v", err)
  19569. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19570. // return
  19571. // }
  19572. //
  19573. // if res.Infcode == 0 {
  19574. //
  19575. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  19576. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19577. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  19578. // resp, requestErr := http.Get(api)
  19579. // if requestErr != nil {
  19580. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19581. // return
  19582. // }
  19583. //
  19584. // body, ioErr := ioutil.ReadAll(resp.Body)
  19585. // if ioErr != nil {
  19586. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19587. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19588. // return
  19589. // }
  19590. // var respJSON map[string]interface{}
  19591. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19592. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19593. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19594. // return
  19595. // }
  19596. // var res Result2001
  19597. //
  19598. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19599. // result2, _ := json.Marshal(respJSON)
  19600. //
  19601. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  19602. // utils.ErrorLog("解析失败:%v", err)
  19603. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19604. // return
  19605. // }
  19606. //
  19607. // if res.Infcode == 0 {
  19608. // c.ServeSuccessJSON(map[string]interface{}{
  19609. // "msg": res.Output.Trtinfo,
  19610. // })
  19611. // }
  19612. //
  19613. // } else {
  19614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  19615. // return
  19616. // }
  19617. //
  19618. // } else {
  19619. //
  19620. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  19621. // var dat map[string]interface{}
  19622. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19623. // fmt.Println(dat)
  19624. // } else {
  19625. // fmt.Println(err)
  19626. // }
  19627. // userJSONBytes, _ := json.Marshal(dat)
  19628. // var res ResultTwo
  19629. // var res10265 ResultTwo10265
  19630. // if miConfig.Code == "H15049901371" {
  19631. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  19632. // utils.ErrorLog("解析失败:%v", err)
  19633. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19634. // return
  19635. // }
  19636. // res.ErrMsg = res10265.ErrMsg
  19637. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  19638. // res.Infcode = infocode
  19639. // res.Output = res10265.Output
  19640. // res.InfRefmsgid = res10265.InfRefmsgid
  19641. // } else {
  19642. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19643. // utils.ErrorLog("解析失败:%v", err)
  19644. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19645. // return
  19646. // }
  19647. // }
  19648. //
  19649. // var user_name string
  19650. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  19651. // if role.ID == 0 {
  19652. // user_name = "xxx"
  19653. // } else {
  19654. // user_name = role.UserName
  19655. // }
  19656. //
  19657. // baseParams := models.BaseParams{
  19658. // SecretKey: miConfig.SecretKey,
  19659. // FixmedinsCode: miConfig.Code,
  19660. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  19661. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  19662. // OrgName: miConfig.OrgName,
  19663. // Doctor: user_name,
  19664. // }
  19665. //
  19666. // if config.IsOpen == 1 {
  19667. // if miConfig.Code == "H15049901371" {
  19668. // if med_type == "14" {
  19669. // if insutype == "390" {
  19670. // med_type = "9933"
  19671. // } else if insutype == "310" {
  19672. // med_type = "990502"
  19673. // }
  19674. // } else if med_type == "11" {
  19675. // med_type = "11"
  19676. // }
  19677. // }
  19678. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  19679. // var dat map[string]interface{}
  19680. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19681. // fmt.Println(dat)
  19682. // } else {
  19683. // fmt.Println(err)
  19684. // }
  19685. // var res Result2001
  19686. // var res10265 Result2001Org10265
  19687. // if miConfig.Code == "H15049901371" {
  19688. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  19689. // utils.ErrorLog("解析失败:%v", err)
  19690. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19691. // return
  19692. // }
  19693. // res.ErrMsg = res10265.ErrMsg
  19694. // res.Output = res10265.Output
  19695. // res.InfRefmsgid = res10265.InfRefmsgid
  19696. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  19697. // res.Infcode = infocode
  19698. // } else {
  19699. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  19700. // utils.ErrorLog("解析失败:%v", err)
  19701. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19702. // return
  19703. // }
  19704. // }
  19705. // if res.Infcode == 0 {
  19706. // c.ServeSuccessJSON(map[string]interface{}{
  19707. // "msg": res.Output.Trtinfo,
  19708. // })
  19709. // }
  19710. // }
  19711. // }
  19712. //}
  19713. //func (c *HisApiController) PutRecord() {
  19714. // id, _ := c.GetInt64("id")
  19715. // record_time := c.GetString("record_time")
  19716. // timeLayout := "2006-01-02"
  19717. // loc, _ := time.LoadLocation("Local")
  19718. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  19719. // if err != nil {
  19720. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19721. // return
  19722. // }
  19723. // recordDateTime := theTime.Unix()
  19724. //
  19725. // adminInfo := c.GetAdminUserInfo()
  19726. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  19727. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  19728. //
  19729. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  19730. //
  19731. // fmt.Println(miConfig.SecretKey)
  19732. //
  19733. // if patient == nil {
  19734. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  19735. // return
  19736. // }
  19737. // if len(patient.IdCardNo) == 0 {
  19738. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  19739. // return
  19740. // }
  19741. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  19742. // if config.IsOpen == 1 {
  19743. // 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
  19744. // resp, requestErr := http.Get(api)
  19745. // if requestErr != nil {
  19746. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19747. // return
  19748. // }
  19749. // defer resp.Body.Close()
  19750. // body, ioErr := ioutil.ReadAll(resp.Body)
  19751. // if ioErr != nil {
  19752. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19753. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19754. // return
  19755. // }
  19756. // var respJSON map[string]interface{}
  19757. //
  19758. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19759. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19761. // return
  19762. // }
  19763. //
  19764. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19765. // userJSONBytes, _ := json.Marshal(userJSON)
  19766. // var res ResultTwo
  19767. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19768. // utils.ErrorLog("解析失败:%v", err)
  19769. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19770. // return
  19771. // }
  19772. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  19773. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  19774. // infoStr := string(Iinfos)
  19775. // idetinfoStr := string(Idetinfos)
  19776. //
  19777. // if res.Infcode == 0 {
  19778. // his := models.VMHisPatient{
  19779. // Status: 1,
  19780. // Ctime: time.Now().Unix(),
  19781. // Mtime: time.Now().Unix(),
  19782. // PsnNo: res.Output.Baseinfo.PsnNo,
  19783. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  19784. // Certno: res.Output.Baseinfo.Certno,
  19785. // PsnName: res.Output.Baseinfo.PsnName,
  19786. // Gend: res.Output.Baseinfo.Gend,
  19787. // Naty: res.Output.Baseinfo.Naty,
  19788. // Brdy: res.Output.Baseinfo.Brdy,
  19789. // Age: res.Output.Baseinfo.Age,
  19790. // Iinfo: infoStr,
  19791. // Idetinfo: idetinfoStr,
  19792. // PatientId: patient.ID,
  19793. // RecordDate: theTime.Unix(),
  19794. // UserOrgId: adminInfo.CurrentOrgId,
  19795. // AdminUserId: adminInfo.AdminUser.Id,
  19796. // IsReturn: 1,
  19797. // }
  19798. //
  19799. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  19800. // //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")
  19801. // //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")
  19802. //
  19803. // //var dat map[string]interface{}
  19804. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19805. // // fmt.Println(dat)
  19806. // //} else {
  19807. // // fmt.Println(err)
  19808. // //}
  19809. //
  19810. // var dat2 map[string]interface{}
  19811. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  19812. // fmt.Println(dat2)
  19813. // } else {
  19814. // fmt.Println(err)
  19815. // }
  19816. //
  19817. // } else {
  19818. // adminUser := c.GetAdminUserInfo()
  19819. // errlog := &models.HisOrderError{
  19820. // UserOrgId: adminUser.CurrentOrgId,
  19821. // Ctime: time.Now().Unix(),
  19822. // Mtime: time.Now().Unix(),
  19823. // ErrMsg: res.ErrMsg,
  19824. // Status: 1,
  19825. // PatientId: id,
  19826. // RecordTime: recordDateTime,
  19827. // Stage: 1,
  19828. // }
  19829. // service.CreateErrMsgLog(errlog)
  19830. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  19831. // return
  19832. // }
  19833. // }
  19834. //
  19835. //}
  19836. //func (c *HisApiController) GetUploadDiag() {
  19837. // id, _ := c.GetInt64("id")
  19838. // record_time := c.GetString("record_time")
  19839. //
  19840. // diagnosis_id, _ := c.GetInt64("diagnosis")
  19841. // sick_type, _ := c.GetInt64("sick_type")
  19842. // reg_type, _ := c.GetInt64("reg_type")
  19843. //
  19844. // timeLayout := "2006-01-02"
  19845. // loc, _ := time.LoadLocation("Local")
  19846. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  19847. // if err != nil {
  19848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19849. // return
  19850. // }
  19851. //
  19852. // var patientPrescription models.HisPrescriptionInfo
  19853. // recordDateTime := theTime.Unix()
  19854. // adminInfo := c.GetAdminUserInfo()
  19855. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  19856. //
  19857. // if patientPrescription.ID == 0 {
  19858. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  19859. // }
  19860. //
  19861. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  19862. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  19863. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  19864. // sickConfig, _ := service.FindSickById(sick_type)
  19865. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  19866. //
  19867. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  19868. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  19869. // "&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 +
  19870. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  19871. // resp2, requestErr2 := http.Get(api2)
  19872. // if requestErr2 != nil {
  19873. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19874. // return
  19875. // }
  19876. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  19877. // if ioErr2 != nil {
  19878. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  19879. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19880. // return
  19881. // }
  19882. // var respJSON2 map[string]interface{}
  19883. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  19884. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19885. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19886. // return
  19887. // }
  19888. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19889. // userJSONBytes2, _ := json.Marshal(respJSON2)
  19890. //
  19891. // var res2 ResultSix
  19892. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  19893. // utils.ErrorLog("解析失败:%v", err)
  19894. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19895. // return
  19896. // }
  19897. // if res2.Infcode != 0 {
  19898. // adminUser := c.GetAdminUserInfo()
  19899. // errlog := &models.HisOrderError{
  19900. // UserOrgId: adminUser.CurrentOrgId,
  19901. // Ctime: time.Now().Unix(),
  19902. // Mtime: time.Now().Unix(),
  19903. // ErrMsg: res2.ErrMsg,
  19904. // Status: 1,
  19905. // PatientId: id,
  19906. // RecordTime: recordDateTime,
  19907. // Stage: 3,
  19908. // }
  19909. // service.CreateErrMsgLog(errlog)
  19910. //
  19911. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  19912. // return
  19913. // }
  19914. //
  19915. // c.ServeSuccessJSON(map[string]interface{}{
  19916. // "msg": "上传成功",
  19917. // })
  19918. //
  19919. //}
  19920. type QueryResult struct {
  19921. ID int64
  19922. Name string
  19923. Code string
  19924. List_type_code string
  19925. }
  19926. func (c *HisApiController) GetCheckCode() {
  19927. ids_str := c.GetString("ids")
  19928. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  19929. ids_arr := strings.Split(ids_str, ",")
  19930. var queryResult []QueryResult
  19931. ids := make([]int64, 0)
  19932. for _, item := range ids_arr {
  19933. id, _ := strconv.ParseInt(item, 10, 64)
  19934. ids = append(ids, id)
  19935. }
  19936. if record_type == 1 {
  19937. drugs, _ := service.GetBatchDrugList(ids)
  19938. for _, item := range drugs {
  19939. result := QueryResult{
  19940. ID: item.ID,
  19941. Name: item.DrugName,
  19942. Code: item.MedicalInsuranceNumber,
  19943. List_type_code: "101",
  19944. }
  19945. queryResult = append(queryResult, result)
  19946. }
  19947. } else if record_type == 2 {
  19948. goods, _ := service.GetBatchGoodInformationList(ids)
  19949. fmt.Println(goods)
  19950. for _, item := range goods {
  19951. result := QueryResult{
  19952. ID: item.ID,
  19953. Name: item.GoodName,
  19954. Code: item.SocialSecurityDirectoryCode,
  19955. List_type_code: "301",
  19956. }
  19957. queryResult = append(queryResult, result)
  19958. }
  19959. } else if record_type == 3 {
  19960. projects, _ := service.GetBathchMyPorjecgList(ids)
  19961. for _, item := range projects {
  19962. result := QueryResult{
  19963. ID: item.ID,
  19964. Name: item.ProjectName,
  19965. Code: item.MedicalCode,
  19966. List_type_code: "201",
  19967. }
  19968. queryResult = append(queryResult, result)
  19969. }
  19970. }
  19971. admin_user_id, _ := c.GetInt64("admin_user_id")
  19972. adminUser := c.GetAdminUserInfo()
  19973. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  19974. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  19975. var user_name string
  19976. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  19977. if role.ID == 0 {
  19978. user_name = "管理员"
  19979. } else {
  19980. user_name = role.UserName
  19981. }
  19982. baseParams := models.BaseParams{
  19983. SecretKey: miConfig.SecretKey,
  19984. FixmedinsCode: miConfig.Code,
  19985. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  19986. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  19987. OrgName: miConfig.OrgName,
  19988. Doctor: user_name,
  19989. }
  19990. var result string
  19991. if miConfig.MdtrtareaAdmvs == "430800" {
  19992. for _, item := range queryResult {
  19993. if record_type == 1 {
  19994. 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)
  19995. } else if record_type == 2 {
  19996. fmt.Println(item.Code)
  19997. 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)
  19998. } else if record_type == 3 {
  19999. 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)
  20000. }
  20001. var dat map[string]interface{}
  20002. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20003. fmt.Println(dat)
  20004. } else {
  20005. fmt.Println(err)
  20006. }
  20007. userJSONBytes, _ := json.Marshal(dat)
  20008. var res ResultSix
  20009. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20010. utils.ErrorLog("解析失败:%v", err)
  20011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20012. return
  20013. }
  20014. if res.Infcode == 0 {
  20015. if record_type == 1 {
  20016. service.UpdateBaseDrugById(item.ID)
  20017. } else if record_type == 2 {
  20018. service.UpdateGoodInformaitonByDetail(item.ID)
  20019. } else if record_type == 3 {
  20020. service.UpdateProjectById(item.ID)
  20021. }
  20022. c.ServeSuccessJSON(map[string]interface{}{
  20023. "failed_code": 0,
  20024. "msg": "目录对照成功",
  20025. })
  20026. } else {
  20027. c.ServeSuccessJSON(map[string]interface{}{
  20028. "failed_code": -10,
  20029. "msg": res.ErrMsg,
  20030. })
  20031. }
  20032. }
  20033. } else {
  20034. for _, item := range queryResult {
  20035. var result string
  20036. if record_type == 1 {
  20037. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  20038. } else if record_type == 2 {
  20039. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  20040. } else if record_type == 3 {
  20041. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  20042. }
  20043. var dat map[string]interface{}
  20044. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20045. fmt.Println(dat)
  20046. } else {
  20047. fmt.Println(err)
  20048. }
  20049. userJSONBytes, _ := json.Marshal(dat)
  20050. var res ResultSix
  20051. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20052. utils.ErrorLog("解析失败:%v", err)
  20053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20054. return
  20055. }
  20056. if res.Infcode == 0 {
  20057. if record_type == 1 {
  20058. service.UpdateBaseDrugById(item.ID)
  20059. } else if record_type == 2 {
  20060. service.UpdateGoodInformaitonByDetail(item.ID)
  20061. } else if record_type == 3 {
  20062. service.UpdateProjectById(item.ID)
  20063. }
  20064. c.ServeSuccessJSON(map[string]interface{}{
  20065. "failed_code": 0,
  20066. "msg": "目录对照成功",
  20067. })
  20068. } else {
  20069. c.ServeSuccessJSON(map[string]interface{}{
  20070. "failed_code": -10,
  20071. "msg": res.ErrMsg,
  20072. })
  20073. }
  20074. }
  20075. }
  20076. }
  20077. func (c *HisApiController) UnCheckCode() {
  20078. ids_str := c.GetString("ids")
  20079. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  20080. admin_user_id, _ := c.GetInt64("admin_user_id")
  20081. ids_arr := strings.Split(ids_str, ",")
  20082. var queryResult []QueryResult
  20083. ids := make([]int64, 0)
  20084. for _, item := range ids_arr {
  20085. id, _ := strconv.ParseInt(item, 10, 64)
  20086. ids = append(ids, id)
  20087. }
  20088. if record_type == 1 {
  20089. drugs, _ := service.GetBatchDrugList(ids)
  20090. for _, item := range drugs {
  20091. result := QueryResult{
  20092. ID: item.ID,
  20093. Name: item.DrugName,
  20094. Code: item.MedicalInsuranceNumber,
  20095. List_type_code: "101",
  20096. }
  20097. queryResult = append(queryResult, result)
  20098. }
  20099. } else if record_type == 2 {
  20100. goods, _ := service.GetBatchGoodInformationList(ids)
  20101. for _, item := range goods {
  20102. result := QueryResult{
  20103. ID: item.ID,
  20104. Name: item.GoodName,
  20105. Code: item.SocialSecurityDirectoryCode,
  20106. List_type_code: "301",
  20107. }
  20108. queryResult = append(queryResult, result)
  20109. }
  20110. } else if record_type == 3 {
  20111. projects, _ := service.GetBathchMyPorjecgList(ids)
  20112. for _, item := range projects {
  20113. result := QueryResult{
  20114. ID: item.ID,
  20115. Name: item.ProjectName,
  20116. Code: item.MedicalCode,
  20117. List_type_code: "201",
  20118. }
  20119. queryResult = append(queryResult, result)
  20120. }
  20121. }
  20122. adminUser := c.GetAdminUserInfo()
  20123. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20124. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  20125. var user_name string
  20126. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  20127. if role.ID == 0 {
  20128. user_name = "xxx"
  20129. } else {
  20130. user_name = role.UserName
  20131. }
  20132. baseParams := &models.BaseParams{
  20133. SecretKey: miConfig.SecretKey,
  20134. FixmedinsCode: miConfig.Code,
  20135. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  20136. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  20137. OrgName: miConfig.OrgName,
  20138. Doctor: user_name,
  20139. }
  20140. if config.IsOpen == 1 {
  20141. if miConfig.MdtrtareaAdmvs == "430800" {
  20142. for _, item := range queryResult {
  20143. var result string
  20144. if record_type == 1 {
  20145. 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)
  20146. } else if record_type == 2 {
  20147. fmt.Println(item.Code)
  20148. 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)
  20149. } else if record_type == 3 {
  20150. 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)
  20151. }
  20152. var dat map[string]interface{}
  20153. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20154. fmt.Println(dat)
  20155. } else {
  20156. fmt.Println(err)
  20157. }
  20158. userJSONBytes, _ := json.Marshal(dat)
  20159. var res ResultSix
  20160. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20161. utils.ErrorLog("解析失败:%v", err)
  20162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20163. return
  20164. }
  20165. if res.Infcode == 0 {
  20166. if record_type == 1 {
  20167. service.UpdateBaseDrugById(item.ID)
  20168. } else if record_type == 2 {
  20169. service.UpdateGoodInformaitonByDetail(item.ID)
  20170. } else if record_type == 3 {
  20171. service.UpdateProjectById(item.ID)
  20172. }
  20173. c.ServeSuccessJSON(map[string]interface{}{
  20174. "failed_code": 0,
  20175. "msg": "目录对照成功",
  20176. })
  20177. } else {
  20178. c.ServeSuccessJSON(map[string]interface{}{
  20179. "failed_code": -10,
  20180. "msg": res.ErrMsg,
  20181. })
  20182. }
  20183. }
  20184. } else {
  20185. for _, item := range queryResult {
  20186. var result string
  20187. if record_type == 1 {
  20188. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  20189. } else if record_type == 2 {
  20190. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  20191. } else if record_type == 3 {
  20192. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  20193. }
  20194. var dat2 map[string]interface{}
  20195. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  20196. fmt.Println(dat2)
  20197. } else {
  20198. fmt.Println(err)
  20199. }
  20200. userJSONBytes, _ := json.Marshal(dat2)
  20201. var res ResultSix
  20202. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20203. utils.ErrorLog("解析失败:%v", err)
  20204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20205. return
  20206. }
  20207. if res.Infcode == 0 {
  20208. if record_type == 1 {
  20209. service.UpdateDrugByIdDetail(item.ID)
  20210. } else if record_type == 2 {
  20211. service.UpdateGoodInfoById(item.ID)
  20212. } else if record_type == 3 {
  20213. service.UpdateMyProjectById(item.ID)
  20214. }
  20215. c.ServeSuccessJSON(map[string]interface{}{
  20216. "failed_code": 0,
  20217. "msg": "撤销目录对照成功",
  20218. })
  20219. } else {
  20220. c.ServeSuccessJSON(map[string]interface{}{
  20221. "failed_code": -10,
  20222. "msg": res.ErrMsg,
  20223. })
  20224. }
  20225. }
  20226. }
  20227. }
  20228. }
  20229. func (c *HisApiController) GetPatientInfo() {
  20230. id_card_no := c.GetString("id_card_no")
  20231. admin_user_id, _ := c.GetInt64("admin_user_id")
  20232. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  20233. if patient.ID == 0 {
  20234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  20235. return
  20236. }
  20237. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20238. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20239. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  20240. var res ResultTwo
  20241. var res10265 ResultTwo10265
  20242. if config.IsOpen == 1 {
  20243. if miConfig.MdtrtareaAdmvs == "150499" {
  20244. //请求内网数据
  20245. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  20246. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  20247. "&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
  20248. resp, requestErr := http.Get(api)
  20249. if requestErr != nil {
  20250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20251. return
  20252. }
  20253. body, ioErr := ioutil.ReadAll(resp.Body)
  20254. if ioErr != nil {
  20255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20257. return
  20258. }
  20259. var respJSON map[string]interface{}
  20260. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20263. return
  20264. }
  20265. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20266. result_byte, _ := json.Marshal(respJSON)
  20267. result := string(result_byte)
  20268. var dat map[string]interface{}
  20269. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20270. fmt.Println(dat)
  20271. } else {
  20272. fmt.Println(err)
  20273. }
  20274. userJSONBytes, _ := json.Marshal(dat)
  20275. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  20276. utils.ErrorLog("解析失败:%v", err)
  20277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20278. return
  20279. }
  20280. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  20281. res.Infcode = Infcode
  20282. res.ErrMsg = res10265.ErrMsg
  20283. res.Output = res10265.Output
  20284. res.InfRefmsgid = res10265.InfRefmsgid
  20285. res.RespondTime = res10265.RespondTime
  20286. res.WarnInfo = res10265.WarnInfo
  20287. } else {
  20288. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  20289. var dat map[string]interface{}
  20290. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20291. fmt.Println(dat)
  20292. } else {
  20293. fmt.Println(err)
  20294. }
  20295. userJSONBytes, _ := json.Marshal(dat)
  20296. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20297. utils.ErrorLog("解析失败:%v", err)
  20298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20299. return
  20300. }
  20301. }
  20302. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20303. // utils.ErrorLog("解析失败:%v", err)
  20304. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20305. // return
  20306. //}
  20307. for index, item := range res.Output.Iinfo {
  20308. if item.PsnInsuStas == "2" {
  20309. fmt.Println("--------")
  20310. res.Output.Iinfo[index].Insutype = "300"
  20311. res.Output.Iinfo[index].PsnInsuStas = "1"
  20312. }
  20313. }
  20314. fmt.Println(res.Output.Iinfo)
  20315. if res.Infcode != 0 {
  20316. c.ServeSuccessJSON(map[string]interface{}{
  20317. "failed_code": -10,
  20318. "msg": res.ErrMsg,
  20319. })
  20320. } else {
  20321. c.ServeSuccessJSON(map[string]interface{}{
  20322. "failed_code": 0,
  20323. "info": res,
  20324. })
  20325. }
  20326. }
  20327. }
  20328. func (c *HisApiController) PsnPutOnRecord() {
  20329. record_type, _ := c.GetInt64("type")
  20330. patient_id, _ := c.GetInt64("patient_id")
  20331. admin_user_id, _ := c.GetInt64("admin_user_id")
  20332. start_time := c.GetString("start_time")
  20333. end_time := c.GetString("end_time")
  20334. adminUser := c.GetAdminUserInfo()
  20335. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20336. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  20337. var patients []*models.Patients
  20338. if record_type == 1 { //全部备案
  20339. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  20340. patients = append(patients, patient...)
  20341. } else { //单个备案
  20342. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  20343. patients = append(patients, patient)
  20344. }
  20345. var user_name string
  20346. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  20347. if role.ID == 0 {
  20348. user_name = "xxx"
  20349. } else {
  20350. user_name = role.UserName
  20351. }
  20352. if config.IsOpen == 1 {
  20353. for _, item := range patients {
  20354. 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
  20355. resp, requestErr := http.Get(api)
  20356. if requestErr != nil {
  20357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20358. return
  20359. }
  20360. defer resp.Body.Close()
  20361. body, ioErr := ioutil.ReadAll(resp.Body)
  20362. if ioErr != nil {
  20363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20365. return
  20366. }
  20367. var respJSON map[string]interface{}
  20368. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20371. return
  20372. }
  20373. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20374. userJSONBytes, _ := json.Marshal(userJSON)
  20375. var res ResultTwo
  20376. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20377. utils.ErrorLog("解析失败:%v", err)
  20378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20379. return
  20380. }
  20381. if res.Infcode == 0 {
  20382. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  20383. var dat map[string]interface{}
  20384. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20385. fmt.Println(dat)
  20386. } else {
  20387. fmt.Println(err)
  20388. }
  20389. userJSONBytes, _ := json.Marshal(dat)
  20390. var res2 ResultThirteen
  20391. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20392. utils.ErrorLog("解析失败:%v", err)
  20393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20394. return
  20395. }
  20396. if res2.Infcode == 0 {
  20397. psnResult := &models.GdybPsnRecord{
  20398. UserOrgId: adminUser.CurrentOrgId,
  20399. PatientId: item.ID,
  20400. PsnNo: res.Output.Baseinfo.PsnNo,
  20401. Ctime: time.Now().Unix(),
  20402. Mtime: time.Now().Unix(),
  20403. Status: 1,
  20404. IsCancel: 1,
  20405. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  20406. }
  20407. service.CreatePsnRecord(psnResult)
  20408. } else {
  20409. c.ServeSuccessJSON(map[string]interface{}{
  20410. "failed_code": -10,
  20411. "msg": res2.ErrMsg,
  20412. })
  20413. return
  20414. }
  20415. }
  20416. }
  20417. }
  20418. }
  20419. func (c *HisApiController) PsnUnPutOnRecord() {
  20420. id, _ := c.GetInt64("id")
  20421. //record_type, _ := c.GetInt64("type")
  20422. admin_user_id, _ := c.GetInt64("admin_user_id")
  20423. adminUser := c.GetAdminUserInfo()
  20424. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20425. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  20426. var user_name string
  20427. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  20428. if role.ID == 0 {
  20429. user_name = "xxx"
  20430. } else {
  20431. user_name = role.UserName
  20432. }
  20433. psn_record, _ := service.GetPsnRecordById(id)
  20434. if psn_record.ID == 0 {
  20435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  20436. return
  20437. }
  20438. if config.IsOpen == 1 {
  20439. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  20440. var dat map[string]interface{}
  20441. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20442. fmt.Println(dat)
  20443. } else {
  20444. fmt.Println(err)
  20445. }
  20446. userJSONBytes, _ := json.Marshal(dat)
  20447. var res ResultFourteen
  20448. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20449. utils.ErrorLog("解析失败:%v", err)
  20450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20451. return
  20452. }
  20453. if res.Infcode == 0 {
  20454. psn_record.IsCancel = 2
  20455. service.CreatePsnRecord(&psn_record)
  20456. } else {
  20457. c.ServeSuccessJSON(map[string]interface{}{
  20458. "failed_code": -10,
  20459. "msg": res.ErrMsg,
  20460. })
  20461. return
  20462. }
  20463. }
  20464. }
  20465. func (c *HisApiController) PsnPutNCDSOnRecord() {
  20466. patient_id, _ := c.GetInt64("patient_id")
  20467. insutype_two := c.GetString("insutype")
  20468. psn_no := c.GetString("psn_no")
  20469. doctor_id, _ := c.GetInt64("doctor_id")
  20470. sick_id, _ := c.GetInt64("sick_id")
  20471. department_id, _ := c.GetInt64("department_id")
  20472. start_time := c.GetString("start_time")
  20473. end_time := c.GetString("end_time")
  20474. check_time := c.GetString("check_time")
  20475. hospital_code := c.GetString("hospital_code")
  20476. hospital_name := c.GetString("hospital_name")
  20477. adminUser := c.GetAdminUserInfo()
  20478. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  20479. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20480. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  20481. sick, _ := service.FindSickById(sick_id)
  20482. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  20483. if len(hospital_code) == 0 {
  20484. hospital_code = miConfig.Code
  20485. }
  20486. if len(hospital_name) == 0 {
  20487. hospital_name = miConfig.OrgName
  20488. }
  20489. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  20490. var res ResultTwo
  20491. var res10265 ResultTwo10265
  20492. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20493. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  20494. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  20495. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  20496. "&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
  20497. resp, requestErr := http.Get(api)
  20498. if requestErr != nil {
  20499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20500. return
  20501. }
  20502. body, ioErr := ioutil.ReadAll(resp.Body)
  20503. if ioErr != nil {
  20504. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20506. return
  20507. }
  20508. var respJSON map[string]interface{}
  20509. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20512. return
  20513. }
  20514. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20515. result, _ := json.Marshal(respJSON)
  20516. fmt.Println("log")
  20517. fmt.Println(string(result))
  20518. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  20519. utils.ErrorLog("解析失败:%v", err)
  20520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20521. return
  20522. }
  20523. res.ErrMsg = res10265.ErrMsg
  20524. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  20525. res.Infcode = infocode
  20526. res.Output = res10265.Output
  20527. res.InfRefmsgid = res10265.InfRefmsgid
  20528. } else {
  20529. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  20530. if miConfig.Code == "H15049901371" {
  20531. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  20532. utils.ErrorLog("解析失败:%v", err)
  20533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20534. return
  20535. }
  20536. res.ErrMsg = res10265.ErrMsg
  20537. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  20538. res.Infcode = infocode
  20539. res.Output = res10265.Output
  20540. res.InfRefmsgid = res10265.InfRefmsgid
  20541. } else {
  20542. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20543. utils.ErrorLog("解析失败:%v", err)
  20544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20545. return
  20546. }
  20547. }
  20548. }
  20549. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  20550. infoStr := string(Iinfos)
  20551. var rf []*ResultFive
  20552. json.Unmarshal([]byte(infoStr), &rf)
  20553. var insuplc_admdvs string
  20554. var insutype string
  20555. var is390 int = 0
  20556. var is310 int = 0
  20557. var insutypes []*ResultFive
  20558. for _, item := range rf {
  20559. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20560. insutypes = append(insutypes, item)
  20561. }
  20562. }
  20563. if len(insutypes) == 1 {
  20564. insutype = insutypes[0].Insutype
  20565. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  20566. } else {
  20567. for _, i := range insutypes {
  20568. if i.Insutype == "390" {
  20569. is390 = 1
  20570. }
  20571. if i.Insutype == "310" {
  20572. is310 = 1
  20573. }
  20574. }
  20575. }
  20576. if is390 == 1 {
  20577. insutype = "390"
  20578. }
  20579. if is310 == 1 {
  20580. insutype = "310"
  20581. }
  20582. if len(insutypes) == 2 {
  20583. insutype = insutype_two
  20584. }
  20585. if len(insutypes) == 0 {
  20586. insutype = "310"
  20587. }
  20588. insutype = insutype_two
  20589. fmt.Println(insutype)
  20590. for _, item := range rf {
  20591. fmt.Println(item.Insutype)
  20592. fmt.Println(insutype)
  20593. if item.Insutype == insutype {
  20594. fmt.Println(item.Insutype)
  20595. fmt.Println(insutype)
  20596. insuplc_admdvs = item.InsuplcAdmdvs
  20597. }
  20598. }
  20599. fmt.Println(insuplc_admdvs)
  20600. var res2 ResultThirteen
  20601. var res10265_2 ResultThirteen10265
  20602. if config.IsOpen == 1 {
  20603. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20604. } else {
  20605. if miConfig.MdtrtareaAdmvs == "150499" {
  20606. //
  20607. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  20608. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  20609. // "&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
  20610. //resp, requestErr := http.Get(api)
  20611. //if requestErr != nil {
  20612. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20613. // return
  20614. //}
  20615. //
  20616. //body, ioErr := ioutil.ReadAll(resp.Body)
  20617. //if ioErr != nil {
  20618. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20619. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20620. // return
  20621. //}
  20622. //var respJSON map[string]interface{}
  20623. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20624. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20625. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20626. // return
  20627. //}
  20628. //
  20629. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20630. //result, _ := json.Marshal(respJSON)
  20631. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  20632. // utils.ErrorLog("解析失败:%v", err)
  20633. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20634. // return
  20635. //}
  20636. //infocode = resThree.Infcode
  20637. //result, _ := json.Marshal(respJSON)
  20638. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  20639. // utils.ErrorLog("解析失败:%v", err)
  20640. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20641. // return
  20642. //}
  20643. //
  20644. //resThree.ErrMsg = resThree10265.ErrMsg
  20645. //
  20646. //resThree.Output = resThree10265.Output
  20647. //
  20648. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  20649. //
  20650. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  20651. //
  20652. } else {
  20653. 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)
  20654. var dat map[string]interface{}
  20655. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20656. fmt.Println(dat)
  20657. } else {
  20658. fmt.Println(err)
  20659. }
  20660. userJSONBytes, _ := json.Marshal(dat)
  20661. if miConfig.Code == "H15049901371" {
  20662. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  20663. utils.ErrorLog("解析失败:%v", err)
  20664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20665. return
  20666. }
  20667. res2.ErrMsg = res10265_2.ErrMsg
  20668. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  20669. res2.Infcode = infocode
  20670. res2.Output = res10265_2.Output
  20671. res2.InfRefmsgid = res10265_2.InfRefmsgid
  20672. } else {
  20673. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20674. utils.ErrorLog("解析失败:%v", err)
  20675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20676. return
  20677. }
  20678. }
  20679. }
  20680. }
  20681. if res2.Infcode == 0 {
  20682. psnResult := &models.GdybPsnNcdsRecord{
  20683. UserOrgId: adminUser.CurrentOrgId,
  20684. PatientId: patient.ID,
  20685. PsnNo: psn_no,
  20686. DoctorId: doctor.AdminUserId,
  20687. DepartmentId: department_id,
  20688. SickType: sick_id,
  20689. Insutype: insutype,
  20690. Ctime: time.Now().Unix(),
  20691. Mtime: time.Now().Unix(),
  20692. Status: 1,
  20693. IsCancel: 1,
  20694. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  20695. }
  20696. service.CreatePsnNCDSRecord(psnResult)
  20697. c.ServeSuccessJSON(map[string]interface{}{
  20698. "failed_code": 0,
  20699. "msg": "备案成功",
  20700. "result": psnResult,
  20701. })
  20702. } else {
  20703. c.ServeSuccessJSON(map[string]interface{}{
  20704. "failed_code": -10,
  20705. "msg": res2.ErrMsg,
  20706. })
  20707. return
  20708. }
  20709. }
  20710. }
  20711. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  20712. id, _ := c.GetInt64("id")
  20713. admin_user_id, _ := c.GetInt64("admin_user_id")
  20714. adminUser := c.GetAdminUserInfo()
  20715. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20716. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  20717. //config, _ := service.Ge(adminUser.CurrentOrgId)
  20718. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  20719. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  20720. //var user_name string
  20721. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  20722. //if role.ID == 0 {
  20723. // user_name = "xxx"
  20724. //} else {
  20725. // user_name = role.UserName
  20726. //}
  20727. psn_record, _ := service.GetPsnNCDSRecordById(id)
  20728. if psn_record.ID == 0 {
  20729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  20730. return
  20731. }
  20732. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  20733. var res ResultTwo
  20734. var res10265 ResultTwo10265
  20735. if miConfig.Code == "H15049901371" {
  20736. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  20737. utils.ErrorLog("解析失败:%v", err)
  20738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20739. return
  20740. }
  20741. res.ErrMsg = res10265.ErrMsg
  20742. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  20743. res.Infcode = infocode
  20744. res.Output = res10265.Output
  20745. res.InfRefmsgid = res10265.InfRefmsgid
  20746. } else {
  20747. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20748. utils.ErrorLog("解析失败:%v", err)
  20749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20750. return
  20751. }
  20752. }
  20753. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  20754. infoStr := string(Iinfos)
  20755. var rf []*ResultFive
  20756. json.Unmarshal([]byte(infoStr), &rf)
  20757. var insuplc_admdvs string
  20758. var insutype string
  20759. var is390 int = 0
  20760. var is310 int = 0
  20761. var insutypes []*ResultFive
  20762. for _, item := range rf {
  20763. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20764. insutypes = append(insutypes, item)
  20765. }
  20766. }
  20767. if len(insutypes) == 1 {
  20768. insutype = insutypes[0].Insutype
  20769. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  20770. } else {
  20771. for _, i := range insutypes {
  20772. if i.Insutype == "390" {
  20773. is390 = 1
  20774. }
  20775. if i.Insutype == "310" {
  20776. is310 = 1
  20777. }
  20778. }
  20779. }
  20780. if is390 == 1 {
  20781. insutype = "390"
  20782. }
  20783. if is310 == 1 {
  20784. insutype = "310"
  20785. }
  20786. if len(insutypes) == 0 {
  20787. insutype = "310"
  20788. }
  20789. insutype = psn_record.Insutype
  20790. for _, item := range rf {
  20791. if item.Insutype == insutype {
  20792. insuplc_admdvs = item.InsuplcAdmdvs
  20793. }
  20794. }
  20795. if config.IsOpen == 1 {
  20796. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  20797. var dat map[string]interface{}
  20798. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20799. fmt.Println(dat)
  20800. } else {
  20801. fmt.Println(err)
  20802. }
  20803. userJSONBytes, _ := json.Marshal(dat)
  20804. var res ResultFourteen
  20805. var res10265 ResultFourteen10265
  20806. if miConfig.Code == "H15049901371" {
  20807. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  20808. utils.ErrorLog("解析失败:%v", err)
  20809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20810. return
  20811. }
  20812. res.ErrMsg = res10265.ErrMsg
  20813. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  20814. res.Infcode = infocode
  20815. res.Output = res10265.Output
  20816. res.InfRefmsgid = res10265.InfRefmsgid
  20817. } else {
  20818. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20819. utils.ErrorLog("解析失败:%v", err)
  20820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20821. return
  20822. }
  20823. }
  20824. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20825. // utils.ErrorLog("解析失败:%v", err)
  20826. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20827. // return
  20828. //}
  20829. if res.Infcode == 0 {
  20830. psn_record.IsCancel = 2
  20831. service.CreatePsnNCDSRecord(&psn_record)
  20832. c.ServeSuccessJSON(map[string]interface{}{
  20833. "failed_code": 0,
  20834. "msg": "撤销备案成功",
  20835. })
  20836. } else {
  20837. c.ServeSuccessJSON(map[string]interface{}{
  20838. "failed_code": -10,
  20839. "msg": res.ErrMsg,
  20840. })
  20841. return
  20842. }
  20843. }
  20844. }
  20845. func (c *HisApiController) TestTest() {
  20846. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  20847. fmt.Println(patient.Iinfo)
  20848. }
  20849. type CustomData struct {
  20850. MsgId string
  20851. PsnNo string
  20852. Info string
  20853. }
  20854. func (c *HisApiController) ReversalData() {
  20855. var customData []*CustomData
  20856. custom := &CustomData{
  20857. MsgId: "H44022900158202103301714472004",
  20858. PsnNo: "44020000001101329945",
  20859. Info: "2207",
  20860. }
  20861. customData = append(customData, custom)
  20862. custom1 := &CustomData{
  20863. MsgId: "H4402290015820210330172057803",
  20864. PsnNo: "44020000001101161813",
  20865. Info: "2207",
  20866. }
  20867. customData = append(customData, custom1)
  20868. custom2 := &CustomData{
  20869. MsgId: "H44022900158202103301705198813",
  20870. PsnNo: "44190000133097375417",
  20871. Info: "2207",
  20872. }
  20873. customData = append(customData, custom2)
  20874. custom3 := &CustomData{
  20875. MsgId: "H44022900158202103301715524756",
  20876. PsnNo: "44020000001100187221",
  20877. Info: "2207",
  20878. }
  20879. customData = append(customData, custom3)
  20880. custom4 := &CustomData{
  20881. MsgId: "H44022900158202103301730376224",
  20882. PsnNo: "44020000001101959155",
  20883. Info: "2207",
  20884. }
  20885. customData = append(customData, custom4)
  20886. custom5 := &CustomData{
  20887. MsgId: "H44022900158202103301748008725",
  20888. PsnNo: "44020000001104246641",
  20889. Info: "2207",
  20890. }
  20891. customData = append(customData, custom5)
  20892. custom6 := &CustomData{
  20893. MsgId: "H44022900158202103301718096755",
  20894. PsnNo: "44020000001102211860",
  20895. Info: "2207",
  20896. }
  20897. customData = append(customData, custom6)
  20898. custom7 := &CustomData{
  20899. MsgId: "H44022900158202103301736551640",
  20900. PsnNo: "44020000001102687718",
  20901. Info: "2207",
  20902. }
  20903. customData = append(customData, custom7)
  20904. custom8 := &CustomData{
  20905. MsgId: "H44022900158202103301743097676",
  20906. PsnNo: "44020000001102127785",
  20907. Info: "2207",
  20908. }
  20909. customData = append(customData, custom8)
  20910. custom9 := &CustomData{
  20911. MsgId: "H44022900158202103301712304203",
  20912. PsnNo: "44020000001101518097",
  20913. Info: "2207",
  20914. }
  20915. customData = append(customData, custom9)
  20916. custom10 := &CustomData{
  20917. MsgId: "H44022900158202103301738448785",
  20918. PsnNo: "44020000001100500813",
  20919. Info: "2207",
  20920. }
  20921. customData = append(customData, custom10)
  20922. custom11 := &CustomData{
  20923. MsgId: "H44022900158202103301732455843",
  20924. PsnNo: "44020000001102690557",
  20925. Info: "2207",
  20926. }
  20927. customData = append(customData, custom11)
  20928. custom12 := &CustomData{
  20929. MsgId: "H44022900158202103301745421708",
  20930. PsnNo: "44020000001102211928",
  20931. Info: "2207",
  20932. }
  20933. customData = append(customData, custom12)
  20934. custom1212 := &CustomData{
  20935. MsgId: "H440229001582021033017351627",
  20936. PsnNo: "44020000001102481733",
  20937. Info: "2207",
  20938. }
  20939. customData = append(customData, custom1212)
  20940. custom13 := &CustomData{
  20941. MsgId: "H44022900158202103301740327951",
  20942. PsnNo: "44020000001103174866",
  20943. Info: "2207",
  20944. }
  20945. customData = append(customData, custom13)
  20946. custom14 := &CustomData{
  20947. MsgId: "H4402290015820210330174922668",
  20948. PsnNo: "44020000001102927272",
  20949. Info: "2207",
  20950. }
  20951. customData = append(customData, custom14)
  20952. custom15 := &CustomData{
  20953. MsgId: "H44022900158202103301752362273",
  20954. PsnNo: "44020000001102942890",
  20955. Info: "2207",
  20956. }
  20957. customData = append(customData, custom15)
  20958. custom16 := &CustomData{
  20959. MsgId: "H44022900158202103301751082917",
  20960. PsnNo: "44020000001101662162",
  20961. Info: "2207",
  20962. }
  20963. customData = append(customData, custom16)
  20964. custom17 := &CustomData{
  20965. MsgId: "H44022900158202103301754147728",
  20966. PsnNo: "44020000000229014511",
  20967. Info: "2207",
  20968. }
  20969. customData = append(customData, custom17)
  20970. adminUser := c.GetAdminUserInfo()
  20971. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20972. for _, item := range customData {
  20973. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  20974. fmt.Println(result)
  20975. }
  20976. }
  20977. func (c *HisApiController) GetAllopatry() {
  20978. year := c.GetString("year")
  20979. month := c.GetString("month")
  20980. admin_user_id, _ := c.GetInt64("admin_user_id")
  20981. adminUser := c.GetAdminUserInfo()
  20982. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20983. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  20984. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  20985. var dat map[string]interface{}
  20986. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20987. fmt.Println(dat)
  20988. } else {
  20989. fmt.Println(err)
  20990. }
  20991. userJSONBytes, _ := json.Marshal(dat)
  20992. var res models.Result9001
  20993. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20994. utils.ErrorLog("解析失败:%v", err)
  20995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20996. return
  20997. }
  20998. fmt.Println(res.Output.Signinoutb)
  20999. fmt.Println(res.Output.Signinoutb.SignNo)
  21000. fmt.Println(string(userJSONBytes))
  21001. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  21002. var dat3 map[string]interface{}
  21003. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  21004. fmt.Println(dat3)
  21005. } else {
  21006. fmt.Println(err)
  21007. }
  21008. userJSONBytes3, _ := json.Marshal(dat3)
  21009. var res3 models.Result3260
  21010. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  21011. utils.ErrorLog("解析失败:%v", err)
  21012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21013. return
  21014. }
  21015. var curpage int
  21016. var pagesize int = 100
  21017. var start int = 1
  21018. //var stop int
  21019. //pagecount := 10
  21020. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  21021. for curpage = 1; curpage <= pagecount; curpage++ {
  21022. if curpage == 1 {
  21023. start = 0
  21024. } else {
  21025. start = (curpage-1)*pagesize + 1
  21026. }
  21027. fmt.Println(start)
  21028. //stop = curpage * pagesize
  21029. //if stop > int(res3.Output.Totalrow) {
  21030. // stop =int(res3.Output.Totalrow)
  21031. //}
  21032. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  21033. var dat2 map[string]interface{}
  21034. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  21035. fmt.Println(dat)
  21036. } else {
  21037. fmt.Println(err)
  21038. }
  21039. userJSONBytes2, _ := json.Marshal(dat2)
  21040. var res2 models.Result3260
  21041. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21042. utils.ErrorLog("解析失败:%v", err)
  21043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21044. return
  21045. }
  21046. if res2.Infcode == 0 {
  21047. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  21048. var dat2 map[string]interface{}
  21049. if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  21050. fmt.Println(dat)
  21051. } else {
  21052. fmt.Println(err)
  21053. }
  21054. c.ServeSuccessJSON(map[string]interface{}{
  21055. "list": res2.Output.Data,
  21056. })
  21057. continue
  21058. }
  21059. }
  21060. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  21061. //var dat2 map[string]interface{}
  21062. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  21063. // fmt.Println(dat)
  21064. //} else {
  21065. // fmt.Println(err)
  21066. //}
  21067. //userJSONBytes2, _ := json.Marshal(dat2)
  21068. //var res2 models.Result3260
  21069. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21070. // utils.ErrorLog("解析失败:%v", err)
  21071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21072. // return
  21073. //}
  21074. //if res2.Infcode == 0 {
  21075. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  21076. // var dat2 map[string]interface{}
  21077. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  21078. // fmt.Println(dat)
  21079. // } else {
  21080. // fmt.Println(err)
  21081. // }
  21082. // c.ServeSuccessJSON(map[string]interface{}{
  21083. // "list": res2.Output.Data,
  21084. // })
  21085. //}
  21086. }
  21087. func (c *HisApiController) ComfirmAllopatry() {
  21088. year := c.GetString("year")
  21089. month := c.GetString("month")
  21090. admin_user_id, _ := c.GetInt64("admin_user_id")
  21091. adminUser := c.GetAdminUserInfo()
  21092. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21093. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  21094. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  21095. var dat map[string]interface{}
  21096. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21097. fmt.Println(dat)
  21098. } else {
  21099. fmt.Println(err)
  21100. }
  21101. userJSONBytes, _ := json.Marshal(dat)
  21102. var res models.Result9001
  21103. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21104. utils.ErrorLog("解析失败:%v", err)
  21105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21106. return
  21107. }
  21108. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  21109. var dat2 map[string]interface{}
  21110. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  21111. fmt.Println(dat)
  21112. } else {
  21113. fmt.Println(err)
  21114. }
  21115. userJSONBytes2, _ := json.Marshal(dat2)
  21116. var res2 models.Result3260
  21117. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21118. utils.ErrorLog("解析失败:%v", err)
  21119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21120. return
  21121. }
  21122. //if res2.Infcode == 0 {
  21123. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  21124. // var dat map[string]interface{}
  21125. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21126. // fmt.Println(dat)
  21127. // } else {
  21128. // fmt.Println(err)
  21129. // }
  21130. // userJSONBytes, _ := json.Marshal(dat)
  21131. // var res3 models.Result3261
  21132. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  21133. // utils.ErrorLog("解析失败:%v", err)
  21134. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21135. // return
  21136. // }
  21137. //
  21138. // if res3.Infcode == 0 {
  21139. // record := &models.HisYidiClearRecord{
  21140. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21141. // Ctime: time.Now().Unix(),
  21142. // Mtime: time.Now().Unix(),
  21143. // Status: 1,
  21144. // MsgId: msgId,
  21145. // }
  21146. // service.SaveClearRecord(record)
  21147. // c.ServeSuccessJSON(map[string]interface{}{
  21148. // "msg": "提取成功",
  21149. // })
  21150. // }
  21151. //}
  21152. }
  21153. func (c *HisApiController) RefundAllopatry() {
  21154. year := c.GetString("year")
  21155. month := c.GetString("month")
  21156. //id, _ := c.GetInt64("id")
  21157. admin_user_id, _ := c.GetInt64("admin_user_id")
  21158. adminUser := c.GetAdminUserInfo()
  21159. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21160. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  21161. //record, _ := service.GetClearRecordById(id)
  21162. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  21163. var dat map[string]interface{}
  21164. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21165. fmt.Println(dat)
  21166. } else {
  21167. fmt.Println(err)
  21168. }
  21169. userJSONBytes, _ := json.Marshal(dat)
  21170. var res models.Result9001
  21171. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21172. utils.ErrorLog("解析失败:%v", err)
  21173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21174. return
  21175. }
  21176. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  21177. var dat2 map[string]interface{}
  21178. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  21179. fmt.Println(dat)
  21180. } else {
  21181. fmt.Println(err)
  21182. }
  21183. userJSONBytes2, _ := json.Marshal(dat2)
  21184. var empty ResultFourteen
  21185. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  21186. utils.ErrorLog("解析失败:%v", err)
  21187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21188. return
  21189. }
  21190. if empty.Infcode == 0 {
  21191. c.ServeSuccessJSON(map[string]interface{}{
  21192. "msg": "撤销成功",
  21193. })
  21194. return
  21195. }
  21196. }
  21197. func (c *HisApiController) ReversalOtherData() {
  21198. var customData []*CustomData
  21199. custom := &CustomData{
  21200. MsgId: "H44022900158202103301714472004",
  21201. PsnNo: "44020000001101329945",
  21202. Info: "2208",
  21203. }
  21204. customData = append(customData, custom)
  21205. custom1 := &CustomData{
  21206. MsgId: "H4402290015820210330172057803",
  21207. PsnNo: "44020000001101161813",
  21208. Info: "2208",
  21209. }
  21210. customData = append(customData, custom1)
  21211. custom2 := &CustomData{
  21212. MsgId: "H44022900158202103301705198813",
  21213. PsnNo: "44190000133097375417",
  21214. Info: "2208",
  21215. }
  21216. customData = append(customData, custom2)
  21217. custom3 := &CustomData{
  21218. MsgId: "H44022900158202103301715524756",
  21219. PsnNo: "44020000001100187221",
  21220. Info: "2208",
  21221. }
  21222. customData = append(customData, custom3)
  21223. custom4 := &CustomData{
  21224. MsgId: "H44022900158202103301730376224",
  21225. PsnNo: "44020000001101959155",
  21226. Info: "2208",
  21227. }
  21228. customData = append(customData, custom4)
  21229. custom5 := &CustomData{
  21230. MsgId: "H44022900158202103301748008725",
  21231. PsnNo: "44020000001104246641",
  21232. Info: "2208",
  21233. }
  21234. customData = append(customData, custom5)
  21235. custom6 := &CustomData{
  21236. MsgId: "H44022900158202103301718096755",
  21237. PsnNo: "44020000001102211860",
  21238. Info: "2208",
  21239. }
  21240. customData = append(customData, custom6)
  21241. custom7 := &CustomData{
  21242. MsgId: "H44022900158202103301736551640",
  21243. PsnNo: "44020000001102687718",
  21244. Info: "2208",
  21245. }
  21246. customData = append(customData, custom7)
  21247. custom8 := &CustomData{
  21248. MsgId: "H44022900158202103301743097676",
  21249. PsnNo: "44020000001102127785",
  21250. Info: "2208",
  21251. }
  21252. customData = append(customData, custom8)
  21253. custom9 := &CustomData{
  21254. MsgId: "H44022900158202103301712304203",
  21255. PsnNo: "44020000001101518097",
  21256. Info: "2208",
  21257. }
  21258. customData = append(customData, custom9)
  21259. custom10 := &CustomData{
  21260. MsgId: "H44022900158202103301738448785",
  21261. PsnNo: "44020000001100500813",
  21262. Info: "2208",
  21263. }
  21264. customData = append(customData, custom10)
  21265. custom11 := &CustomData{
  21266. MsgId: "H44022900158202103301732455843",
  21267. PsnNo: "44020000001102690557",
  21268. Info: "2208",
  21269. }
  21270. customData = append(customData, custom11)
  21271. custom12 := &CustomData{
  21272. MsgId: "H44022900158202103301745421708",
  21273. PsnNo: "44020000001102211928",
  21274. Info: "2208",
  21275. }
  21276. customData = append(customData, custom12)
  21277. custom1212 := &CustomData{
  21278. MsgId: "H440229001582021033017351627",
  21279. PsnNo: "44020000001102481733",
  21280. Info: "2208",
  21281. }
  21282. customData = append(customData, custom1212)
  21283. custom13 := &CustomData{
  21284. MsgId: "H44022900158202103301740327951",
  21285. PsnNo: "44020000001103174866",
  21286. Info: "2208",
  21287. }
  21288. customData = append(customData, custom13)
  21289. custom14 := &CustomData{
  21290. MsgId: "H4402290015820210330174922668",
  21291. PsnNo: "44020000001102927272",
  21292. Info: "2208",
  21293. }
  21294. customData = append(customData, custom14)
  21295. custom15 := &CustomData{
  21296. MsgId: "H44022900158202103301752362273",
  21297. PsnNo: "44020000001102942890",
  21298. Info: "2208",
  21299. }
  21300. customData = append(customData, custom15)
  21301. custom16 := &CustomData{
  21302. MsgId: "H44022900158202103301751082917",
  21303. PsnNo: "44020000001101662162",
  21304. Info: "2208",
  21305. }
  21306. customData = append(customData, custom16)
  21307. custom17 := &CustomData{
  21308. MsgId: "H44022900158202103301754147728",
  21309. PsnNo: "44020000000229014511",
  21310. Info: "2208",
  21311. }
  21312. customData = append(customData, custom17)
  21313. adminUser := c.GetAdminUserInfo()
  21314. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21315. for _, item := range customData {
  21316. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  21317. fmt.Println(result)
  21318. }
  21319. }
  21320. func PathExists(path string) (bool, error) {
  21321. _, err := os.Stat(path)
  21322. if err == nil {
  21323. return true, nil
  21324. }
  21325. if os.IsNotExist(err) {
  21326. return false, nil
  21327. }
  21328. return false, err
  21329. }
  21330. // 创建文件夹
  21331. func Mkdir(dir string) {
  21332. // 创建文件夹
  21333. exist, err := PathExists(dir)
  21334. if err != nil {
  21335. fmt.Println(err.Error())
  21336. } else {
  21337. if exist {
  21338. fmt.Println(dir + "文件夹已存在!")
  21339. } else {
  21340. // 文件夹名称,权限
  21341. err := os.Mkdir(dir, os.ModePerm)
  21342. if err != nil {
  21343. fmt.Println(dir+"文件夹创建失败:", err.Error())
  21344. } else {
  21345. fmt.Println(dir + "文件夹创建成功!")
  21346. }
  21347. }
  21348. }
  21349. }
  21350. // 压缩文件
  21351. func Zip(srcFile string, destZip string) error {
  21352. zipfile, err := os.Create(destZip)
  21353. if err != nil {
  21354. return err
  21355. }
  21356. defer zipfile.Close()
  21357. archive := zip.NewWriter(zipfile)
  21358. defer archive.Close()
  21359. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  21360. if err != nil {
  21361. return err
  21362. }
  21363. header, err := zip.FileInfoHeader(info)
  21364. if err != nil {
  21365. return err
  21366. }
  21367. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  21368. // header.Name = path
  21369. if info.IsDir() {
  21370. header.Name += "/"
  21371. } else {
  21372. header.Method = zip.Deflate
  21373. }
  21374. writer, err := archive.CreateHeader(header)
  21375. if err != nil {
  21376. return err
  21377. }
  21378. if !info.IsDir() {
  21379. file, err := os.Open(path)
  21380. if err != nil {
  21381. return err
  21382. }
  21383. defer file.Close()
  21384. _, err = io.Copy(writer, file)
  21385. }
  21386. return err
  21387. })
  21388. return err
  21389. }
  21390. func ReadFile(filePath string) []byte {
  21391. f, err := os.Open(filePath)
  21392. if err != nil {
  21393. fmt.Println("read file fail", err)
  21394. return nil
  21395. }
  21396. defer f.Close()
  21397. fd, err := ioutil.ReadAll(f)
  21398. if err != nil {
  21399. fmt.Println("read to fd fail", err)
  21400. return nil
  21401. }
  21402. return fd
  21403. }
  21404. func saveLog(result string, request string, infno string, desc string) {
  21405. org_id, _ := beego.AppConfig.Int64("org_id")
  21406. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  21407. dir := miConfig.OrgName + "日志"
  21408. utils.Mkdir(dir)
  21409. month := time.Unix(1557042972, 0).Format("1")
  21410. year := time.Now().Format("2006")
  21411. month = time.Now().Format("01")
  21412. day := time.Now().Format("02")
  21413. hour := time.Now().Format("15")
  21414. min := time.Now().Format("04")
  21415. sec := time.Now().Format("05")
  21416. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  21417. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  21418. file_name := file + ".txt"
  21419. file_path := miConfig.OrgName + "日志" + "/" + file_name
  21420. exist, _ := utils.PathExists(file_path)
  21421. if exist { //存在
  21422. fmt.Println("存在")
  21423. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  21424. if err != nil {
  21425. fmt.Println("read fail")
  21426. }
  21427. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  21428. n, _ := f.Seek(0, 2)
  21429. _, err = f.WriteAt([]byte(content), n)
  21430. } else { //不存在
  21431. fmt.Println("文件不存在,创建文件")
  21432. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  21433. defer f.Close()
  21434. if err != nil {
  21435. } else {
  21436. _, err = f.Write([]byte("记录日志"))
  21437. }
  21438. }
  21439. }
  21440. type Charset string
  21441. const (
  21442. UTF8 = Charset("UTF-8")
  21443. GB18030 = Charset("GB18030")
  21444. )
  21445. func ConvertToString(src string, srcCode string, tagCode string) string {
  21446. srcCoder := mahonia.NewDecoder(srcCode)
  21447. srcResult := srcCoder.ConvertString(src)
  21448. tagCoder := mahonia.NewDecoder(tagCode)
  21449. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  21450. result := string(cdata)
  21451. return result
  21452. }
  21453. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  21454. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  21455. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  21456. var token string
  21457. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21458. var api string
  21459. if miConfig.MdtrtareaAdmvs == "320921" {
  21460. 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 +
  21461. "&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
  21462. fmt.Println(api)
  21463. } else {
  21464. 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 +
  21465. "&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
  21466. }
  21467. resp, requestErr := http.Get(api)
  21468. if requestErr != nil {
  21469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21470. return ""
  21471. }
  21472. body, ioErr := ioutil.ReadAll(resp.Body)
  21473. if ioErr != nil {
  21474. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21476. return ""
  21477. }
  21478. var respJSON map[string]interface{}
  21479. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21480. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21482. return ""
  21483. }
  21484. var status string
  21485. status = respJSON["data"].(map[string]interface{})["status"].(string)
  21486. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  21487. var res ResultTwo //1101结果
  21488. var res10265 ResultTwo10265 //1101结果
  21489. if status == "0" { //读卡成功
  21490. var card_info string //卡信息
  21491. var busi_card_info string
  21492. token = respJSON["data"].(map[string]interface{})["token"].(string)
  21493. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  21494. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  21495. fmt.Println(card_info)
  21496. fmt.Println(busi_card_info)
  21497. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  21498. result, _ := json.Marshal(respJSON)
  21499. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  21500. utils.ErrorLog("解析失败:%v", err)
  21501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21502. return ""
  21503. }
  21504. res.ErrMsg = res10265.ErrMsg
  21505. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  21506. res.Infcode = infocode
  21507. res.Output = res10265.Output
  21508. res.InfRefmsgid = res10265.InfRefmsgid
  21509. if res.Infcode == 0 {
  21510. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  21511. if err == gorm.ErrRecordNotFound {
  21512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  21513. return ""
  21514. } else if err != nil {
  21515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  21516. return ""
  21517. } else {
  21518. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21519. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21520. infoStr := string(Iinfos)
  21521. idetinfoStr := string(Idetinfos)
  21522. psn := &models.HisPsn{
  21523. PsnNo: res.Output.Baseinfo.PsnNo,
  21524. Age: res.Output.Baseinfo.Age,
  21525. PatientId: patient.ID,
  21526. Certno: res.Output.Baseinfo.Certno,
  21527. Brdy: res.Output.Baseinfo.Brdy,
  21528. Gend: res.Output.Baseinfo.Gend,
  21529. Naty: res.Output.Baseinfo.Naty,
  21530. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21531. PsnName: res.Output.Baseinfo.PsnName,
  21532. Idetinfo: idetinfoStr,
  21533. Insuinfo: infoStr,
  21534. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21535. CardInfo: card_info,
  21536. VerifyNumber: token,
  21537. }
  21538. service.CreateHisPsn(psn)
  21539. return token
  21540. }
  21541. }
  21542. } else {
  21543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21544. return ""
  21545. }
  21546. } else { //读卡失败
  21547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21548. return ""
  21549. }
  21550. return token
  21551. }
  21552. func DeleteExtraSpaceTwo(s string) string {
  21553. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  21554. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  21555. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  21556. reg, _ := regexp.Compile(regstr) //编译正则表达式
  21557. s2 := make([]byte, len(s1)) //定义字符数组切片
  21558. copy(s2, s1) //将字符串复制到切片
  21559. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  21560. for len(spc_index) > 0 { //找到适配项
  21561. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  21562. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  21563. }
  21564. return string(s2)
  21565. }
  21566. func Remove0000(s string) string {
  21567. str := make([]rune, 0, len(s))
  21568. for _, v := range []rune(s) {
  21569. if v == 0 {
  21570. continue
  21571. }
  21572. str = append(str, v)
  21573. }
  21574. return string(str)
  21575. }
  21576. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  21577. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  21578. readCard := DllDef.MustFindProc("EcQuery")
  21579. pCardInfo := make([]byte, 8192)
  21580. pBusiCardInfo := make([]byte, 8192)
  21581. data := make(map[string]interface{})
  21582. //pData := make(map[string]interface{})
  21583. inputData := make(map[string]interface{})
  21584. inputData["orgId"] = code
  21585. inputData["businessType"] = "01101"
  21586. inputData["operatorId"] = operator_id
  21587. inputData["operatorName"] = operator_name
  21588. inputData["officeId"] = "001"
  21589. inputData["officeName"] = "血透室"
  21590. //
  21591. data["data"] = inputData
  21592. data["transType"] = "ec.query"
  21593. data["orgId"] = code
  21594. bytesData, _ := json.Marshal(data)
  21595. pCardInfo = bytesData
  21596. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  21597. fmt.Println(ret2)
  21598. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  21599. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  21600. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  21601. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  21602. if ret2 != 0 {
  21603. return "", ""
  21604. }
  21605. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  21606. }
  21607. func DeleteExtraSpace(s string) string {
  21608. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  21609. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  21610. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  21611. reg, _ := regexp.Compile(regstr) //编译正则表达式
  21612. s2 := make([]byte, len(s1)) //定义字符数组切片
  21613. copy(s2, s1) //将字符串复制到切片
  21614. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  21615. for len(spc_index) > 0 { //找到适配项
  21616. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  21617. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  21618. }
  21619. return string(s2)
  21620. }
  21621. // 对账
  21622. func (c *HisApiController) Post3202() {
  21623. start_time := c.GetString("start_time")
  21624. end_time := c.GetString("end_time")
  21625. //insutype := c.GetString("insutype")
  21626. clr_type := c.GetString("clr_type")
  21627. clr_org := c.GetString("clr_optins")
  21628. admin_user_id, _ := c.GetInt64("admin_user_id")
  21629. adminUser := c.GetAdminUserInfo()
  21630. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21631. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  21632. if len(clr_org) == 0 {
  21633. clr_org = miConfig.MdtrtareaAdmvs
  21634. }
  21635. timeLayout := "2006-01-02"
  21636. loc, _ := time.LoadLocation("Local")
  21637. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  21638. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  21639. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  21640. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  21641. //fixmedins_setl_cnt := int64(len(orders))
  21642. var medfee_sumamt float64
  21643. var acct_pay float64
  21644. var fund_pay_sumamt float64
  21645. for _, item := range orders {
  21646. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  21647. acct_pay = acct_pay + item.AcctPay
  21648. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  21649. }
  21650. //var medfee_sumamt_two float64
  21651. //var acct_pay_two float64
  21652. //var fund_pay_sumamt_two float64
  21653. //for _, item := range orders_two {
  21654. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  21655. // acct_pay_two = acct_pay_two + item.AcctPay
  21656. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  21657. //}
  21658. //var user_name string
  21659. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  21660. //if role.ID == 0 {
  21661. // user_name = "xxx"
  21662. //} else {
  21663. // user_name = role.UserName
  21664. //}
  21665. var res ResultSix
  21666. if config.IsOpen == 1 {
  21667. var bps []*models.BusinessParamsTwo
  21668. var bp models.BusinessParamsTwo
  21669. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  21670. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  21671. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  21672. bp.MedfeeSumamt = medfee_sumamt_str
  21673. bp.AcctPay = acct_pay_str
  21674. bp.FundPaySumamt = fund_pay_sumamt_str
  21675. bp.Insutype = "390"
  21676. bp.StmtBegndate = start_time
  21677. bp.ClrType = clr_type
  21678. bp.SetlOptins = clr_org
  21679. bp.StmtEnddate = end_time
  21680. bps = append(bps, &bp)
  21681. data := make(map[string]interface{})
  21682. data["bps"] = bps
  21683. data["org_name"] = miConfig.OrgName
  21684. data["doctor"] = role.UserName
  21685. data["fixmedins_code"] = miConfig.Code
  21686. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21687. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21688. if miConfig.MdtrtareaAdmvs == "421300" {
  21689. client := &http.Client{}
  21690. bytesData, _ := json.Marshal(data)
  21691. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  21692. resp, _ := client.Do(req)
  21693. defer resp.Body.Close()
  21694. body, ioErr := ioutil.ReadAll(resp.Body)
  21695. if ioErr != nil {
  21696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21698. return
  21699. }
  21700. var respJSON map[string]interface{}
  21701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21704. return
  21705. }
  21706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21707. userJSONBytes, _ := json.Marshal(respJSON)
  21708. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21709. utils.ErrorLog("解析失败:%v", err)
  21710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21711. return
  21712. }
  21713. }
  21714. if res.Infcode == 0 {
  21715. c.ServeSuccessJSON(map[string]interface{}{
  21716. "msg": "发起成功",
  21717. })
  21718. } else {
  21719. c.ServeSuccessJSON(map[string]interface{}{
  21720. "code": -10,
  21721. "msg": res.ErrMsg,
  21722. })
  21723. }
  21724. }
  21725. }
  21726. //5.11.1.1【5262】结算信息按时间段查询
  21727. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  21728. admin_user_id, _ := c.GetInt64("admin_user_id")
  21729. adminUser := c.GetAdminUserInfo()
  21730. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21731. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  21732. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  21733. var res Result5262
  21734. if config.IsOpen == 1 {
  21735. if miConfig.MdtrtareaAdmvs == "421300" {
  21736. data := make(map[string]interface{})
  21737. data["bps"] = bp
  21738. data["org_name"] = miConfig.OrgName
  21739. data["doctor"] = role.UserName
  21740. data["fixmedins_code"] = miConfig.Code
  21741. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21742. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21743. data["page"] = strconv.FormatInt(page, 10)
  21744. data["limit"] = strconv.FormatInt(limit, 10)
  21745. fmt.Println(data)
  21746. client := &http.Client{}
  21747. bytesData, _ := json.Marshal(data)
  21748. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  21749. resp, _ := client.Do(req)
  21750. defer resp.Body.Close()
  21751. body, ioErr := ioutil.ReadAll(resp.Body)
  21752. if ioErr != nil {
  21753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21755. return
  21756. }
  21757. var respJSON map[string]interface{}
  21758. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21761. return
  21762. }
  21763. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21764. userJSONBytes, _ := json.Marshal(respJSON)
  21765. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21766. utils.ErrorLog("解析失败:%v", err)
  21767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21768. return
  21769. }
  21770. }
  21771. if res.Infcode == 0 {
  21772. c.ServeSuccessJSON(map[string]interface{}{
  21773. "order": res.Output.Result,
  21774. "total": res.Output.PageInfo.RecordCounts,
  21775. })
  21776. } else {
  21777. c.ServeSuccessJSON(map[string]interface{}{
  21778. "code": -10,
  21779. "msg": res.ErrMsg,
  21780. })
  21781. }
  21782. }
  21783. }
  21784. //5.11.1.2【5267】异地结算信息时间段查询
  21785. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  21786. admin_user_id, _ := c.GetInt64("admin_user_id")
  21787. adminUser := c.GetAdminUserInfo()
  21788. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21789. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  21790. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  21791. var res Result5267
  21792. if config.IsOpen == 1 {
  21793. if miConfig.MdtrtareaAdmvs == "421300" {
  21794. data := make(map[string]interface{})
  21795. data["bps"] = bp
  21796. data["org_name"] = miConfig.OrgName
  21797. data["doctor"] = role.UserName
  21798. data["fixmedins_code"] = miConfig.Code
  21799. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21800. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21801. data["page"] = page
  21802. data["limit"] = limit
  21803. fmt.Println(data)
  21804. client := &http.Client{}
  21805. bytesData, _ := json.Marshal(data)
  21806. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  21807. resp, _ := client.Do(req)
  21808. defer resp.Body.Close()
  21809. body, ioErr := ioutil.ReadAll(resp.Body)
  21810. if ioErr != nil {
  21811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21813. return
  21814. }
  21815. var respJSON map[string]interface{}
  21816. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21819. return
  21820. }
  21821. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21822. userJSONBytes, _ := json.Marshal(respJSON)
  21823. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21824. utils.ErrorLog("解析失败:%v", err)
  21825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21826. return
  21827. }
  21828. }
  21829. if res.Infcode == 0 {
  21830. c.ServeSuccessJSON(map[string]interface{}{
  21831. "order": res.Output.Result,
  21832. "total": res.Output.PageInfo.RecordCounts,
  21833. })
  21834. } else {
  21835. c.ServeSuccessJSON(map[string]interface{}{
  21836. "code": -10,
  21837. "msg": res.ErrMsg,
  21838. })
  21839. }
  21840. }
  21841. }
  21842. func (c *HisApiController) Post3501() {
  21843. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21844. data := make(map[string]interface{})
  21845. var struct3501s []models.Struct3501
  21846. var struct3501 models.Struct3501
  21847. struct3501.OrgName = miConfig.OrgName
  21848. struct3501.AccessKey = miConfig.AccessKey
  21849. struct3501.RequestUrl = miConfig.Url
  21850. struct3501.SecretKey = miConfig.SecretKey
  21851. struct3501.ManuDate = "2022-08-17"
  21852. struct3501.FixmedinsBchno = ""
  21853. struct3501.ManuLotnum = ""
  21854. struct3501.RxFlag = "0"
  21855. struct3501.ExpyEnd = "2022-08-17"
  21856. struct3501.Invdate = "2022-08-17"
  21857. struct3501.InvCnt = "20.25"
  21858. struct3501.Memo = ""
  21859. struct3501.MedListCodg = "XB01ABD056B002020200517"
  21860. struct3501.FixmedinsHilistId = miConfig.Code
  21861. struct3501.FixmedinsHilistName = miConfig.OrgName
  21862. struct3501s = append(struct3501s, struct3501)
  21863. data["struct_3501s"] = struct3501s
  21864. client := &http.Client{}
  21865. bytesData, _ := json.Marshal(data)
  21866. var req *http.Request
  21867. if miConfig.MdtrtareaAdmvs == "320921" {
  21868. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  21869. } else {
  21870. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  21871. }
  21872. resp, _ := client.Do(req)
  21873. defer resp.Body.Close()
  21874. body, ioErr := ioutil.ReadAll(resp.Body)
  21875. if ioErr != nil {
  21876. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21878. return
  21879. }
  21880. var respJSON map[string]interface{}
  21881. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21884. return
  21885. }
  21886. var res ResultSix
  21887. var resSix10265 ResultSix10265 //1101结果
  21888. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  21889. result, _ := json.Marshal(respJSON)
  21890. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  21891. utils.ErrorLog("解析失败:%v", err)
  21892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21893. return
  21894. }
  21895. res.InfRefmsgid = resSix10265.InfRefmsgid
  21896. res.Output = resSix10265.Output
  21897. res.ErrMsg = resSix10265.ErrMsg
  21898. res.Cainfo = resSix10265.Cainfo
  21899. res.WarnMsg = resSix10265.WarnMsg
  21900. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21901. res.Infcode = infocode
  21902. if infocode == 0 {
  21903. c.ServeSuccessJSON(map[string]interface{}{
  21904. "msg": "上传成功",
  21905. })
  21906. return
  21907. } else {
  21908. c.ServeSuccessJSON(map[string]interface{}{
  21909. "failed_code": -10,
  21910. "msg": res.ErrMsg,
  21911. })
  21912. return
  21913. }
  21914. }
  21915. func (c *HisApiController) Post3502() {
  21916. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21917. data := make(map[string]interface{})
  21918. var struct3502s []models.Struct3502
  21919. var struct3502 models.Struct3502
  21920. struct3502.OrgName = miConfig.OrgName
  21921. struct3502.AccessKey = miConfig.AccessKey
  21922. struct3502.RequestUrl = miConfig.Url
  21923. struct3502.SecretKey = miConfig.SecretKey
  21924. struct3502.ManuDate = "2022-08-15"
  21925. struct3502.FixmedinsBchno = ""
  21926. struct3502.ManuLotnum = ""
  21927. struct3502.RxFlag = "0"
  21928. struct3502.ExpyEnd = "2022-08-15"
  21929. struct3502.Invdate = "2022-08-15"
  21930. struct3502.InvCnt = "20.25"
  21931. struct3502.Memo = ""
  21932. struct3502.MedListCodg = "XB01ABD056B002020200517"
  21933. struct3502.FixmedinsHilistId = miConfig.Code
  21934. struct3502.FixmedinsHilistName = miConfig.OrgName
  21935. struct3502s = append(struct3502s, struct3502)
  21936. data["struct_3502s"] = struct3502s
  21937. client := &http.Client{}
  21938. bytesData, _ := json.Marshal(data)
  21939. var req *http.Request
  21940. if miConfig.MdtrtareaAdmvs == "320921" {
  21941. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  21942. } else {
  21943. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  21944. }
  21945. resp, _ := client.Do(req)
  21946. defer resp.Body.Close()
  21947. body, ioErr := ioutil.ReadAll(resp.Body)
  21948. if ioErr != nil {
  21949. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21951. return
  21952. }
  21953. var respJSON map[string]interface{}
  21954. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21957. return
  21958. }
  21959. var res ResultSix
  21960. var resSix10265 ResultSix10265 //1101结果
  21961. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  21962. result, _ := json.Marshal(respJSON)
  21963. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  21964. utils.ErrorLog("解析失败:%v", err)
  21965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21966. return
  21967. }
  21968. res.InfRefmsgid = resSix10265.InfRefmsgid
  21969. res.Output = resSix10265.Output
  21970. res.ErrMsg = resSix10265.ErrMsg
  21971. res.Cainfo = resSix10265.Cainfo
  21972. res.WarnMsg = resSix10265.WarnMsg
  21973. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21974. res.Infcode = infocode
  21975. if infocode == 0 {
  21976. c.ServeSuccessJSON(map[string]interface{}{
  21977. "msg": "上传成功",
  21978. })
  21979. return
  21980. } else {
  21981. c.ServeSuccessJSON(map[string]interface{}{
  21982. "failed_code": -10,
  21983. "msg": res.ErrMsg,
  21984. })
  21985. return
  21986. }
  21987. }
  21988. func (c *HisApiController) Post3503() {
  21989. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21990. data := make(map[string]interface{})
  21991. var struct3501s []models.Struct3501
  21992. var struct3501 models.Struct3501
  21993. struct3501.OrgName = miConfig.OrgName
  21994. struct3501.AccessKey = miConfig.AccessKey
  21995. struct3501.RequestUrl = miConfig.Url
  21996. struct3501.SecretKey = miConfig.SecretKey
  21997. struct3501.ManuDate = "2022-08-15"
  21998. struct3501.FixmedinsBchno = ""
  21999. struct3501.ManuLotnum = ""
  22000. struct3501.RxFlag = "0"
  22001. struct3501.ExpyEnd = "2022-08-15"
  22002. struct3501.Invdate = "2022-08-15"
  22003. struct3501.InvCnt = "20.25"
  22004. struct3501.Memo = ""
  22005. struct3501.MedListCodg = "XB01ABD056B002020200517"
  22006. struct3501.FixmedinsHilistId = miConfig.Code
  22007. struct3501.FixmedinsHilistName = miConfig.OrgName
  22008. struct3501s = append(struct3501s, struct3501)
  22009. data["struct_3501s"] = struct3501s
  22010. client := &http.Client{}
  22011. bytesData, _ := json.Marshal(data)
  22012. var req *http.Request
  22013. if miConfig.MdtrtareaAdmvs == "320921" {
  22014. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  22015. } else {
  22016. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  22017. }
  22018. resp, _ := client.Do(req)
  22019. defer resp.Body.Close()
  22020. body, ioErr := ioutil.ReadAll(resp.Body)
  22021. if ioErr != nil {
  22022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22024. return
  22025. }
  22026. var respJSON map[string]interface{}
  22027. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22030. return
  22031. }
  22032. var res ResultSix
  22033. var resSix10265 ResultSix10265 //1101结果
  22034. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  22035. result, _ := json.Marshal(respJSON)
  22036. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  22037. utils.ErrorLog("解析失败:%v", err)
  22038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22039. return
  22040. }
  22041. res.InfRefmsgid = resSix10265.InfRefmsgid
  22042. res.Output = resSix10265.Output
  22043. res.ErrMsg = resSix10265.ErrMsg
  22044. res.Cainfo = resSix10265.Cainfo
  22045. res.WarnMsg = resSix10265.WarnMsg
  22046. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22047. res.Infcode = infocode
  22048. if infocode == 0 {
  22049. c.ServeSuccessJSON(map[string]interface{}{
  22050. "msg": "上传成功",
  22051. })
  22052. return
  22053. } else {
  22054. c.ServeSuccessJSON(map[string]interface{}{
  22055. "failed_code": -10,
  22056. "msg": res.ErrMsg,
  22057. })
  22058. return
  22059. }
  22060. }
  22061. func (c *HisApiController) Post3504() {
  22062. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  22063. data := make(map[string]interface{})
  22064. var struct3501s []models.Struct3501
  22065. var struct3501 models.Struct3501
  22066. struct3501.OrgName = miConfig.OrgName
  22067. struct3501.AccessKey = miConfig.AccessKey
  22068. struct3501.RequestUrl = miConfig.Url
  22069. struct3501.SecretKey = miConfig.SecretKey
  22070. struct3501.ManuDate = "2022-08-15"
  22071. struct3501.FixmedinsBchno = ""
  22072. struct3501.ManuLotnum = ""
  22073. struct3501.RxFlag = "0"
  22074. struct3501.ExpyEnd = "2022-08-15"
  22075. struct3501.Invdate = "2022-08-15"
  22076. struct3501.InvCnt = "20.25"
  22077. struct3501.Memo = ""
  22078. struct3501.MedListCodg = "XB01ABD056B002020200517"
  22079. struct3501.FixmedinsHilistId = miConfig.Code
  22080. struct3501.FixmedinsHilistName = miConfig.OrgName
  22081. struct3501s = append(struct3501s, struct3501)
  22082. data["struct_3501s"] = struct3501s
  22083. client := &http.Client{}
  22084. bytesData, _ := json.Marshal(data)
  22085. var req *http.Request
  22086. if miConfig.MdtrtareaAdmvs == "320921" {
  22087. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  22088. } else {
  22089. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  22090. }
  22091. resp, _ := client.Do(req)
  22092. defer resp.Body.Close()
  22093. body, ioErr := ioutil.ReadAll(resp.Body)
  22094. if ioErr != nil {
  22095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22097. return
  22098. }
  22099. var respJSON map[string]interface{}
  22100. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22103. return
  22104. }
  22105. var res ResultSix
  22106. var resSix10265 ResultSix10265 //1101结果
  22107. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  22108. result, _ := json.Marshal(respJSON)
  22109. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  22110. utils.ErrorLog("解析失败:%v", err)
  22111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22112. return
  22113. }
  22114. res.InfRefmsgid = resSix10265.InfRefmsgid
  22115. res.Output = resSix10265.Output
  22116. res.ErrMsg = resSix10265.ErrMsg
  22117. res.Cainfo = resSix10265.Cainfo
  22118. res.WarnMsg = resSix10265.WarnMsg
  22119. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22120. res.Infcode = infocode
  22121. if infocode == 0 {
  22122. c.ServeSuccessJSON(map[string]interface{}{
  22123. "msg": "上传成功",
  22124. })
  22125. return
  22126. } else {
  22127. c.ServeSuccessJSON(map[string]interface{}{
  22128. "failed_code": -10,
  22129. "msg": res.ErrMsg,
  22130. })
  22131. return
  22132. }
  22133. }
  22134. func (c *HisApiController) Post3505() {
  22135. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  22136. data := make(map[string]interface{})
  22137. var struct3501s []models.Struct3501
  22138. var struct3501 models.Struct3501
  22139. struct3501.OrgName = miConfig.OrgName
  22140. struct3501.AccessKey = miConfig.AccessKey
  22141. struct3501.RequestUrl = miConfig.Url
  22142. struct3501.SecretKey = miConfig.SecretKey
  22143. struct3501.ManuDate = "2022-08-15"
  22144. struct3501.FixmedinsBchno = ""
  22145. struct3501.ManuLotnum = ""
  22146. struct3501.RxFlag = "0"
  22147. struct3501.ExpyEnd = "2022-08-15"
  22148. struct3501.Invdate = "2022-08-15"
  22149. struct3501.InvCnt = "20.25"
  22150. struct3501.Memo = ""
  22151. struct3501.MedListCodg = "XB01ABD056B002020200517"
  22152. struct3501.FixmedinsHilistId = miConfig.Code
  22153. struct3501.FixmedinsHilistName = miConfig.OrgName
  22154. struct3501s = append(struct3501s, struct3501)
  22155. data["struct_3501s"] = struct3501s
  22156. client := &http.Client{}
  22157. bytesData, _ := json.Marshal(data)
  22158. var req *http.Request
  22159. if miConfig.MdtrtareaAdmvs == "320921" {
  22160. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  22161. } else {
  22162. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  22163. }
  22164. resp, _ := client.Do(req)
  22165. defer resp.Body.Close()
  22166. body, ioErr := ioutil.ReadAll(resp.Body)
  22167. if ioErr != nil {
  22168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22170. return
  22171. }
  22172. var respJSON map[string]interface{}
  22173. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22176. return
  22177. }
  22178. var res ResultSix
  22179. var resSix10265 ResultSix10265 //1101结果
  22180. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  22181. result, _ := json.Marshal(respJSON)
  22182. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  22183. utils.ErrorLog("解析失败:%v", err)
  22184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22185. return
  22186. }
  22187. res.InfRefmsgid = resSix10265.InfRefmsgid
  22188. res.Output = resSix10265.Output
  22189. res.ErrMsg = resSix10265.ErrMsg
  22190. res.Cainfo = resSix10265.Cainfo
  22191. res.WarnMsg = resSix10265.WarnMsg
  22192. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22193. res.Infcode = infocode
  22194. if infocode == 0 {
  22195. c.ServeSuccessJSON(map[string]interface{}{
  22196. "msg": "上传成功",
  22197. })
  22198. return
  22199. } else {
  22200. c.ServeSuccessJSON(map[string]interface{}{
  22201. "failed_code": -10,
  22202. "msg": res.ErrMsg,
  22203. })
  22204. return
  22205. }
  22206. }
  22207. func (c *HisApiController) Post3506() {
  22208. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  22209. data := make(map[string]interface{})
  22210. var struct3501s []models.Struct3501
  22211. var struct3501 models.Struct3501
  22212. struct3501.OrgName = miConfig.OrgName
  22213. struct3501.AccessKey = miConfig.AccessKey
  22214. struct3501.RequestUrl = miConfig.Url
  22215. struct3501.SecretKey = miConfig.SecretKey
  22216. struct3501.ManuDate = "2022-08-15"
  22217. struct3501.FixmedinsBchno = ""
  22218. struct3501.ManuLotnum = ""
  22219. struct3501.RxFlag = "0"
  22220. struct3501.ExpyEnd = "2022-08-15"
  22221. struct3501.Invdate = "2022-08-15"
  22222. struct3501.InvCnt = "20.25"
  22223. struct3501.Memo = ""
  22224. struct3501.MedListCodg = "XB01ABD056B002020200517"
  22225. struct3501.FixmedinsHilistId = miConfig.Code
  22226. struct3501.FixmedinsHilistName = miConfig.OrgName
  22227. struct3501s = append(struct3501s, struct3501)
  22228. data["struct_3501s"] = struct3501s
  22229. client := &http.Client{}
  22230. bytesData, _ := json.Marshal(data)
  22231. var req *http.Request
  22232. if miConfig.MdtrtareaAdmvs == "320921" {
  22233. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  22234. } else {
  22235. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  22236. }
  22237. resp, _ := client.Do(req)
  22238. defer resp.Body.Close()
  22239. body, ioErr := ioutil.ReadAll(resp.Body)
  22240. if ioErr != nil {
  22241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22243. return
  22244. }
  22245. var respJSON map[string]interface{}
  22246. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22249. return
  22250. }
  22251. var res ResultSix
  22252. var resSix10265 ResultSix10265 //1101结果
  22253. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  22254. result, _ := json.Marshal(respJSON)
  22255. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  22256. utils.ErrorLog("解析失败:%v", err)
  22257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22258. return
  22259. }
  22260. res.InfRefmsgid = resSix10265.InfRefmsgid
  22261. res.Output = resSix10265.Output
  22262. res.ErrMsg = resSix10265.ErrMsg
  22263. res.Cainfo = resSix10265.Cainfo
  22264. res.WarnMsg = resSix10265.WarnMsg
  22265. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22266. res.Infcode = infocode
  22267. if infocode == 0 {
  22268. c.ServeSuccessJSON(map[string]interface{}{
  22269. "msg": "上传成功",
  22270. })
  22271. return
  22272. } else {
  22273. c.ServeSuccessJSON(map[string]interface{}{
  22274. "failed_code": -10,
  22275. "msg": res.ErrMsg,
  22276. })
  22277. return
  22278. }
  22279. }
  22280. func (c *HisApiController) Post3507() {
  22281. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  22282. data := make(map[string]interface{})
  22283. var struct3501s []models.Struct3501
  22284. var struct3501 models.Struct3501
  22285. struct3501.OrgName = miConfig.OrgName
  22286. struct3501.AccessKey = miConfig.AccessKey
  22287. struct3501.RequestUrl = miConfig.Url
  22288. struct3501.SecretKey = miConfig.SecretKey
  22289. struct3501.ManuDate = "2022-08-15"
  22290. struct3501.FixmedinsBchno = ""
  22291. struct3501.ManuLotnum = ""
  22292. struct3501.RxFlag = "0"
  22293. struct3501.ExpyEnd = "2022-08-15"
  22294. struct3501.Invdate = "2022-08-15"
  22295. struct3501.InvCnt = "20.25"
  22296. struct3501.Memo = ""
  22297. struct3501.MedListCodg = "XB01ABD056B002020200517"
  22298. struct3501.FixmedinsHilistId = miConfig.Code
  22299. struct3501.FixmedinsHilistName = miConfig.OrgName
  22300. struct3501s = append(struct3501s, struct3501)
  22301. data["struct_3501s"] = struct3501s
  22302. client := &http.Client{}
  22303. bytesData, _ := json.Marshal(data)
  22304. var req *http.Request
  22305. if miConfig.MdtrtareaAdmvs == "320921" {
  22306. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  22307. } else {
  22308. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  22309. }
  22310. resp, _ := client.Do(req)
  22311. defer resp.Body.Close()
  22312. body, ioErr := ioutil.ReadAll(resp.Body)
  22313. if ioErr != nil {
  22314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22316. return
  22317. }
  22318. var respJSON map[string]interface{}
  22319. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22322. return
  22323. }
  22324. var res ResultSix
  22325. var resSix10265 ResultSix10265 //1101结果
  22326. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  22327. result, _ := json.Marshal(respJSON)
  22328. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  22329. utils.ErrorLog("解析失败:%v", err)
  22330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22331. return
  22332. }
  22333. res.InfRefmsgid = resSix10265.InfRefmsgid
  22334. res.Output = resSix10265.Output
  22335. res.ErrMsg = resSix10265.ErrMsg
  22336. res.Cainfo = resSix10265.Cainfo
  22337. res.WarnMsg = resSix10265.WarnMsg
  22338. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22339. res.Infcode = infocode
  22340. if infocode == 0 {
  22341. c.ServeSuccessJSON(map[string]interface{}{
  22342. "msg": "上传成功",
  22343. })
  22344. return
  22345. } else {
  22346. c.ServeSuccessJSON(map[string]interface{}{
  22347. "failed_code": -10,
  22348. "msg": res.ErrMsg,
  22349. })
  22350. return
  22351. }
  22352. }
  22353. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  22354. // WebSocket服务器地址
  22355. serverURL := "ws://127.0.0.1:8899"
  22356. // 解析WebSocket服务器地址
  22357. u, err := url.Parse(serverURL)
  22358. if err != nil {
  22359. }
  22360. // 建立WebSocket连接
  22361. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  22362. if err != nil {
  22363. }
  22364. defer conn.Close()
  22365. input2 := make(map[string]interface{})
  22366. input := make(map[string]interface{})
  22367. inputData := make(map[string]interface{})
  22368. inputData["orgId"] = code
  22369. inputData["businessType"] = "01101"
  22370. inputData["operatorId"] = operator_id
  22371. inputData["operatorName"] = operator_name
  22372. inputData["officeId"] = "001"
  22373. inputData["officeName"] = "血透室"
  22374. inputData["deviceType"] = ""
  22375. input["data"] = inputData
  22376. input["orgId"] = code
  22377. input["transType"] = "ec.query"
  22378. //if md == ""
  22379. if md[:4] == "4403" {
  22380. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  22381. } else if md[:4] == "4401" {
  22382. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  22383. } else {
  22384. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  22385. }
  22386. input2["indata"] = input
  22387. bytesData, _ := json.Marshal(input2)
  22388. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  22389. if err != nil {
  22390. fmt.Println(err)
  22391. }
  22392. // 接收消息
  22393. _, receivedMessage, err := conn.ReadMessage()
  22394. if err != nil {
  22395. fmt.Println(err)
  22396. }
  22397. return "", string(receivedMessage)
  22398. }
  22399. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  22400. // WebSocket服务器地址
  22401. serverURL := "ws://127.0.0.1:8899"
  22402. // 解析WebSocket服务器地址
  22403. u, err := url.Parse(serverURL)
  22404. if err != nil {
  22405. }
  22406. // 建立WebSocket连接
  22407. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  22408. if err != nil {
  22409. }
  22410. defer conn.Close()
  22411. input2 := make(map[string]interface{})
  22412. input := make(map[string]interface{})
  22413. inputData := make(map[string]interface{})
  22414. inputData["orgId"] = code
  22415. inputData["businessType"] = "01301"
  22416. inputData["operatorId"] = operator_id
  22417. inputData["operatorName"] = operator_name
  22418. inputData["officeId"] = "001"
  22419. inputData["officeName"] = "血透室"
  22420. inputData["deviceType"] = ""
  22421. input["data"] = inputData
  22422. input["orgId"] = code
  22423. input["transType"] = "ec.query"
  22424. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  22425. input2["indata"] = input
  22426. bytesData, _ := json.Marshal(input2)
  22427. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  22428. if err != nil {
  22429. fmt.Println(err)
  22430. }
  22431. // 接收消息
  22432. _, receivedMessage, err := conn.ReadMessage()
  22433. if err != nil {
  22434. fmt.Println(err)
  22435. }
  22436. return "", string(receivedMessage)
  22437. }
  22438. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  22439. newArr = make([]string, 0)
  22440. for i := 0; i < len(arr); i++ {
  22441. repeat := false
  22442. for j := i + 1; j < len(arr); j++ {
  22443. if arr[i] == arr[j] {
  22444. repeat = true
  22445. break
  22446. }
  22447. }
  22448. if !repeat {
  22449. newArr = append(newArr, arr[i])
  22450. }
  22451. }
  22452. return
  22453. }