his_api_controller.go 739KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "math"
  6. //"crypto/x509/pkix"
  7. "encoding/json"
  8. "fmt"
  9. //"github.com/tjfoc/gmsm/sm2"
  10. //"github.com/tjfoc/gmsm/sm3"
  11. "gdyb/controllers"
  12. "gdyb/enums"
  13. "gdyb/models"
  14. "gdyb/service"
  15. "gdyb/utils"
  16. "github.com/astaxie/beego"
  17. "github.com/axgle/mahonia"
  18. "github.com/gorilla/websocket"
  19. "github.com/jinzhu/gorm"
  20. "github.com/shopspring/decimal"
  21. "io"
  22. "io/ioutil"
  23. //"math"
  24. "math/rand"
  25. "net/http"
  26. "net/url"
  27. "os"
  28. "path/filepath"
  29. "regexp"
  30. "strconv"
  31. "strings"
  32. "syscall"
  33. "time"
  34. "unsafe"
  35. )
  36. type HisApiController struct {
  37. controllers.BaseAuthAPIController
  38. }
  39. func HisManagerApiRegistRouters() {
  40. //挂号
  41. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  42. //上传就诊信息-上传明细-结算
  43. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  44. //查询
  45. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  46. //对总账
  47. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  48. //对明细
  49. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  50. //退费,退明细
  51. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  52. //退号
  53. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  54. //退明细
  55. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  56. //上传就诊信息-上传明细-预结算
  57. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  58. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  59. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  60. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  61. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  62. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  63. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  64. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  65. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  66. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  67. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  68. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  69. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  70. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  71. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  72. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  73. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  74. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  75. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  76. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  77. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  78. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  79. beego.Router("/api/check", &HisApiController{}, "get:Check")
  80. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  81. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  82. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  83. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  84. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  85. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  86. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  87. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  88. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  89. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  90. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  91. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  92. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  93. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  94. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  95. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  96. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  97. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  98. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  99. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  100. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  101. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  102. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  103. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  104. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  105. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  106. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  107. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  108. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  109. //beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  110. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  111. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  112. beego.Router("/jsyb/3260", &HisApiController{}, "get:Get3260")
  113. beego.Router("/jsyb/3261", &HisApiController{}, "get:Get3261")
  114. beego.Router("/jsyb/3262", &HisApiController{}, "get:Get3262")
  115. beego.Router("/jsyb/3263", &HisApiController{}, "get:Get3263")
  116. beego.Router("/jsyb/3264", &HisApiController{}, "get:Get3264")
  117. beego.Router("/jsyb/3265", &HisApiController{}, "get:Get3265")
  118. beego.Router("/jsyb/3266", &HisApiController{}, "get:Get3266")
  119. beego.Router("/jsyb/3267", &HisApiController{}, "get:Get3267")
  120. beego.Router("/jsyb/3268", &HisApiController{}, "get:Get3268")
  121. beego.Router("/jsyb/3269", &HisApiController{}, "get:Get3269")
  122. beego.Router("/jsyb/3270", &HisApiController{}, "get:Get3270")
  123. beego.Router("/jsyb/3271", &HisApiController{}, "get:Get3271")
  124. beego.Router("/jsyb/3272", &HisApiController{}, "get:Get3272")
  125. beego.Router("/jsyb/3273", &HisApiController{}, "get:Get3273")
  126. beego.Router("/jsyb/3274", &HisApiController{}, "get:Get3274")
  127. beego.Router("/jsyb/3275", &HisApiController{}, "get:Get3275")
  128. beego.Router("/jsyb/3276", &HisApiController{}, "get:Get3276")
  129. beego.Router("/jsyb/3277", &HisApiController{}, "get:Get3277")
  130. }
  131. // 对账权限查询
  132. func (c *HisApiController) Get3260() {
  133. admin_user_id, _ := c.GetInt64("admin_user_id")
  134. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  135. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  136. var api string
  137. var res models.JSResult3260
  138. if miConfig.MdtrtareaAdmvs == "320921" {
  139. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  140. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  141. } else {
  142. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  143. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  144. }
  145. resp, requestErr := http.Get(api)
  146. if requestErr != nil {
  147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  148. return
  149. }
  150. body, ioErr := ioutil.ReadAll(resp.Body)
  151. if ioErr != nil {
  152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  154. return
  155. }
  156. var respJSON map[string]interface{}
  157. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  160. return
  161. }
  162. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  163. result, _ := json.Marshal(respJSON)
  164. if err := json.Unmarshal([]byte(result), &res); err != nil {
  165. utils.ErrorLog("解析失败:%v", err)
  166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  167. return
  168. }
  169. if res.Infcode == 0 {
  170. c.ServeSuccessJSON(map[string]interface{}{
  171. "result": res.Output.Data,
  172. })
  173. } else {
  174. c.ServeSuccessJSON(map[string]interface{}{
  175. "failed_code": -10,
  176. "msg": res.ErrMsg,
  177. })
  178. return
  179. }
  180. }
  181. func (c *HisApiController) Get3261() {
  182. admin_user_id, _ := c.GetInt64("admin_user_id")
  183. //month := c.GetString("month")
  184. startTime := c.GetString("start_time")
  185. //endTime, _ := c.GetString("end_time")
  186. times := strings.Split(startTime, "-")
  187. stmt_mon := times[0] + times[1]
  188. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  189. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  190. var api string
  191. var res models.JSResult3261
  192. //var res10265 Result5301For10265
  193. if miConfig.MdtrtareaAdmvs == "320921" {
  194. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  195. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  196. } else {
  197. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  198. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  199. }
  200. resp, requestErr := http.Get(api)
  201. if requestErr != nil {
  202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  203. return
  204. }
  205. body, ioErr := ioutil.ReadAll(resp.Body)
  206. if ioErr != nil {
  207. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  209. return
  210. }
  211. var respJSON map[string]interface{}
  212. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  215. return
  216. }
  217. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  218. result, _ := json.Marshal(respJSON)
  219. if err := json.Unmarshal([]byte(result), &res); err != nil {
  220. utils.ErrorLog("解析失败:%v", err)
  221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  222. return
  223. }
  224. if res.Infcode == 0 {
  225. c.ServeSuccessJSON(map[string]interface{}{
  226. "result": res.Output,
  227. })
  228. } else {
  229. c.ServeSuccessJSON(map[string]interface{}{
  230. "failed_code": -10,
  231. "msg": res.ErrMsg,
  232. })
  233. return
  234. }
  235. }
  236. func (c *HisApiController) Get3262() {
  237. admin_user_id, _ := c.GetInt64("admin_user_id")
  238. startTime, _ := c.GetString("start_time")
  239. endTime, _ := c.GetString("end_time")
  240. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  241. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  242. timeLayout := "2006-01-02"
  243. loc, _ := time.LoadLocation("Local")
  244. var theStartTIme int64
  245. if len(startTime) > 0 {
  246. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  247. if err != nil {
  248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  249. return
  250. }
  251. theStartTIme = theTime.Unix()
  252. }
  253. var theEndtTIme int64
  254. if len(endTime) > 0 {
  255. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  256. if err != nil {
  257. utils.ErrorLog(err.Error())
  258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  259. return
  260. }
  261. theEndtTIme = theTime.Unix()
  262. }
  263. datas, _ := service.GetOrderByTimeTen(theStartTIme, theEndtTIme, c.GetAdminUserInfo().CurrentOrgId)
  264. //startTime := c.GetString("start_time")
  265. //endTime, _ := c.GetString("end_time")
  266. times := strings.Split(startTime, "-")
  267. stmt_mon := times[0] + times[1]
  268. var funs []models.FundDetail
  269. for _, item := range datas {
  270. fun, _ := service.GetOrderDetailByTimeTen(theStartTIme, theEndtTIme, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  271. funs = append(funs, fun...)
  272. }
  273. var funInfos []models.Fund
  274. for _, item := range funs {
  275. var rf []models.FundInfo
  276. json.Unmarshal([]byte(item.SetlDetail), &rf)
  277. for _, subitem := range rf {
  278. var fund models.Fund
  279. fund.FundCode = subitem.FundPayType
  280. fund.FundName = subitem.FundPayTypeName
  281. fund.FundAmt = subitem.FundPayAmt
  282. fund.FundKey = item.FundKey
  283. fund.InsuAdmdvs = "555555"
  284. fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  285. funInfos = append(funInfos, fund)
  286. }
  287. }
  288. var upld_btch string
  289. var empty models.JSResultEmpty
  290. data := make(map[string]interface{})
  291. data["org_name"] = miConfig.OrgName
  292. data["doctor"] = curRoles.UserName
  293. data["doctor_name"] = curRoles.UserName
  294. data["fixmedins_code"] = miConfig.Code
  295. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  296. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  297. data["secret_key"] = miConfig.SecretKey
  298. data["url"] = miConfig.Url
  299. data["ak"] = miConfig.AccessKey
  300. data["cainfo"] = miConfig.Cainfo
  301. data["data"] = datas
  302. data["fund"] = funInfos
  303. month := time.Unix(1557042972, 0).Format("1")
  304. year := time.Now().Format("2006")
  305. month = time.Now().Format("01")
  306. day := time.Now().Format("02")
  307. hour := time.Now().Format("15")
  308. min := time.Now().Format("04")
  309. sec := time.Now().Format("05")
  310. fix_fill_date := year + month + day + hour + min + sec
  311. data["fix_fill_dept"] = miConfig.OrgName
  312. data["fix_fill_psn_id"] = curRoles.AdminUserId
  313. data["fix_fill_psn"] = curRoles.UserName
  314. data["fix_fill_date"] = fix_fill_date
  315. data["stmt_loc"] = "2"
  316. data["setl_mon"] = stmt_mon
  317. data["upld_btch"] = upld_btch
  318. client := &http.Client{}
  319. bytesData, _ := json.Marshal(data)
  320. var req *http.Request
  321. if miConfig.MdtrtareaAdmvs == "320921" {
  322. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  323. } else {
  324. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  325. }
  326. resp, _ := client.Do(req)
  327. defer resp.Body.Close()
  328. body, ioErr := ioutil.ReadAll(resp.Body)
  329. if ioErr != nil {
  330. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  332. }
  333. var respJSON map[string]interface{}
  334. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  337. }
  338. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  339. fmt.Println(respJSON)
  340. result, _ := json.Marshal(respJSON)
  341. fmt.Println(result)
  342. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  343. utils.ErrorLog("解析失败:%v", err)
  344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  345. }
  346. if empty.Infcode != 0 {
  347. c.ServeSuccessJSON(map[string]interface{}{
  348. "failed_code": -10,
  349. "msg": empty.ErrMsg,
  350. })
  351. return
  352. } else {
  353. c.ServeSuccessJSON(map[string]interface{}{
  354. "msg": "上传成功",
  355. })
  356. return
  357. }
  358. }
  359. func (c *HisApiController) Get3263() {
  360. admin_user_id, _ := c.GetInt64("admin_user_id")
  361. startTime := c.GetString("start_time")
  362. //endTime, _ := c.GetString("end_time")
  363. times := strings.Split(startTime, "-")
  364. setl_mon := times[0] + times[1]
  365. upld_btch := 0
  366. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  367. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  368. var result3263 models.JSResult3263
  369. data := make(map[string]interface{})
  370. data["org_name"] = miConfig.OrgName
  371. data["doctor"] = curRoles.UserName
  372. data["doctor_name"] = curRoles.UserName
  373. data["fixmedins_code"] = miConfig.Code
  374. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  375. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  376. data["secret_key"] = miConfig.SecretKey
  377. data["url"] = miConfig.Url
  378. data["ak"] = miConfig.AccessKey
  379. data["cainfo"] = miConfig.Cainfo
  380. data["setl_mon"] = setl_mon
  381. data["stmt_loc"] = "2"
  382. data["upld_btch"] = upld_btch
  383. client := &http.Client{}
  384. bytesData, _ := json.Marshal(data)
  385. var req *http.Request
  386. if miConfig.MdtrtareaAdmvs == "320921" {
  387. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  388. } else {
  389. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  390. }
  391. resp, _ := client.Do(req)
  392. defer resp.Body.Close()
  393. body, ioErr := ioutil.ReadAll(resp.Body)
  394. if ioErr != nil {
  395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  397. }
  398. var respJSON map[string]interface{}
  399. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  402. }
  403. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  404. fmt.Println(respJSON)
  405. result, _ := json.Marshal(respJSON)
  406. fmt.Println(result)
  407. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  408. utils.ErrorLog("解析失败:%v", err)
  409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  410. }
  411. if result3263.Infcode != 0 {
  412. c.ServeSuccessJSON(map[string]interface{}{
  413. "failed_code": -10,
  414. "msg": result3263.ErrMsg,
  415. })
  416. return
  417. } else {
  418. c.ServeSuccessJSON(map[string]interface{}{
  419. "list": result3263.Output.Data,
  420. })
  421. return
  422. }
  423. }
  424. func (c *HisApiController) Get3264() {
  425. admin_user_id, _ := c.GetInt64("admin_user_id")
  426. startTime := c.GetString("start_time")
  427. //endTime, _ := c.GetString("end_time")
  428. times := strings.Split(startTime, "-")
  429. setl_mon := times[0] + times[1]
  430. upld_btch := 0
  431. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  432. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  433. //solidify_id := []
  434. var empty models.JSResultEmpty
  435. data := make(map[string]interface{})
  436. data["org_name"] = miConfig.OrgName
  437. data["doctor"] = curRoles.UserName
  438. data["doctor_name"] = curRoles.UserName
  439. data["fixmedins_code"] = miConfig.Code
  440. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  441. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  442. data["secret_key"] = miConfig.SecretKey
  443. data["url"] = miConfig.Url
  444. data["ak"] = miConfig.AccessKey
  445. data["cainfo"] = miConfig.Cainfo
  446. data["setl_mon"] = setl_mon
  447. data["stmt_loc"] = "2"
  448. data["upld_btch"] = upld_btch
  449. //data["solidify_id"] = solidify_id
  450. client := &http.Client{}
  451. bytesData, _ := json.Marshal(data)
  452. var req *http.Request
  453. if miConfig.MdtrtareaAdmvs == "320921" {
  454. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData))
  455. } else {
  456. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData))
  457. }
  458. resp, _ := client.Do(req)
  459. defer resp.Body.Close()
  460. body, ioErr := ioutil.ReadAll(resp.Body)
  461. if ioErr != nil {
  462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  464. }
  465. var respJSON map[string]interface{}
  466. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  469. }
  470. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  471. fmt.Println(respJSON)
  472. result, _ := json.Marshal(respJSON)
  473. fmt.Println(result)
  474. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  475. utils.ErrorLog("解析失败:%v", err)
  476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  477. }
  478. if result3264.Infcode != 0 {
  479. c.ServeSuccessJSON(map[string]interface{}{
  480. "failed_code": -10,
  481. "msg": empty.ErrMsg,
  482. })
  483. return
  484. } else {
  485. c.ServeSuccessJSON(map[string]interface{}{
  486. "msg": "",
  487. })
  488. return
  489. }
  490. }
  491. func (c *HisApiController) Get3265() {
  492. admin_user_id, _ := c.GetInt64("admin_user_id")
  493. startTime, _ := c.GetString("start_time")
  494. //endTime, _ := c.GetString("end_time")
  495. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  496. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  497. times := strings.Split(startTime, "-")
  498. stmt_mon := times[0] + times[1]
  499. var upld_btch string
  500. //var empty models.JSResultEmpty
  501. var result3265 models.JSResult3264
  502. data := make(map[string]interface{})
  503. data["org_name"] = miConfig.OrgName
  504. data["doctor"] = curRoles.UserName
  505. data["doctor_name"] = curRoles.UserName
  506. data["fixmedins_code"] = miConfig.Code
  507. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  508. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  509. data["secret_key"] = miConfig.SecretKey
  510. data["url"] = miConfig.Url
  511. data["ak"] = miConfig.AccessKey
  512. data["cainfo"] = miConfig.Cainfo
  513. data["stmt_mon"] = stmt_mon
  514. month := time.Unix(1557042972, 0).Format("1")
  515. year := time.Now().Format("2006")
  516. month = time.Now().Format("01")
  517. day := time.Now().Format("02")
  518. hour := time.Now().Format("15")
  519. min := time.Now().Format("04")
  520. sec := time.Now().Format("05")
  521. fix_fill_date := year + month + day + hour + min + sec
  522. data["fix_fill_dept"] = miConfig.OrgName
  523. data["fix_fill_psn_id"] = curRoles.AdminUserId
  524. data["fix_fill_psn"] = curRoles.UserName
  525. data["fix_fill_date"] = fix_fill_date
  526. data["stmt_loc"] = "2"
  527. data["upld_btch"] = upld_btch
  528. client := &http.Client{}
  529. bytesData, _ := json.Marshal(data)
  530. var req *http.Request
  531. if miConfig.MdtrtareaAdmvs == "320921" {
  532. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  533. } else {
  534. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  535. }
  536. resp, _ := client.Do(req)
  537. defer resp.Body.Close()
  538. body, ioErr := ioutil.ReadAll(resp.Body)
  539. if ioErr != nil {
  540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  542. }
  543. var respJSON map[string]interface{}
  544. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  547. }
  548. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  549. fmt.Println(respJSON)
  550. result, _ := json.Marshal(respJSON)
  551. fmt.Println(result)
  552. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  553. utils.ErrorLog("解析失败:%v", err)
  554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  555. }
  556. if result3265.Infcode != 0 {
  557. c.ServeSuccessJSON(map[string]interface{}{
  558. "failed_code": -10,
  559. "msg": result3265.ErrMsg,
  560. })
  561. return
  562. } else {
  563. c.ServeSuccessJSON(map[string]interface{}{
  564. "info": result3265.Output.Data,
  565. })
  566. return
  567. }
  568. }
  569. func (c *HisApiController) Get3266() {
  570. admin_user_id, _ := c.GetInt64("admin_user_id")
  571. startTime, _ := c.GetString("start_time")
  572. //endTime, _ := c.GetString("end_time")
  573. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  574. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  575. times := strings.Split(startTime, "-")
  576. stmt_mon := times[0] + times[1]
  577. var upld_btch string
  578. //var empty models.JSResultEmpty
  579. var result3265 models.JSResult3264
  580. data := make(map[string]interface{})
  581. data["org_name"] = miConfig.OrgName
  582. data["doctor"] = curRoles.UserName
  583. data["doctor_name"] = curRoles.UserName
  584. data["fixmedins_code"] = miConfig.Code
  585. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  586. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  587. data["secret_key"] = miConfig.SecretKey
  588. data["url"] = miConfig.Url
  589. data["ak"] = miConfig.AccessKey
  590. data["cainfo"] = miConfig.Cainfo
  591. data["setl_mon"] = stmt_mon
  592. month := time.Unix(1557042972, 0).Format("1")
  593. year := time.Now().Format("2006")
  594. month = time.Now().Format("01")
  595. day := time.Now().Format("02")
  596. hour := time.Now().Format("15")
  597. min := time.Now().Format("04")
  598. sec := time.Now().Format("05")
  599. fix_fill_date := year + month + day + hour + min + sec
  600. data["fix_fill_dept"] = miConfig.OrgName
  601. data["fix_fill_psn_id"] = curRoles.AdminUserId
  602. data["fix_fill_psn"] = curRoles.UserName
  603. data["fix_fill_date"] = fix_fill_date
  604. data["stmt_loc"] = "2"
  605. data["upld_btch"] = upld_btch
  606. client := &http.Client{}
  607. bytesData, _ := json.Marshal(data)
  608. var req *http.Request
  609. if miConfig.MdtrtareaAdmvs == "320921" {
  610. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  611. } else {
  612. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  613. }
  614. resp, _ := client.Do(req)
  615. defer resp.Body.Close()
  616. body, ioErr := ioutil.ReadAll(resp.Body)
  617. if ioErr != nil {
  618. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  620. }
  621. var respJSON map[string]interface{}
  622. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  625. }
  626. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  627. fmt.Println(respJSON)
  628. result, _ := json.Marshal(respJSON)
  629. fmt.Println(result)
  630. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  631. utils.ErrorLog("解析失败:%v", err)
  632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  633. }
  634. if result3265.Infcode != 0 {
  635. c.ServeSuccessJSON(map[string]interface{}{
  636. "failed_code": -10,
  637. "msg": result3265.ErrMsg,
  638. })
  639. return
  640. } else {
  641. c.ServeSuccessJSON(map[string]interface{}{
  642. "info": result3265.Output.Data,
  643. })
  644. return
  645. }
  646. }
  647. func (c *HisApiController) Get3267() {
  648. admin_user_id, _ := c.GetInt64("admin_user_id")
  649. startTime, _ := c.GetString("start_time")
  650. //endTime, _ := c.GetString("end_time")
  651. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  652. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  653. times := strings.Split(startTime, "-")
  654. stmt_mon := times[0] + times[1]
  655. var upld_btch string
  656. //var empty models.JSResultEmpty
  657. var result3265 models.JSResult3264
  658. data := make(map[string]interface{})
  659. data["org_name"] = miConfig.OrgName
  660. data["doctor"] = curRoles.UserName
  661. data["doctor_name"] = curRoles.UserName
  662. data["fixmedins_code"] = miConfig.Code
  663. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  664. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  665. data["secret_key"] = miConfig.SecretKey
  666. data["url"] = miConfig.Url
  667. data["ak"] = miConfig.AccessKey
  668. data["cainfo"] = miConfig.Cainfo
  669. data["setl_mon"] = stmt_mon
  670. data["stmt_loc"] = "2"
  671. data["upld_btch"] = upld_btch
  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/3267", bytes.NewReader(bytesData))
  677. } else {
  678. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", 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{})["request_log"].(map[string]interface{})
  693. fmt.Println(respJSON)
  694. result, _ := json.Marshal(respJSON)
  695. fmt.Println(result)
  696. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  697. utils.ErrorLog("解析失败:%v", err)
  698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  699. }
  700. if result3265.Infcode != 0 {
  701. c.ServeSuccessJSON(map[string]interface{}{
  702. "failed_code": -10,
  703. "msg": result3265.ErrMsg,
  704. })
  705. return
  706. } else {
  707. c.ServeSuccessJSON(map[string]interface{}{
  708. "info": result3265.Output.Data,
  709. })
  710. return
  711. }
  712. }
  713. func (c *HisApiController) Get3268() {
  714. admin_user_id, _ := c.GetInt64("admin_user_id")
  715. startTime, _ := c.GetString("start_time")
  716. //endTime, _ := c.GetString("end_time")
  717. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  718. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  719. timeLayout := "2006-01-02"
  720. loc, _ := time.LoadLocation("Local")
  721. var theStartTIme int64
  722. if len(startTime) > 0 {
  723. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  724. if err != nil {
  725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  726. return
  727. }
  728. theStartTIme = theTime.Unix()
  729. }
  730. //var theEndtTIme int64
  731. //if len(endTime) > 0 {
  732. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  733. // if err != nil {
  734. // utils.ErrorLog(err.Error())
  735. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  736. // return
  737. // }
  738. // theEndtTIme = theTime.Unix()
  739. //}
  740. datas, _ := service.GetOrderByTimeTen(theStartTIme, theStartTIme, c.GetAdminUserInfo().CurrentOrgId)
  741. var funs []models.FundDetail
  742. for _, item := range datas {
  743. fun, _ := service.GetOrderDetailByTimeTen(theStartTIme, theStartTIme, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  744. funs = append(funs, fun...)
  745. }
  746. var funInfos []models.Fund
  747. for _, item := range funs {
  748. var rf []models.FundInfo
  749. json.Unmarshal([]byte(item.SetlDetail), &rf)
  750. for _, subitem := range rf {
  751. var fund models.Fund
  752. fund.FundCode = subitem.FundPayType
  753. fund.FundName = subitem.FundPayTypeName
  754. fund.FundAmt = subitem.FundPayAmt
  755. fund.FundKey = item.FundKey
  756. fund.InsuAdmdvs = "555555"
  757. fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  758. funInfos = append(funInfos, fund)
  759. }
  760. }
  761. var upld_btch string
  762. var empty models.JSResultEmpty
  763. data := make(map[string]interface{})
  764. data["org_name"] = miConfig.OrgName
  765. data["doctor"] = curRoles.UserName
  766. data["doctor_name"] = curRoles.UserName
  767. data["fixmedins_code"] = miConfig.Code
  768. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  769. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  770. data["secret_key"] = miConfig.SecretKey
  771. data["url"] = miConfig.Url
  772. data["ak"] = miConfig.AccessKey
  773. data["cainfo"] = miConfig.Cainfo
  774. data["data"] = datas
  775. data["fund"] = funInfos
  776. month := time.Unix(1557042972, 0).Format("1")
  777. year := time.Now().Format("2006")
  778. month = time.Now().Format("01")
  779. day := time.Now().Format("02")
  780. hour := time.Now().Format("15")
  781. min := time.Now().Format("04")
  782. sec := time.Now().Format("05")
  783. fix_fill_date := year + month + day + hour + min + sec
  784. data["fix_fill_dept"] = miConfig.OrgName
  785. data["fix_fill_psn_id"] = curRoles.AdminUserId
  786. data["fix_fill_psn"] = curRoles.UserName
  787. data["fix_fill_date"] = fix_fill_date
  788. data["stmt_loc"] = "2"
  789. data["upld_btch"] = upld_btch
  790. client := &http.Client{}
  791. bytesData, _ := json.Marshal(data)
  792. var req *http.Request
  793. if miConfig.MdtrtareaAdmvs == "320921" {
  794. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  795. } else {
  796. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  797. }
  798. resp, _ := client.Do(req)
  799. defer resp.Body.Close()
  800. body, ioErr := ioutil.ReadAll(resp.Body)
  801. if ioErr != nil {
  802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  804. }
  805. var respJSON map[string]interface{}
  806. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  809. }
  810. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  811. fmt.Println(respJSON)
  812. result, _ := json.Marshal(respJSON)
  813. fmt.Println(result)
  814. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  815. utils.ErrorLog("解析失败:%v", err)
  816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  817. }
  818. if empty.Infcode != 0 {
  819. c.ServeSuccessJSON(map[string]interface{}{
  820. "failed_code": -10,
  821. "msg": empty.ErrMsg,
  822. })
  823. return
  824. } else {
  825. c.ServeSuccessJSON(map[string]interface{}{
  826. "msg": "上传成功",
  827. })
  828. return
  829. }
  830. }
  831. func (c *HisApiController) Get3269() {
  832. admin_user_id, _ := c.GetInt64("admin_user_id")
  833. startTime := c.GetString("start_time")
  834. //endTime, _ := c.GetString("end_time")
  835. times := strings.Split(startTime, "-")
  836. setl_mon := times[0] + times[1]
  837. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  838. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  839. var result3263 models.JSResult3263
  840. data := make(map[string]interface{})
  841. data["org_name"] = miConfig.OrgName
  842. data["doctor"] = curRoles.UserName
  843. data["doctor_name"] = curRoles.UserName
  844. data["fixmedins_code"] = miConfig.Code
  845. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  846. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  847. data["secret_key"] = miConfig.SecretKey
  848. data["url"] = miConfig.Url
  849. data["ak"] = miConfig.AccessKey
  850. data["cainfo"] = miConfig.Cainfo
  851. data["setl_mon"] = setl_mon
  852. data["stmt_loc"] = "2"
  853. client := &http.Client{}
  854. bytesData, _ := json.Marshal(data)
  855. var req *http.Request
  856. if miConfig.MdtrtareaAdmvs == "320921" {
  857. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  858. } else {
  859. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  860. }
  861. resp, _ := client.Do(req)
  862. defer resp.Body.Close()
  863. body, ioErr := ioutil.ReadAll(resp.Body)
  864. if ioErr != nil {
  865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  867. }
  868. var respJSON map[string]interface{}
  869. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  872. }
  873. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  874. fmt.Println(respJSON)
  875. result, _ := json.Marshal(respJSON)
  876. fmt.Println(result)
  877. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  878. utils.ErrorLog("解析失败:%v", err)
  879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  880. }
  881. if result3263.Infcode != 0 {
  882. c.ServeSuccessJSON(map[string]interface{}{
  883. "failed_code": -10,
  884. "msg": result3263.ErrMsg,
  885. })
  886. return
  887. } else {
  888. c.ServeSuccessJSON(map[string]interface{}{
  889. "msg": "上传成功",
  890. })
  891. return
  892. }
  893. }
  894. func (c *HisApiController) Get3270() {
  895. admin_user_id, _ := c.GetInt64("admin_user_id")
  896. startTime := c.GetString("start_time")
  897. //endTime, _ := c.GetString("end_time")
  898. times := strings.Split(startTime, "-")
  899. setl_mon := times[0] + times[1]
  900. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  901. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  902. var result3264 models.JSResult3264
  903. data := make(map[string]interface{})
  904. data["org_name"] = miConfig.OrgName
  905. data["doctor"] = curRoles.UserName
  906. data["doctor_name"] = curRoles.UserName
  907. data["fixmedins_code"] = miConfig.Code
  908. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  909. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  910. data["secret_key"] = miConfig.SecretKey
  911. data["url"] = miConfig.Url
  912. data["ak"] = miConfig.AccessKey
  913. data["cainfo"] = miConfig.Cainfo
  914. data["setl_mon"] = setl_mon
  915. data["stmt_loc"] = "2"
  916. client := &http.Client{}
  917. bytesData, _ := json.Marshal(data)
  918. var req *http.Request
  919. if miConfig.MdtrtareaAdmvs == "320921" {
  920. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  921. } else {
  922. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  923. }
  924. resp, _ := client.Do(req)
  925. defer resp.Body.Close()
  926. body, ioErr := ioutil.ReadAll(resp.Body)
  927. if ioErr != nil {
  928. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  930. }
  931. var respJSON map[string]interface{}
  932. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  935. }
  936. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  937. fmt.Println(respJSON)
  938. result, _ := json.Marshal(respJSON)
  939. fmt.Println(result)
  940. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  941. utils.ErrorLog("解析失败:%v", err)
  942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  943. }
  944. if result3264.Infcode != 0 {
  945. c.ServeSuccessJSON(map[string]interface{}{
  946. "failed_code": -10,
  947. "msg": result3264.ErrMsg,
  948. })
  949. return
  950. } else {
  951. c.ServeSuccessJSON(map[string]interface{}{
  952. "info": result3264.Output.Data,
  953. })
  954. return
  955. }
  956. }
  957. func (c *HisApiController) Get3271() {
  958. admin_user_id, _ := c.GetInt64("admin_user_id")
  959. startTime, _ := c.GetString("start_time")
  960. //endTime, _ := c.GetString("end_time")
  961. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  962. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  963. times := strings.Split(startTime, "-")
  964. stmt_mon := times[0] + times[1]
  965. //var empty models.JSResultEmpty
  966. var result3265 models.JSResult3264
  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["stmt_mon"] = stmt_mon
  979. month := time.Unix(1557042972, 0).Format("1")
  980. year := time.Now().Format("2006")
  981. month = time.Now().Format("01")
  982. day := time.Now().Format("02")
  983. hour := time.Now().Format("15")
  984. min := time.Now().Format("04")
  985. sec := time.Now().Format("05")
  986. fix_fill_date := year + month + day + hour + min + sec
  987. data["fix_fill_dept"] = miConfig.OrgName
  988. data["fix_fill_psn_id"] = curRoles.AdminUserId
  989. data["fix_fill_psn"] = curRoles.UserName
  990. data["fix_fill_date"] = fix_fill_date
  991. data["stmt_loc"] = "2"
  992. client := &http.Client{}
  993. bytesData, _ := json.Marshal(data)
  994. var req *http.Request
  995. if miConfig.MdtrtareaAdmvs == "320921" {
  996. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  997. } else {
  998. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  999. }
  1000. resp, _ := client.Do(req)
  1001. defer resp.Body.Close()
  1002. body, ioErr := ioutil.ReadAll(resp.Body)
  1003. if ioErr != nil {
  1004. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1006. }
  1007. var respJSON map[string]interface{}
  1008. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1011. }
  1012. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1013. fmt.Println(respJSON)
  1014. result, _ := json.Marshal(respJSON)
  1015. fmt.Println(result)
  1016. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1017. utils.ErrorLog("解析失败:%v", err)
  1018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1019. }
  1020. if result3265.Infcode != 0 {
  1021. c.ServeSuccessJSON(map[string]interface{}{
  1022. "failed_code": -10,
  1023. "msg": result3265.ErrMsg,
  1024. })
  1025. return
  1026. } else {
  1027. c.ServeSuccessJSON(map[string]interface{}{
  1028. "info": result3265.Output.Data,
  1029. })
  1030. return
  1031. }
  1032. }
  1033. func (c *HisApiController) Get3272() {
  1034. admin_user_id, _ := c.GetInt64("admin_user_id")
  1035. startTime, _ := c.GetString("start_time")
  1036. //endTime, _ := c.GetString("end_time")
  1037. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1038. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1039. times := strings.Split(startTime, "-")
  1040. setl_mon := times[0] + times[1]
  1041. var upld_btch string
  1042. //var empty models.JSResultEmpty
  1043. var result3265 models.JSResult3264
  1044. data := make(map[string]interface{})
  1045. data["org_name"] = miConfig.OrgName
  1046. data["doctor"] = curRoles.UserName
  1047. data["doctor_name"] = curRoles.UserName
  1048. data["fixmedins_code"] = miConfig.Code
  1049. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1050. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1051. data["secret_key"] = miConfig.SecretKey
  1052. data["url"] = miConfig.Url
  1053. data["ak"] = miConfig.AccessKey
  1054. data["cainfo"] = miConfig.Cainfo
  1055. data["setl_mon"] = setl_mon
  1056. month := time.Unix(1557042972, 0).Format("1")
  1057. year := time.Now().Format("2006")
  1058. month = time.Now().Format("01")
  1059. day := time.Now().Format("02")
  1060. hour := time.Now().Format("15")
  1061. min := time.Now().Format("04")
  1062. sec := time.Now().Format("05")
  1063. fix_fill_date := year + month + day + hour + min + sec
  1064. data["fix_fill_dept"] = miConfig.OrgName
  1065. data["fix_fill_psn_id"] = curRoles.AdminUserId
  1066. data["fix_fill_psn"] = curRoles.UserName
  1067. data["fix_fill_date"] = fix_fill_date
  1068. data["stmt_loc"] = "2"
  1069. data["upld_btch"] = upld_btch
  1070. client := &http.Client{}
  1071. bytesData, _ := json.Marshal(data)
  1072. var req *http.Request
  1073. if miConfig.MdtrtareaAdmvs == "320921" {
  1074. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  1075. } else {
  1076. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  1077. }
  1078. resp, _ := client.Do(req)
  1079. defer resp.Body.Close()
  1080. body, ioErr := ioutil.ReadAll(resp.Body)
  1081. if ioErr != nil {
  1082. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1084. }
  1085. var respJSON map[string]interface{}
  1086. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1089. }
  1090. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1091. fmt.Println(respJSON)
  1092. result, _ := json.Marshal(respJSON)
  1093. fmt.Println(result)
  1094. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1095. utils.ErrorLog("解析失败:%v", err)
  1096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1097. }
  1098. if result3265.Infcode != 0 {
  1099. c.ServeSuccessJSON(map[string]interface{}{
  1100. "failed_code": -10,
  1101. "msg": result3265.ErrMsg,
  1102. })
  1103. return
  1104. } else {
  1105. c.ServeSuccessJSON(map[string]interface{}{
  1106. "info": result3265.Output.Data,
  1107. })
  1108. return
  1109. }
  1110. }
  1111. func (c *HisApiController) Get3273() {
  1112. admin_user_id, _ := c.GetInt64("admin_user_id")
  1113. startTime, _ := c.GetString("start_time")
  1114. //endTime, _ := c.GetString("end_time")
  1115. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1116. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1117. times := strings.Split(startTime, "-")
  1118. stmt_mon := times[0] + times[1]
  1119. var result3265 models.JSResult3264
  1120. data := make(map[string]interface{})
  1121. data["org_name"] = miConfig.OrgName
  1122. data["doctor"] = curRoles.UserName
  1123. data["doctor_name"] = curRoles.UserName
  1124. data["fixmedins_code"] = miConfig.Code
  1125. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1126. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1127. data["secret_key"] = miConfig.SecretKey
  1128. data["url"] = miConfig.Url
  1129. data["ak"] = miConfig.AccessKey
  1130. data["cainfo"] = miConfig.Cainfo
  1131. data["setl_mon"] = stmt_mon
  1132. data["stmt_loc"] = "2"
  1133. client := &http.Client{}
  1134. bytesData, _ := json.Marshal(data)
  1135. var req *http.Request
  1136. if miConfig.MdtrtareaAdmvs == "320921" {
  1137. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  1138. } else {
  1139. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  1140. }
  1141. resp, _ := client.Do(req)
  1142. defer resp.Body.Close()
  1143. body, ioErr := ioutil.ReadAll(resp.Body)
  1144. if ioErr != nil {
  1145. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1147. }
  1148. var respJSON map[string]interface{}
  1149. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1152. }
  1153. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1154. fmt.Println(respJSON)
  1155. result, _ := json.Marshal(respJSON)
  1156. fmt.Println(result)
  1157. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1158. utils.ErrorLog("解析失败:%v", err)
  1159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1160. }
  1161. if result3265.Infcode != 0 {
  1162. c.ServeSuccessJSON(map[string]interface{}{
  1163. "failed_code": -10,
  1164. "msg": result3265.ErrMsg,
  1165. })
  1166. return
  1167. } else {
  1168. c.ServeSuccessJSON(map[string]interface{}{
  1169. "info": result3265.Output.Data,
  1170. })
  1171. return
  1172. }
  1173. }
  1174. func (c *HisApiController) Get3274() {
  1175. if miConfig.MdtrtareaAdmvs == "320921" {
  1176. api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1177. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1178. "&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
  1179. } else {
  1180. api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1181. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1182. "&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
  1183. }
  1184. }
  1185. func (c *HisApiController) Get3275() {
  1186. if miConfig.MdtrtareaAdmvs == "320921" {
  1187. api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1188. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1189. "&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
  1190. } else {
  1191. api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1192. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1193. "&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
  1194. }
  1195. }
  1196. func (c *HisApiController) Get3276() {
  1197. admin_user_id, _ := c.GetInt64("admin_user_id")
  1198. month := c.GetString("month")
  1199. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1200. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1201. var api string
  1202. var res Result5301
  1203. if miConfig.MdtrtareaAdmvs == "320921" {
  1204. api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1205. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1206. } else {
  1207. api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1208. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1209. }
  1210. resp, requestErr := http.Get(api)
  1211. if requestErr != nil {
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1213. return
  1214. }
  1215. body, ioErr := ioutil.ReadAll(resp.Body)
  1216. if ioErr != nil {
  1217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1219. return
  1220. }
  1221. var respJSON map[string]interface{}
  1222. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1223. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1225. return
  1226. }
  1227. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1228. result, _ := json.Marshal(respJSON)
  1229. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1230. utils.ErrorLog("解析失败:%v", err)
  1231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1232. return
  1233. }
  1234. }
  1235. func (c *HisApiController) Get3277() {
  1236. admin_user_id, _ := c.GetInt64("admin_user_id")
  1237. month := c.GetString("month")
  1238. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1239. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1240. var api string
  1241. var res Result5301
  1242. if miConfig.MdtrtareaAdmvs == "320921" {
  1243. api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1244. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1245. } else {
  1246. api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1247. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1248. }
  1249. resp, requestErr := http.Get(api)
  1250. if requestErr != nil {
  1251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1252. return
  1253. }
  1254. body, ioErr := ioutil.ReadAll(resp.Body)
  1255. if ioErr != nil {
  1256. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1258. return
  1259. }
  1260. var respJSON map[string]interface{}
  1261. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1262. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1264. return
  1265. }
  1266. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1267. result, _ := json.Marshal(respJSON)
  1268. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1269. utils.ErrorLog("解析失败:%v", err)
  1270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1271. return
  1272. }
  1273. }
  1274. func (c *HisApiController) GetCFYLJG001() {
  1275. admin_user_id, _ := c.GetInt64("admin_user_id")
  1276. patient_id, _ := c.GetInt64("patient_id")
  1277. his_patient_id, _ := c.GetInt64("his_patient_id")
  1278. record_time := c.GetString("record_time")
  1279. admin_user_id = 3626
  1280. patient_id = 19424
  1281. his_patient_id = 238932
  1282. record_time = "2023-07-03"
  1283. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1284. psn, _ := service.GetPsnByPatientId(patient_id)
  1285. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  1286. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  1287. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1288. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1289. var cFYLJG001 models.CFYLJG001
  1290. timeLayout := "2006-01-02"
  1291. loc, _ := time.LoadLocation("Local")
  1292. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1293. if err != nil {
  1294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1295. return
  1296. }
  1297. recordDateTime := theTime.Unix()
  1298. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  1299. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  1300. for _, item := range prescriptions {
  1301. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  1302. if his.IdCardType == 1 {
  1303. bas := strings.Split(psn.CardInfo, "|")
  1304. basNumber := bas[1]
  1305. fmt.Println(basNumber)
  1306. card_sn := bas[3]
  1307. card_no := bas[2]
  1308. cFYLJG001.MdtrtCertType = "03"
  1309. cFYLJG001.CardSn = card_sn
  1310. cFYLJG001.MdtrtCertNo = card_no
  1311. cFYLJG001.EcToken = ""
  1312. cFYLJG001.AuthNo = ""
  1313. } else if his.IdCardType == 2 {
  1314. cFYLJG001.MdtrtCertType = "02"
  1315. cFYLJG001.CardSn = ""
  1316. cFYLJG001.MdtrtCertNo = his.IdCardNo
  1317. cFYLJG001.EcToken = ""
  1318. cFYLJG001.AuthNo = ""
  1319. } else if his.IdCardType == 4 {
  1320. cFYLJG001.MdtrtCertType = "01"
  1321. cFYLJG001.CardSn = ""
  1322. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  1323. cFYLJG001.EcToken = psn.VerifyNumber
  1324. cFYLJG001.AuthNo = ""
  1325. }
  1326. cFYLJG001.BizTypeCode = "01"
  1327. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  1328. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  1329. cFYLJG001.RxTypeCode = "1"
  1330. tempTime := time.Unix(item.PreTime, 0)
  1331. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1332. cFYLJG001.PrscTime = timeFormatOne
  1333. var count float64
  1334. if item.Type == 1 {
  1335. for _, sumItem := range item.HisDoctorAdviceInfo {
  1336. count = count + sumItem.PrescribingNumber
  1337. }
  1338. }
  1339. cFYLJG001.RxDrugCnt = count
  1340. cFYLJG001.ValiDays = "5"
  1341. ts := time.Unix(item.PreTime, 0)
  1342. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  1343. tempTime3 := time.Unix(record_time2, 0)
  1344. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  1345. cFYLJG001.ValiEndTime = timeFormat3
  1346. cFYLJG001.RxCotnFlag = "0"
  1347. for _, subItem := range item.HisDoctorAdviceInfo {
  1348. var drug models.RxDrug
  1349. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  1350. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  1351. drug.RxItemTypeCode = "11"
  1352. drug.DrugDosform = "乳膏剂" //TODO
  1353. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  1354. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  1355. }
  1356. drug.MedcWayDscr = subItem.DeliveryWay
  1357. tempTime2 := time.Unix(subItem.StartTime, 0)
  1358. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  1359. drug.MedcBegntime = timeFormatTwo
  1360. if subItem.Day > 0 {
  1361. ts := time.Unix(subItem.StartTime, 0)
  1362. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  1363. tempTime4 := time.Unix(record_time, 0)
  1364. timeFormat5 := tempTime4.Format("2006-01-02") + " 23:59:00"
  1365. drug.MedcEndtime = timeFormat5
  1366. } else {
  1367. tempTime2 := time.Unix(subItem.StartTime, 0)
  1368. timeFormatTwo := tempTime2.Format("2006-01-02") + " 23:59:00"
  1369. drug.MedcEndtime = timeFormatTwo
  1370. }
  1371. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  1372. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  1373. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  1374. drug.DrugCnt = subItem.PrescribingNumber
  1375. drug.DrugDosunt = subItem.PrescribingNumberUnit
  1376. drug.DrugGenname = subItem.AdviceName
  1377. drug.MedcWayCodg = subItem.DeliveryWay
  1378. //drug.DrugTotlcnt = subItem.PrescribingNumber
  1379. drug.SinDoscnt = subItem.SingleDose
  1380. drug.SinDosunt = subItem.SingleDoseUnit
  1381. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  1382. drug.UsedFrquName = subItem.ExecutionFrequency
  1383. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1384. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  1385. drug.HospApprFlag = "1"
  1386. cFYLJG001.List = append(cFYLJG001.List, drug)
  1387. }
  1388. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  1389. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  1390. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  1391. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  1392. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  1393. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  1394. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  1395. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  1396. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  1397. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  1398. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  1399. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  1400. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  1401. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  1402. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  1403. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  1404. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  1405. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  1406. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  1407. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  1408. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  1409. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  1410. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  1411. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  1412. tempTime2 := time.Now().Unix()
  1413. tempTime6 := time.Unix(tempTime2, 0)
  1414. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  1415. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  1416. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  1417. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  1418. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  1419. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  1420. memo := make(map[string]interface{})
  1421. memo["insutype"] = his.Insutype
  1422. bytesData, _ := json.Marshal(memo)
  1423. cFYLJG001.Mdtrtinfo.Extras = string(bytesData)
  1424. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  1425. var config []*models.HisXtDiagnoseConfig
  1426. for _, item := range diagnosis_ids {
  1427. id, _ := strconv.ParseInt(item, 10, 64)
  1428. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1429. config = append(config, &diagnosisConfig)
  1430. }
  1431. for index, subitem := range config {
  1432. if index == 0 {
  1433. var dia models.DiseInfo
  1434. dia.DiagType = "1"
  1435. dia.MaindiagFlag = "1"
  1436. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  1437. dia.DiagCode = subitem.CountryCode
  1438. dia.DiagName = subitem.ClassName
  1439. dia.DiagDept = "肾内科"
  1440. dia.DiagDrNo = doctor.DoctorNumber
  1441. dia.DiagDrName = doctor.UserName
  1442. tempTime3 := time.Unix(item.PreTime, 0)
  1443. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  1444. dia.DiagTime = timeFormatTwo
  1445. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  1446. } else {
  1447. var dia models.DiseInfo
  1448. dia.DiagType = "1"
  1449. dia.MaindiagFlag = "0"
  1450. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  1451. dia.DiagCode = subitem.CountryCode
  1452. dia.DiagName = subitem.ClassName
  1453. dia.DiagDept = "肾内科"
  1454. dia.DiagDrNo = doctor.DoctorNumber
  1455. dia.DiagDrName = doctor.UserName
  1456. tempTime3 := time.Unix(item.PreTime, 0)
  1457. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  1458. dia.DiagTime = timeFormatTwo
  1459. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  1460. }
  1461. }
  1462. fmt.Println(cFYLJG001)
  1463. service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001)
  1464. }
  1465. }
  1466. func (c *HisApiController) GetCFYLJG002() {
  1467. admin_user_id, _ := c.GetInt64("admin_user_id")
  1468. id, _ := c.GetInt64("id")
  1469. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1470. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1471. flow, _ := service.Getflow(id)
  1472. his, _ := service.GetHisPatientByNumber(flow.MID)
  1473. inputData := make(map[string]interface{})
  1474. inputData["rxtracecode"] = flow.RxTraceCode
  1475. inputData["hirxno"] = flow.HiRxno
  1476. inputData["mdtrtid"] = flow.MID
  1477. inputData["patnname"] = his.PsnName
  1478. inputData["psncerttype"] = his.PsnCertType
  1479. inputData["certno"] = his.Certno
  1480. inputData["fixmedinsname"] = miConfig.OrgName
  1481. inputData["fixmedinscode"] = miConfig.Code
  1482. inputData["drcode"] = ""
  1483. inputData["prscdrname"] = ""
  1484. inputData["phardeptname"] = ""
  1485. inputData["phardeptcode"] = ""
  1486. inputData["pharprofttlcodg"] = ""
  1487. inputData["pharprofttlname"] = ""
  1488. inputData["pharcode"] = ""
  1489. inputData["rxfrquname"] = ""
  1490. inputData["pharcerttype"] = ""
  1491. inputData["pharcertno"] = ""
  1492. inputData["pharname"] = ""
  1493. inputData["pharpraccertno"] = ""
  1494. inputData["pharchktime"] = ""
  1495. bytesData, _ := json.Marshal(inputData)
  1496. fmt.Println(bytesData)
  1497. //// 使用 SM3 计算 JSON 数据的哈希值
  1498. //hash := sm3.New()
  1499. //hash.Write(bytesData)
  1500. //hashValue := hash.Sum(nil)
  1501. //
  1502. //// 加载 SM2 私钥
  1503. //privateKeyBytes, err := ioutil.ReadFile("path/to/private_key.pem")
  1504. //if err != nil {
  1505. // fmt.Println("Failed to read private key file:", err)
  1506. // return
  1507. //}
  1508. //privateKey, err := sm2.ParsePKCS8PrivateKey(privateKeyBytes)
  1509. //if err != nil {
  1510. // fmt.Println("Failed to parse private key:", err)
  1511. // return
  1512. //}
  1513. //
  1514. //// 使用私钥对哈希值进行签名
  1515. //r, s, err := sm2.Sign(rand.Reader, privateKey.(*sm2.PrivateKey), hashValue, nil)
  1516. //if err != nil {
  1517. // fmt.Println("Failed to sign data:", err)
  1518. // return
  1519. //}
  1520. //signature, err := syntax.EncodeSM2Signature(r, s)
  1521. //if err != nil {
  1522. // fmt.Println("Failed to encode signature:", err)
  1523. // return
  1524. //}
  1525. //
  1526. //// 构建 CMS/PKCS#7 Detached 数据结构
  1527. //// 这里只包含签名值和原始数据
  1528. //signedData := &pkix.ContentInfo{
  1529. // ContentType: pkix.SignedDataOID,
  1530. // Content: &pkix.SignedData{
  1531. // Version: 3,
  1532. // DigestAlgorithms: []pkix.AlgorithmIdentifier{{Algorithm: sm3.OID}},
  1533. // EncapContentInfo: pkix.EncapContentInfo{
  1534. // EContentType: pkix.DataOID,
  1535. // EContent: jsonBytes,
  1536. // },
  1537. // Certificates: []pkix.Certificate{},
  1538. // CRLs: []pkix.CertificateList{},
  1539. // SignerInfos: []pkix.SignerInfo{},
  1540. // DigestEncryptionAlgorithm: pkix.AlgorithmIdentifier{
  1541. // Algorithm: sm2.SignAlgorithmSM2WithSM3,
  1542. // },
  1543. // EncryptedDigest: signature,
  1544. // },
  1545. //}
  1546. //
  1547. //// 使用 DER 编码进行序列化
  1548. //derBytes, err := syntax.Marshal(signedData)
  1549. //if err != nil {
  1550. // fmt.Println("Failed to marshal CMS/PKCS#7 data:", err)
  1551. // return
  1552. //}
  1553. service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "", "", "")
  1554. }
  1555. func (c *HisApiController) GetCFYLJG003() {
  1556. admin_user_id, _ := c.GetInt64("admin_user_id")
  1557. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1558. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1559. var cFYLJG003 models.CFYLJG003
  1560. service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  1561. }
  1562. func (c *HisApiController) GetCFYLJG004() {
  1563. admin_user_id, _ := c.GetInt64("admin_user_id")
  1564. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1565. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1566. var cFYLJG004 models.CFYLJG004
  1567. service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  1568. }
  1569. func (c *HisApiController) GetCFYLJG005() {
  1570. admin_user_id, _ := c.GetInt64("admin_user_id")
  1571. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1572. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1573. var cFYLJG005 models.CFYLJG005
  1574. service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  1575. }
  1576. func (c *HisApiController) GetCFYLJG006() {
  1577. admin_user_id, _ := c.GetInt64("admin_user_id")
  1578. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1579. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1580. var cFYLJG006 models.CFYLJG006
  1581. service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  1582. }
  1583. func (c *HisApiController) GetCFYLJG007() {
  1584. admin_user_id, _ := c.GetInt64("admin_user_id")
  1585. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1586. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1587. var cFYLJG007 models.CFYLJG007
  1588. service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  1589. }
  1590. func (c *HisApiController) GetBL4201A() {
  1591. order_id, _ := c.GetInt64("order_id")
  1592. admin_user_id, _ := c.GetInt64("admin_user_id")
  1593. order, _ := service.GetHisOrderByIDTwo(order_id)
  1594. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1595. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  1596. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  1597. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1598. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1599. department, _ := service.GetDepartMentDetail(his.Departments)
  1600. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  1601. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  1602. if order.ID == 0 {
  1603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1604. return
  1605. }
  1606. var struct4201A models.Struct4201A
  1607. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  1608. for _, items := range order_info {
  1609. memo := make(map[string]interface{})
  1610. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1611. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1612. fsiOPFLD.MedType = "14"
  1613. fsiOPFLD.BkkpSn = items.FeedetlSn
  1614. fsiOPFLD.FixmedinsCode = miConfig.Code
  1615. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1616. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1617. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1618. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1619. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1620. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1621. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1622. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1623. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1624. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1625. fsiOPFLD.BilgDeptName = department.Name
  1626. fsiOPFLD.BilgDeptCodg = department.Number
  1627. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1628. fsiOPFLD.BilgDrName = doctor.UserName
  1629. fsiOPFLD.MedChrgitmType = "09"
  1630. memo["hosp_appr_flag"] = "1"
  1631. memo["invoice_no"] = order.MdtrtId
  1632. memo["memo"] = "自费"
  1633. bytesData, _ := json.Marshal(memo)
  1634. fsiOPFLD.Memo = string(bytesData)
  1635. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1636. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1637. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1638. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1639. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1640. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1641. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1642. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1643. fsiOPFLD.BilgDeptName = department.Name
  1644. fsiOPFLD.BilgDeptCodg = department.Number
  1645. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1646. fsiOPFLD.BilgDrName = doctor.UserName
  1647. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1648. case 0:
  1649. break
  1650. case 1:
  1651. fsiOPFLD.MedChrgitmType = "14"
  1652. break
  1653. case 2:
  1654. fsiOPFLD.MedChrgitmType = "05"
  1655. break
  1656. case 3:
  1657. fsiOPFLD.MedChrgitmType = "03"
  1658. break
  1659. case 4:
  1660. fsiOPFLD.MedChrgitmType = "03"
  1661. break
  1662. case 5:
  1663. fsiOPFLD.MedChrgitmType = "08"
  1664. break
  1665. case 6:
  1666. fsiOPFLD.MedChrgitmType = "14"
  1667. break
  1668. case 7:
  1669. fsiOPFLD.MedChrgitmType = "14"
  1670. break
  1671. case 8:
  1672. fsiOPFLD.MedChrgitmType = "03"
  1673. break
  1674. case 9:
  1675. fsiOPFLD.MedChrgitmType = "14"
  1676. break
  1677. case 10:
  1678. fsiOPFLD.MedChrgitmType = "14"
  1679. break
  1680. case 11:
  1681. fsiOPFLD.MedChrgitmType = "06"
  1682. break
  1683. case 12:
  1684. fsiOPFLD.MedChrgitmType = "12"
  1685. break
  1686. case 13:
  1687. fsiOPFLD.MedChrgitmType = "01"
  1688. break
  1689. case 14:
  1690. fsiOPFLD.MedChrgitmType = "04"
  1691. break
  1692. case 15:
  1693. fsiOPFLD.MedChrgitmType = "14"
  1694. break
  1695. }
  1696. memo["hosp_appr_flag"] = "1"
  1697. memo["invoice_no"] = order.MdtrtId
  1698. memo["memo"] = "自费"
  1699. bytesData, _ := json.Marshal(memo)
  1700. fsiOPFLD.Memo = string(bytesData)
  1701. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1702. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  1703. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1704. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1705. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1706. fsiOPFLD.BilgDeptName = department.Name
  1707. fsiOPFLD.BilgDeptCodg = department.Number
  1708. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1709. fsiOPFLD.BilgDrName = doctor.UserName
  1710. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1711. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1712. fsiOPFLD.MedChrgitmType = "08"
  1713. memo["hosp_appr_flag"] = "1"
  1714. memo["invoice_no"] = order.MdtrtId
  1715. memo["memo"] = "自费"
  1716. bytesData, _ := json.Marshal(memo)
  1717. fsiOPFLD.Memo = string(bytesData)
  1718. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1719. }
  1720. }
  1721. }
  1722. for _, items := range order_info_two {
  1723. memo := make(map[string]interface{})
  1724. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1725. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1726. fsiOPFLD.MedType = "14"
  1727. fsiOPFLD.BkkpSn = items.FeedetlSn
  1728. fsiOPFLD.FixmedinsCode = miConfig.Code
  1729. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1730. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1731. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1732. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1733. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1734. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1735. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1736. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1737. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1738. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1739. fsiOPFLD.BilgDeptName = department.Name
  1740. fsiOPFLD.BilgDeptCodg = department.Number
  1741. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1742. fsiOPFLD.BilgDrName = doctor.UserName
  1743. fsiOPFLD.MedChrgitmType = "09"
  1744. memo["hosp_appr_flag"] = "1"
  1745. memo["invoice_no"] = order.MdtrtId
  1746. memo["memo"] = "自费"
  1747. bytesData, _ := json.Marshal(memo)
  1748. fsiOPFLD.Memo = string(bytesData)
  1749. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1750. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1751. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1752. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1753. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1754. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1755. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1756. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1757. fsiOPFLD.BilgDeptName = department.Name
  1758. fsiOPFLD.BilgDeptCodg = department.Number
  1759. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1760. fsiOPFLD.BilgDrName = doctor.UserName
  1761. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1762. case 0:
  1763. break
  1764. case 1:
  1765. fsiOPFLD.MedChrgitmType = "14"
  1766. break
  1767. case 2:
  1768. fsiOPFLD.MedChrgitmType = "05"
  1769. break
  1770. case 3:
  1771. fsiOPFLD.MedChrgitmType = "03"
  1772. break
  1773. case 4:
  1774. fsiOPFLD.MedChrgitmType = "03"
  1775. break
  1776. case 5:
  1777. fsiOPFLD.MedChrgitmType = "08"
  1778. break
  1779. case 6:
  1780. fsiOPFLD.MedChrgitmType = "14"
  1781. break
  1782. case 7:
  1783. fsiOPFLD.MedChrgitmType = "14"
  1784. break
  1785. case 8:
  1786. fsiOPFLD.MedChrgitmType = "03"
  1787. break
  1788. case 9:
  1789. fsiOPFLD.MedChrgitmType = "14"
  1790. break
  1791. case 10:
  1792. fsiOPFLD.MedChrgitmType = "14"
  1793. break
  1794. case 11:
  1795. fsiOPFLD.MedChrgitmType = "06"
  1796. break
  1797. case 12:
  1798. fsiOPFLD.MedChrgitmType = "12"
  1799. break
  1800. case 13:
  1801. fsiOPFLD.MedChrgitmType = "01"
  1802. break
  1803. case 14:
  1804. fsiOPFLD.MedChrgitmType = "04"
  1805. break
  1806. case 15:
  1807. fsiOPFLD.MedChrgitmType = "14"
  1808. break
  1809. }
  1810. memo["hosp_appr_flag"] = "1"
  1811. memo["invoice_no"] = order.MdtrtId
  1812. memo["memo"] = "自费"
  1813. bytesData, _ := json.Marshal(memo)
  1814. fsiOPFLD.Memo = string(bytesData)
  1815. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1816. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  1817. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1818. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1819. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1820. fsiOPFLD.BilgDeptName = department.Name
  1821. fsiOPFLD.BilgDeptCodg = department.Number
  1822. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1823. fsiOPFLD.BilgDrName = doctor.UserName
  1824. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1825. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1826. fsiOPFLD.MedChrgitmType = "08"
  1827. memo["hosp_appr_flag"] = "1"
  1828. memo["invoice_no"] = order.MdtrtId
  1829. memo["memo"] = "自费"
  1830. bytesData, _ := json.Marshal(memo)
  1831. fsiOPFLD.Memo = string(bytesData)
  1832. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1833. }
  1834. }
  1835. }
  1836. fmt.Println(fsiOPFLDs)
  1837. struct4201A.Fopfd = fsiOPFLDs
  1838. fmt.Println(struct4201A.Fopfd)
  1839. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  1840. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  1841. var res2 ResultSix
  1842. var respJSON2 map[string]interface{}
  1843. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1844. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1846. return
  1847. }
  1848. userJSONBytes2, _ := json.Marshal(respJSON2)
  1849. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1850. utils.ErrorLog("解析失败:%v", err)
  1851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1852. return
  1853. }
  1854. if res2.Infcode != 0 {
  1855. c.ServeSuccessJSON(map[string]interface{}{
  1856. "failed_code": -10,
  1857. "msg": res2.ErrMsg,
  1858. })
  1859. return
  1860. } else {
  1861. order.IsUploadOrderInfo = 1
  1862. service.UpdateOrder(order)
  1863. c.ServeSuccessJSON(map[string]interface{}{
  1864. "msg": "上传成功",
  1865. })
  1866. }
  1867. }
  1868. func (c *HisApiController) Get2505() {
  1869. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  1870. 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")
  1871. }
  1872. func (c *HisApiController) Get4201A() {
  1873. order_id, _ := c.GetInt64("order_id")
  1874. admin_user_id, _ := c.GetInt64("admin_user_id")
  1875. order, _ := service.GetHisOrderByIDTwo(order_id)
  1876. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1877. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  1878. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  1879. //order_info = append(order_info, order_info_two...)
  1880. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1881. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1882. department, _ := service.GetDepartMentDetail(his.Departments)
  1883. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  1884. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  1885. if order.ID == 0 {
  1886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1887. return
  1888. }
  1889. var struct4201A models.Struct4201A
  1890. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  1891. for _, items := range order_info {
  1892. memo := make(map[string]interface{})
  1893. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1894. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1895. fsiOPFLD.MedType = "14"
  1896. fsiOPFLD.BkkpSn = items.FeedetlSn
  1897. fsiOPFLD.FixmedinsCode = miConfig.Code
  1898. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1899. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1900. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1901. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1902. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1903. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1904. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1905. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1906. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1907. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1908. fsiOPFLD.BilgDeptName = department.Name
  1909. fsiOPFLD.BilgDeptCodg = department.Number
  1910. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1911. fsiOPFLD.BilgDrName = doctor.UserName
  1912. fsiOPFLD.MedChrgitmType = "09"
  1913. memo["hosp_appr_flag"] = "1"
  1914. memo["invoice_no"] = order.MdtrtId
  1915. memo["memo"] = "自费"
  1916. bytesData, _ := json.Marshal(memo)
  1917. fsiOPFLD.Memo = string(bytesData)
  1918. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1919. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1920. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1921. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1922. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1923. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1924. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1925. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1926. fsiOPFLD.BilgDeptName = department.Name
  1927. fsiOPFLD.BilgDeptCodg = department.Number
  1928. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1929. fsiOPFLD.BilgDrName = doctor.UserName
  1930. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1931. case 0:
  1932. break
  1933. case 1:
  1934. fsiOPFLD.MedChrgitmType = "14"
  1935. break
  1936. case 2:
  1937. fsiOPFLD.MedChrgitmType = "05"
  1938. break
  1939. case 3:
  1940. fsiOPFLD.MedChrgitmType = "03"
  1941. break
  1942. case 4:
  1943. fsiOPFLD.MedChrgitmType = "03"
  1944. break
  1945. case 5:
  1946. fsiOPFLD.MedChrgitmType = "08"
  1947. break
  1948. case 6:
  1949. fsiOPFLD.MedChrgitmType = "14"
  1950. break
  1951. case 7:
  1952. fsiOPFLD.MedChrgitmType = "14"
  1953. break
  1954. case 8:
  1955. fsiOPFLD.MedChrgitmType = "03"
  1956. break
  1957. case 9:
  1958. fsiOPFLD.MedChrgitmType = "14"
  1959. break
  1960. case 10:
  1961. fsiOPFLD.MedChrgitmType = "14"
  1962. break
  1963. case 11:
  1964. fsiOPFLD.MedChrgitmType = "06"
  1965. break
  1966. case 12:
  1967. fsiOPFLD.MedChrgitmType = "12"
  1968. break
  1969. case 13:
  1970. fsiOPFLD.MedChrgitmType = "01"
  1971. break
  1972. case 14:
  1973. fsiOPFLD.MedChrgitmType = "04"
  1974. break
  1975. case 15:
  1976. fsiOPFLD.MedChrgitmType = "14"
  1977. break
  1978. }
  1979. memo["hosp_appr_flag"] = "1"
  1980. memo["invoice_no"] = order.MdtrtId
  1981. memo["memo"] = "自费"
  1982. bytesData, _ := json.Marshal(memo)
  1983. fsiOPFLD.Memo = string(bytesData)
  1984. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1985. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  1986. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1987. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1988. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1989. fsiOPFLD.BilgDeptName = department.Name
  1990. fsiOPFLD.BilgDeptCodg = department.Number
  1991. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1992. fsiOPFLD.BilgDrName = doctor.UserName
  1993. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1994. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1995. fsiOPFLD.MedChrgitmType = "08"
  1996. memo["hosp_appr_flag"] = "1"
  1997. memo["invoice_no"] = order.MdtrtId
  1998. memo["memo"] = "自费"
  1999. bytesData, _ := json.Marshal(memo)
  2000. fsiOPFLD.Memo = string(bytesData)
  2001. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2002. }
  2003. }
  2004. }
  2005. for _, items := range order_info_two {
  2006. memo := make(map[string]interface{})
  2007. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2008. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2009. fsiOPFLD.MedType = "14"
  2010. fsiOPFLD.BkkpSn = items.FeedetlSn
  2011. fsiOPFLD.FixmedinsCode = miConfig.Code
  2012. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2013. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2014. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2015. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2016. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2017. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2018. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2019. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2020. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2021. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2022. fsiOPFLD.BilgDeptName = department.Name
  2023. fsiOPFLD.BilgDeptCodg = department.Number
  2024. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2025. fsiOPFLD.BilgDrName = doctor.UserName
  2026. fsiOPFLD.MedChrgitmType = "09"
  2027. memo["hosp_appr_flag"] = "1"
  2028. memo["invoice_no"] = order.MdtrtId
  2029. memo["memo"] = "自费"
  2030. bytesData, _ := json.Marshal(memo)
  2031. fsiOPFLD.Memo = string(bytesData)
  2032. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2033. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2034. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2035. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2036. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2037. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2038. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2039. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2040. fsiOPFLD.BilgDeptName = department.Name
  2041. fsiOPFLD.BilgDeptCodg = department.Number
  2042. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2043. fsiOPFLD.BilgDrName = doctor.UserName
  2044. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2045. case 0:
  2046. break
  2047. case 1:
  2048. fsiOPFLD.MedChrgitmType = "14"
  2049. break
  2050. case 2:
  2051. fsiOPFLD.MedChrgitmType = "05"
  2052. break
  2053. case 3:
  2054. fsiOPFLD.MedChrgitmType = "03"
  2055. break
  2056. case 4:
  2057. fsiOPFLD.MedChrgitmType = "03"
  2058. break
  2059. case 5:
  2060. fsiOPFLD.MedChrgitmType = "08"
  2061. break
  2062. case 6:
  2063. fsiOPFLD.MedChrgitmType = "14"
  2064. break
  2065. case 7:
  2066. fsiOPFLD.MedChrgitmType = "14"
  2067. break
  2068. case 8:
  2069. fsiOPFLD.MedChrgitmType = "03"
  2070. break
  2071. case 9:
  2072. fsiOPFLD.MedChrgitmType = "14"
  2073. break
  2074. case 10:
  2075. fsiOPFLD.MedChrgitmType = "14"
  2076. break
  2077. case 11:
  2078. fsiOPFLD.MedChrgitmType = "06"
  2079. break
  2080. case 12:
  2081. fsiOPFLD.MedChrgitmType = "12"
  2082. break
  2083. case 13:
  2084. fsiOPFLD.MedChrgitmType = "01"
  2085. break
  2086. case 14:
  2087. fsiOPFLD.MedChrgitmType = "04"
  2088. break
  2089. case 15:
  2090. fsiOPFLD.MedChrgitmType = "14"
  2091. break
  2092. }
  2093. memo["hosp_appr_flag"] = "1"
  2094. memo["invoice_no"] = order.MdtrtId
  2095. memo["memo"] = "自费"
  2096. bytesData, _ := json.Marshal(memo)
  2097. fsiOPFLD.Memo = string(bytesData)
  2098. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2099. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  2100. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2101. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2102. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2103. fsiOPFLD.BilgDeptName = department.Name
  2104. fsiOPFLD.BilgDeptCodg = department.Number
  2105. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2106. fsiOPFLD.BilgDrName = doctor.UserName
  2107. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2108. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2109. fsiOPFLD.MedChrgitmType = "08"
  2110. memo["hosp_appr_flag"] = "1"
  2111. memo["invoice_no"] = order.MdtrtId
  2112. memo["memo"] = "自费"
  2113. bytesData, _ := json.Marshal(memo)
  2114. fsiOPFLD.Memo = string(bytesData)
  2115. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2116. }
  2117. }
  2118. }
  2119. fmt.Println(fsiOPFLDs)
  2120. struct4201A.Fopfd = fsiOPFLDs
  2121. fmt.Println(struct4201A.Fopfd)
  2122. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  2123. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  2124. var res2 ResultSix
  2125. var respJSON2 map[string]interface{}
  2126. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2129. return
  2130. }
  2131. userJSONBytes2, _ := json.Marshal(respJSON2)
  2132. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2133. utils.ErrorLog("解析失败:%v", err)
  2134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2135. return
  2136. }
  2137. if res2.Infcode != 0 {
  2138. c.ServeSuccessJSON(map[string]interface{}{
  2139. "failed_code": -10,
  2140. "msg": res2.ErrMsg,
  2141. })
  2142. return
  2143. } else {
  2144. order.IsUploadOrderInfo = 1
  2145. service.UpdateOrder(order)
  2146. c.ServeSuccessJSON(map[string]interface{}{
  2147. "msg": "上传成功",
  2148. })
  2149. }
  2150. }
  2151. func (c *HisApiController) Get4202() {
  2152. order_id, _ := c.GetInt64("order_id")
  2153. admin_user_id, _ := c.GetInt64("admin_user_id")
  2154. order, _ := service.GetHisOrderByIDTwo(order_id)
  2155. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2156. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2157. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2158. if order.ID == 0 {
  2159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2160. return
  2161. }
  2162. var struct4202 models.Struct4202
  2163. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  2164. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  2165. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  2166. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  2167. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  2168. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  2169. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  2170. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  2171. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  2172. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2173. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2174. var config []*models.HisXtDiagnoseConfig
  2175. for _, item := range diagnosis_ids {
  2176. id, _ := strconv.ParseInt(item, 10, 64)
  2177. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2178. config = append(config, &diagnosisConfig)
  2179. }
  2180. var tempDiaginfos []models.OwnPayPatnDiagListD
  2181. for index, item := range config {
  2182. if index == 0 {
  2183. var tempDiaginfo models.OwnPayPatnDiagListD
  2184. tempDiaginfo.InoutDiagType = "1"
  2185. tempDiaginfo.DiagCode = item.CountryCode
  2186. tempDiaginfo.DiagName = item.CountryContentName
  2187. tempDiaginfo.DiagType = "1"
  2188. tempDiaginfo.DiagSrtNo = "1"
  2189. tempDiaginfo.MaindiagFlag = "1"
  2190. tempDiaginfo.ValiFlag = "1"
  2191. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2192. } else {
  2193. var tempDiaginfo models.OwnPayPatnDiagListD
  2194. tempDiaginfo.DiagCode = item.CountryCode
  2195. tempDiaginfo.DiagName = item.CountryContentName
  2196. tempDiaginfo.DiagType = "2"
  2197. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2198. tempDiaginfo.MaindiagFlag = "0"
  2199. tempDiaginfo.ValiFlag = "1"
  2200. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2201. }
  2202. }
  2203. struct4202.ODiagListD = tempDiaginfos
  2204. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  2205. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  2206. var res2 ResultSix
  2207. var respJSON2 map[string]interface{}
  2208. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2211. return
  2212. }
  2213. userJSONBytes2, _ := json.Marshal(respJSON2)
  2214. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2215. utils.ErrorLog("解析失败:%v", err)
  2216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2217. return
  2218. }
  2219. if res2.Infcode != 0 {
  2220. c.ServeSuccessJSON(map[string]interface{}{
  2221. "failed_code": -10,
  2222. "msg": res2.ErrMsg,
  2223. })
  2224. return
  2225. } else {
  2226. order.IsUploadDiagnose = 1
  2227. service.UpdateOrder(order)
  2228. c.ServeSuccessJSON(map[string]interface{}{
  2229. "msg": "上传成功",
  2230. })
  2231. }
  2232. }
  2233. func (c *HisApiController) Get4203() {
  2234. admin_user_id, _ := c.GetInt64("admin_user_id")
  2235. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2236. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2237. order_id, _ := c.GetInt64("order_id")
  2238. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  2239. number := ""
  2240. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2241. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2242. if his.ID == 0 {
  2243. number = hospital.Number
  2244. } else {
  2245. number = his.Number
  2246. }
  2247. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  2248. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  2249. var res2 ResultSix
  2250. var respJSON2 map[string]interface{}
  2251. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2254. return
  2255. }
  2256. userJSONBytes2, _ := json.Marshal(respJSON2)
  2257. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2258. utils.ErrorLog("解析失败:%v", err)
  2259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2260. return
  2261. }
  2262. if res2.Infcode != 0 {
  2263. c.ServeSuccessJSON(map[string]interface{}{
  2264. "failed_code": -10,
  2265. "msg": res2.ErrMsg,
  2266. })
  2267. return
  2268. } else {
  2269. order.IsUploadSuccess = 1
  2270. service.UpdateOrderTwo(order)
  2271. c.ServeSuccessJSON(map[string]interface{}{
  2272. "msg": "上传成功",
  2273. })
  2274. }
  2275. }
  2276. func (c *HisApiController) Get4205() {
  2277. order_id, _ := c.GetInt64("order_id")
  2278. admin_user_id, _ := c.GetInt64("admin_user_id")
  2279. fapiao_code := c.GetString("fapiao_code")
  2280. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  2281. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2282. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2283. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2284. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  2285. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  2286. //order_info = append(order_info, order_info_two...)
  2287. department, _ := service.GetDepartMentDetail(his.Departments)
  2288. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  2289. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  2290. if order.ID == 0 {
  2291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2292. return
  2293. }
  2294. var struct4201A models.Struct4201A
  2295. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  2296. for _, items := range order_info {
  2297. memo := make(map[string]interface{})
  2298. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2299. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2300. fsiOPFLD.MedType = pre.MedType
  2301. fsiOPFLD.FixmedinsCode = miConfig.Code
  2302. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2303. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2304. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2305. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2306. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2307. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2308. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2309. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  2310. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2311. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2312. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2313. fsiOPFLD.BilgDeptName = department.Name
  2314. fsiOPFLD.BilgDeptCodg = department.Number
  2315. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2316. fsiOPFLD.BilgDrName = doctor.UserName
  2317. fsiOPFLD.MedChrgitmType = "09"
  2318. memo["hosp_appr_flag"] = "1"
  2319. memo["invoice_no"] = fapiao_code
  2320. memo["memo"] = "自费"
  2321. bytesData, _ := json.Marshal(memo)
  2322. fsiOPFLD.Memo = string(bytesData)
  2323. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2324. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2325. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  2326. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2327. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2328. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2329. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2330. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2331. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2332. fsiOPFLD.BilgDeptName = department.Name
  2333. fsiOPFLD.BilgDeptCodg = department.Number
  2334. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2335. fsiOPFLD.BilgDrName = doctor.UserName
  2336. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2337. case 0:
  2338. break
  2339. case 1:
  2340. fsiOPFLD.MedChrgitmType = "14"
  2341. break
  2342. case 2:
  2343. fsiOPFLD.MedChrgitmType = "05"
  2344. break
  2345. case 3:
  2346. fsiOPFLD.MedChrgitmType = "03"
  2347. break
  2348. case 4:
  2349. fsiOPFLD.MedChrgitmType = "03"
  2350. break
  2351. case 5:
  2352. fsiOPFLD.MedChrgitmType = "08"
  2353. break
  2354. case 6:
  2355. fsiOPFLD.MedChrgitmType = "14"
  2356. break
  2357. case 7:
  2358. fsiOPFLD.MedChrgitmType = "14"
  2359. break
  2360. case 8:
  2361. fsiOPFLD.MedChrgitmType = "03"
  2362. break
  2363. case 9:
  2364. fsiOPFLD.MedChrgitmType = "14"
  2365. break
  2366. case 10:
  2367. fsiOPFLD.MedChrgitmType = "14"
  2368. break
  2369. case 11:
  2370. fsiOPFLD.MedChrgitmType = "06"
  2371. break
  2372. case 12:
  2373. fsiOPFLD.MedChrgitmType = "12"
  2374. break
  2375. case 13:
  2376. fsiOPFLD.MedChrgitmType = "01"
  2377. break
  2378. case 14:
  2379. fsiOPFLD.MedChrgitmType = "04"
  2380. break
  2381. case 15:
  2382. fsiOPFLD.MedChrgitmType = "14"
  2383. break
  2384. }
  2385. memo["hosp_appr_flag"] = "1"
  2386. memo["invoice_no"] = fapiao_code
  2387. memo["memo"] = "自费"
  2388. bytesData, _ := json.Marshal(memo)
  2389. fsiOPFLD.Memo = string(bytesData)
  2390. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2391. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  2392. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2393. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2394. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2395. fsiOPFLD.BilgDeptName = department.Name
  2396. fsiOPFLD.BilgDeptCodg = department.Number
  2397. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2398. fsiOPFLD.BilgDrName = doctor.UserName
  2399. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2400. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2401. fsiOPFLD.MedChrgitmType = "08"
  2402. memo["hosp_appr_flag"] = "1"
  2403. memo["invoice_no"] = fapiao_code
  2404. memo["memo"] = "自费"
  2405. bytesData, _ := json.Marshal(memo)
  2406. fsiOPFLD.Memo = string(bytesData)
  2407. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2408. }
  2409. }
  2410. }
  2411. for _, items := range order_info_two {
  2412. memo := make(map[string]interface{})
  2413. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2414. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2415. fsiOPFLD.MedType = pre.MedType
  2416. fsiOPFLD.BkkpSn = items.FeedetlSn
  2417. fsiOPFLD.FixmedinsCode = miConfig.Code
  2418. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2419. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2420. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2421. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2422. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2423. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2424. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2425. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2426. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2427. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2428. fsiOPFLD.BilgDeptName = department.Name
  2429. fsiOPFLD.BilgDeptCodg = department.Number
  2430. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2431. fsiOPFLD.BilgDrName = doctor.UserName
  2432. fsiOPFLD.MedChrgitmType = "09"
  2433. memo["hosp_appr_flag"] = "1"
  2434. memo["invoice_no"] = fapiao_code
  2435. memo["memo"] = "自费"
  2436. bytesData, _ := json.Marshal(memo)
  2437. fsiOPFLD.Memo = string(bytesData)
  2438. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2439. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2440. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  2441. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2442. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2443. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2444. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2445. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2446. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2447. fsiOPFLD.BilgDeptName = department.Name
  2448. fsiOPFLD.BilgDeptCodg = department.Number
  2449. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2450. fsiOPFLD.BilgDrName = doctor.UserName
  2451. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2452. case 0:
  2453. break
  2454. case 1:
  2455. fsiOPFLD.MedChrgitmType = "14"
  2456. break
  2457. case 2:
  2458. fsiOPFLD.MedChrgitmType = "05"
  2459. break
  2460. case 3:
  2461. fsiOPFLD.MedChrgitmType = "03"
  2462. break
  2463. case 4:
  2464. fsiOPFLD.MedChrgitmType = "03"
  2465. break
  2466. case 5:
  2467. fsiOPFLD.MedChrgitmType = "08"
  2468. break
  2469. case 6:
  2470. fsiOPFLD.MedChrgitmType = "14"
  2471. break
  2472. case 7:
  2473. fsiOPFLD.MedChrgitmType = "14"
  2474. break
  2475. case 8:
  2476. fsiOPFLD.MedChrgitmType = "03"
  2477. break
  2478. case 9:
  2479. fsiOPFLD.MedChrgitmType = "14"
  2480. break
  2481. case 10:
  2482. fsiOPFLD.MedChrgitmType = "14"
  2483. break
  2484. case 11:
  2485. fsiOPFLD.MedChrgitmType = "06"
  2486. break
  2487. case 12:
  2488. fsiOPFLD.MedChrgitmType = "12"
  2489. break
  2490. case 13:
  2491. fsiOPFLD.MedChrgitmType = "01"
  2492. break
  2493. case 14:
  2494. fsiOPFLD.MedChrgitmType = "04"
  2495. break
  2496. case 15:
  2497. fsiOPFLD.MedChrgitmType = "14"
  2498. break
  2499. }
  2500. memo["hosp_appr_flag"] = "1"
  2501. memo["invoice_no"] = fapiao_code
  2502. memo["memo"] = "自费"
  2503. bytesData, _ := json.Marshal(memo)
  2504. fsiOPFLD.Memo = string(bytesData)
  2505. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2506. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  2507. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2508. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2509. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2510. fsiOPFLD.BilgDeptName = department.Name
  2511. fsiOPFLD.BilgDeptCodg = department.Number
  2512. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2513. fsiOPFLD.BilgDrName = doctor.UserName
  2514. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2515. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2516. fsiOPFLD.MedChrgitmType = "08"
  2517. memo["hosp_appr_flag"] = "1"
  2518. memo["invoice_no"] = fapiao_code
  2519. memo["memo"] = "自费"
  2520. bytesData, _ := json.Marshal(memo)
  2521. fsiOPFLD.Memo = string(bytesData)
  2522. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2523. }
  2524. }
  2525. }
  2526. fmt.Println(fsiOPFLDs)
  2527. struct4201A.Fopfd = fsiOPFLDs
  2528. fmt.Println(struct4201A.Fopfd)
  2529. var struct4202 models.Struct4202
  2530. timeLayout := "2006-01-02 15:04:05"
  2531. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  2532. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  2533. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  2534. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  2535. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  2536. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  2537. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  2538. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  2539. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  2540. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  2541. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2542. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2543. var config []*models.HisXtDiagnoseConfig
  2544. for _, item := range diagnosis_ids {
  2545. id, _ := strconv.ParseInt(item, 10, 64)
  2546. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2547. config = append(config, &diagnosisConfig)
  2548. }
  2549. var tempDiaginfos []models.OwnPayPatnDiagListD
  2550. for index, item := range config {
  2551. if index == 0 {
  2552. var tempDiaginfo models.OwnPayPatnDiagListD
  2553. tempDiaginfo.InoutDiagType = "1"
  2554. tempDiaginfo.DiagCode = item.CountryCode
  2555. tempDiaginfo.DiagName = item.CountryContentName
  2556. tempDiaginfo.DiagType = "1"
  2557. tempDiaginfo.DiagSrtNo = "1"
  2558. tempDiaginfo.MaindiagFlag = "1"
  2559. tempDiaginfo.ValiFlag = "1"
  2560. tempDiaginfo.DiagDrName = doctor.UserName
  2561. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  2562. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  2563. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2564. } else {
  2565. var tempDiaginfo models.OwnPayPatnDiagListD
  2566. tempDiaginfo.DiagCode = item.CountryCode
  2567. tempDiaginfo.DiagName = item.CountryContentName
  2568. tempDiaginfo.DiagType = "2"
  2569. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2570. tempDiaginfo.MaindiagFlag = "0"
  2571. tempDiaginfo.ValiFlag = "1"
  2572. tempDiaginfo.DiagDrName = doctor.UserName
  2573. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  2574. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  2575. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2576. }
  2577. }
  2578. struct4202.ODiagListD = tempDiaginfos
  2579. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  2580. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  2581. var res2 ResultSix
  2582. var respJSON2 map[string]interface{}
  2583. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2586. return
  2587. }
  2588. userJSONBytes2, _ := json.Marshal(respJSON2)
  2589. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2590. utils.ErrorLog("解析失败:%v", err)
  2591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2592. return
  2593. }
  2594. if res2.Infcode != 0 {
  2595. c.ServeSuccessJSON(map[string]interface{}{
  2596. "failed_code": -10,
  2597. "msg": res2.ErrMsg,
  2598. })
  2599. return
  2600. } else {
  2601. order.IsUploadDiagnose = 1
  2602. order.IsUploadOrderInfo = 1
  2603. service.UpdateOrderTwo(order)
  2604. c.ServeSuccessJSON(map[string]interface{}{
  2605. "msg": "上传成功",
  2606. })
  2607. }
  2608. }
  2609. func (c *HisApiController) Get4207() {
  2610. admin_user_id, _ := c.GetInt64("admin_user_id")
  2611. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2612. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2613. order_id, _ := c.GetInt64("order_id")
  2614. order, _ := service.GetHisOrderByIDTwo(order_id)
  2615. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2616. var struct4207 models.Struct4207
  2617. struct4207.PageNum = "1"
  2618. struct4207.PageSize = "1000"
  2619. struct4207.FixmedinsCode = miConfig.Code
  2620. struct4207.FixmedinsMdtrtID = order.Number
  2621. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  2622. saveLog(result, requestLog, "4207", "查询")
  2623. var res2 ResultSix
  2624. var respJSON2 map[string]interface{}
  2625. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2628. return
  2629. }
  2630. userJSONBytes2, _ := json.Marshal(respJSON2)
  2631. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2632. utils.ErrorLog("解析失败:%v", err)
  2633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2634. return
  2635. }
  2636. if res2.Infcode != 0 {
  2637. c.ServeSuccessJSON(map[string]interface{}{
  2638. "failed_code": -10,
  2639. "msg": res2.ErrMsg,
  2640. })
  2641. return
  2642. } else {
  2643. c.ServeSuccessJSON(map[string]interface{}{
  2644. "msg": "查询成功",
  2645. })
  2646. }
  2647. }
  2648. func (c *HisApiController) Get4208() {
  2649. admin_user_id, _ := c.GetInt64("admin_user_id")
  2650. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2651. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2652. order_id, _ := c.GetInt64("order_id")
  2653. order, _ := service.GetHisOrderByIDTwo(order_id)
  2654. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2655. var struct4208 models.Struct4208
  2656. struct4208.PageNum = "1"
  2657. struct4208.PageSize = "1000"
  2658. struct4208.PsnCertType = "01"
  2659. struct4208.Certno = his.Certno
  2660. struct4208.MedType = order.MedType
  2661. struct4208.PsnName = his.Name
  2662. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  2663. saveLog(result, requestLog, "4208", "查询")
  2664. var res2 ResultSix
  2665. var respJSON2 map[string]interface{}
  2666. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2669. return
  2670. }
  2671. userJSONBytes2, _ := json.Marshal(respJSON2)
  2672. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2673. utils.ErrorLog("解析失败:%v", err)
  2674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2675. return
  2676. }
  2677. if res2.Infcode != 0 {
  2678. c.ServeSuccessJSON(map[string]interface{}{
  2679. "failed_code": -10,
  2680. "msg": res2.ErrMsg,
  2681. })
  2682. return
  2683. } else {
  2684. c.ServeSuccessJSON(map[string]interface{}{
  2685. "msg": "查询成功",
  2686. })
  2687. }
  2688. }
  2689. func (c *HisApiController) Get4209() {
  2690. admin_user_id, _ := c.GetInt64("admin_user_id")
  2691. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2692. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2693. order_id, _ := c.GetInt64("order_id")
  2694. order, _ := service.GetHisOrderByIDTwo(order_id)
  2695. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2696. var struct4209 models.Struct4209
  2697. struct4209.FixmedinsMdtrtID = order.Number
  2698. struct4209.FixmedinsCode = miConfig.Code
  2699. struct4209.PageSize = "1000"
  2700. struct4209.PageNum = "1"
  2701. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  2702. saveLog(result, requestLog, "4209", "查询")
  2703. var res2 ResultSix
  2704. var respJSON2 map[string]interface{}
  2705. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2708. return
  2709. }
  2710. userJSONBytes2, _ := json.Marshal(respJSON2)
  2711. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2712. utils.ErrorLog("解析失败:%v", err)
  2713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2714. return
  2715. }
  2716. if res2.Infcode != 0 {
  2717. c.ServeSuccessJSON(map[string]interface{}{
  2718. "failed_code": -10,
  2719. "msg": res2.ErrMsg,
  2720. })
  2721. return
  2722. } else {
  2723. c.ServeSuccessJSON(map[string]interface{}{
  2724. "msg": "查询成功",
  2725. })
  2726. }
  2727. }
  2728. type Result3101 struct {
  2729. Infcode string `json:"infcode"`
  2730. InfRefmsgid string `json:"inf_refmsgid"`
  2731. RefmsgTime string `json:"refmsg_time"`
  2732. RespondTime string `json:"respond_time"`
  2733. Enctype string `json:"enctype"`
  2734. Signtype string `json:"signtype"`
  2735. ErrMsg string `json:"err_msg"`
  2736. Output struct {
  2737. Result []struct {
  2738. JudgeResultDetailDtos []struct {
  2739. VolaItemType string `json:"vola_item_type"`
  2740. MdtrtID string `json:"mdtrt_id"`
  2741. JrdID string `json:"jrd_id"`
  2742. PatnID string `json:"patn_id"`
  2743. RxID string `json:"rx_id"`
  2744. VolaAmt interface{} `json:"vola_amt"`
  2745. } `json:"judge_result_detail_dtos"`
  2746. RuleID string `json:"rule_id"`
  2747. VolaEvid string `json:"vola_evid"`
  2748. MdtrtID string `json:"mdtrt_id"`
  2749. RuleName string `json:"rule_name"`
  2750. VolaAmtStas string `json:"vola_amt_stas"`
  2751. JrID string `json:"jr_id"`
  2752. PatnID string `json:"patn_id"`
  2753. SevDeg string `json:"sev_deg"`
  2754. VolaAmt float64 `json:"vola_amt"`
  2755. VolaBhvrType string `json:"vola_bhvr_type"`
  2756. VolaCont string `json:"vola_cont"`
  2757. } `json:"result"`
  2758. } `json:"output"`
  2759. }
  2760. func (c *HisApiController) ReadEleToken() {
  2761. admin_user_id, _ := c.GetInt64("admin_user_id")
  2762. his_patient_id, _ := c.GetInt64("his_patient_id")
  2763. adminUser := c.GetAdminUserInfo()
  2764. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2765. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2766. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2767. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2768. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  2769. if len(tokens) > 0 {
  2770. c.ServeSuccessJSON(map[string]interface{}{
  2771. "msg": "读取成功",
  2772. })
  2773. } else {
  2774. c.ServeSuccessJSON(map[string]interface{}{
  2775. "failed_code": -10,
  2776. "msg": "读取失败",
  2777. })
  2778. }
  2779. } else if miConfig.MdtrtareaAdmvs == "350500" {
  2780. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  2781. if len(errMsg) == 0 {
  2782. type ELeData struct {
  2783. Data struct {
  2784. IdNo string `json:"idNo"`
  2785. IdType string `json:"idType"`
  2786. UserName string `json:"userName"`
  2787. EcToken string `json:"ecToken"`
  2788. InsuOrg string `json:"insuOrg"`
  2789. Gender string `json:"gender"`
  2790. Birthday string `json:"birthday"`
  2791. Nationality string `json:"nationality"`
  2792. Email string `json:"email"`
  2793. Extra string `json:"extra"`
  2794. } `json:"data"`
  2795. Code int `json:"code"`
  2796. Message string `json:"message"`
  2797. }
  2798. var ele ELeData
  2799. err := json.Unmarshal([]byte(outPutInfo), &ele)
  2800. if err != nil {
  2801. utils.ErrorLog("解析失败:%v", err)
  2802. }
  2803. token := ele.Data.EcToken
  2804. if len(token) > 0 {
  2805. psn := &models.HisPsn{
  2806. PsnNo: his.PsnNo,
  2807. Age: 0,
  2808. PatientId: his.PatientId,
  2809. Certno: his.Certno,
  2810. Brdy: his.Brdy,
  2811. Gend: his.Gend,
  2812. Naty: his.Naty,
  2813. PsnCertType: his.PsnCertType,
  2814. PsnName: his.PsnName,
  2815. Idetinfo: his.Idetinfo,
  2816. Insuinfo: his.Iinfo,
  2817. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2818. CardInfo: outPutInfo,
  2819. VerifyNumber: token,
  2820. }
  2821. service.CreateHisPsn(psn)
  2822. }
  2823. if len(token) > 0 {
  2824. c.ServeSuccessJSON(map[string]interface{}{
  2825. "msg": "读取成功",
  2826. })
  2827. } else {
  2828. c.ServeSuccessJSON(map[string]interface{}{
  2829. "failed_code": -10,
  2830. "msg": "读取失败",
  2831. })
  2832. }
  2833. }
  2834. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2835. if initFlag == 0 {
  2836. c.TestGetJiangXiBasBaseInit()
  2837. }
  2838. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  2839. type ELeData struct {
  2840. Data struct {
  2841. IdNo string `json:"idNo"`
  2842. IdType string `json:"idType"`
  2843. UserName string `json:"userName"`
  2844. EcToken string `json:"ecToken"`
  2845. InsuOrg string `json:"insuOrg"`
  2846. Gender string `json:"gender"`
  2847. Birthday string `json:"birthday"`
  2848. Nationality string `json:"nationality"`
  2849. Email string `json:"email"`
  2850. Extra string `json:"extra"`
  2851. } `json:"data"`
  2852. Code int `json:"code"`
  2853. Message string `json:"message"`
  2854. }
  2855. var ele ELeData
  2856. err := json.Unmarshal([]byte(json_result), &ele)
  2857. if err != nil {
  2858. utils.ErrorLog("解析失败:%v", err)
  2859. }
  2860. token := ele.Data.EcToken
  2861. token = Remove0000(token)
  2862. fmt.Println(ele.Data.UserName)
  2863. 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)
  2864. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2865. var res ResultTwo
  2866. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2867. utils.ErrorLog("解析失败:%v", err)
  2868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2869. return
  2870. }
  2871. if res.Infcode == 0 {
  2872. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2873. if err == gorm.ErrRecordNotFound {
  2874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2875. return
  2876. } else if err != nil {
  2877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2878. return
  2879. } else {
  2880. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2881. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2882. infoStr := string(Iinfos)
  2883. idetinfoStr := string(Idetinfos)
  2884. psn := &models.HisPsn{
  2885. PsnNo: res.Output.Baseinfo.PsnNo,
  2886. Age: res.Output.Baseinfo.Age,
  2887. PatientId: patient.ID,
  2888. Certno: res.Output.Baseinfo.Certno,
  2889. Brdy: res.Output.Baseinfo.Brdy,
  2890. Gend: res.Output.Baseinfo.Gend,
  2891. Naty: res.Output.Baseinfo.Naty,
  2892. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2893. PsnName: res.Output.Baseinfo.PsnName,
  2894. Idetinfo: idetinfoStr,
  2895. Insuinfo: infoStr,
  2896. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2897. CardInfo: "",
  2898. VerifyNumber: token,
  2899. }
  2900. service.CreateHisPsn(psn)
  2901. c.ServeSuccessJSON(map[string]interface{}{
  2902. "patient": patient,
  2903. "number": token,
  2904. })
  2905. }
  2906. } else {
  2907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2908. return
  2909. }
  2910. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2911. idNo := c.GetString("idNo")
  2912. userName := c.GetString("userName")
  2913. ecToken := c.GetString("ecToken")
  2914. insuOrg := c.GetString("insuOrg")
  2915. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  2916. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2917. var res ResultTwo
  2918. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2919. utils.ErrorLog("解析失败:%v", err)
  2920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2921. return
  2922. }
  2923. if res.Infcode == 0 {
  2924. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2925. if err == gorm.ErrRecordNotFound {
  2926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2927. return
  2928. } else if err != nil {
  2929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2930. return
  2931. } else {
  2932. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2933. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2934. infoStr := string(Iinfos)
  2935. idetinfoStr := string(Idetinfos)
  2936. psn := &models.HisPsn{
  2937. PsnNo: res.Output.Baseinfo.PsnNo,
  2938. Age: res.Output.Baseinfo.Age,
  2939. PatientId: patient.ID,
  2940. Certno: res.Output.Baseinfo.Certno,
  2941. Brdy: res.Output.Baseinfo.Brdy,
  2942. Gend: res.Output.Baseinfo.Gend,
  2943. Naty: res.Output.Baseinfo.Naty,
  2944. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2945. PsnName: res.Output.Baseinfo.PsnName,
  2946. Idetinfo: idetinfoStr,
  2947. Insuinfo: infoStr,
  2948. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2949. CardInfo: "",
  2950. VerifyNumber: ecToken,
  2951. InsuplcAdmdvs: insuOrg,
  2952. }
  2953. service.CreateHisPsn(psn)
  2954. c.ServeSuccessJSON(map[string]interface{}{
  2955. "patient": patient,
  2956. "number": ecToken,
  2957. })
  2958. }
  2959. } else {
  2960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2961. return
  2962. }
  2963. } else {
  2964. //if initFlag == 0 {
  2965. // c.TestGetBasBaseInit()
  2966. //}
  2967. //token := c.GetEleBaseInfo()
  2968. //token = Remove0000(token)
  2969. type ELeData struct {
  2970. Code string `json:"code"`
  2971. Data struct {
  2972. Aac002 string `json:"aac002"`
  2973. Aaz500 string `json:"aaz500"`
  2974. ActCardNo string `json:"actCardNo"`
  2975. Bab520 string `json:"bab520"`
  2976. Bkz543 string `json:"bkz543"`
  2977. BusinessType string `json:"businessType"`
  2978. CertfCodg string `json:"certfCodg"`
  2979. EcIndexNo string `json:"ecIndexNo"`
  2980. EcToken string `json:"ecToken"`
  2981. ID0000 string `json:"id0000"`
  2982. IDNo string `json:"idNo"`
  2983. IDType string `json:"idType"`
  2984. Idcode string `json:"idcode"`
  2985. IdentityToken string `json:"identity_token"`
  2986. InsuOrg string `json:"insuOrg"`
  2987. OfficeID string `json:"officeId"`
  2988. OfficeName string `json:"officeName"`
  2989. OperatorID string `json:"operatorId"`
  2990. OperatorName string `json:"operatorName"`
  2991. OrgID string `json:"orgId"`
  2992. UserName string `json:"userName"`
  2993. } `json:"data"`
  2994. Infno interface{} `json:"infno"`
  2995. Message string `json:"message"`
  2996. OrgID string `json:"orgId"`
  2997. TransType string `json:"transType"`
  2998. }
  2999. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  3000. fmt.Println(result)
  3001. outPutInfo := Remove0000(result)
  3002. fmt.Println(outPutInfo)
  3003. var ele ELeData
  3004. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3005. if err != nil {
  3006. utils.ErrorLog("解析失败:%v", err)
  3007. }
  3008. token := ele.Data.EcToken
  3009. if len(token) > 0 {
  3010. result2, requestLog2 := service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  3011. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3012. var res ResultTwo
  3013. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3014. utils.ErrorLog("解析失败:%v", err)
  3015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3016. return
  3017. }
  3018. if res.Infcode == 0 {
  3019. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3020. if err == gorm.ErrRecordNotFound {
  3021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3022. return
  3023. } else if err != nil {
  3024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3025. return
  3026. } else {
  3027. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3028. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3029. infoStr := string(Iinfos)
  3030. idetinfoStr := string(Idetinfos)
  3031. psn := &models.HisPsn{
  3032. PsnNo: res.Output.Baseinfo.PsnNo,
  3033. Age: res.Output.Baseinfo.Age,
  3034. PatientId: patient.ID,
  3035. Certno: res.Output.Baseinfo.Certno,
  3036. Brdy: res.Output.Baseinfo.Brdy,
  3037. Gend: res.Output.Baseinfo.Gend,
  3038. Naty: res.Output.Baseinfo.Naty,
  3039. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3040. PsnName: res.Output.Baseinfo.PsnName,
  3041. Idetinfo: idetinfoStr,
  3042. Insuinfo: infoStr,
  3043. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3044. CardInfo: "",
  3045. VerifyNumber: token,
  3046. }
  3047. service.CreateHisPsn(psn)
  3048. c.ServeSuccessJSON(map[string]interface{}{
  3049. "msg": "读取成功",
  3050. })
  3051. }
  3052. } else {
  3053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3054. return
  3055. }
  3056. } else {
  3057. c.ServeSuccessJSON(map[string]interface{}{
  3058. "failed_code": -10,
  3059. "msg": "读取失败",
  3060. })
  3061. }
  3062. }
  3063. }
  3064. func (c *HisApiController) Get9001() {
  3065. adminUser := c.GetAdminUserInfo()
  3066. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3067. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  3068. if miConfig.MdtrtareaAdmvs == "350500" {
  3069. service.GetFjAuthorizationInfo(miConfig.Code)
  3070. } else if miConfig.MdtrtareaAdmvs == "131023" {
  3071. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  3072. var dat map[string]interface{}
  3073. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3074. fmt.Println(dat)
  3075. } else {
  3076. fmt.Println(err)
  3077. }
  3078. userJSONBytes, _ := json.Marshal(dat)
  3079. var res models.Result9001
  3080. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3081. utils.ErrorLog("解析失败:%v", err)
  3082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3083. return
  3084. }
  3085. } else {
  3086. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  3087. var dat map[string]interface{}
  3088. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3089. fmt.Println(dat)
  3090. } else {
  3091. fmt.Println(err)
  3092. }
  3093. userJSONBytes, _ := json.Marshal(dat)
  3094. var res models.Result9001
  3095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3096. utils.ErrorLog("解析失败:%v", err)
  3097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3098. return
  3099. }
  3100. }
  3101. }
  3102. 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) {
  3103. var res Result3101
  3104. adminUser := c.GetAdminUserInfo()
  3105. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3106. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3107. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3108. //record_time := c.GetString("record_time")
  3109. //trig_scen := c.GetString("trig_scen")
  3110. timeLayout := "2006-01-02"
  3111. loc, _ := time.LoadLocation("Local")
  3112. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3113. if err != nil {
  3114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3115. return res
  3116. }
  3117. recordDateTime := theTime.Unix()
  3118. var patientPrescription models.HisPrescriptionInfo
  3119. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3120. //if patientPrescription.ID == 0 {
  3121. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3122. //}
  3123. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3124. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3125. //
  3126. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  3127. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3128. var pp models.PublicParams
  3129. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3130. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3131. pp.FixmedinsName = miConfig.OrgName
  3132. pp.FixmedinsCode = miConfig.Code
  3133. pp.RequestUrl = miConfig.Url
  3134. pp.Cainfo = miConfig.Cainfo
  3135. pp.SecretKey = miConfig.SecretKey
  3136. pp.AccessKey = miConfig.AccessKey
  3137. pp.OpterName = roles.UserName
  3138. var config []*models.HisXtDiagnoseConfig
  3139. for _, item := range diagnosis_ids {
  3140. id, _ := strconv.ParseInt(item, 10, 64)
  3141. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3142. config = append(config, &diagnosisConfig)
  3143. }
  3144. var pd models.PatientDtos
  3145. pd.PatnID = his.PsnNo
  3146. pd.PatnName = his.Name
  3147. pd.Gend = his.Gend
  3148. pd.Brdy = his.Brdy
  3149. pd.Poolarea = miConfig.MdtrtareaAdmvs
  3150. pd.CurrMdtrtID = his.Number
  3151. var fed models.FsiEncounterDtos
  3152. fed.MdtrtID = his.Number
  3153. fed.MedinsID = miConfig.Code
  3154. fed.MedinsName = miConfig.OrgName
  3155. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  3156. fed.MedMdtrtType = "1"
  3157. fed.MedinsType = "1"
  3158. fed.MedinsLv = "11"
  3159. tm := time.Unix(his.RecordDate, 0)
  3160. s_tm := tm.Format("2006-01-02 15:04:05")
  3161. fed.AdmDate = s_tm
  3162. fed.DscgDate = s_tm
  3163. fed.DscgMainDiseCodg = config[0].CountryCode
  3164. fed.DscgMainDiseName = config[0].CountryContentName
  3165. //诊断信息
  3166. var fdds []*models.FsiDiagnoseDtos
  3167. for index, item := range config {
  3168. if index == 0 {
  3169. var fdd models.FsiDiagnoseDtos
  3170. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3171. fdd.InoutDiseType = "1"
  3172. fdd.MaindiseFlag = "1"
  3173. fdd.DiseDate = s_tm
  3174. fdd.DiasSrtNo = "1"
  3175. fdd.DiseName = item.CountryContentName
  3176. fdd.DiseCodg = item.CountryCode
  3177. fdds = append(fdds, &fdd)
  3178. } else {
  3179. var fdd models.FsiDiagnoseDtos
  3180. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3181. fdd.InoutDiseType = "1"
  3182. fdd.MaindiseFlag = "1"
  3183. fdd.DiseDate = s_tm
  3184. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  3185. fdd.DiseName = item.CountryContentName
  3186. fdd.DiseCodg = item.CountryCode
  3187. fdds = append(fdds, &fdd)
  3188. }
  3189. }
  3190. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  3191. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  3192. fed.AdmDeptName = department.Name
  3193. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  3194. fed.DscgDeptName = department.Name
  3195. fed.MedMdtrtType = "1"
  3196. fed.MedType = "11"
  3197. //if his.Insutype == "390" {
  3198. // fed.MedType = "1402"
  3199. //} else {
  3200. // fed.MedType = "9933"
  3201. //}
  3202. var orders []*models.FsiOrderDtos
  3203. if trig_scen == "2" {
  3204. //处方医嘱信息
  3205. for _, item := range prescriptions {
  3206. for _, subItem := range item.HisDoctorAdviceInfo {
  3207. var order models.FsiOrderDtos
  3208. order.RxID = strconv.FormatInt(item.ID, 10)
  3209. order.Rxno = strconv.FormatInt(item.ID, 10)
  3210. order.LongDrordFlag = "0"
  3211. order.HilistType = "1"
  3212. order.ChrgType = "1"
  3213. order.DrordBhvr = "-"
  3214. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3215. order.HosplistName = subItem.BaseDrugLib.DrugName
  3216. order.HilistLv = "1"
  3217. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3218. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3219. order.HosplistName = subItem.BaseDrugLib.DrugName
  3220. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  3221. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3222. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  3223. order.OwnpayAmt = ""
  3224. order.SelfpayAmt = ""
  3225. order.Spec = ""
  3226. order.SpecUnt = ""
  3227. order.DrordBegnDate = s_tm
  3228. order.DrordStopDate = ""
  3229. order.DrordDrCodg = "1"
  3230. order.DrordDeptName = department.Name
  3231. order.DrordDrCodg = "1"
  3232. order.DrordDrName = doctor_info.UserName
  3233. order.DrordDrProfttl = ""
  3234. order.CurrDrordFlag = "1"
  3235. orders = append(orders, &order)
  3236. }
  3237. for _, subItem := range item.HisPrescriptionProject {
  3238. if subItem.Type == 2 {
  3239. var order models.FsiOrderDtos
  3240. order.RxID = strconv.FormatInt(item.ID, 10)
  3241. order.Rxno = strconv.FormatInt(item.ID, 10)
  3242. order.LongDrordFlag = "0"
  3243. order.HilistType = "1"
  3244. order.ChrgType = "1"
  3245. order.DrordBhvr = "-"
  3246. order.HilistCode = subItem.HisProject.MedicalCode
  3247. order.HosplistName = subItem.HisProject.ProjectName
  3248. order.HilistLv = "1"
  3249. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3250. order.HosplistCode = subItem.HisProject.MedicalCode
  3251. order.HosplistName = subItem.HisProject.ProjectName
  3252. order.Cnt = subItem.Count
  3253. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3254. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3255. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3256. order.OwnpayAmt = ""
  3257. order.SelfpayAmt = ""
  3258. order.Spec = ""
  3259. order.SpecUnt = ""
  3260. order.DrordBegnDate = s_tm
  3261. order.DrordStopDate = ""
  3262. order.DrordDrCodg = "1"
  3263. order.DrordDeptName = department.Name
  3264. order.DrordDrCodg = "1"
  3265. order.DrordDrName = doctor_info.UserName
  3266. order.DrordDrProfttl = ""
  3267. order.CurrDrordFlag = "1"
  3268. orders = append(orders, &order)
  3269. }
  3270. if subItem.Type == 3 {
  3271. var order models.FsiOrderDtos
  3272. order.RxID = strconv.FormatInt(item.ID, 10)
  3273. order.Rxno = strconv.FormatInt(item.ID, 10)
  3274. order.LongDrordFlag = "0"
  3275. order.HilistType = "1"
  3276. order.ChrgType = "1"
  3277. order.DrordBhvr = "-"
  3278. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3279. order.HosplistName = subItem.GoodInfo.GoodName
  3280. order.HilistLv = "1"
  3281. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3282. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3283. order.HosplistName = subItem.GoodInfo.GoodName
  3284. order.Cnt = subItem.Count
  3285. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3286. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3287. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3288. order.OwnpayAmt = ""
  3289. order.SelfpayAmt = ""
  3290. order.Spec = ""
  3291. order.SpecUnt = ""
  3292. order.DrordBegnDate = s_tm
  3293. order.DrordStopDate = ""
  3294. order.DrordDrCodg = "1"
  3295. order.DrordDeptName = department.Name
  3296. order.DrordDrCodg = "1"
  3297. order.DrordDrName = doctor_info.UserName
  3298. order.DrordDrProfttl = ""
  3299. order.CurrDrordFlag = "1"
  3300. orders = append(orders, &order)
  3301. }
  3302. }
  3303. }
  3304. //处方医嘱信息
  3305. }
  3306. fed.MatnStas = "0"
  3307. fed.MedfeeSumamt = "0"
  3308. fed.OwnpayAmt = "0"
  3309. fed.SelfpayAmt = "0"
  3310. fed.AcctPayamt = "0"
  3311. fed.MaAmt = "0"
  3312. fed.HifpPayamt = "0"
  3313. fed.SetlTotlnum = "1"
  3314. fed.Insutype = his.Insutype
  3315. fed.ReimFlag = "0"
  3316. fed.OutSetlFlag = "0"
  3317. var fopd []*models.FsiOperationDtosData
  3318. data := make(map[string]interface{})
  3319. data["fed"] = fed
  3320. data["fdd"] = fdds
  3321. data["fod"] = orders
  3322. data["pd"] = pd
  3323. data["pp"] = pp
  3324. data["fopd"] = fopd
  3325. data["trig_scen"] = trig_scen
  3326. fmt.Println(data)
  3327. fmt.Println(fed)
  3328. fmt.Println(fdds)
  3329. fmt.Println(orders)
  3330. fmt.Println(pd)
  3331. fmt.Println(pp)
  3332. fmt.Println(fopd)
  3333. client := &http.Client{}
  3334. bytesData, _ := json.Marshal(data)
  3335. var req *http.Request
  3336. if miConfig.MdtrtareaAdmvs == "320921" {
  3337. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  3338. } else {
  3339. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  3340. }
  3341. resp, _ := client.Do(req)
  3342. defer resp.Body.Close()
  3343. body, ioErr := ioutil.ReadAll(resp.Body)
  3344. if ioErr != nil {
  3345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3347. return res
  3348. }
  3349. var respJSON map[string]interface{}
  3350. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3353. return res
  3354. }
  3355. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3356. fmt.Println(respJSON)
  3357. result, _ := json.Marshal(respJSON)
  3358. fmt.Println(result)
  3359. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3360. utils.ErrorLog("解析失败:%v", err)
  3361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3362. return res
  3363. }
  3364. return res
  3365. }
  3366. 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) {
  3367. adminUser := c.GetAdminUserInfo()
  3368. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3369. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3370. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3371. //record_time := c.GetString("record_time")
  3372. //trig_scen := c.GetString("trig_scen")
  3373. timeLayout := "2006-01-02"
  3374. loc, _ := time.LoadLocation("Local")
  3375. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3376. if err != nil {
  3377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3378. return res
  3379. }
  3380. recordDateTime := theTime.Unix()
  3381. var patientPrescription models.HisPrescriptionInfo
  3382. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3383. if patientPrescription.ID == 0 {
  3384. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3385. }
  3386. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3387. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3388. //
  3389. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  3390. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3391. var pp models.PublicParams
  3392. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3393. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3394. pp.FixmedinsName = miConfig.OrgName
  3395. pp.FixmedinsCode = miConfig.Code
  3396. pp.RequestUrl = miConfig.Url
  3397. pp.Cainfo = miConfig.Cainfo
  3398. pp.SecretKey = miConfig.SecretKey
  3399. pp.AccessKey = miConfig.AccessKey
  3400. pp.OpterName = roles.UserName
  3401. var config []*models.HisXtDiagnoseConfig
  3402. for _, item := range diagnosis_ids {
  3403. id, _ := strconv.ParseInt(item, 10, 64)
  3404. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3405. config = append(config, &diagnosisConfig)
  3406. }
  3407. var pd models.PatientDtos
  3408. pd.PatnID = his.PsnNo
  3409. pd.PatnName = his.Name
  3410. pd.Gend = his.Gend
  3411. pd.Brdy = his.Brdy
  3412. pd.Poolarea = his.InsuplcAdmdvs
  3413. pd.CurrMdtrtID = his.Number
  3414. var fed models.FsiEncounterDtos
  3415. fed.MdtrtID = his.Number
  3416. fed.MedinsID = miConfig.Code
  3417. fed.MedinsName = miConfig.OrgName
  3418. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  3419. fed.MedMdtrtType = "1"
  3420. fed.MedinsType = "1"
  3421. fed.MedinsLv = "11"
  3422. tm := time.Unix(his.RecordDate, 0)
  3423. s_tm := tm.Format("2006-01-02 15:04:05")
  3424. fed.AdmDate = s_tm
  3425. fed.DscgDate = s_tm
  3426. fed.DscgMainDiseCodg = config[0].CountryCode
  3427. fed.DscgMainDiseName = config[0].CountryContentName
  3428. //诊断信息
  3429. var fdds []*models.FsiDiagnoseDtos
  3430. for index, item := range config {
  3431. if index == 0 {
  3432. var fdd models.FsiDiagnoseDtos
  3433. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3434. fdd.InoutDiseType = "1"
  3435. fdd.MaindiseFlag = "1"
  3436. fdd.DiseDate = s_tm
  3437. fdd.DiasSrtNo = "1"
  3438. fdd.DiseName = item.CountryContentName
  3439. fdd.DiseCodg = item.CountryCode
  3440. fdds = append(fdds, &fdd)
  3441. } else {
  3442. var fdd models.FsiDiagnoseDtos
  3443. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3444. fdd.InoutDiseType = "1"
  3445. fdd.MaindiseFlag = "1"
  3446. fdd.DiseDate = s_tm
  3447. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  3448. fdd.DiseName = item.CountryContentName
  3449. fdd.DiseCodg = item.CountryCode
  3450. fdds = append(fdds, &fdd)
  3451. }
  3452. }
  3453. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  3454. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  3455. fed.AdmDeptName = department.Name
  3456. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  3457. fed.DscgDeptName = department.Name
  3458. fed.MedMdtrtType = "1"
  3459. fed.MedType = "11"
  3460. //if his.Insutype == "390" {
  3461. // fed.MedType = "1402"
  3462. //} else {
  3463. // fed.MedType = "9933"
  3464. //}
  3465. var orders []*models.FsiOrderDtos
  3466. if trig_scen == "2" {
  3467. //处方医嘱信息
  3468. for _, item := range prescriptions {
  3469. for _, subItem := range item.HisDoctorAdviceInfo {
  3470. var order models.FsiOrderDtos
  3471. order.RxID = strconv.FormatInt(item.ID, 10)
  3472. order.Rxno = strconv.FormatInt(item.ID, 10)
  3473. order.LongDrordFlag = "0"
  3474. order.HilistType = "1"
  3475. order.ChrgType = "1"
  3476. order.DrordBhvr = "-"
  3477. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3478. order.HosplistName = subItem.BaseDrugLib.DrugName
  3479. order.HilistLv = "1"
  3480. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3481. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3482. order.HosplistName = subItem.BaseDrugLib.DrugName
  3483. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  3484. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3485. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  3486. order.OwnpayAmt = ""
  3487. order.SelfpayAmt = ""
  3488. order.Spec = ""
  3489. order.SpecUnt = ""
  3490. order.DrordBegnDate = s_tm
  3491. order.DrordStopDate = ""
  3492. order.DrordDrCodg = "1"
  3493. order.DrordDeptName = department.Name
  3494. order.DrordDrCodg = "1"
  3495. order.DrordDrName = doctor_info.UserName
  3496. order.DrordDrProfttl = ""
  3497. order.CurrDrordFlag = "1"
  3498. orders = append(orders, &order)
  3499. }
  3500. for _, subItem := range item.HisPrescriptionProject {
  3501. if subItem.Type == 2 {
  3502. var order models.FsiOrderDtos
  3503. order.RxID = strconv.FormatInt(item.ID, 10)
  3504. order.Rxno = strconv.FormatInt(item.ID, 10)
  3505. order.LongDrordFlag = "0"
  3506. order.HilistType = "1"
  3507. order.ChrgType = "1"
  3508. order.DrordBhvr = "-"
  3509. order.HilistCode = subItem.HisProject.MedicalCode
  3510. order.HosplistName = subItem.HisProject.ProjectName
  3511. order.HilistLv = "1"
  3512. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3513. order.HosplistCode = subItem.HisProject.MedicalCode
  3514. order.HosplistName = subItem.HisProject.ProjectName
  3515. order.Cnt = subItem.Count
  3516. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3517. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3518. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3519. order.OwnpayAmt = ""
  3520. order.SelfpayAmt = ""
  3521. order.Spec = ""
  3522. order.SpecUnt = ""
  3523. order.DrordBegnDate = s_tm
  3524. order.DrordStopDate = ""
  3525. order.DrordDrCodg = "1"
  3526. order.DrordDeptName = department.Name
  3527. order.DrordDrCodg = "1"
  3528. order.DrordDrName = doctor_info.UserName
  3529. order.DrordDrProfttl = ""
  3530. order.CurrDrordFlag = "1"
  3531. orders = append(orders, &order)
  3532. }
  3533. if subItem.Type == 3 {
  3534. var order models.FsiOrderDtos
  3535. order.RxID = strconv.FormatInt(item.ID, 10)
  3536. order.Rxno = strconv.FormatInt(item.ID, 10)
  3537. order.LongDrordFlag = "0"
  3538. order.HilistType = "1"
  3539. order.ChrgType = "1"
  3540. order.DrordBhvr = "-"
  3541. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3542. order.HosplistName = subItem.GoodInfo.GoodName
  3543. order.HilistLv = "1"
  3544. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3545. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3546. order.HosplistName = subItem.GoodInfo.GoodName
  3547. order.Cnt = subItem.Count
  3548. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3549. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3550. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3551. order.OwnpayAmt = ""
  3552. order.SelfpayAmt = ""
  3553. order.Spec = ""
  3554. order.SpecUnt = ""
  3555. order.DrordBegnDate = s_tm
  3556. order.DrordStopDate = ""
  3557. order.DrordDrCodg = "1"
  3558. order.DrordDeptName = department.Name
  3559. order.DrordDrCodg = "1"
  3560. order.DrordDrName = doctor_info.UserName
  3561. order.DrordDrProfttl = ""
  3562. order.CurrDrordFlag = "1"
  3563. orders = append(orders, &order)
  3564. }
  3565. }
  3566. }
  3567. //处方医嘱信息
  3568. }
  3569. fed.MatnStas = "0"
  3570. fed.MedfeeSumamt = "0"
  3571. fed.OwnpayAmt = "0"
  3572. fed.SelfpayAmt = "0"
  3573. fed.AcctPayamt = "0"
  3574. fed.MaAmt = "0"
  3575. fed.HifpPayamt = "0"
  3576. fed.SetlTotlnum = "1"
  3577. fed.Insutype = his.Insutype
  3578. fed.ReimFlag = "0"
  3579. fed.OutSetlFlag = "0"
  3580. var fopd []*models.FsiOperationDtosData
  3581. data := make(map[string]interface{})
  3582. data["fed"] = fed
  3583. data["fdd"] = fdds
  3584. data["fod"] = orders
  3585. data["pd"] = pd
  3586. data["pp"] = pp
  3587. data["fopd"] = fopd
  3588. data["trig_scen"] = trig_scen
  3589. fmt.Println(data)
  3590. fmt.Println(fed)
  3591. fmt.Println(fdds)
  3592. fmt.Println(orders)
  3593. fmt.Println(pd)
  3594. fmt.Println(pp)
  3595. fmt.Println(fopd)
  3596. client := &http.Client{}
  3597. bytesData, _ := json.Marshal(data)
  3598. var req *http.Request
  3599. if miConfig.MdtrtareaAdmvs == "320921" {
  3600. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  3601. } else {
  3602. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  3603. }
  3604. resp, _ := client.Do(req)
  3605. defer resp.Body.Close()
  3606. body, ioErr := ioutil.ReadAll(resp.Body)
  3607. if ioErr != nil {
  3608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3610. return res
  3611. }
  3612. var respJSON map[string]interface{}
  3613. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3616. return res
  3617. }
  3618. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3619. result, _ := json.Marshal(respJSON)
  3620. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3621. utils.ErrorLog("解析失败:%v", err)
  3622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3623. return res
  3624. }
  3625. return res
  3626. }
  3627. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  3628. ////patient_id, _ := c.GetInt64("patient_id")
  3629. //order_id, _ := c.GetInt64("order_id")
  3630. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  3631. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  3632. //trig_scen := c.GetString("trig_scen")
  3633. adminUser := c.GetAdminUserInfo()
  3634. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3635. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3636. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3637. record_time := c.GetString("record_time")
  3638. order, _ := service.GetHisOrderByID(order_id)
  3639. timeLayout := "2006-01-02"
  3640. loc, _ := time.LoadLocation("Local")
  3641. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3642. if err != nil {
  3643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3644. return
  3645. }
  3646. recordDateTime := theTime.Unix()
  3647. var patientPrescription models.HisPrescriptionInfo
  3648. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3649. if patientPrescription.ID == 0 {
  3650. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3651. }
  3652. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3653. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3654. //
  3655. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3656. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3657. var pp models.PublicParams
  3658. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3659. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3660. pp.FixmedinsName = miConfig.OrgName
  3661. pp.FixmedinsCode = miConfig.Code
  3662. pp.RequestUrl = miConfig.Url
  3663. pp.Cainfo = miConfig.Cainfo
  3664. pp.SecretKey = miConfig.SecretKey
  3665. pp.AccessKey = miConfig.AccessKey
  3666. pp.OpterName = roles.UserName
  3667. var config []*models.HisXtDiagnoseConfig
  3668. for _, item := range diagnosis_ids {
  3669. id, _ := strconv.ParseInt(item, 10, 64)
  3670. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3671. config = append(config, &diagnosisConfig)
  3672. }
  3673. var pd models.PatientDtos
  3674. pd.PatnID = his.PsnNo
  3675. pd.PatnName = his.Name
  3676. pd.Gend = his.Gend
  3677. pd.Brdy = his.Brdy
  3678. pd.Poolarea = his.InsuplcAdmdvs
  3679. pd.CurrMdtrtID = his.Number
  3680. var fed models.FsiEncounterDtos
  3681. fed.MdtrtID = his.Number
  3682. fed.MedinsID = miConfig.Code
  3683. fed.MedinsName = miConfig.OrgName
  3684. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  3685. fed.MedMdtrtType = "1"
  3686. fed.MedinsType = "1"
  3687. fed.MedinsLv = "11"
  3688. tm := time.Unix(his.RecordDate, 0)
  3689. s_tm := tm.Format("2006-01-02 15:04:05")
  3690. fed.AdmDate = s_tm
  3691. fed.DscgDate = s_tm
  3692. fed.DscgMainDiseCodg = config[0].CountryCode
  3693. fed.DscgMainDiseName = config[0].CountryContentName
  3694. //诊断信息
  3695. var fdds []*models.FsiDiagnoseDtos
  3696. for index, item := range config {
  3697. if index == 0 {
  3698. var fdd models.FsiDiagnoseDtos
  3699. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3700. fdd.InoutDiseType = "1"
  3701. fdd.MaindiseFlag = "1"
  3702. fdd.DiseDate = s_tm
  3703. fdd.DiasSrtNo = "1"
  3704. fdd.DiseName = item.CountryContentName
  3705. fdd.DiseCodg = item.CountryCode
  3706. fdds = append(fdds, &fdd)
  3707. } else {
  3708. var fdd models.FsiDiagnoseDtos
  3709. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3710. fdd.InoutDiseType = "1"
  3711. fdd.MaindiseFlag = "1"
  3712. fdd.DiseDate = s_tm
  3713. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  3714. fdd.DiseName = item.CountryContentName
  3715. fdd.DiseCodg = item.CountryCode
  3716. fdds = append(fdds, &fdd)
  3717. }
  3718. }
  3719. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  3720. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  3721. fed.AdmDeptName = department.Name
  3722. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  3723. fed.DscgDeptName = department.Name
  3724. fed.MedType = order.MedType
  3725. //处方医嘱信息
  3726. var orders []*models.FsiOrderDtos
  3727. //for _, item := range prescriptions {
  3728. // for _, subItem := range item.HisDoctorAdviceInfo {
  3729. // var order models.FsiOrderDtos
  3730. // order.RxID = strconv.FormatInt(item.ID, 10)
  3731. // order.Rxno = strconv.FormatInt(item.ID, 10)
  3732. // order.LongDrordFlag = "0"
  3733. // order.HilistType = "1"
  3734. // order.ChrgType = "1"
  3735. // order.DrordBhvr = "-"
  3736. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3737. // order.HosplistName = subItem.BaseDrugLib.DrugName
  3738. // order.HilistLv = "1"
  3739. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  3740. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3741. // order.HosplistName = subItem.BaseDrugLib.DrugName
  3742. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  3743. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  3744. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  3745. // order.OwnpayAmt = ""
  3746. // order.SelfpayAmt = ""
  3747. // order.Spec = ""
  3748. // order.SpecUnt = ""
  3749. // order.DrordBegnDate = s_tm
  3750. // order.DrordStopDate = ""
  3751. // order.DrordDrCodg = "1"
  3752. // order.DrordDeptName = department.Name
  3753. // order.DrordDrCodg = "1"
  3754. // order.DrordDrName = doctor_info.UserName
  3755. // order.DrordDrProfttl = ""
  3756. // order.CurrDrordFlag = "1"
  3757. // orders = append(orders, &order)
  3758. // }
  3759. // for _, subItem := range item.HisPrescriptionProject {
  3760. // if subItem.Type == 2 {
  3761. // var order models.FsiOrderDtos
  3762. // order.RxID = strconv.FormatInt(item.ID, 10)
  3763. // order.Rxno = strconv.FormatInt(item.ID, 10)
  3764. // order.LongDrordFlag = "0"
  3765. // order.HilistType = "1"
  3766. // order.ChrgType = "1"
  3767. // order.DrordBhvr = "-"
  3768. // order.HilistCode = subItem.HisProject.MedicalCode
  3769. // order.HosplistName = subItem.HisProject.ProjectName
  3770. // order.HilistLv = "1"
  3771. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  3772. // order.HosplistCode = subItem.HisProject.MedicalCode
  3773. // order.HosplistName = subItem.HisProject.ProjectName
  3774. // order.Cnt = subItem.Count
  3775. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3776. //
  3777. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  3778. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  3779. // order.OwnpayAmt = ""
  3780. // order.SelfpayAmt = ""
  3781. // order.Spec = ""
  3782. // order.SpecUnt = ""
  3783. // order.DrordBegnDate = s_tm
  3784. // order.DrordStopDate = ""
  3785. // order.DrordDrCodg = "1"
  3786. // order.DrordDeptName = department.Name
  3787. // order.DrordDrCodg = "1"
  3788. // order.DrordDrName = doctor_info.UserName
  3789. // order.DrordDrProfttl = ""
  3790. // order.CurrDrordFlag = "1"
  3791. // orders = append(orders, &order)
  3792. //
  3793. // }
  3794. // if subItem.Type == 3 {
  3795. //
  3796. // var order models.FsiOrderDtos
  3797. // order.RxID = strconv.FormatInt(item.ID, 10)
  3798. // order.Rxno = strconv.FormatInt(item.ID, 10)
  3799. // order.LongDrordFlag = "0"
  3800. // order.HilistType = "1"
  3801. // order.ChrgType = "1"
  3802. // order.DrordBhvr = "-"
  3803. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3804. // order.HosplistName = subItem.GoodInfo.GoodName
  3805. // order.HilistLv = "1"
  3806. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  3807. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3808. // order.HosplistName = subItem.GoodInfo.GoodName
  3809. // order.Cnt = subItem.Count
  3810. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3811. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  3812. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  3813. // order.OwnpayAmt = ""
  3814. // order.SelfpayAmt = ""
  3815. // order.Spec = ""
  3816. // order.SpecUnt = ""
  3817. // order.DrordBegnDate = s_tm
  3818. // order.DrordStopDate = ""
  3819. // order.DrordDrCodg = "1"
  3820. // order.DrordDeptName = department.Name
  3821. // order.DrordDrCodg = "1"
  3822. // order.DrordDrName = doctor_info.UserName
  3823. // order.DrordDrProfttl = ""
  3824. // order.CurrDrordFlag = "1"
  3825. // orders = append(orders, &order)
  3826. //
  3827. // }
  3828. // }
  3829. //}
  3830. for _, item := range prescriptions {
  3831. for _, subItem := range item.HisDoctorAdviceInfo {
  3832. var order models.FsiOrderDtos
  3833. order.RxID = strconv.FormatInt(item.ID, 10)
  3834. order.Rxno = strconv.FormatInt(item.ID, 10)
  3835. order.LongDrordFlag = "0"
  3836. order.HilistType = "1"
  3837. order.ChrgType = "1"
  3838. order.DrordBhvr = "-"
  3839. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3840. order.HosplistName = subItem.BaseDrugLib.DrugName
  3841. order.HilistLv = "1"
  3842. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3843. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3844. order.HosplistName = subItem.BaseDrugLib.DrugName
  3845. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  3846. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3847. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  3848. order.OwnpayAmt = ""
  3849. order.SelfpayAmt = ""
  3850. order.Spec = ""
  3851. order.SpecUnt = ""
  3852. order.DrordBegnDate = s_tm
  3853. order.DrordStopDate = ""
  3854. order.DrordDrCodg = "1"
  3855. order.DrordDeptName = department.Name
  3856. order.DrordDrCodg = "1"
  3857. order.DrordDrName = doctor_info.UserName
  3858. order.DrordDrProfttl = ""
  3859. order.CurrDrordFlag = "1"
  3860. orders = append(orders, &order)
  3861. }
  3862. for _, subItem := range item.HisPrescriptionProject {
  3863. if subItem.Type == 2 {
  3864. var order models.FsiOrderDtos
  3865. order.RxID = strconv.FormatInt(item.ID, 10)
  3866. order.Rxno = strconv.FormatInt(item.ID, 10)
  3867. order.LongDrordFlag = "0"
  3868. order.HilistType = "1"
  3869. order.ChrgType = "1"
  3870. order.DrordBhvr = "-"
  3871. order.HilistCode = subItem.HisProject.MedicalCode
  3872. order.HosplistName = subItem.HisProject.ProjectName
  3873. order.HilistLv = "1"
  3874. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3875. order.HosplistCode = subItem.HisProject.MedicalCode
  3876. order.HosplistName = subItem.HisProject.ProjectName
  3877. order.Cnt = subItem.Count
  3878. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3879. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3880. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3881. order.OwnpayAmt = ""
  3882. order.SelfpayAmt = ""
  3883. order.Spec = ""
  3884. order.SpecUnt = ""
  3885. order.DrordBegnDate = s_tm
  3886. order.DrordStopDate = ""
  3887. order.DrordDrCodg = "1"
  3888. order.DrordDeptName = department.Name
  3889. order.DrordDrCodg = "1"
  3890. order.DrordDrName = doctor_info.UserName
  3891. order.DrordDrProfttl = ""
  3892. order.CurrDrordFlag = "1"
  3893. orders = append(orders, &order)
  3894. }
  3895. if subItem.Type == 3 {
  3896. var order models.FsiOrderDtos
  3897. order.RxID = strconv.FormatInt(item.ID, 10)
  3898. order.Rxno = strconv.FormatInt(item.ID, 10)
  3899. order.LongDrordFlag = "0"
  3900. order.HilistType = "1"
  3901. order.ChrgType = "1"
  3902. order.DrordBhvr = "-"
  3903. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3904. order.HosplistName = subItem.GoodInfo.GoodName
  3905. order.HilistLv = "1"
  3906. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3907. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3908. order.HosplistName = subItem.GoodInfo.GoodName
  3909. order.Cnt = subItem.Count
  3910. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3911. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3912. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3913. order.OwnpayAmt = ""
  3914. order.SelfpayAmt = ""
  3915. order.Spec = ""
  3916. order.SpecUnt = ""
  3917. order.DrordBegnDate = s_tm
  3918. order.DrordStopDate = ""
  3919. order.DrordDrCodg = "1"
  3920. order.DrordDeptName = department.Name
  3921. order.DrordDrCodg = "1"
  3922. order.DrordDrName = doctor_info.UserName
  3923. order.DrordDrProfttl = ""
  3924. order.CurrDrordFlag = "1"
  3925. orders = append(orders, &order)
  3926. }
  3927. }
  3928. }
  3929. //处方医嘱信息
  3930. fed.MatnStas = "0"
  3931. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3932. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  3933. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  3934. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  3935. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  3936. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  3937. fed.SetlTotlnum = "1"
  3938. fed.Insutype = his.Insutype
  3939. fed.ReimFlag = "0"
  3940. fed.OutSetlFlag = "0"
  3941. var fopd []*models.FsiOperationDtosData
  3942. data := make(map[string]interface{})
  3943. data["fed"] = fed
  3944. data["fdd"] = fdds
  3945. data["fod"] = orders
  3946. data["pd"] = pd
  3947. data["pp"] = pp
  3948. data["fopd"] = fopd
  3949. data["trig_scen"] = trig_scen
  3950. client := &http.Client{}
  3951. bytesData, _ := json.Marshal(data)
  3952. var req *http.Request
  3953. if miConfig.MdtrtareaAdmvs == "320921" {
  3954. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  3955. } else {
  3956. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  3957. }
  3958. resp, _ := client.Do(req)
  3959. defer resp.Body.Close()
  3960. body, ioErr := ioutil.ReadAll(resp.Body)
  3961. if ioErr != nil {
  3962. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3964. return res
  3965. }
  3966. var respJSON map[string]interface{}
  3967. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3970. return res
  3971. }
  3972. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3973. result, _ := json.Marshal(respJSON)
  3974. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3975. utils.ErrorLog("解析失败:%v", err)
  3976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3977. return res
  3978. }
  3979. return res
  3980. //手术操作集合
  3981. //手术操作集合
  3982. }
  3983. func (c *HisApiController) Check() {
  3984. psn_no := c.GetString("psn_no")
  3985. in := c.GetString("in")
  3986. mt := c.GetString("mt")
  3987. baseParams := models.BaseParams{
  3988. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  3989. FixmedinsCode: "H15049901371",
  3990. InsuplcAdmdvs: "150499",
  3991. MdtrtareaAdmvs: "150499",
  3992. OrgName: "赤峰费森血液透析中心",
  3993. Doctor: "1111",
  3994. }
  3995. service.Gdyb2001(baseParams, psn_no, in, mt)
  3996. }
  3997. func (c *HisApiController) GetPsnNcdsInfo() {
  3998. admin_user_id, _ := c.GetInt64("admin_user_id")
  3999. patient_id, _ := c.GetInt64("patient_id")
  4000. id, _ := c.GetInt64("id")
  4001. adminUser := c.GetAdminUserInfo()
  4002. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4003. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4004. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  4005. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4006. psn_record, _ := service.GetPsnNCDSRecordById(id)
  4007. //
  4008. //if psn_record.ID == 0 {
  4009. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  4010. // return
  4011. //}
  4012. var res Result5301
  4013. var res10265 Result5301For10265
  4014. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4015. psn_info, _ := service.GetPsnByPatientId(patient_id)
  4016. var api string
  4017. if miConfig.MdtrtareaAdmvs == "320921" {
  4018. 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 +
  4019. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  4020. } else {
  4021. 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 +
  4022. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  4023. }
  4024. resp, requestErr := http.Get(api)
  4025. if requestErr != nil {
  4026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4027. return
  4028. }
  4029. body, ioErr := ioutil.ReadAll(resp.Body)
  4030. if ioErr != nil {
  4031. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4033. return
  4034. }
  4035. var respJSON map[string]interface{}
  4036. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4039. return
  4040. }
  4041. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4042. result, _ := json.Marshal(respJSON)
  4043. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4044. utils.ErrorLog("解析失败:%v", err)
  4045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4046. return
  4047. }
  4048. res.ErrMsg = res10265.ErrMsg
  4049. res.Output = res10265.Output
  4050. res.InfRefmsgid = res10265.InfRefmsgid
  4051. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4052. res.Infcode = infocode
  4053. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4054. p, _ := service.GetHisPatientById(patient_id)
  4055. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  4056. var dat map[string]interface{}
  4057. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4058. fmt.Println(dat)
  4059. } else {
  4060. fmt.Println(err)
  4061. }
  4062. userJSONBytes, _ := json.Marshal(dat)
  4063. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4064. utils.ErrorLog("解析失败:%v", err)
  4065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4066. return
  4067. }
  4068. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4069. p, _ := service.GetHisPatientById(patient_id)
  4070. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  4071. var dat map[string]interface{}
  4072. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4073. fmt.Println(dat)
  4074. } else {
  4075. fmt.Println(err)
  4076. }
  4077. userJSONBytes, _ := json.Marshal(dat)
  4078. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4079. utils.ErrorLog("解析失败:%v", err)
  4080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4081. return
  4082. }
  4083. } else {
  4084. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4085. var dat map[string]interface{}
  4086. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4087. fmt.Println(dat)
  4088. } else {
  4089. fmt.Println(err)
  4090. }
  4091. userJSONBytes, _ := json.Marshal(dat)
  4092. if miConfig.Code == "H15049901371" {
  4093. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  4094. utils.ErrorLog("解析失败:%v", err)
  4095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4096. return
  4097. }
  4098. res.InfRefmsgid = res10265.InfRefmsgid
  4099. res.Output = res10265.Output
  4100. res.ErrMsg = res10265.ErrMsg
  4101. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4102. res.Infcode = infocode
  4103. } else {
  4104. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4105. utils.ErrorLog("解析失败:%v", err)
  4106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4107. return
  4108. }
  4109. }
  4110. }
  4111. if res.Infcode == 0 {
  4112. c.ServeSuccessJSON(map[string]interface{}{
  4113. "result": res.Output.Result,
  4114. })
  4115. }
  4116. }
  4117. func (c *HisApiController) CheckInsutype() {
  4118. his_patient_id, _ := c.GetInt64("his_patient_id")
  4119. admin_user_id, _ := c.GetInt64("admin_user_id")
  4120. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4121. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4122. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4123. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4124. var dat map[string]interface{}
  4125. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4126. fmt.Println(dat)
  4127. } else {
  4128. fmt.Println(err)
  4129. }
  4130. userJSONBytes, _ := json.Marshal(dat)
  4131. var res Result90100
  4132. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4133. utils.ErrorLog("解析失败:%v", err)
  4134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4135. return
  4136. }
  4137. if res.Infcode != 0 {
  4138. c.ServeSuccessJSON(map[string]interface{}{
  4139. "failed_code": -10,
  4140. "msg": res.ErrMsg,
  4141. })
  4142. return
  4143. } else {
  4144. fmt.Println(res)
  4145. }
  4146. }
  4147. func (c *HisApiController) CheckCardPWD() {
  4148. card_pwd := c.GetString("card_pwd")
  4149. his_patient_id, _ := c.GetInt64("his_patient_id")
  4150. admin_user_id, _ := c.GetInt64("admin_user_id")
  4151. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4152. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4153. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4154. psn, _ := service.GetPsnByPatientId(his.PatientId)
  4155. bas := strings.Split(psn.CardInfo, "|")
  4156. basNumber := bas[2]
  4157. if psn.InsuplcAdmdvs[:4] == "4403" {
  4158. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  4159. var dat map[string]interface{}
  4160. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4161. fmt.Println(dat)
  4162. } else {
  4163. fmt.Println(err)
  4164. }
  4165. userJSONBytes, _ := json.Marshal(dat)
  4166. var res Result90991
  4167. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4168. utils.ErrorLog("解析失败:%v", err)
  4169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4170. return
  4171. }
  4172. if res.Infcode != 0 {
  4173. c.ServeSuccessJSON(map[string]interface{}{
  4174. "failed_code": -10,
  4175. "msg": res.ErrMsg,
  4176. })
  4177. return
  4178. } else {
  4179. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  4180. var msg string
  4181. switch res.Output.Result.CardStat {
  4182. case "00":
  4183. msg = "未激活"
  4184. break
  4185. case "10":
  4186. msg = "激活"
  4187. break
  4188. case "20":
  4189. msg = "窗口挂失"
  4190. break
  4191. case "21":
  4192. msg = "电话挂失"
  4193. break
  4194. case "22":
  4195. msg = "单位网上申报挂失"
  4196. break
  4197. case "23":
  4198. msg = "保健办挂失"
  4199. break
  4200. case "24":
  4201. msg = "个人网上挂失"
  4202. break
  4203. case "25":
  4204. msg = "网上服务大厅挂失"
  4205. break
  4206. case "30":
  4207. msg = "注销"
  4208. break
  4209. case "40":
  4210. msg = "回收"
  4211. break
  4212. case "99":
  4213. msg = "制卡中(无效卡)"
  4214. break
  4215. }
  4216. c.ServeSuccessJSON(map[string]interface{}{
  4217. "failed_code": -10,
  4218. "msg": msg,
  4219. })
  4220. return
  4221. } else {
  4222. c.ServeSuccessJSON(map[string]interface{}{
  4223. "msg": "校验成功",
  4224. })
  4225. return
  4226. }
  4227. }
  4228. } else {
  4229. c.ServeSuccessJSON(map[string]interface{}{
  4230. "msg": "校验成功",
  4231. })
  4232. return
  4233. }
  4234. }
  4235. func (c *HisApiController) CheckCardPWDTwo() {
  4236. //card_pwd := c.GetString("card_pwd")
  4237. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4238. admin_user_id, _ := c.GetInt64("admin_user_id")
  4239. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4240. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4241. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  4242. var dat map[string]interface{}
  4243. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4244. fmt.Println(dat)
  4245. } else {
  4246. fmt.Println(err)
  4247. }
  4248. userJSONBytes, _ := json.Marshal(dat)
  4249. var res Result90991
  4250. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4251. utils.ErrorLog("解析失败:%v", err)
  4252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4253. return
  4254. }
  4255. if res.Infcode != 0 {
  4256. c.ServeSuccessJSON(map[string]interface{}{
  4257. "failed_code": -10,
  4258. "msg": res.ErrMsg,
  4259. })
  4260. return
  4261. } else {
  4262. if res.Output.Result.SscnoCheckStat == "0" {
  4263. var msg string
  4264. switch res.Output.Result.CardStat {
  4265. case "00":
  4266. msg = "未激活"
  4267. break
  4268. case "10":
  4269. msg = "激活"
  4270. break
  4271. case "20":
  4272. msg = "窗口挂失"
  4273. break
  4274. case "21":
  4275. msg = "电话挂失"
  4276. break
  4277. case "22":
  4278. msg = "单位网上申报挂失"
  4279. break
  4280. case "23":
  4281. msg = "保健办挂失"
  4282. break
  4283. case "24":
  4284. msg = "个人网上挂失"
  4285. break
  4286. case "25":
  4287. msg = "网上服务大厅挂失"
  4288. break
  4289. case "30":
  4290. msg = "注销"
  4291. break
  4292. case "40":
  4293. msg = "回收"
  4294. break
  4295. case "99":
  4296. msg = "制卡中(无效卡)"
  4297. break
  4298. }
  4299. c.ServeSuccessJSON(map[string]interface{}{
  4300. "failed_code": -10,
  4301. "msg": msg,
  4302. })
  4303. return
  4304. } else {
  4305. c.ServeSuccessJSON(map[string]interface{}{
  4306. "msg": "校验成功",
  4307. })
  4308. return
  4309. }
  4310. }
  4311. }
  4312. type ELeCertData struct {
  4313. Data struct {
  4314. Extra string `json:"extra"`
  4315. IDNo string `json:"idNo"`
  4316. IDType string `json:"idType"`
  4317. EcToken string `json:"ecToken"`
  4318. InsuOrg string `json:"insuOrg"`
  4319. UserName string `json:"userName"`
  4320. EcIndexNo string `json:"ecIndexNo"`
  4321. Gender string `json:"gender"`
  4322. Birthday string `json:"birthday"`
  4323. Nationality string `json:"nationality"`
  4324. Email string `json:"email"`
  4325. } `json:"OutData"`
  4326. }
  4327. func (c *HisApiController) ReadCard() {
  4328. id_card_type, _ := c.GetInt64("id_card_type")
  4329. admin_user_id, _ := c.GetInt64("admin_user_id")
  4330. certificates, _ := c.GetInt64("certificates")
  4331. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  4332. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4333. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4334. switch id_card_type {
  4335. case 1:
  4336. if miConfig.MdtrtareaAdmvs == "421300" {
  4337. var res ResultTwo
  4338. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  4339. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4340. "&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)
  4341. resp, requestErr := http.Get(api)
  4342. if requestErr != nil {
  4343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4344. return
  4345. }
  4346. body, ioErr := ioutil.ReadAll(resp.Body)
  4347. if ioErr != nil {
  4348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4350. return
  4351. }
  4352. var respJSON map[string]interface{}
  4353. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4356. return
  4357. }
  4358. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4359. result, _ := json.Marshal(respJSON)
  4360. fmt.Println("log")
  4361. fmt.Println(string(result))
  4362. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4363. utils.ErrorLog("解析失败:%v", err)
  4364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4365. return
  4366. }
  4367. if res.Infcode == 0 {
  4368. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4369. if err == gorm.ErrRecordNotFound {
  4370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4371. return
  4372. } else if err != nil {
  4373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4374. return
  4375. } else {
  4376. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4377. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4378. infoStr := string(Iinfos)
  4379. idetinfoStr := string(Idetinfos)
  4380. psn := &models.HisPsn{
  4381. PsnNo: res.Output.Baseinfo.PsnNo,
  4382. Age: res.Output.Baseinfo.Age,
  4383. PatientId: patient.ID,
  4384. Certno: res.Output.Baseinfo.Certno,
  4385. Brdy: res.Output.Baseinfo.Brdy,
  4386. Gend: res.Output.Baseinfo.Gend,
  4387. Naty: res.Output.Baseinfo.Naty,
  4388. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4389. PsnName: res.Output.Baseinfo.PsnName,
  4390. Idetinfo: idetinfoStr,
  4391. Insuinfo: infoStr,
  4392. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4393. }
  4394. service.CreateHisPsn(psn)
  4395. c.ServeSuccessJSON(map[string]interface{}{
  4396. "patient": patient,
  4397. "number": res.Output.Baseinfo.Certno,
  4398. })
  4399. }
  4400. } else {
  4401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4402. return
  4403. }
  4404. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4405. var api string
  4406. if miConfig.MdtrtareaAdmvs == "320921" {
  4407. 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 +
  4408. "&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
  4409. fmt.Println(api)
  4410. } else {
  4411. 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 +
  4412. "&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)
  4413. }
  4414. resp, requestErr := http.Get(api)
  4415. if requestErr != nil {
  4416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4417. return
  4418. }
  4419. body, ioErr := ioutil.ReadAll(resp.Body)
  4420. if ioErr != nil {
  4421. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4423. return
  4424. }
  4425. var respJSON map[string]interface{}
  4426. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4429. return
  4430. }
  4431. var status string
  4432. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4433. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4434. //console.log()
  4435. fmt.Println("type===")
  4436. fmt.Println(card_type)
  4437. var token string
  4438. var res ResultTwo //1101结果
  4439. var res10265 ResultTwo10265 //1101结果
  4440. var card_info string //卡信息
  4441. var busi_card_info string
  4442. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4443. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4444. if status == "0" { //读卡成功
  4445. if card_type == "1" {
  4446. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4447. result, _ := json.Marshal(respJSON)
  4448. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4449. utils.ErrorLog("解析失败:%v", err)
  4450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4451. return
  4452. }
  4453. res.ErrMsg = res10265.ErrMsg
  4454. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4455. res.Infcode = infocode
  4456. res.Output = res10265.Output
  4457. res.InfRefmsgid = res10265.InfRefmsgid
  4458. } else {
  4459. //var card_info string //卡信息
  4460. //var busi_card_info string
  4461. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4462. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4463. //fmt.Println(card_info)
  4464. //fmt.Println(busi_card_info)
  4465. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4466. result, _ := json.Marshal(respJSON)
  4467. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4468. utils.ErrorLog("解析失败:%v", err)
  4469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4470. return
  4471. }
  4472. res.ErrMsg = res10265.ErrMsg
  4473. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4474. res.Infcode = infocode
  4475. res.Output = res10265.Output
  4476. res.InfRefmsgid = res10265.InfRefmsgid
  4477. }
  4478. if res.Infcode == 0 {
  4479. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4480. if err == gorm.ErrRecordNotFound {
  4481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4482. return
  4483. } else if err != nil {
  4484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4485. return
  4486. } else {
  4487. if card_type == "1" {
  4488. bas := strings.Split(card_info, "|")
  4489. basNumber := bas[2]
  4490. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4491. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4492. infoStr := string(Iinfos)
  4493. idetinfoStr := string(Idetinfos)
  4494. psn := &models.HisPsn{
  4495. PsnNo: res.Output.Baseinfo.PsnNo,
  4496. Age: res.Output.Baseinfo.Age,
  4497. PatientId: patient.ID,
  4498. Certno: res.Output.Baseinfo.Certno,
  4499. Brdy: res.Output.Baseinfo.Brdy,
  4500. Gend: res.Output.Baseinfo.Gend,
  4501. Naty: res.Output.Baseinfo.Naty,
  4502. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4503. PsnName: res.Output.Baseinfo.PsnName,
  4504. Idetinfo: idetinfoStr,
  4505. Insuinfo: infoStr,
  4506. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4507. CardInfo: card_info,
  4508. VerifyNumber: busi_card_info,
  4509. }
  4510. service.CreateHisPsn(psn)
  4511. var rf []*ResultFive
  4512. json.Unmarshal([]byte(infoStr), &rf)
  4513. var insutypes []*ResultFive
  4514. var insutype string
  4515. var is390 int = 0
  4516. var is310 int = 0
  4517. for _, item := range rf {
  4518. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4519. insutypes = append(insutypes, item)
  4520. }
  4521. }
  4522. if len(insutypes) == 1 {
  4523. insutype = insutypes[0].Insutype
  4524. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4525. } else {
  4526. for _, i := range insutypes {
  4527. if i.Insutype == "390" {
  4528. is390 = 1
  4529. }
  4530. if i.Insutype == "310" {
  4531. is310 = 1
  4532. }
  4533. }
  4534. }
  4535. if is390 == 1 {
  4536. insutype = "390"
  4537. }
  4538. if is310 == 1 {
  4539. insutype = "310"
  4540. }
  4541. if len(insutypes) == 0 {
  4542. insutype = "310"
  4543. }
  4544. c.ServeSuccessJSON(map[string]interface{}{
  4545. "patient": patient,
  4546. "number": basNumber,
  4547. "insutype": insutype,
  4548. })
  4549. } else {
  4550. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4551. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4552. infoStr := string(Iinfos)
  4553. idetinfoStr := string(Idetinfos)
  4554. psn := &models.HisPsn{
  4555. PsnNo: res.Output.Baseinfo.PsnNo,
  4556. Age: res.Output.Baseinfo.Age,
  4557. PatientId: patient.ID,
  4558. Certno: res.Output.Baseinfo.Certno,
  4559. Brdy: res.Output.Baseinfo.Brdy,
  4560. Gend: res.Output.Baseinfo.Gend,
  4561. Naty: res.Output.Baseinfo.Naty,
  4562. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4563. PsnName: res.Output.Baseinfo.PsnName,
  4564. Idetinfo: idetinfoStr,
  4565. Insuinfo: infoStr,
  4566. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4567. CardInfo: card_info,
  4568. VerifyNumber: token,
  4569. }
  4570. service.CreateHisPsn(psn)
  4571. c.ServeSuccessJSON(map[string]interface{}{
  4572. "patient": patient,
  4573. "number": token,
  4574. })
  4575. }
  4576. }
  4577. } else {
  4578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4579. return
  4580. }
  4581. } else { //读卡失败
  4582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4583. return
  4584. }
  4585. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4586. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  4587. cardnum = DeleteExtraSpaceTwo(cardnum)
  4588. cardCode = DeleteExtraSpaceTwo(cardCode)
  4589. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  4590. name = DeleteExtraSpaceTwo(name)
  4591. errmsg = DeleteExtraSpaceTwo(errmsg)
  4592. cardnum = Remove0000(cardnum)
  4593. cardCode = Remove0000(cardCode)
  4594. id_card_no = Remove0000(id_card_no)
  4595. name = Remove0000(name)
  4596. errmsg = Remove0000(errmsg)
  4597. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  4598. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  4599. //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)
  4600. //fmt.Println(result2)
  4601. //fmt.Println(requestLog2)
  4602. //fmt.Println(errMsgLog2)
  4603. 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)
  4604. saveLog(result, requestLog, "1101", "获取人员信息")
  4605. fmt.Println(errMsgLog)
  4606. if len(errMsgLog) > 0 {
  4607. } else {
  4608. var dat map[string]interface{}
  4609. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4610. fmt.Println(dat)
  4611. } else {
  4612. fmt.Println(err)
  4613. }
  4614. userJSONBytes, _ := json.Marshal(dat)
  4615. var res ResultTwo
  4616. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4617. utils.ErrorLog("解析失败:%v", err)
  4618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4619. return
  4620. }
  4621. res.ErrMsg = errMsgLog
  4622. if res.Infcode == 0 {
  4623. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  4624. if err == gorm.ErrRecordNotFound {
  4625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4626. return
  4627. } else if err != nil {
  4628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4629. return
  4630. } else {
  4631. fmt.Println(res)
  4632. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4633. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4634. infoStr := string(Iinfos)
  4635. idetinfoStr := string(Idetinfos)
  4636. var rf []*ResultFive
  4637. json.Unmarshal([]byte(infoStr), &rf)
  4638. var insutypes []*ResultFive
  4639. var insutype string
  4640. var is390 int = 0
  4641. var is310 int = 0
  4642. for _, item := range rf {
  4643. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4644. insutypes = append(insutypes, item)
  4645. }
  4646. }
  4647. if len(insutypes) == 1 {
  4648. insutype = insutypes[0].Insutype
  4649. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4650. } else {
  4651. for _, i := range insutypes {
  4652. if i.Insutype == "390" {
  4653. is390 = 1
  4654. }
  4655. if i.Insutype == "310" {
  4656. is310 = 1
  4657. }
  4658. }
  4659. }
  4660. if is390 == 1 {
  4661. insutype = "390"
  4662. }
  4663. if is310 == 1 {
  4664. insutype = "310"
  4665. }
  4666. if len(insutypes) == 0 {
  4667. insutype = "390"
  4668. }
  4669. var insuplc_admdvs string
  4670. for _, item := range rf {
  4671. if item.Insutype == insutype {
  4672. insuplc_admdvs = item.InsuplcAdmdvs
  4673. }
  4674. }
  4675. psn := &models.HisPsn{
  4676. PsnNo: res.Output.Baseinfo.PsnNo,
  4677. Age: res.Output.Baseinfo.Age,
  4678. PatientId: patient.ID,
  4679. Certno: res.Output.Baseinfo.Certno,
  4680. Brdy: res.Output.Baseinfo.Brdy,
  4681. Gend: res.Output.Baseinfo.Gend,
  4682. Naty: res.Output.Baseinfo.Naty,
  4683. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4684. PsnName: res.Output.Baseinfo.PsnName,
  4685. Idetinfo: idetinfoStr,
  4686. Insuinfo: infoStr,
  4687. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4688. CardInfo: basStr,
  4689. VerifyNumber: "",
  4690. InsuplcAdmdvs: insuplc_admdvs,
  4691. }
  4692. service.CreateHisPsn(psn)
  4693. c.ServeSuccessJSON(map[string]interface{}{
  4694. "patient": patient,
  4695. "number": cardnum,
  4696. "insutype": insutype,
  4697. })
  4698. }
  4699. } else {
  4700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4701. return
  4702. }
  4703. }
  4704. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4705. fmt.Println(initFlag)
  4706. fmt.Println("initFlag")
  4707. if initFlag == 0 {
  4708. c.TestGetJiangXiBasBaseInit()
  4709. }
  4710. basStr := c.GetBasBaseInfo()
  4711. if len(basStr) == 0 {
  4712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4713. return
  4714. }
  4715. fmt.Println(basStr)
  4716. bas := strings.Split(basStr, "|")
  4717. basNumber := bas[1]
  4718. fmt.Println(basNumber)
  4719. card_sn := bas[3]
  4720. fmt.Println(card_sn)
  4721. 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, "")
  4722. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  4723. var dat map[string]interface{}
  4724. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4725. fmt.Println(dat)
  4726. } else {
  4727. fmt.Println(err)
  4728. }
  4729. userJSONBytes, _ := json.Marshal(dat)
  4730. var res ResultTwo
  4731. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4732. utils.ErrorLog("解析失败:%v", err)
  4733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4734. return
  4735. }
  4736. if res.Infcode == 0 {
  4737. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  4738. if err == gorm.ErrRecordNotFound {
  4739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4740. return
  4741. } else if err != nil {
  4742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4743. return
  4744. } else {
  4745. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4746. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4747. infoStr := string(Iinfos)
  4748. idetinfoStr := string(Idetinfos)
  4749. psn := &models.HisPsn{
  4750. PsnNo: res.Output.Baseinfo.PsnNo,
  4751. Age: res.Output.Baseinfo.Age,
  4752. PatientId: patient.ID,
  4753. Certno: res.Output.Baseinfo.Certno,
  4754. Brdy: res.Output.Baseinfo.Brdy,
  4755. Gend: res.Output.Baseinfo.Gend,
  4756. Naty: res.Output.Baseinfo.Naty,
  4757. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4758. PsnName: res.Output.Baseinfo.PsnName,
  4759. Idetinfo: idetinfoStr,
  4760. Insuinfo: infoStr,
  4761. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4762. CardInfo: basStr,
  4763. VerifyNumber: "",
  4764. }
  4765. service.CreateHisPsn(psn)
  4766. var rf []*ResultFive
  4767. json.Unmarshal([]byte(infoStr), &rf)
  4768. var insutypes []*ResultFive
  4769. var insutype string
  4770. var is390 int = 0
  4771. var is310 int = 0
  4772. for _, item := range rf {
  4773. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4774. insutypes = append(insutypes, item)
  4775. }
  4776. }
  4777. if len(insutypes) == 1 {
  4778. insutype = insutypes[0].Insutype
  4779. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4780. } else {
  4781. for _, i := range insutypes {
  4782. if i.Insutype == "390" {
  4783. is390 = 1
  4784. }
  4785. if i.Insutype == "310" {
  4786. is310 = 1
  4787. }
  4788. }
  4789. }
  4790. if is390 == 1 {
  4791. insutype = "390"
  4792. }
  4793. if is310 == 1 {
  4794. insutype = "310"
  4795. }
  4796. if len(insutypes) == 0 {
  4797. insutype = "310"
  4798. }
  4799. c.ServeSuccessJSON(map[string]interface{}{
  4800. "patient": patient,
  4801. "number": basNumber,
  4802. "insutype": insutype,
  4803. })
  4804. }
  4805. } else {
  4806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4807. return
  4808. }
  4809. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4810. fmt.Println(initFlag)
  4811. fmt.Println("initFlag")
  4812. if initFlag == 0 {
  4813. c.TestGetHnBasBaseInit()
  4814. }
  4815. basStr := c.GetBasBaseInfo()
  4816. if len(basStr) == 0 {
  4817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4818. return
  4819. }
  4820. fmt.Println(basStr)
  4821. bas := strings.Split(basStr, "|")
  4822. basNumber := bas[1]
  4823. fmt.Println(basNumber)
  4824. card_sn := bas[3]
  4825. card_no := bas[2]
  4826. fmt.Println(card_sn)
  4827. name := bas[4]
  4828. name = ConvertToString(name, "gbk", "utf-8")
  4829. 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)
  4830. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  4831. var dat map[string]interface{}
  4832. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4833. fmt.Println(dat)
  4834. } else {
  4835. fmt.Println(err)
  4836. }
  4837. userJSONBytes, _ := json.Marshal(dat)
  4838. var res ResultTwo
  4839. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4840. utils.ErrorLog("解析失败:%v", err)
  4841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4842. return
  4843. }
  4844. if res.Infcode == 0 {
  4845. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  4846. if err == gorm.ErrRecordNotFound {
  4847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4848. return
  4849. } else if err != nil {
  4850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4851. return
  4852. } else {
  4853. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4854. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4855. infoStr := string(Iinfos)
  4856. idetinfoStr := string(Idetinfos)
  4857. psn := &models.HisPsn{
  4858. PsnNo: res.Output.Baseinfo.PsnNo,
  4859. Age: res.Output.Baseinfo.Age,
  4860. PatientId: patient.ID,
  4861. Certno: res.Output.Baseinfo.Certno,
  4862. Brdy: res.Output.Baseinfo.Brdy,
  4863. Gend: res.Output.Baseinfo.Gend,
  4864. Naty: res.Output.Baseinfo.Naty,
  4865. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4866. PsnName: res.Output.Baseinfo.PsnName,
  4867. Idetinfo: idetinfoStr,
  4868. Insuinfo: infoStr,
  4869. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4870. CardInfo: basStr,
  4871. VerifyNumber: "",
  4872. }
  4873. service.CreateHisPsn(psn)
  4874. var rf []*ResultFive
  4875. json.Unmarshal([]byte(infoStr), &rf)
  4876. var insutypes []*ResultFive
  4877. var insutype string
  4878. var is390 int = 0
  4879. var is310 int = 0
  4880. for _, item := range rf {
  4881. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4882. insutypes = append(insutypes, item)
  4883. }
  4884. }
  4885. if len(insutypes) == 1 {
  4886. insutype = insutypes[0].Insutype
  4887. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4888. } else {
  4889. for _, i := range insutypes {
  4890. if i.Insutype == "390" {
  4891. is390 = 1
  4892. }
  4893. if i.Insutype == "310" {
  4894. is310 = 1
  4895. }
  4896. }
  4897. }
  4898. if is390 == 1 {
  4899. insutype = "390"
  4900. }
  4901. if is310 == 1 {
  4902. insutype = "310"
  4903. }
  4904. if len(insutypes) == 0 {
  4905. insutype = "310"
  4906. }
  4907. c.ServeSuccessJSON(map[string]interface{}{
  4908. "patient": patient,
  4909. "number": basNumber,
  4910. "insutype": insutype,
  4911. })
  4912. }
  4913. } else {
  4914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4915. return
  4916. }
  4917. } else {
  4918. if initFlag == 0 {
  4919. c.TestGetBasBaseInit()
  4920. }
  4921. basStr := c.GetBasBaseInfo()
  4922. if len(basStr) == 0 {
  4923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4924. return
  4925. }
  4926. fmt.Println(basStr)
  4927. bas := strings.Split(basStr, "|")
  4928. basNumber := bas[1]
  4929. fmt.Println(basNumber)
  4930. card_sn := bas[3]
  4931. fmt.Println(card_sn)
  4932. cardNumber := bas[2]
  4933. fmt.Println(cardNumber)
  4934. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  4935. var result string
  4936. if bas[0][:2] == "44" {
  4937. 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)
  4938. } else {
  4939. 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)
  4940. }
  4941. var dat map[string]interface{}
  4942. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4943. fmt.Println(dat)
  4944. } else {
  4945. fmt.Println(err)
  4946. }
  4947. userJSONBytes, _ := json.Marshal(dat)
  4948. var res ResultTwo
  4949. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4950. utils.ErrorLog("解析失败:%v", err)
  4951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4952. return
  4953. }
  4954. if res.Infcode == 0 {
  4955. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  4956. if err == gorm.ErrRecordNotFound {
  4957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4958. return
  4959. } else if err != nil {
  4960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4961. return
  4962. } else {
  4963. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4964. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4965. infoStr := string(Iinfos)
  4966. idetinfoStr := string(Idetinfos)
  4967. var rf []*ResultFive
  4968. json.Unmarshal([]byte(infoStr), &rf)
  4969. var insutypes []*ResultFive
  4970. var insutype string
  4971. var is390 int = 0
  4972. var is310 int = 0
  4973. var insuplc_admdvs string
  4974. for _, item := range rf {
  4975. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4976. insutypes = append(insutypes, item)
  4977. }
  4978. }
  4979. if len(insutypes) == 1 {
  4980. insutype = insutypes[0].Insutype
  4981. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4982. } else {
  4983. for _, i := range insutypes {
  4984. if i.Insutype == "390" {
  4985. is390 = 1
  4986. }
  4987. if i.Insutype == "310" {
  4988. is310 = 1
  4989. }
  4990. }
  4991. }
  4992. if is390 == 1 {
  4993. insutype = "390"
  4994. }
  4995. if is310 == 1 {
  4996. insutype = "310"
  4997. }
  4998. if len(insutypes) == 0 {
  4999. insutype = "310"
  5000. }
  5001. for _, item := range rf {
  5002. if item.Insutype == insutype {
  5003. insuplc_admdvs = item.InsuplcAdmdvs
  5004. }
  5005. }
  5006. psn := &models.HisPsn{
  5007. PsnNo: res.Output.Baseinfo.PsnNo,
  5008. Age: res.Output.Baseinfo.Age,
  5009. PatientId: patient.ID,
  5010. Certno: res.Output.Baseinfo.Certno,
  5011. Brdy: res.Output.Baseinfo.Brdy,
  5012. Gend: res.Output.Baseinfo.Gend,
  5013. Naty: res.Output.Baseinfo.Naty,
  5014. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5015. PsnName: res.Output.Baseinfo.PsnName,
  5016. Idetinfo: idetinfoStr,
  5017. Insuinfo: infoStr,
  5018. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5019. CardInfo: basStr,
  5020. VerifyNumber: "",
  5021. InsuplcAdmdvs: insuplc_admdvs,
  5022. }
  5023. service.CreateHisPsn(psn)
  5024. c.ServeSuccessJSON(map[string]interface{}{
  5025. "patient": patient,
  5026. "number": basNumber,
  5027. })
  5028. }
  5029. } else {
  5030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5031. return
  5032. }
  5033. break
  5034. }
  5035. case 2:
  5036. if miConfig.MdtrtareaAdmvs == "430800" {
  5037. if initFlag == 0 {
  5038. c.TestGetHnBasBaseInit()
  5039. }
  5040. SFZStr := c.GetSFZBaseInfo()
  5041. if len(SFZStr) == 0 {
  5042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5043. return
  5044. }
  5045. fmt.Println(SFZStr)
  5046. id_card_str := strings.Split(SFZStr, "^")
  5047. card_no := id_card_str[0]
  5048. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  5049. //name := id_card_str[1]
  5050. //name = ConvertToString(name, "gbk", "utf-8")
  5051. 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)
  5052. var dat map[string]interface{}
  5053. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5054. fmt.Println(dat)
  5055. } else {
  5056. fmt.Println(err)
  5057. }
  5058. userJSONBytes, _ := json.Marshal(dat)
  5059. var res ResultTwo
  5060. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5061. utils.ErrorLog("解析失败:%v", err)
  5062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5063. return
  5064. }
  5065. if res.Infcode == 0 {
  5066. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  5067. if err == gorm.ErrRecordNotFound {
  5068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5069. return
  5070. } else if err != nil {
  5071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5072. return
  5073. } else {
  5074. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5075. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5076. infoStr := string(Iinfos)
  5077. idetinfoStr := string(Idetinfos)
  5078. psn := &models.HisPsn{
  5079. PsnNo: res.Output.Baseinfo.PsnNo,
  5080. Age: res.Output.Baseinfo.Age,
  5081. PatientId: patient.ID,
  5082. Certno: res.Output.Baseinfo.Certno,
  5083. Brdy: res.Output.Baseinfo.Brdy,
  5084. Gend: res.Output.Baseinfo.Gend,
  5085. Naty: res.Output.Baseinfo.Naty,
  5086. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5087. PsnName: res.Output.Baseinfo.PsnName,
  5088. Idetinfo: idetinfoStr,
  5089. Insuinfo: infoStr,
  5090. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5091. CardInfo: SFZStr,
  5092. VerifyNumber: "",
  5093. }
  5094. service.CreateHisPsn(psn)
  5095. var rf []*ResultFive
  5096. json.Unmarshal([]byte(infoStr), &rf)
  5097. var insutypes []*ResultFive
  5098. var insutype string
  5099. var is390 int = 0
  5100. var is310 int = 0
  5101. for _, item := range rf {
  5102. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5103. insutypes = append(insutypes, item)
  5104. }
  5105. }
  5106. if len(insutypes) == 1 {
  5107. insutype = insutypes[0].Insutype
  5108. } else {
  5109. for _, i := range insutypes {
  5110. if i.Insutype == "390" {
  5111. is390 = 1
  5112. }
  5113. if i.Insutype == "310" {
  5114. is310 = 1
  5115. }
  5116. }
  5117. }
  5118. if is390 == 1 {
  5119. insutype = "390"
  5120. }
  5121. if is310 == 1 {
  5122. insutype = "310"
  5123. }
  5124. if len(insutypes) == 0 {
  5125. insutype = "310"
  5126. }
  5127. c.ServeSuccessJSON(map[string]interface{}{
  5128. "patient": patient,
  5129. "number": card_no,
  5130. "insutype": insutype,
  5131. })
  5132. }
  5133. } else {
  5134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5135. return
  5136. }
  5137. } else {
  5138. SFZStr := c.GetSFZBaseInfo()
  5139. id_card_str := strings.Split(SFZStr, "^")
  5140. id_card_number := id_card_str[0]
  5141. card_sn := ""
  5142. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "")
  5143. var dat map[string]interface{}
  5144. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5145. fmt.Println(dat)
  5146. } else {
  5147. fmt.Println(err)
  5148. }
  5149. userJSONBytes, _ := json.Marshal(dat)
  5150. var res ResultTwo
  5151. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5152. utils.ErrorLog("解析失败:%v", err)
  5153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5154. return
  5155. }
  5156. if res.Infcode == 0 {
  5157. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  5158. if err == gorm.ErrRecordNotFound {
  5159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5160. return
  5161. } else if err != nil {
  5162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5163. return
  5164. } else {
  5165. c.ServeSuccessJSON(map[string]interface{}{
  5166. "patient": patient,
  5167. "number": id_card_number,
  5168. })
  5169. }
  5170. } else {
  5171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5172. return
  5173. }
  5174. }
  5175. break
  5176. case 3:
  5177. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5178. var api string
  5179. if miConfig.MdtrtareaAdmvs == "320921" {
  5180. 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 +
  5181. "&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
  5182. fmt.Println(api)
  5183. } else {
  5184. 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 +
  5185. "&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)
  5186. }
  5187. resp, requestErr := http.Get(api)
  5188. if requestErr != nil {
  5189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5190. return
  5191. }
  5192. body, ioErr := ioutil.ReadAll(resp.Body)
  5193. if ioErr != nil {
  5194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5196. return
  5197. }
  5198. var respJSON map[string]interface{}
  5199. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5202. return
  5203. }
  5204. var status string
  5205. status = respJSON["data"].(map[string]interface{})["status"].(string)
  5206. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  5207. var token string
  5208. var res ResultTwo //1101结果
  5209. var res10265 ResultTwo10265 //1101结果
  5210. var card_info string //卡信息
  5211. var busi_card_info string
  5212. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  5213. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5214. if status == "0" { //读卡成功
  5215. if card_type == "1" {
  5216. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5217. result, _ := json.Marshal(respJSON)
  5218. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5219. utils.ErrorLog("解析失败:%v", err)
  5220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5221. return
  5222. }
  5223. res.ErrMsg = res10265.ErrMsg
  5224. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5225. res.Infcode = infocode
  5226. res.Output = res10265.Output
  5227. res.InfRefmsgid = res10265.InfRefmsgid
  5228. } else {
  5229. //var card_info string //卡信息
  5230. //var busi_card_info string
  5231. token = respJSON["data"].(map[string]interface{})["token"].(string)
  5232. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5233. //fmt.Println(card_info)
  5234. //fmt.Println(busi_card_info)
  5235. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5236. result, _ := json.Marshal(respJSON)
  5237. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5238. utils.ErrorLog("解析失败:%v", err)
  5239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5240. return
  5241. }
  5242. res.ErrMsg = res10265.ErrMsg
  5243. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5244. res.Infcode = infocode
  5245. res.Output = res10265.Output
  5246. res.InfRefmsgid = res10265.InfRefmsgid
  5247. }
  5248. if res.Infcode == 0 {
  5249. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5250. if err == gorm.ErrRecordNotFound {
  5251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5252. return
  5253. } else if err != nil {
  5254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5255. return
  5256. } else {
  5257. if card_type == "1" {
  5258. bas := strings.Split(card_info, "|")
  5259. basNumber := bas[2]
  5260. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5261. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5262. infoStr := string(Iinfos)
  5263. idetinfoStr := string(Idetinfos)
  5264. psn := &models.HisPsn{
  5265. PsnNo: res.Output.Baseinfo.PsnNo,
  5266. Age: res.Output.Baseinfo.Age,
  5267. PatientId: patient.ID,
  5268. Certno: res.Output.Baseinfo.Certno,
  5269. Brdy: res.Output.Baseinfo.Brdy,
  5270. Gend: res.Output.Baseinfo.Gend,
  5271. Naty: res.Output.Baseinfo.Naty,
  5272. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5273. PsnName: res.Output.Baseinfo.PsnName,
  5274. Idetinfo: idetinfoStr,
  5275. Insuinfo: infoStr,
  5276. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5277. CardInfo: card_info,
  5278. VerifyNumber: busi_card_info,
  5279. }
  5280. service.CreateHisPsn(psn)
  5281. c.ServeSuccessJSON(map[string]interface{}{
  5282. "patient": patient,
  5283. "number": basNumber,
  5284. })
  5285. } else {
  5286. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5287. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5288. infoStr := string(Iinfos)
  5289. idetinfoStr := string(Idetinfos)
  5290. psn := &models.HisPsn{
  5291. PsnNo: res.Output.Baseinfo.PsnNo,
  5292. Age: res.Output.Baseinfo.Age,
  5293. PatientId: patient.ID,
  5294. Certno: res.Output.Baseinfo.Certno,
  5295. Brdy: res.Output.Baseinfo.Brdy,
  5296. Gend: res.Output.Baseinfo.Gend,
  5297. Naty: res.Output.Baseinfo.Naty,
  5298. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5299. PsnName: res.Output.Baseinfo.PsnName,
  5300. Idetinfo: idetinfoStr,
  5301. Insuinfo: infoStr,
  5302. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5303. CardInfo: card_info,
  5304. VerifyNumber: token,
  5305. }
  5306. service.CreateHisPsn(psn)
  5307. var rf []*ResultFive
  5308. json.Unmarshal([]byte(infoStr), &rf)
  5309. var insutypes []*ResultFive
  5310. var insutype string
  5311. var is390 int = 0
  5312. var is310 int = 0
  5313. for _, item := range rf {
  5314. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5315. insutypes = append(insutypes, item)
  5316. }
  5317. }
  5318. if len(insutypes) == 1 {
  5319. insutype = insutypes[0].Insutype
  5320. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5321. } else {
  5322. for _, i := range insutypes {
  5323. if i.Insutype == "390" {
  5324. is390 = 1
  5325. }
  5326. if i.Insutype == "310" {
  5327. is310 = 1
  5328. }
  5329. }
  5330. }
  5331. if is390 == 1 {
  5332. insutype = "390"
  5333. }
  5334. if is310 == 1 {
  5335. insutype = "310"
  5336. }
  5337. if len(insutypes) == 0 {
  5338. insutype = "310"
  5339. }
  5340. c.ServeSuccessJSON(map[string]interface{}{
  5341. "patient": patient,
  5342. "number": token,
  5343. "insutype": insutype,
  5344. })
  5345. }
  5346. }
  5347. } else {
  5348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5349. return
  5350. }
  5351. } else { //读卡失败
  5352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5353. return
  5354. }
  5355. }
  5356. break
  5357. case 4:
  5358. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5359. var api string
  5360. if miConfig.MdtrtareaAdmvs == "320921" {
  5361. 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 +
  5362. "&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
  5363. fmt.Println(api)
  5364. } else {
  5365. 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 +
  5366. "&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)
  5367. }
  5368. resp, requestErr := http.Get(api)
  5369. if requestErr != nil {
  5370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5371. return
  5372. }
  5373. body, ioErr := ioutil.ReadAll(resp.Body)
  5374. if ioErr != nil {
  5375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5377. return
  5378. }
  5379. var respJSON map[string]interface{}
  5380. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5383. return
  5384. }
  5385. var status string
  5386. status = respJSON["data"].(map[string]interface{})["status"].(string)
  5387. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  5388. var token string
  5389. var res ResultTwo //1101结果
  5390. var res10265 ResultTwo10265 //1101结果
  5391. if status == "0" { //读卡成功
  5392. var card_info string //卡信息
  5393. var busi_card_info string
  5394. token = respJSON["data"].(map[string]interface{})["token"].(string)
  5395. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5396. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  5397. fmt.Println(card_info)
  5398. fmt.Println(busi_card_info)
  5399. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5400. result, _ := json.Marshal(respJSON)
  5401. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5402. utils.ErrorLog("解析失败:%v", err)
  5403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5404. return
  5405. }
  5406. res.ErrMsg = res10265.ErrMsg
  5407. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5408. res.Infcode = infocode
  5409. res.Output = res10265.Output
  5410. res.InfRefmsgid = res10265.InfRefmsgid
  5411. if res.Infcode == 0 {
  5412. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5413. if err == gorm.ErrRecordNotFound {
  5414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5415. return
  5416. } else if err != nil {
  5417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5418. return
  5419. } else {
  5420. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5421. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5422. infoStr := string(Iinfos)
  5423. idetinfoStr := string(Idetinfos)
  5424. psn := &models.HisPsn{
  5425. PsnNo: res.Output.Baseinfo.PsnNo,
  5426. Age: res.Output.Baseinfo.Age,
  5427. PatientId: patient.ID,
  5428. Certno: res.Output.Baseinfo.Certno,
  5429. Brdy: res.Output.Baseinfo.Brdy,
  5430. Gend: res.Output.Baseinfo.Gend,
  5431. Naty: res.Output.Baseinfo.Naty,
  5432. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5433. PsnName: res.Output.Baseinfo.PsnName,
  5434. Idetinfo: idetinfoStr,
  5435. Insuinfo: infoStr,
  5436. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5437. CardInfo: card_info,
  5438. VerifyNumber: token,
  5439. }
  5440. var rf []*ResultFive
  5441. json.Unmarshal([]byte(infoStr), &rf)
  5442. var insutypes []*ResultFive
  5443. var insutype string
  5444. var is390 int = 0
  5445. var is310 int = 0
  5446. for _, item := range rf {
  5447. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5448. insutypes = append(insutypes, item)
  5449. }
  5450. }
  5451. if len(insutypes) == 1 {
  5452. insutype = insutypes[0].Insutype
  5453. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5454. } else {
  5455. for _, i := range insutypes {
  5456. if i.Insutype == "390" {
  5457. is390 = 1
  5458. }
  5459. if i.Insutype == "310" {
  5460. is310 = 1
  5461. }
  5462. }
  5463. }
  5464. if is390 == 1 {
  5465. insutype = "390"
  5466. }
  5467. if is310 == 1 {
  5468. insutype = "310"
  5469. }
  5470. if len(insutypes) == 0 {
  5471. insutype = "310"
  5472. }
  5473. service.CreateHisPsn(psn)
  5474. c.ServeSuccessJSON(map[string]interface{}{
  5475. "patient": patient,
  5476. "number": token,
  5477. "insutype": insutype,
  5478. })
  5479. }
  5480. } else {
  5481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5482. return
  5483. }
  5484. } else { //读卡失败
  5485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5486. return
  5487. }
  5488. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5489. idNo := c.GetString("idNo")
  5490. userName := c.GetString("userName")
  5491. ecToken := c.GetString("ecToken")
  5492. insuOrg := c.GetString("insuOrg")
  5493. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  5494. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5495. var res ResultTwo
  5496. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5497. utils.ErrorLog("解析失败:%v", err)
  5498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5499. return
  5500. }
  5501. if res.Infcode == 0 {
  5502. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5503. if err == gorm.ErrRecordNotFound {
  5504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5505. return
  5506. } else if err != nil {
  5507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5508. return
  5509. } else {
  5510. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5511. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5512. infoStr := string(Iinfos)
  5513. idetinfoStr := string(Idetinfos)
  5514. psn := &models.HisPsn{
  5515. PsnNo: res.Output.Baseinfo.PsnNo,
  5516. Age: res.Output.Baseinfo.Age,
  5517. PatientId: patient.ID,
  5518. Certno: res.Output.Baseinfo.Certno,
  5519. Brdy: res.Output.Baseinfo.Brdy,
  5520. Gend: res.Output.Baseinfo.Gend,
  5521. Naty: res.Output.Baseinfo.Naty,
  5522. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5523. PsnName: res.Output.Baseinfo.PsnName,
  5524. Idetinfo: idetinfoStr,
  5525. Insuinfo: infoStr,
  5526. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5527. CardInfo: "",
  5528. Stage: "1",
  5529. VerifyNumber: ecToken,
  5530. InsuplcAdmdvs: insuOrg,
  5531. }
  5532. service.CreateHisPsn(psn)
  5533. var rf []*ResultFive
  5534. json.Unmarshal([]byte(infoStr), &rf)
  5535. var insutypes []*ResultFive
  5536. var insutype string
  5537. var is390 int = 0
  5538. var is310 int = 0
  5539. for _, item := range rf {
  5540. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5541. insutypes = append(insutypes, item)
  5542. }
  5543. }
  5544. if len(insutypes) == 1 {
  5545. insutype = insutypes[0].Insutype
  5546. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5547. } else {
  5548. for _, i := range insutypes {
  5549. if i.Insutype == "390" {
  5550. is390 = 1
  5551. }
  5552. if i.Insutype == "310" {
  5553. is310 = 1
  5554. }
  5555. }
  5556. }
  5557. if is390 == 1 {
  5558. insutype = "390"
  5559. }
  5560. if is310 == 1 {
  5561. insutype = "310"
  5562. }
  5563. if len(insutypes) == 0 {
  5564. insutype = "310"
  5565. }
  5566. c.ServeSuccessJSON(map[string]interface{}{
  5567. "patient": patient,
  5568. "number": ecToken,
  5569. "insutype": insutype,
  5570. })
  5571. }
  5572. } else {
  5573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5574. return
  5575. }
  5576. } else if miConfig.MdtrtareaAdmvs == "360399" {
  5577. //if initFlag == 0 {
  5578. c.TestGetJiangXiBasBaseInit()
  5579. //}
  5580. //if initEleFlag == 0 {
  5581. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  5582. //}
  5583. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  5584. type ELeData struct {
  5585. Data struct {
  5586. IdNo string `json:"idNo"`
  5587. IdType string `json:"idType"`
  5588. UserName string `json:"userName"`
  5589. EcToken string `json:"ecToken"`
  5590. InsuOrg string `json:"insuOrg"`
  5591. Gender string `json:"gender"`
  5592. Birthday string `json:"birthday"`
  5593. Nationality string `json:"nationality"`
  5594. Email string `json:"email"`
  5595. Extra string `json:"extra"`
  5596. } `json:"data"`
  5597. Code int `json:"code"`
  5598. Message string `json:"message"`
  5599. }
  5600. var ele ELeData
  5601. err := json.Unmarshal([]byte(json_result), &ele)
  5602. if err != nil {
  5603. utils.ErrorLog("解析失败:%v", err)
  5604. }
  5605. token := ele.Data.EcToken
  5606. token = Remove0000(token)
  5607. 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)
  5608. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5609. var res ResultTwo
  5610. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5611. utils.ErrorLog("解析失败:%v", err)
  5612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5613. return
  5614. }
  5615. if res.Infcode == 0 {
  5616. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5617. if err == gorm.ErrRecordNotFound {
  5618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5619. return
  5620. } else if err != nil {
  5621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5622. return
  5623. } else {
  5624. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5625. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5626. infoStr := string(Iinfos)
  5627. idetinfoStr := string(Idetinfos)
  5628. psn := &models.HisPsn{
  5629. PsnNo: res.Output.Baseinfo.PsnNo,
  5630. Age: res.Output.Baseinfo.Age,
  5631. PatientId: patient.ID,
  5632. Certno: res.Output.Baseinfo.Certno,
  5633. Brdy: res.Output.Baseinfo.Brdy,
  5634. Gend: res.Output.Baseinfo.Gend,
  5635. Naty: res.Output.Baseinfo.Naty,
  5636. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5637. PsnName: res.Output.Baseinfo.PsnName,
  5638. Idetinfo: idetinfoStr,
  5639. Insuinfo: infoStr,
  5640. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5641. CardInfo: "",
  5642. //RecordDate:
  5643. VerifyNumber: token,
  5644. }
  5645. service.CreateHisPsn(psn)
  5646. var rf []*ResultFive
  5647. json.Unmarshal([]byte(infoStr), &rf)
  5648. var insutypes []*ResultFive
  5649. var insutype string
  5650. var is390 int = 0
  5651. var is310 int = 0
  5652. for _, item := range rf {
  5653. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5654. insutypes = append(insutypes, item)
  5655. }
  5656. }
  5657. if len(insutypes) == 1 {
  5658. insutype = insutypes[0].Insutype
  5659. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5660. } else {
  5661. for _, i := range insutypes {
  5662. if i.Insutype == "390" {
  5663. is390 = 1
  5664. }
  5665. if i.Insutype == "310" {
  5666. is310 = 1
  5667. }
  5668. }
  5669. }
  5670. if is390 == 1 {
  5671. insutype = "390"
  5672. }
  5673. if is310 == 1 {
  5674. insutype = "310"
  5675. }
  5676. if len(insutypes) == 0 {
  5677. insutype = "310"
  5678. }
  5679. c.ServeSuccessJSON(map[string]interface{}{
  5680. "patient": patient,
  5681. "number": token,
  5682. "insutype": insutype,
  5683. })
  5684. }
  5685. } else {
  5686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5687. return
  5688. }
  5689. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5690. //if initFlag == 0 {
  5691. c.TestGetJiangXiBasBaseInit()
  5692. //}
  5693. //if initEleFlag == 0 {
  5694. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  5695. //}
  5696. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  5697. type ELeData struct {
  5698. Data struct {
  5699. IdNo string `json:"idNo"`
  5700. IdType string `json:"idType"`
  5701. UserName string `json:"userName"`
  5702. EcToken string `json:"ecToken"`
  5703. InsuOrg string `json:"insuOrg"`
  5704. Gender string `json:"gender"`
  5705. Birthday string `json:"birthday"`
  5706. Nationality string `json:"nationality"`
  5707. Email string `json:"email"`
  5708. Extra string `json:"extra"`
  5709. } `json:"data"`
  5710. Code int `json:"code"`
  5711. Message string `json:"message"`
  5712. }
  5713. var ele ELeData
  5714. err := json.Unmarshal([]byte(json_result), &ele)
  5715. if err != nil {
  5716. utils.ErrorLog("解析失败:%v", err)
  5717. }
  5718. token := ele.Data.EcToken
  5719. token = Remove0000(token)
  5720. 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)
  5721. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5722. var res ResultTwo
  5723. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5724. utils.ErrorLog("解析失败:%v", err)
  5725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5726. return
  5727. }
  5728. if res.Infcode == 0 {
  5729. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5730. if err == gorm.ErrRecordNotFound {
  5731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5732. return
  5733. } else if err != nil {
  5734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5735. return
  5736. } else {
  5737. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5738. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5739. infoStr := string(Iinfos)
  5740. idetinfoStr := string(Idetinfos)
  5741. psn := &models.HisPsn{
  5742. PsnNo: res.Output.Baseinfo.PsnNo,
  5743. Age: res.Output.Baseinfo.Age,
  5744. PatientId: patient.ID,
  5745. Certno: res.Output.Baseinfo.Certno,
  5746. Brdy: res.Output.Baseinfo.Brdy,
  5747. Gend: res.Output.Baseinfo.Gend,
  5748. Naty: res.Output.Baseinfo.Naty,
  5749. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5750. PsnName: res.Output.Baseinfo.PsnName,
  5751. Idetinfo: idetinfoStr,
  5752. Insuinfo: infoStr,
  5753. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5754. CardInfo: "",
  5755. VerifyNumber: token,
  5756. }
  5757. service.CreateHisPsn(psn)
  5758. var rf []*ResultFive
  5759. json.Unmarshal([]byte(infoStr), &rf)
  5760. var insutypes []*ResultFive
  5761. var insutype string
  5762. var is390 int = 0
  5763. var is310 int = 0
  5764. for _, item := range rf {
  5765. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5766. insutypes = append(insutypes, item)
  5767. }
  5768. }
  5769. if len(insutypes) == 1 {
  5770. insutype = insutypes[0].Insutype
  5771. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5772. } else {
  5773. for _, i := range insutypes {
  5774. if i.Insutype == "390" {
  5775. is390 = 1
  5776. }
  5777. if i.Insutype == "310" {
  5778. is310 = 1
  5779. }
  5780. }
  5781. }
  5782. if is390 == 1 {
  5783. insutype = "390"
  5784. }
  5785. if is310 == 1 {
  5786. insutype = "310"
  5787. }
  5788. if len(insutypes) == 0 {
  5789. insutype = "310"
  5790. }
  5791. c.ServeSuccessJSON(map[string]interface{}{
  5792. "patient": patient,
  5793. "number": token,
  5794. "insutype": insutype,
  5795. })
  5796. }
  5797. } else {
  5798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5799. return
  5800. }
  5801. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5802. type ELeData struct {
  5803. Code string `json:"code"`
  5804. Data struct {
  5805. Aac002 string `json:"aac002"`
  5806. Aaz500 string `json:"aaz500"`
  5807. ActCardNo string `json:"actCardNo"`
  5808. Bab520 string `json:"bab520"`
  5809. Bkz543 string `json:"bkz543"`
  5810. BusinessType string `json:"businessType"`
  5811. CertfCodg string `json:"certfCodg"`
  5812. EcIndexNo string `json:"ecIndexNo"`
  5813. EcToken string `json:"ecToken"`
  5814. ID0000 string `json:"id0000"`
  5815. IDNo string `json:"idNo"`
  5816. IDType string `json:"idType"`
  5817. Idcode string `json:"idcode"`
  5818. IdentityToken string `json:"identity_token"`
  5819. InsuOrg string `json:"insuOrg"`
  5820. OfficeID string `json:"officeId"`
  5821. OfficeName string `json:"officeName"`
  5822. OperatorID string `json:"operatorId"`
  5823. OperatorName string `json:"operatorName"`
  5824. OrgID string `json:"orgId"`
  5825. UserName string `json:"userName"`
  5826. } `json:"data"`
  5827. Infno interface{} `json:"infno"`
  5828. Message string `json:"message"`
  5829. OrgID string `json:"orgId"`
  5830. TransType string `json:"transType"`
  5831. }
  5832. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  5833. outPutInfo = Remove0000(outPutInfo)
  5834. if len(outPutInfo) > 0 {
  5835. var ele ELeData
  5836. err := json.Unmarshal([]byte(outPutInfo), &ele)
  5837. if err != nil {
  5838. utils.ErrorLog("解析失败:%v", err)
  5839. }
  5840. token := ele.Data.EcToken
  5841. fmt.Println(inputInfo)
  5842. fmt.Println(outPutInfo)
  5843. 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)
  5844. saveLog(result, requestLog, "1101", "获取人员信息")
  5845. var dat map[string]interface{}
  5846. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5847. fmt.Println(dat)
  5848. } else {
  5849. fmt.Println(err)
  5850. }
  5851. userJSONBytes, _ := json.Marshal(dat)
  5852. var res ResultTwo
  5853. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5854. utils.ErrorLog("解析失败:%v", err)
  5855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5856. return
  5857. }
  5858. res.ErrMsg = errMsgLog
  5859. if res.Infcode == 0 {
  5860. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  5861. if err == gorm.ErrRecordNotFound {
  5862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5863. return
  5864. } else if err != nil {
  5865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5866. return
  5867. } else {
  5868. fmt.Println(res)
  5869. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5870. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5871. infoStr := string(Iinfos)
  5872. idetinfoStr := string(Idetinfos)
  5873. psn := &models.HisPsn{
  5874. PsnNo: res.Output.Baseinfo.PsnNo,
  5875. Age: res.Output.Baseinfo.Age,
  5876. PatientId: patient.ID,
  5877. Certno: res.Output.Baseinfo.Certno,
  5878. Brdy: res.Output.Baseinfo.Brdy,
  5879. Gend: res.Output.Baseinfo.Gend,
  5880. Naty: res.Output.Baseinfo.Naty,
  5881. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5882. PsnName: res.Output.Baseinfo.PsnName,
  5883. Idetinfo: idetinfoStr,
  5884. Insuinfo: infoStr,
  5885. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5886. CardInfo: outPutInfo,
  5887. VerifyNumber: token,
  5888. InsuplcAdmdvs: ele.Data.InsuOrg,
  5889. }
  5890. service.CreateHisPsn(psn)
  5891. var rf []*ResultFive
  5892. json.Unmarshal([]byte(infoStr), &rf)
  5893. var insutypes []*ResultFive
  5894. var insutype string
  5895. var is390 int = 0
  5896. var is310 int = 0
  5897. for _, item := range rf {
  5898. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5899. insutypes = append(insutypes, item)
  5900. }
  5901. }
  5902. if len(insutypes) == 1 {
  5903. insutype = insutypes[0].Insutype
  5904. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5905. } else {
  5906. for _, i := range insutypes {
  5907. if i.Insutype == "390" {
  5908. is390 = 1
  5909. }
  5910. if i.Insutype == "310" {
  5911. is310 = 1
  5912. }
  5913. }
  5914. }
  5915. if is390 == 1 {
  5916. insutype = "390"
  5917. }
  5918. if is310 == 1 {
  5919. insutype = "310"
  5920. }
  5921. if len(insutypes) == 0 {
  5922. insutype = "310"
  5923. }
  5924. c.ServeSuccessJSON(map[string]interface{}{
  5925. "patient": patient,
  5926. "number": token,
  5927. "insutype": insutype,
  5928. })
  5929. }
  5930. } else {
  5931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5932. return
  5933. }
  5934. }
  5935. } else {
  5936. type ELeData struct {
  5937. Code string `json:"code"`
  5938. Data struct {
  5939. Aac002 string `json:"aac002"`
  5940. Aaz500 string `json:"aaz500"`
  5941. ActCardNo string `json:"actCardNo"`
  5942. Bab520 string `json:"bab520"`
  5943. Bkz543 string `json:"bkz543"`
  5944. BusinessType string `json:"businessType"`
  5945. CertfCodg string `json:"certfCodg"`
  5946. EcIndexNo string `json:"ecIndexNo"`
  5947. EcToken string `json:"ecToken"`
  5948. ID0000 string `json:"id0000"`
  5949. IDNo string `json:"idNo"`
  5950. IDType string `json:"idType"`
  5951. Idcode string `json:"idcode"`
  5952. IdentityToken string `json:"identity_token"`
  5953. InsuOrg string `json:"insuOrg"`
  5954. OfficeID string `json:"officeId"`
  5955. OfficeName string `json:"officeName"`
  5956. OperatorID string `json:"operatorId"`
  5957. OperatorName string `json:"operatorName"`
  5958. OrgID string `json:"orgId"`
  5959. UserName string `json:"userName"`
  5960. } `json:"data"`
  5961. Infno interface{} `json:"infno"`
  5962. Message string `json:"message"`
  5963. OrgID string `json:"orgId"`
  5964. TransType string `json:"transType"`
  5965. }
  5966. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName)
  5967. fmt.Println(result)
  5968. outPutInfo := Remove0000(result)
  5969. fmt.Println(outPutInfo)
  5970. if len(outPutInfo) > 0 {
  5971. var ele ELeData
  5972. err := json.Unmarshal([]byte(outPutInfo), &ele)
  5973. if err != nil {
  5974. utils.ErrorLog("解析失败:%v", err)
  5975. }
  5976. token := ele.Data.EcToken
  5977. fmt.Println(outPutInfo)
  5978. result, requestLog := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  5979. saveLog(result, requestLog, "1101", "获取人员信息")
  5980. var dat map[string]interface{}
  5981. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5982. fmt.Println(dat)
  5983. } else {
  5984. fmt.Println(err)
  5985. }
  5986. userJSONBytes, _ := json.Marshal(dat)
  5987. var res ResultTwo
  5988. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5989. utils.ErrorLog("解析失败:%v", err)
  5990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5991. return
  5992. }
  5993. if res.Infcode == 0 {
  5994. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  5995. if err == gorm.ErrRecordNotFound {
  5996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5997. return
  5998. } else if err != nil {
  5999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6000. return
  6001. } else {
  6002. fmt.Println(res)
  6003. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6004. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6005. infoStr := string(Iinfos)
  6006. idetinfoStr := string(Idetinfos)
  6007. psn := &models.HisPsn{
  6008. PsnNo: res.Output.Baseinfo.PsnNo,
  6009. Age: res.Output.Baseinfo.Age,
  6010. PatientId: patient.ID,
  6011. Certno: res.Output.Baseinfo.Certno,
  6012. Brdy: res.Output.Baseinfo.Brdy,
  6013. Gend: res.Output.Baseinfo.Gend,
  6014. Naty: res.Output.Baseinfo.Naty,
  6015. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6016. PsnName: res.Output.Baseinfo.PsnName,
  6017. Idetinfo: idetinfoStr,
  6018. Insuinfo: infoStr,
  6019. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6020. CardInfo: outPutInfo,
  6021. VerifyNumber: token,
  6022. InsuplcAdmdvs: ele.Data.InsuOrg,
  6023. }
  6024. service.CreateHisPsn(psn)
  6025. var rf []*ResultFive
  6026. json.Unmarshal([]byte(infoStr), &rf)
  6027. var insutypes []*ResultFive
  6028. var insutype string
  6029. var is390 int = 0
  6030. var is310 int = 0
  6031. for _, item := range rf {
  6032. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6033. insutypes = append(insutypes, item)
  6034. }
  6035. }
  6036. if len(insutypes) == 1 {
  6037. insutype = insutypes[0].Insutype
  6038. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6039. } else {
  6040. for _, i := range insutypes {
  6041. if i.Insutype == "390" {
  6042. is390 = 1
  6043. }
  6044. if i.Insutype == "310" {
  6045. is310 = 1
  6046. }
  6047. }
  6048. }
  6049. if is390 == 1 {
  6050. insutype = "390"
  6051. }
  6052. if is310 == 1 {
  6053. insutype = "310"
  6054. }
  6055. if len(insutypes) == 0 {
  6056. insutype = "310"
  6057. }
  6058. c.ServeSuccessJSON(map[string]interface{}{
  6059. "patient": patient,
  6060. "number": token,
  6061. "insutype": insutype,
  6062. })
  6063. }
  6064. } else {
  6065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6066. return
  6067. }
  6068. }
  6069. //fmt.Println(result)
  6070. //
  6071. //if initFlag == 0 {
  6072. // c.TestGetBasBaseInit()
  6073. //}
  6074. //token := c.GetEleBaseInfo()
  6075. //
  6076. //token = Remove0000(token)
  6077. //
  6078. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  6079. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  6080. ////
  6081. //var res ResultTwo
  6082. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  6083. // utils.ErrorLog("解析失败:%v", err)
  6084. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6085. // return
  6086. //}
  6087. //
  6088. //if res.Infcode == 0 {
  6089. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6090. // if err == gorm.ErrRecordNotFound {
  6091. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6092. // return
  6093. // } else if err != nil {
  6094. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6095. // return
  6096. //
  6097. // } else {
  6098. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6099. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6100. // infoStr := string(Iinfos)
  6101. // idetinfoStr := string(Idetinfos)
  6102. //
  6103. //
  6104. //
  6105. //
  6106. // var rf []*ResultFive
  6107. // json.Unmarshal([]byte(infoStr), &rf)
  6108. //
  6109. // var insutypes []*ResultFive
  6110. // var insutype string
  6111. // var is390 int = 0
  6112. // var is310 int = 0
  6113. // var insuplc_admdvs string
  6114. //
  6115. // for _, item := range rf {
  6116. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6117. // insutypes = append(insutypes, item)
  6118. // }
  6119. // }
  6120. //
  6121. // if len(insutypes) == 1 {
  6122. // insutype = insutypes[0].Insutype
  6123. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6124. // } else {
  6125. // for _, i := range insutypes {
  6126. // if i.Insutype == "390" {
  6127. // is390 = 1
  6128. // }
  6129. //
  6130. // if i.Insutype == "310" {
  6131. // is310 = 1
  6132. // }
  6133. // }
  6134. // }
  6135. // if is390 == 1 {
  6136. // insutype = "390"
  6137. // }
  6138. //
  6139. // if is310 == 1 {
  6140. // insutype = "310"
  6141. // }
  6142. // if len(insutypes) == 0 {
  6143. // insutype = "310"
  6144. // }
  6145. // for _, item := range rf {
  6146. // if item.Insutype == insutype {
  6147. // insuplc_admdvs = item.InsuplcAdmdvs
  6148. // }
  6149. // }
  6150. // psn := &models.HisPsn{
  6151. // PsnNo: res.Output.Baseinfo.PsnNo,
  6152. // Age: res.Output.Baseinfo.Age,
  6153. // PatientId: patient.ID,
  6154. // Certno: res.Output.Baseinfo.Certno,
  6155. // Brdy: res.Output.Baseinfo.Brdy,
  6156. // Gend: res.Output.Baseinfo.Gend,
  6157. // Naty: res.Output.Baseinfo.Naty,
  6158. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  6159. // PsnName: res.Output.Baseinfo.PsnName,
  6160. // Idetinfo: idetinfoStr,
  6161. // Insuinfo: infoStr,
  6162. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6163. // CardInfo: "",
  6164. // VerifyNumber: token,
  6165. // InsuplcAdmdvs: insuplc_admdvs,
  6166. // }
  6167. // service.CreateHisPsn(psn)
  6168. //
  6169. // c.ServeSuccessJSON(map[string]interface{}{
  6170. // "patient": patient,
  6171. // "number": token,
  6172. // })
  6173. // }
  6174. //} else {
  6175. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6176. // return
  6177. //}
  6178. }
  6179. break
  6180. }
  6181. }
  6182. var initFlag int64 = 0
  6183. var initEleFlag int64 = 0
  6184. func (c *HisApiController) TestGetBasBaseInit() {
  6185. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6186. Iinit := DllDef.MustFindProc("Init")
  6187. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6188. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  6189. if ret != 0 {
  6190. fmt.Println("SSCard的报错原因:", err)
  6191. fmt.Println("SSCard的运算结果为:", ret)
  6192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  6193. return
  6194. }
  6195. result := int(ret)
  6196. fmt.Println("SSCard的运算结果为1:", result)
  6197. initFlag = 1
  6198. return
  6199. }
  6200. func (c *HisApiController) HandleJiangXiReadCard() {
  6201. fmt.Println("~~~~~~")
  6202. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6203. admin_user_id, _ := c.GetInt64("admin_user_id")
  6204. id_card_type, _ := c.GetInt64("id_card_type")
  6205. //certificates, _ := c.GetInt64("certificates")
  6206. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6207. if initFlag == 0 {
  6208. c.TestGetJiangXiBasBaseInit()
  6209. }
  6210. basStr := c.GetBasBaseInfo()
  6211. if len(basStr) == 0 {
  6212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  6213. return
  6214. }
  6215. fmt.Println(basStr)
  6216. bas := strings.Split(basStr, "|")
  6217. basNumber := bas[1]
  6218. fmt.Println(basNumber)
  6219. card_sn := bas[3]
  6220. fmt.Println(card_sn)
  6221. 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, "")
  6222. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  6223. var dat map[string]interface{}
  6224. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6225. fmt.Println(dat)
  6226. } else {
  6227. fmt.Println(err)
  6228. }
  6229. userJSONBytes, _ := json.Marshal(dat)
  6230. var res ResultTwo
  6231. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6232. utils.ErrorLog("解析失败:%v", err)
  6233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6234. return
  6235. }
  6236. if res.Infcode == 0 {
  6237. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  6238. if err == gorm.ErrRecordNotFound {
  6239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6240. return
  6241. } else if err != nil {
  6242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6243. return
  6244. } else {
  6245. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6246. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6247. infoStr := string(Iinfos)
  6248. idetinfoStr := string(Idetinfos)
  6249. psn := &models.HisPsn{
  6250. PsnNo: res.Output.Baseinfo.PsnNo,
  6251. Age: res.Output.Baseinfo.Age,
  6252. PatientId: patient.ID,
  6253. Certno: res.Output.Baseinfo.Certno,
  6254. Brdy: res.Output.Baseinfo.Brdy,
  6255. Gend: res.Output.Baseinfo.Gend,
  6256. Naty: res.Output.Baseinfo.Naty,
  6257. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6258. PsnName: res.Output.Baseinfo.PsnName,
  6259. Idetinfo: idetinfoStr,
  6260. Insuinfo: infoStr,
  6261. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6262. CardInfo: basStr,
  6263. VerifyNumber: "",
  6264. }
  6265. service.CreateHisPsn(psn)
  6266. c.ServeSuccessJSON(map[string]interface{}{
  6267. "patient": patient,
  6268. "number": basNumber,
  6269. })
  6270. }
  6271. } else {
  6272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6273. return
  6274. }
  6275. }
  6276. func (c *HisApiController) TestGetHnBasBaseInit() {
  6277. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6278. Iinit := DllDef.MustFindProc("Init")
  6279. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6280. //http://10.77.211.236/CSB/hsa-fsi-1303
  6281. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  6282. if ret != 0 {
  6283. fmt.Println("SSCard的报错原因:", err)
  6284. fmt.Println("SSCard的运算结果为:", ret)
  6285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  6286. return
  6287. }
  6288. result := int(ret)
  6289. fmt.Println("SSCard的运算结果为1:", result)
  6290. initFlag = 1
  6291. return
  6292. }
  6293. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  6294. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6295. Iinit := DllDef.MustFindProc("Init")
  6296. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6297. //http://10.77.211.236/CSB/hsa-fsi-1303
  6298. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  6299. if ret != 0 {
  6300. fmt.Println("SSCard的报错原因:", err)
  6301. fmt.Println("SSCard的运算结果为:", ret)
  6302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  6303. return
  6304. }
  6305. result := int(ret)
  6306. fmt.Println("SSCard的运算结果为1:", result)
  6307. initFlag = 1
  6308. return
  6309. }
  6310. func (c *HisApiController) GetSFZBaseInfo() string {
  6311. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6312. readCard := DllDef.MustFindProc("ReadSFZ")
  6313. if readCard == nil {
  6314. fmt.Println("readcard is nil")
  6315. readCard = DllDef.MustFindProc("ReadSFZ")
  6316. }
  6317. str := make([]byte, 8096)
  6318. str1 := make([]byte, 8096)
  6319. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  6320. fmt.Println(r)
  6321. return Remove0000(string(str))
  6322. }
  6323. func (c *HisApiController) GetEleBaseInfo() string {
  6324. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6325. readCard := DllDef.MustFindProc("GetQRBase")
  6326. fmt.Println(readCard)
  6327. if readCard == nil {
  6328. fmt.Println("readcard is nil")
  6329. readCard = DllDef.MustFindProc("GetQRBase")
  6330. }
  6331. str := make([]byte, 1024)
  6332. str1 := make([]byte, 1024)
  6333. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  6334. fmt.Println(ret2)
  6335. fmt.Println(string(str1))
  6336. fmt.Println(string(str))
  6337. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  6338. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  6339. if ret2 != 0 {
  6340. return ""
  6341. }
  6342. return string(str)
  6343. }
  6344. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  6345. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  6346. readCard := DllDef.MustFindProc("NationEcTrans")
  6347. fmt.Println(readCard)
  6348. fmt.Println("!!!!!")
  6349. pBusiCardInfo := make([]byte, 2048)
  6350. input := make(map[string]interface{})
  6351. inputData := make(map[string]interface{})
  6352. inputData["orgId"] = code
  6353. inputData["businessType"] = "01101"
  6354. inputData["operatorId"] = "1"
  6355. inputData["operatorName"] = "admin"
  6356. inputData["officeId"] = "001"
  6357. inputData["officeName"] = "血透室"
  6358. inputData["deviceType"] = ""
  6359. input["data"] = inputData
  6360. input["orgId"] = code
  6361. input["transType"] = "ec.query"
  6362. bytesData, _ := json.Marshal(input)
  6363. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  6364. fmt.Println(ret2)
  6365. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  6366. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  6367. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  6368. }
  6369. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  6370. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  6371. readCard := DllDef.MustFindProc("NationEcTrans")
  6372. fmt.Println(readCard)
  6373. fmt.Println("!!!!!")
  6374. pBusiCardInfo := make([]byte, 2048)
  6375. input := make(map[string]interface{})
  6376. inputData := make(map[string]interface{})
  6377. inputData["orgId"] = code
  6378. inputData["businessType"] = "01101"
  6379. inputData["operatorId"] = "9"
  6380. inputData["operatorName"] = "admin"
  6381. inputData["officeId"] = "001"
  6382. inputData["officeName"] = "血透室"
  6383. inputData["deviceType"] = ""
  6384. input["data"] = inputData
  6385. input["orgId"] = code
  6386. input["transType"] = "ec.query"
  6387. bytesData, _ := json.Marshal(input)
  6388. 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])))
  6389. fmt.Println(ret2)
  6390. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  6391. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  6392. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  6393. }
  6394. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  6395. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  6396. readCard := DllDef.MustFindProc("NationEcTrans")
  6397. fmt.Println(readCard)
  6398. fmt.Println("!!!!!")
  6399. pBusiCardInfo := make([]byte, 2048)
  6400. input := make(map[string]interface{})
  6401. inputData := make(map[string]interface{})
  6402. inputData["orgId"] = code
  6403. inputData["businessType"] = "01301"
  6404. inputData["operatorId"] = "9"
  6405. inputData["operatorName"] = "admin"
  6406. inputData["officeId"] = "001"
  6407. inputData["officeName"] = "血透室"
  6408. inputData["deviceType"] = ""
  6409. input["data"] = inputData
  6410. input["orgId"] = code
  6411. input["transType"] = "ec.query"
  6412. bytesData, _ := json.Marshal(input)
  6413. 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])))
  6414. fmt.Println(ret2)
  6415. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  6416. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  6417. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  6418. }
  6419. func GetJxEleBaseInfo(org_id int64) string {
  6420. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6421. readCard := DllDef.MustFindProc("NationEcTrans")
  6422. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  6423. if readCard == nil {
  6424. fmt.Println("readcard is nil")
  6425. readCard = DllDef.MustFindProc("NationEcTrans")
  6426. }
  6427. str1 := make([]byte, 1024)
  6428. data := make(map[string]interface{})
  6429. inputData := make(map[string]interface{})
  6430. inputData["orgId"] = miConfig.Code
  6431. inputData["businessType"] = "01101"
  6432. inputData["operatorId"] = "test001"
  6433. inputData["operatorName"] = "cn"
  6434. inputData["officeId"] = "32760"
  6435. inputData["officeName"] = "waike"
  6436. inputData["deviceType"] = ""
  6437. data["data"] = inputData
  6438. data["transType"] = "ec.query"
  6439. data["extra "] = ""
  6440. data["orgId"] = miConfig.Code
  6441. bytesData, _ := json.Marshal(data)
  6442. //bytesData, _ := json.Marshal(data)
  6443. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  6444. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  6445. fmt.Println(ret2)
  6446. fmt.Println(string(str1))
  6447. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  6448. if ret2 != 0 {
  6449. return ""
  6450. }
  6451. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  6452. }
  6453. func GetJxEleBaseInitInfo(org_id int64) string {
  6454. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6455. readCard := DllDef.MustFindProc("NationEcTrans")
  6456. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  6457. if readCard == nil {
  6458. fmt.Println("readcard is nil")
  6459. readCard = DllDef.MustFindProc("NationEcTrans")
  6460. }
  6461. str1 := make([]byte, 2048)
  6462. data := make(map[string]interface{})
  6463. inputData := make(map[string]interface{})
  6464. inputData["orgId"] = miConfig.Code
  6465. inputData["businessType"] = "01101"
  6466. inputData["operatorId"] = "1"
  6467. inputData["operatorName"] = "huangchuang"
  6468. inputData["officeId"] = "101"
  6469. inputData["officeName"] = "xuetou"
  6470. inputData["deviceType"] = ""
  6471. data["data"] = inputData
  6472. data["transType"] = "ec.query"
  6473. data["orgId"] = miConfig.Code
  6474. bytesData, _ := json.Marshal(data)
  6475. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  6476. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  6477. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  6478. fmt.Println(ret2)
  6479. fmt.Println(string(str1))
  6480. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  6481. if ret2 != 0 {
  6482. return ""
  6483. }
  6484. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  6485. initEleFlag = 1
  6486. }
  6487. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  6488. }
  6489. func (c *HisApiController) GetBasBaseInfo() string {
  6490. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6491. readCard := DllDef.MustFindProc("ReadCardBas")
  6492. if readCard == nil {
  6493. fmt.Println("readcard is nil")
  6494. readCard = DllDef.MustFindProc("ReadCardBas")
  6495. }
  6496. str := make([]byte, 1024)
  6497. str1 := make([]byte, 1024)
  6498. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  6499. fmt.Println(string(str1))
  6500. fmt.Println(string(str))
  6501. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  6502. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  6503. if ret2 != 0 {
  6504. return ""
  6505. }
  6506. return string(str)
  6507. }
  6508. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  6509. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  6510. readCard := DllDef.MustFindProc("read_cardinfo")
  6511. if readCard == nil {
  6512. fmt.Println("readcard is nil")
  6513. readCard = DllDef.MustFindProc("read_cardinfo")
  6514. }
  6515. str := make([]byte, 1024) //卡号
  6516. str1 := make([]byte, 1024) //卡识别码
  6517. str2 := make([]byte, 1024) //身份证号
  6518. str3 := make([]byte, 1024) //姓名
  6519. str4 := make([]byte, 1024) //错误信息
  6520. 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])))
  6521. fmt.Println(string(str1))
  6522. fmt.Println(string(str))
  6523. fmt.Println(string(str2))
  6524. fmt.Println(string(str3))
  6525. fmt.Println(string(str4))
  6526. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  6527. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  6528. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  6529. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  6530. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  6531. if ret2 != 0 {
  6532. return "", "", "", "", ""
  6533. }
  6534. return string(str), string(str1), string(str2), string(str3), string(str4)
  6535. }
  6536. type CustomFundPay struct {
  6537. FundPayType string `json:"fund_pay_type"`
  6538. FundPayamt float64 `json:"fund_payamt"`
  6539. }
  6540. func (c *HisApiController) GetSettleList() {
  6541. order_id, _ := c.GetInt64("order_id")
  6542. admin_user_id, _ := c.GetInt64("admin_user_id")
  6543. order, _ := service.GetHisOrderByIDTwo(order_id)
  6544. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  6545. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6546. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  6547. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6548. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  6549. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6550. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  6551. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  6552. if order.ID == 0 {
  6553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  6554. return
  6555. }
  6556. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  6557. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  6558. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  6559. //fmt.Println(count)
  6560. //var zero string
  6561. //number := count + 1
  6562. //if number >= 1000 {
  6563. // zero = "0000" + strconv.FormatInt(number, 10)
  6564. //} else if number >= 10000 {
  6565. // zero = "000" + strconv.FormatInt(number, 10)
  6566. //} else if number >= 100000 {
  6567. // zero = "00" + strconv.FormatInt(number, 10)
  6568. //} else if number >= 1000000 {
  6569. // zero = "0" + strconv.FormatInt(number, 10)
  6570. //} else {
  6571. // zero = strconv.FormatInt(number, 10)
  6572. //}
  6573. //fmt.Println(zero)
  6574. struct4101 := service.Struct4101{
  6575. PsnNo: order.PsnNo,
  6576. MdtrtId: order.MdtrtId,
  6577. SetlId: order.SetlId,
  6578. PsnName: order.PsnName,
  6579. Gend: order.Gend,
  6580. Brdy: his.Brdy,
  6581. Age: his.Age,
  6582. Naty: order.Naty,
  6583. PatnCertType: "01",
  6584. Certno: order.Certno,
  6585. Prfs: "90",
  6586. ConerName: roles[0].UserName,
  6587. PatnRlts: "99",
  6588. ConerAddr: miConfig.OrgName,
  6589. ConerTel: admin.Mobile,
  6590. HiType: order.Insutype,
  6591. Insuplc: miConfig.InsuplcAdmdvs,
  6592. MaindiagFlag: "1",
  6593. BillCode: order.SetlId,
  6594. BillNo: order.SetlId,
  6595. BizSn: order.Number,
  6596. PsnSelfPay: order.PsnPartAmt,
  6597. PsnOwnPay: order.PsnPartAmt,
  6598. AcctPay: order.AcctPay,
  6599. PsnCashpay: order.PsnCashPay,
  6600. HiPaymtd: "1",
  6601. Hsorg: miConfig.InsuplcAdmdvs,
  6602. HsorgOpter: miConfig.InsuplcAdmdvs,
  6603. MedinsFillPsn: curRoles.UserName,
  6604. MedinsFillDept: depart.Name,
  6605. IptMedType: "2",
  6606. }
  6607. struct4101.SetlBegnDate = order.SetlTime
  6608. struct4101.SetlEndDate = order.SetlTime
  6609. time_arr := strings.Split(order.SetlTime, " ")
  6610. struct4101.AdmTime = time_arr[0]
  6611. struct4101.AdmEndTime = time_arr[0]
  6612. var rf []CustomFundPay
  6613. json.Unmarshal([]byte(order.SetlDetail), &rf)
  6614. var tempFunPays []service.CustomStruct
  6615. for _, item := range rf {
  6616. var tempFunPay service.CustomStruct
  6617. tempFunPay.FundPayamt = item.FundPayamt
  6618. tempFunPay.FundPayType = item.FundPayType
  6619. tempFunPays = append(tempFunPays, tempFunPay)
  6620. }
  6621. struct4101.CustomStruct = tempFunPays
  6622. var tempDiaginfos []service.DiaginfoStructTwo
  6623. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  6624. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  6625. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6626. var config []*models.HisXtDiagnoseConfig
  6627. for _, item := range diagnosis_ids {
  6628. id, _ := strconv.ParseInt(item, 10, 64)
  6629. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6630. config = append(config, &diagnosisConfig)
  6631. }
  6632. for index, item := range config {
  6633. if index == 0 {
  6634. var tempDiaginfo service.DiaginfoStructTwo
  6635. tempDiaginfo.DiagCode = item.CountryCode
  6636. tempDiaginfo.DiagName = item.CountryContentName
  6637. tempDiaginfo.DiagType = "1"
  6638. tempDiaginfo.MaindiagFlag = "1"
  6639. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6640. } else {
  6641. var tempDiaginfo service.DiaginfoStructTwo
  6642. tempDiaginfo.DiagCode = item.CountryCode
  6643. tempDiaginfo.DiagName = item.CountryContentName
  6644. tempDiaginfo.DiagType = "2"
  6645. tempDiaginfo.MaindiagFlag = "0"
  6646. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6647. }
  6648. }
  6649. struct4101.Diseinfo = tempDiaginfos
  6650. sickConfigTwo, _ := service.FindSickById(his.SickType)
  6651. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  6652. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  6653. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  6654. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  6655. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  6656. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  6657. var iteminfo service.IteminfoStruct
  6658. var bedCostTotal float64 = 0 //床位总费
  6659. var bedCostSelfTotal float64 = 0 //床位自费
  6660. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6661. var operationCostTotal float64 = 0 //手术费
  6662. var operationCostSelfTotal float64 = 0 //手术费
  6663. var operationCostPartSelfTotal float64 = 0 //手术费
  6664. var otherCostTotal float64 = 0 //其他费用
  6665. var otherCostSelfTotal float64 = 0 //其他费用
  6666. var otherCostPartSelfTotal float64 = 0 //其他费用
  6667. var materialCostTotal float64 = 0 //材料费
  6668. var materialCostSelfTotal float64 = 0 //材料费
  6669. var materialCostPartSelfTotal float64 = 0 //材料费
  6670. var westernMedicineCostTotal float64 = 0 //西药费
  6671. var westernMedicineCostSelfTotal float64 = 0 //西药费
  6672. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6673. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6674. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6675. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6676. var checkCostTotal float64 = 0 //检查费
  6677. var checkCostSelfTotal float64 = 0 //检查费
  6678. var checkCostPartSelfTotal float64 = 0 //检查费
  6679. var laboratoryCostTotal float64 = 0 //化验费
  6680. var laboratoryCostSelfTotal float64 = 0 //化验费
  6681. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6682. var treatCostTotal float64 = 0 //治疗费用
  6683. var treatCostSelfTotal float64 = 0 //治疗费用
  6684. var treatCostPartSelfTotal float64 = 0 //治疗费用
  6685. decimal.DivisionPrecision = 2
  6686. var bed_fulamt_ownpay_amt float64 = 0
  6687. var operation_fulamt_ownpay_amt float64 = 0
  6688. var other_fulamt_ownpay_amt float64 = 0
  6689. var westernMedicine_fulamt_ownpay_amt float64 = 0
  6690. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  6691. var check_fulamt_ownpay_amt float64 = 0
  6692. var material_fulamt_ownpay_amt float64 = 0
  6693. var laboratory_fulamt_ownpay_amt float64 = 0
  6694. var treat_fulamt_ownpay_amt float64 = 0
  6695. var bed_claa_sunmfee float64 = 0
  6696. var bed_clab_amt float64 = 0
  6697. var bed_other_amt float64 = 0
  6698. var operation_claa_sunmfee float64 = 0
  6699. var operation_clab_amt float64 = 0
  6700. var operation_other_amt float64 = 0
  6701. var other_claa_sunmfee float64 = 0
  6702. var other_clab_amt float64 = 0
  6703. var other_other_amt float64 = 0
  6704. var westernMedicine_claa_sunmfee float64 = 0
  6705. var westernMedicine_clab_amt float64 = 0
  6706. var westernMedicine_other_amt float64 = 0
  6707. var chineseTraditional_claa_sunmfee float64 = 0
  6708. var chineseTraditional_clab_amt float64 = 0
  6709. var chineseTraditional_other_amt float64 = 0
  6710. var check_claa_sunmfee float64 = 0
  6711. var check_clab_amt float64 = 0
  6712. var check_other_amt float64 = 0
  6713. var material_claa_sunmfee float64 = 0
  6714. var material_clab_amt float64 = 0
  6715. var material_other_amt float64 = 0
  6716. var laboratory_claa_sunmfee float64 = 0
  6717. var laboratory_clab_amt float64 = 0
  6718. var laboratory_other_amt float64 = 0
  6719. var treat_claa_sunmfee float64 = 0
  6720. var treat_clab_amt float64 = 0
  6721. var treat_other_amt float64 = 0
  6722. for _, item := range order.HisOrderInfo {
  6723. if item.MedChrgitmType == "01" { //床位费
  6724. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6725. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6726. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6727. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6728. if item.ChrgitmLv == "1" {
  6729. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6730. }
  6731. if item.ChrgitmLv == "2" {
  6732. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6733. }
  6734. if item.ChrgitmLv == "3" {
  6735. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6736. }
  6737. }
  6738. if item.MedChrgitmType == "03" { //检查费
  6739. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6740. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6741. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6742. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6743. if item.ChrgitmLv == "1" {
  6744. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6745. }
  6746. if item.ChrgitmLv == "2" {
  6747. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6748. }
  6749. if item.ChrgitmLv == "3" {
  6750. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6751. }
  6752. }
  6753. if item.MedChrgitmType == "04" { //化验费
  6754. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6755. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6756. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6757. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6758. if item.ChrgitmLv == "1" {
  6759. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6760. }
  6761. if item.ChrgitmLv == "2" {
  6762. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6763. }
  6764. if item.ChrgitmLv == "3" {
  6765. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6766. }
  6767. }
  6768. if item.MedChrgitmType == "05" { //治疗费
  6769. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6770. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6771. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6772. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6773. if item.ChrgitmLv == "1" {
  6774. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6775. }
  6776. if item.ChrgitmLv == "2" {
  6777. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6778. }
  6779. if item.ChrgitmLv == "3" {
  6780. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6781. }
  6782. }
  6783. if item.MedChrgitmType == "06" { //手术费
  6784. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6785. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6786. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6787. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6788. if item.ChrgitmLv == "1" {
  6789. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6790. }
  6791. if item.ChrgitmLv == "2" {
  6792. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6793. }
  6794. if item.ChrgitmLv == "3" {
  6795. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6796. }
  6797. }
  6798. if item.MedChrgitmType == "08" { //材料费
  6799. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6800. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6801. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6802. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6803. if item.ChrgitmLv == "1" {
  6804. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6805. }
  6806. if item.ChrgitmLv == "2" {
  6807. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6808. }
  6809. if item.ChrgitmLv == "3" {
  6810. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6811. }
  6812. }
  6813. if item.MedChrgitmType == "09" { //西药费
  6814. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6815. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6816. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6817. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6818. if item.ChrgitmLv == "1" {
  6819. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6820. }
  6821. if item.ChrgitmLv == "2" {
  6822. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6823. }
  6824. if item.ChrgitmLv == "3" {
  6825. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6826. }
  6827. }
  6828. if item.MedChrgitmType == "11" { //中成费
  6829. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6830. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6831. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6832. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6833. if item.ChrgitmLv == "1" {
  6834. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6835. }
  6836. if item.ChrgitmLv == "2" {
  6837. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6838. }
  6839. if item.ChrgitmLv == "3" {
  6840. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6841. }
  6842. }
  6843. if item.MedChrgitmType == "14" { //其他费
  6844. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6845. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6846. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6847. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6848. if item.ChrgitmLv == "1" {
  6849. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6850. }
  6851. if item.ChrgitmLv == "2" {
  6852. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6853. }
  6854. if item.ChrgitmLv == "3" {
  6855. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6856. }
  6857. }
  6858. }
  6859. var iteminfoStructs []service.IteminfoStruct
  6860. if bedCostTotal != 0 {
  6861. iteminfo.MedChrgitm = "01"
  6862. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6863. iteminfo.Amt = bedCostTotal
  6864. iteminfo.ClaaSumfee = bed_claa_sunmfee
  6865. iteminfo.ClabAmt = bed_clab_amt
  6866. iteminfo.OthAmt = bed_other_amt
  6867. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6868. }
  6869. if checkCostTotal != 0 {
  6870. iteminfo.MedChrgitm = "03"
  6871. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  6872. iteminfo.Amt = checkCostTotal
  6873. iteminfo.ClaaSumfee = check_claa_sunmfee
  6874. iteminfo.ClabAmt = check_clab_amt
  6875. iteminfo.OthAmt = check_other_amt
  6876. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6877. }
  6878. if laboratoryCostTotal != 0 {
  6879. iteminfo.MedChrgitm = "04"
  6880. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  6881. iteminfo.Amt = laboratoryCostTotal
  6882. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  6883. iteminfo.ClabAmt = laboratory_clab_amt
  6884. iteminfo.OthAmt = laboratory_other_amt
  6885. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6886. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6887. }
  6888. if treatCostTotal != 0 {
  6889. iteminfo.MedChrgitm = "05"
  6890. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  6891. iteminfo.Amt = treatCostTotal
  6892. iteminfo.ClaaSumfee = treat_claa_sunmfee
  6893. iteminfo.ClabAmt = treat_clab_amt
  6894. iteminfo.OthAmt = treat_other_amt
  6895. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6896. //(struct4101.IteminfoStruct, iteminfo)
  6897. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6898. }
  6899. if operationCostTotal != 0 {
  6900. iteminfo.MedChrgitm = "06"
  6901. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6902. iteminfo.Amt = operationCostTotal
  6903. iteminfo.ClaaSumfee = operation_claa_sunmfee
  6904. iteminfo.ClabAmt = operation_clab_amt
  6905. iteminfo.OthAmt = operation_other_amt
  6906. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6907. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6908. }
  6909. if materialCostTotal != 0 {
  6910. iteminfo.MedChrgitm = "08"
  6911. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  6912. iteminfo.Amt = materialCostTotal
  6913. iteminfo.ClaaSumfee = material_claa_sunmfee
  6914. iteminfo.ClabAmt = material_clab_amt
  6915. iteminfo.OthAmt = material_other_amt
  6916. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6917. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6918. }
  6919. if westernMedicineCostTotal != 0 {
  6920. iteminfo.MedChrgitm = "09"
  6921. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6922. iteminfo.Amt = westernMedicineCostTotal
  6923. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6924. iteminfo.ClabAmt = westernMedicine_clab_amt
  6925. iteminfo.OthAmt = westernMedicine_other_amt
  6926. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6927. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6928. }
  6929. if chineseTraditionalMedicineCostTotal != 0 {
  6930. iteminfo.MedChrgitm = "11"
  6931. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6932. iteminfo.Amt = westernMedicineCostTotal
  6933. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6934. iteminfo.ClabAmt = westernMedicine_clab_amt
  6935. iteminfo.OthAmt = westernMedicine_other_amt
  6936. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6937. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6938. }
  6939. if otherCostTotal != 0 {
  6940. iteminfo.MedChrgitm = "14"
  6941. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  6942. iteminfo.Amt = otherCostTotal
  6943. iteminfo.ClaaSumfee = other_claa_sunmfee
  6944. iteminfo.ClabAmt = other_clab_amt
  6945. iteminfo.OthAmt = other_other_amt
  6946. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6947. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6948. }
  6949. struct4101.IteminfoStruct = iteminfoStructs
  6950. struct4101.Ntly = "中国"
  6951. struct4101.AdmCaty = "A03.06"
  6952. struct4101.DoctorName = doctor.UserName
  6953. struct4101.DoctorCode = doctor.DoctorNumber
  6954. var res ResultSeventeen
  6955. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6956. struct4101.BillCode = order.Number
  6957. struct4101.BillNo = order.SetlId
  6958. var resOther ResultSeventeenOther
  6959. var pp models.PublicParams
  6960. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6961. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6962. pp.FixmedinsName = miConfig.OrgName
  6963. pp.FixmedinsCode = miConfig.Code
  6964. pp.RequestUrl = miConfig.Url
  6965. pp.Cainfo = miConfig.Cainfo
  6966. pp.SecretKey = miConfig.SecretKey
  6967. pp.AccessKey = miConfig.AccessKey
  6968. pp.OpterName = curRoles.UserName
  6969. client := &http.Client{}
  6970. var req *http.Request
  6971. data := make(map[string]interface{})
  6972. data["struct4101"] = struct4101
  6973. data["pp"] = pp
  6974. bytesData, _ := json.Marshal(data)
  6975. if miConfig.MdtrtareaAdmvs == "320921" {
  6976. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  6977. } else {
  6978. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  6979. }
  6980. resp, _ := client.Do(req)
  6981. defer resp.Body.Close()
  6982. body, ioErr := ioutil.ReadAll(resp.Body)
  6983. if ioErr != nil {
  6984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6986. return
  6987. }
  6988. var respJSON map[string]interface{}
  6989. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6992. return
  6993. }
  6994. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6995. userJSONBytes, _ := json.Marshal(respJSON)
  6996. fmt.Println("log")
  6997. fmt.Println(string(userJSONBytes))
  6998. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  6999. utils.ErrorLog("解析失败:%v", err)
  7000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7001. return
  7002. }
  7003. res.InfRefmsgid = resOther.InfRefmsgid
  7004. res.Output = resOther.Output
  7005. res.ErrMsg = resOther.ErrMsg
  7006. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  7007. res.Infcode = infocode
  7008. } else if miConfig.MdtrtareaAdmvs == "360399" {
  7009. var pp models.PublicParams
  7010. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7011. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7012. pp.FixmedinsName = miConfig.OrgName
  7013. pp.FixmedinsCode = miConfig.Code
  7014. pp.RequestUrl = miConfig.Url
  7015. pp.Cainfo = miConfig.Cainfo
  7016. pp.SecretKey = miConfig.SecretKey
  7017. pp.AccessKey = miConfig.AccessKey
  7018. pp.OpterName = curRoles.UserName
  7019. result, _ := service.Jxyb4101(struct4101, pp)
  7020. var dat map[string]interface{}
  7021. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7022. fmt.Println(dat)
  7023. } else {
  7024. fmt.Println(err)
  7025. }
  7026. userJSONBytes, _ := json.Marshal(dat)
  7027. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7028. utils.ErrorLog("解析失败:%v", err)
  7029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7030. return
  7031. }
  7032. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7033. var pp models.PublicParams
  7034. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7035. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7036. pp.FixmedinsName = miConfig.OrgName
  7037. pp.FixmedinsCode = miConfig.Code
  7038. pp.RequestUrl = miConfig.Url
  7039. pp.Cainfo = miConfig.Cainfo
  7040. pp.SecretKey = miConfig.SecretKey
  7041. pp.AccessKey = miConfig.AccessKey
  7042. pp.OpterName = curRoles.UserName
  7043. result, _ := service.Hnyb4101(struct4101, pp)
  7044. var dat map[string]interface{}
  7045. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7046. fmt.Println(dat)
  7047. } else {
  7048. fmt.Println(err)
  7049. }
  7050. userJSONBytes, _ := json.Marshal(dat)
  7051. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7052. utils.ErrorLog("解析失败:%v", err)
  7053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7054. return
  7055. }
  7056. } else {
  7057. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  7058. var dat map[string]interface{}
  7059. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7060. fmt.Println(dat)
  7061. } else {
  7062. fmt.Println(err)
  7063. }
  7064. userJSONBytes, _ := json.Marshal(dat)
  7065. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7066. utils.ErrorLog("解析失败:%v", err)
  7067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7068. return
  7069. }
  7070. }
  7071. if res.Infcode != 0 {
  7072. c.ServeSuccessJSON(map[string]interface{}{
  7073. "failed_code": -10,
  7074. "msg": res.ErrMsg,
  7075. })
  7076. return
  7077. } else {
  7078. //order.FaPiaoNumber = zero
  7079. //order.FaPiaoCode = last_order.FaPiaoCode
  7080. //service.UpdateOrder(order)
  7081. hisFundSettleListResult := &models.HisFundSettleListResult{
  7082. Number: res.Output.SetlListId,
  7083. Status: 1,
  7084. Ctime: time.Now().Unix(),
  7085. Mtime: time.Now().Unix(),
  7086. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7087. IsUpload: 1,
  7088. OrderId: order_id,
  7089. }
  7090. service.CreateUploadRecord(hisFundSettleListResult)
  7091. c.ServeSuccessJSON(map[string]interface{}{
  7092. "msg": "上传成功",
  7093. "result": hisFundSettleListResult,
  7094. })
  7095. return
  7096. }
  7097. }
  7098. func (c *HisApiController) GetSettleListHospital() {
  7099. order_id, _ := c.GetInt64("order_id")
  7100. admin_user_id, _ := c.GetInt64("admin_user_id")
  7101. order, _ := service.GetHisOrderByIDTwo(order_id)
  7102. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  7103. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7104. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  7105. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7106. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  7107. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7108. if order.ID == 0 {
  7109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7110. return
  7111. }
  7112. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  7113. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  7114. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  7115. fmt.Println(count)
  7116. var zero string
  7117. number := count + 1
  7118. if number >= 1000 {
  7119. zero = "0000" + strconv.FormatInt(number, 10)
  7120. } else if number >= 10000 {
  7121. zero = "000" + strconv.FormatInt(number, 10)
  7122. } else if number >= 100000 {
  7123. zero = "00" + strconv.FormatInt(number, 10)
  7124. } else if number >= 1000000 {
  7125. zero = "0" + strconv.FormatInt(number, 10)
  7126. } else {
  7127. zero = strconv.FormatInt(number, 10)
  7128. }
  7129. fmt.Println(zero)
  7130. struct4101 := service.Struct4101{
  7131. PsnNo: order.PsnNo,
  7132. MdtrtId: order.MdtrtId,
  7133. SetlId: order.SetlId,
  7134. PsnName: order.PsnName,
  7135. Gend: order.Gend,
  7136. Brdy: his.Brdy,
  7137. Age: int64(order.Age),
  7138. Naty: order.Naty,
  7139. PatnCertType: "01",
  7140. Certno: order.Certno,
  7141. Prfs: "90",
  7142. ConerName: roles[0].UserName,
  7143. PatnRlts: "99",
  7144. ConerAddr: miConfig.OrgName,
  7145. ConerTel: admin.Mobile,
  7146. HiType: order.Insutype,
  7147. Insuplc: miConfig.InsuplcAdmdvs,
  7148. MaindiagFlag: "1",
  7149. BillCode: order.SetlId,
  7150. BillNo: order.SetlId,
  7151. BizSn: order.Number,
  7152. PsnSelfPay: order.PsnPartAmt,
  7153. PsnOwnPay: order.PsnPartAmt,
  7154. AcctPay: order.AcctPay,
  7155. PsnCashpay: order.PsnCashPay,
  7156. HiPaymtd: "1",
  7157. Hsorg: miConfig.InsuplcAdmdvs,
  7158. HsorgOpter: miConfig.InsuplcAdmdvs,
  7159. MedinsFillPsn: curRoles.UserName,
  7160. MedinsFillDept: depart.Name,
  7161. IptMedType: "2",
  7162. AdmTime: his.InHosptialTime,
  7163. AdmEndTime: his.OutHosptialTime,
  7164. }
  7165. struct4101.SetlBegnDate = order.SetlTime
  7166. struct4101.SetlEndDate = order.SetlTime
  7167. var rf []CustomFundPay
  7168. json.Unmarshal([]byte(order.SetlDetail), &rf)
  7169. var tempFunPays []service.CustomStruct
  7170. for _, item := range rf {
  7171. var tempFunPay service.CustomStruct
  7172. tempFunPay.FundPayamt = item.FundPayamt
  7173. tempFunPay.FundPayType = item.FundPayType
  7174. tempFunPays = append(tempFunPays, tempFunPay)
  7175. }
  7176. struct4101.CustomStruct = tempFunPays
  7177. var tempDiaginfos []service.DiaginfoStructTwo
  7178. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  7179. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  7180. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7181. var config []*models.HisXtDiagnoseConfig
  7182. for _, item := range diagnosis_ids {
  7183. id, _ := strconv.ParseInt(item, 10, 64)
  7184. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7185. config = append(config, &diagnosisConfig)
  7186. }
  7187. for index, item := range config {
  7188. if index == 0 {
  7189. var tempDiaginfo service.DiaginfoStructTwo
  7190. tempDiaginfo.DiagCode = item.CountryCode
  7191. tempDiaginfo.DiagName = item.CountryContentName
  7192. tempDiaginfo.DiagType = "1"
  7193. tempDiaginfo.MaindiagFlag = "1"
  7194. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7195. } else {
  7196. var tempDiaginfo service.DiaginfoStructTwo
  7197. tempDiaginfo.DiagCode = item.CountryCode
  7198. tempDiaginfo.DiagName = item.CountryContentName
  7199. tempDiaginfo.DiagType = "2"
  7200. tempDiaginfo.MaindiagFlag = "0"
  7201. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7202. }
  7203. }
  7204. struct4101.Diseinfo = tempDiaginfos
  7205. sickConfigTwo, _ := service.FindSickById(his.SickType)
  7206. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  7207. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  7208. tempOpspdiseinfo2.OprnOprtCode = ""
  7209. tempOpspdiseinfo2.OprnOprtName = ""
  7210. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  7211. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  7212. var iteminfo service.IteminfoStruct
  7213. var bedCostTotal float64 = 0 //床位总费
  7214. var bedCostSelfTotal float64 = 0 //床位自费
  7215. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7216. var operationCostTotal float64 = 0 //手术费
  7217. var operationCostSelfTotal float64 = 0 //手术费
  7218. var operationCostPartSelfTotal float64 = 0 //手术费
  7219. var otherCostTotal float64 = 0 //其他费用
  7220. var otherCostSelfTotal float64 = 0 //其他费用
  7221. var otherCostPartSelfTotal float64 = 0 //其他费用
  7222. var materialCostTotal float64 = 0 //材料费
  7223. var materialCostSelfTotal float64 = 0 //材料费
  7224. var materialCostPartSelfTotal float64 = 0 //材料费
  7225. var westernMedicineCostTotal float64 = 0 //西药费
  7226. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7227. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7228. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7229. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7230. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7231. var checkCostTotal float64 = 0 //检查费
  7232. var checkCostSelfTotal float64 = 0 //检查费
  7233. var checkCostPartSelfTotal float64 = 0 //检查费
  7234. var laboratoryCostTotal float64 = 0 //化验费
  7235. var laboratoryCostSelfTotal float64 = 0 //化验费
  7236. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7237. var treatCostTotal float64 = 0 //治疗费用
  7238. var treatCostSelfTotal float64 = 0 //治疗费用
  7239. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7240. decimal.DivisionPrecision = 2
  7241. var bed_fulamt_ownpay_amt float64 = 0
  7242. var operation_fulamt_ownpay_amt float64 = 0
  7243. var other_fulamt_ownpay_amt float64 = 0
  7244. var westernMedicine_fulamt_ownpay_amt float64 = 0
  7245. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  7246. var check_fulamt_ownpay_amt float64 = 0
  7247. var material_fulamt_ownpay_amt float64 = 0
  7248. var laboratory_fulamt_ownpay_amt float64 = 0
  7249. var treat_fulamt_ownpay_amt float64 = 0
  7250. var bed_claa_sunmfee float64 = 0
  7251. var bed_clab_amt float64 = 0
  7252. var bed_other_amt float64 = 0
  7253. var operation_claa_sunmfee float64 = 0
  7254. var operation_clab_amt float64 = 0
  7255. var operation_other_amt float64 = 0
  7256. var other_claa_sunmfee float64 = 0
  7257. var other_clab_amt float64 = 0
  7258. var other_other_amt float64 = 0
  7259. var westernMedicine_claa_sunmfee float64 = 0
  7260. var westernMedicine_clab_amt float64 = 0
  7261. var westernMedicine_other_amt float64 = 0
  7262. var chineseTraditional_claa_sunmfee float64 = 0
  7263. var chineseTraditional_clab_amt float64 = 0
  7264. var chineseTraditional_other_amt float64 = 0
  7265. var check_claa_sunmfee float64 = 0
  7266. var check_clab_amt float64 = 0
  7267. var check_other_amt float64 = 0
  7268. var material_claa_sunmfee float64 = 0
  7269. var material_clab_amt float64 = 0
  7270. var material_other_amt float64 = 0
  7271. var laboratory_claa_sunmfee float64 = 0
  7272. var laboratory_clab_amt float64 = 0
  7273. var laboratory_other_amt float64 = 0
  7274. var treat_claa_sunmfee float64 = 0
  7275. var treat_clab_amt float64 = 0
  7276. var treat_other_amt float64 = 0
  7277. for _, item := range order.HisOrderInfo {
  7278. if item.MedChrgitmType == "01" { //床位费
  7279. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7280. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7281. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7282. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7283. if item.ChrgitmLv == "1" {
  7284. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7285. }
  7286. if item.ChrgitmLv == "2" {
  7287. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7288. }
  7289. if item.ChrgitmLv == "3" {
  7290. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7291. }
  7292. }
  7293. if item.MedChrgitmType == "03" { //检查费
  7294. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7295. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7296. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7297. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7298. if item.ChrgitmLv == "1" {
  7299. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7300. }
  7301. if item.ChrgitmLv == "2" {
  7302. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7303. }
  7304. if item.ChrgitmLv == "3" {
  7305. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7306. }
  7307. }
  7308. if item.MedChrgitmType == "04" { //化验费
  7309. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7310. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7311. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7312. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7313. if item.ChrgitmLv == "1" {
  7314. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7315. }
  7316. if item.ChrgitmLv == "2" {
  7317. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7318. }
  7319. if item.ChrgitmLv == "3" {
  7320. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7321. }
  7322. }
  7323. if item.MedChrgitmType == "05" { //治疗费
  7324. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7325. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7326. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7327. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7328. if item.ChrgitmLv == "1" {
  7329. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7330. }
  7331. if item.ChrgitmLv == "2" {
  7332. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7333. }
  7334. if item.ChrgitmLv == "3" {
  7335. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7336. }
  7337. }
  7338. if item.MedChrgitmType == "06" { //手术费
  7339. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7340. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7341. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7342. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7343. if item.ChrgitmLv == "1" {
  7344. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7345. }
  7346. if item.ChrgitmLv == "2" {
  7347. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7348. }
  7349. if item.ChrgitmLv == "3" {
  7350. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7351. }
  7352. }
  7353. if item.MedChrgitmType == "08" { //材料费
  7354. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7355. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7356. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7357. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7358. if item.ChrgitmLv == "1" {
  7359. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7360. }
  7361. if item.ChrgitmLv == "2" {
  7362. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7363. }
  7364. if item.ChrgitmLv == "3" {
  7365. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7366. }
  7367. }
  7368. if item.MedChrgitmType == "09" { //西药费
  7369. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7370. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7371. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7372. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7373. if item.ChrgitmLv == "1" {
  7374. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7375. }
  7376. if item.ChrgitmLv == "2" {
  7377. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7378. }
  7379. if item.ChrgitmLv == "3" {
  7380. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7381. }
  7382. }
  7383. if item.MedChrgitmType == "11" { //中成费
  7384. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7385. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7386. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7387. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7388. if item.ChrgitmLv == "1" {
  7389. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7390. }
  7391. if item.ChrgitmLv == "2" {
  7392. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7393. }
  7394. if item.ChrgitmLv == "3" {
  7395. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7396. }
  7397. }
  7398. if item.MedChrgitmType == "14" { //其他费
  7399. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7400. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7401. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7402. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7403. if item.ChrgitmLv == "1" {
  7404. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7405. }
  7406. if item.ChrgitmLv == "2" {
  7407. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7408. }
  7409. if item.ChrgitmLv == "3" {
  7410. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7411. }
  7412. }
  7413. }
  7414. var iteminfoStructs []service.IteminfoStruct
  7415. if bedCostTotal != 0 {
  7416. iteminfo.MedChrgitm = "01"
  7417. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  7418. iteminfo.Amt = bedCostTotal
  7419. iteminfo.ClaaSumfee = bed_claa_sunmfee
  7420. iteminfo.ClabAmt = bed_clab_amt
  7421. iteminfo.OthAmt = bed_other_amt
  7422. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7423. }
  7424. if checkCostTotal != 0 {
  7425. iteminfo.MedChrgitm = "03"
  7426. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  7427. iteminfo.Amt = checkCostTotal
  7428. iteminfo.ClaaSumfee = check_claa_sunmfee
  7429. iteminfo.ClabAmt = check_clab_amt
  7430. iteminfo.OthAmt = check_other_amt
  7431. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7432. }
  7433. if laboratoryCostTotal != 0 {
  7434. iteminfo.MedChrgitm = "04"
  7435. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  7436. iteminfo.Amt = laboratoryCostTotal
  7437. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  7438. iteminfo.ClabAmt = laboratory_clab_amt
  7439. iteminfo.OthAmt = laboratory_other_amt
  7440. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7441. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7442. }
  7443. if treatCostTotal != 0 {
  7444. iteminfo.MedChrgitm = "05"
  7445. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  7446. iteminfo.Amt = treatCostTotal
  7447. iteminfo.ClaaSumfee = treat_claa_sunmfee
  7448. iteminfo.ClabAmt = treat_clab_amt
  7449. iteminfo.OthAmt = treat_other_amt
  7450. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7451. //(struct4101.IteminfoStruct, iteminfo)
  7452. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7453. }
  7454. if operationCostTotal != 0 {
  7455. iteminfo.MedChrgitm = "06"
  7456. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  7457. iteminfo.Amt = operationCostTotal
  7458. iteminfo.ClaaSumfee = operation_claa_sunmfee
  7459. iteminfo.ClabAmt = operation_clab_amt
  7460. iteminfo.OthAmt = operation_other_amt
  7461. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7462. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7463. }
  7464. if materialCostTotal != 0 {
  7465. iteminfo.MedChrgitm = "08"
  7466. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  7467. iteminfo.Amt = materialCostTotal
  7468. iteminfo.ClaaSumfee = material_claa_sunmfee
  7469. iteminfo.ClabAmt = material_clab_amt
  7470. iteminfo.OthAmt = material_other_amt
  7471. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7472. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7473. }
  7474. if westernMedicineCostTotal != 0 {
  7475. iteminfo.MedChrgitm = "09"
  7476. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  7477. iteminfo.Amt = westernMedicineCostTotal
  7478. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  7479. iteminfo.ClabAmt = westernMedicine_clab_amt
  7480. iteminfo.OthAmt = westernMedicine_other_amt
  7481. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7482. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7483. }
  7484. if chineseTraditionalMedicineCostTotal != 0 {
  7485. iteminfo.MedChrgitm = "11"
  7486. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  7487. iteminfo.Amt = westernMedicineCostTotal
  7488. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  7489. iteminfo.ClabAmt = westernMedicine_clab_amt
  7490. iteminfo.OthAmt = westernMedicine_other_amt
  7491. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7492. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7493. }
  7494. if otherCostTotal != 0 {
  7495. iteminfo.MedChrgitm = "14"
  7496. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  7497. iteminfo.Amt = otherCostTotal
  7498. iteminfo.ClaaSumfee = other_claa_sunmfee
  7499. iteminfo.ClabAmt = other_clab_amt
  7500. iteminfo.OthAmt = other_other_amt
  7501. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7502. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7503. }
  7504. struct4101.IteminfoStruct = iteminfoStructs
  7505. struct4101.Ntly = "中国"
  7506. struct4101.AdmCaty = "A03.06"
  7507. var resOther ResultSeventeenOther
  7508. var res ResultSeventeen
  7509. if miConfig.MdtrtareaAdmvs == "150499" {
  7510. var pp models.PublicParams
  7511. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7512. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7513. pp.FixmedinsName = miConfig.OrgName
  7514. pp.FixmedinsCode = miConfig.Code
  7515. pp.RequestUrl = miConfig.Url
  7516. pp.Cainfo = miConfig.Cainfo
  7517. pp.SecretKey = miConfig.SecretKey
  7518. pp.AccessKey = miConfig.AccessKey
  7519. pp.OpterName = curRoles.UserName
  7520. client := &http.Client{}
  7521. var req *http.Request
  7522. data := make(map[string]interface{})
  7523. data["struct4101"] = struct4101
  7524. data["pp"] = pp
  7525. bytesData, _ := json.Marshal(data)
  7526. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  7527. resp, _ := client.Do(req)
  7528. defer resp.Body.Close()
  7529. body, ioErr := ioutil.ReadAll(resp.Body)
  7530. if ioErr != nil {
  7531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7533. return
  7534. }
  7535. var respJSON map[string]interface{}
  7536. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7539. return
  7540. }
  7541. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7542. userJSONBytes, _ := json.Marshal(respJSON)
  7543. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  7544. utils.ErrorLog("解析失败:%v", err)
  7545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7546. return
  7547. }
  7548. res.InfRefmsgid = resOther.InfRefmsgid
  7549. res.Output = resOther.Output
  7550. res.ErrMsg = resOther.ErrMsg
  7551. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  7552. res.Infcode = infocode
  7553. } else {
  7554. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  7555. var dat map[string]interface{}
  7556. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7557. fmt.Println(dat)
  7558. } else {
  7559. fmt.Println(err)
  7560. }
  7561. userJSONBytes, _ := json.Marshal(dat)
  7562. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7563. utils.ErrorLog("解析失败:%v", err)
  7564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7565. return
  7566. }
  7567. }
  7568. if res.Infcode != 0 {
  7569. c.ServeSuccessJSON(map[string]interface{}{
  7570. "failed_code": -10,
  7571. "msg": res.ErrMsg,
  7572. })
  7573. return
  7574. } else {
  7575. if miConfig.MdtrtareaAdmvs != "150499" {
  7576. order.FaPiaoNumber = zero
  7577. order.FaPiaoCode = last_order.FaPiaoCode
  7578. service.UpdateOrder(order)
  7579. }
  7580. hisFundSettleListResult := &models.HisFundSettleListResult{
  7581. Number: res.Output.SetlListId,
  7582. Status: 1,
  7583. Ctime: time.Now().Unix(),
  7584. Mtime: time.Now().Unix(),
  7585. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7586. IsUpload: 1,
  7587. OrderId: order_id,
  7588. }
  7589. service.CreateUploadRecord(hisFundSettleListResult)
  7590. c.ServeSuccessJSON(map[string]interface{}{
  7591. "msg": "上传成功",
  7592. "result": hisFundSettleListResult,
  7593. })
  7594. return
  7595. }
  7596. }
  7597. //func (c *HisApiController) GetBatchSettleList() {
  7598. // orders, _ := service.GetAllHisOrder(10106)
  7599. // for _, item := range orders {
  7600. // order_id := item.ID
  7601. // order, _ := service.GetHisOrderByIDTwo(order_id)
  7602. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  7603. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7604. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  7605. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  7606. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  7607. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7608. //
  7609. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7610. //
  7611. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7612. //
  7613. // if order.ID == 0 {
  7614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7615. // return
  7616. // }
  7617. // if his.BalanceAccountsType == 2 {
  7618. // continue
  7619. // }
  7620. // struct4101 := service.Struct4101{
  7621. // PsnNo: order.PsnNo,
  7622. // MdtrtId: order.MdtrtId,
  7623. // SetlId: order.SetlId,
  7624. // PsnName: order.PsnName,
  7625. // Gend: order.Gend,
  7626. // Brdy: his.Brdy,
  7627. // Age: his.Age,
  7628. // Naty: order.Naty,
  7629. // PatnCertType: "01",
  7630. // Certno: order.Certno,
  7631. // Prfs: "90",
  7632. // ConerName: roles[0].UserName,
  7633. // PatnRlts: "99",
  7634. // ConerAddr: miConfig.OrgName,
  7635. // ConerTel: admin.Mobile,
  7636. // HiType: order.Insutype,
  7637. // Insuplc: his.InsuplcAdmdvs,
  7638. // MaindiagFlag: "1",
  7639. // BillCode: order.SetlId,
  7640. // BillNo: order.SetlId,
  7641. // BizSn: order.Number,
  7642. // PsnSelfPay: order.PsnPartAmt,
  7643. // PsnOwnPay: order.PsnPartAmt,
  7644. // AcctPay: order.AcctPay,
  7645. // PsnCashpay: order.PsnCashPay,
  7646. // HiPaymtd: "1",
  7647. // Hsorg: his.InsuplcAdmdvs,
  7648. // HsorgOpter: his.InsuplcAdmdvs,
  7649. // MedinsFillPsn: curRoles.UserName,
  7650. // MedinsFillDept: depart.Name,
  7651. // IptMedType: "2",
  7652. // }
  7653. // struct4101.SetlBegnDate = order.SetlTime
  7654. // struct4101.SetlEndDate = order.SetlTime
  7655. // //if order.SettleType == 1 {
  7656. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  7657. // // dateStr := t.Format("2006-01-02")
  7658. // // struct4101.SetlBegnDate = dateStr
  7659. // // struct4101.SetlEndDate = dateStr
  7660. // //} else {
  7661. // // t := time.Unix(int64(order.SettleStartTime), 0)
  7662. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  7663. // // dateStartStr := t.Format("2006-01-02")
  7664. // // dateEndStr := t2.Format("2006-01-02")
  7665. // // struct4101.SetlBegnDate = dateStartStr
  7666. // // struct4101.SetlEndDate = dateEndStr
  7667. // //}
  7668. //
  7669. // var rf []CustomFundPay
  7670. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  7671. //
  7672. // var tempFunPays []service.CustomStruct
  7673. // var tempFunPay610100 service.CustomStruct
  7674. //
  7675. // for _, item := range rf {
  7676. // if item.FundPayType == "610100" {
  7677. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  7678. // tempFunPay610100.FundPayType = item.FundPayType
  7679. // } else {
  7680. // var tempFunPay service.CustomStruct
  7681. // tempFunPay.FundPayamt = item.FundPayamt
  7682. // tempFunPay.FundPayType = item.FundPayType
  7683. // tempFunPays = append(tempFunPays, tempFunPay)
  7684. // }
  7685. // }
  7686. // tempFunPays = append(tempFunPays, tempFunPay610100)
  7687. // struct4101.CustomStruct = tempFunPays
  7688. //
  7689. // var tempDiaginfos []service.DiaginfoStructTwo
  7690. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  7691. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  7692. //
  7693. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7694. // var config []*models.HisXtDiagnoseConfig
  7695. // for _, item := range diagnosis_ids {
  7696. // id, _ := strconv.ParseInt(item, 10, 64)
  7697. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  7698. // config = append(config, &diagnosisConfig)
  7699. // }
  7700. //
  7701. // for index, item := range config {
  7702. // if index == 0 {
  7703. // var tempDiaginfo service.DiaginfoStructTwo
  7704. // tempDiaginfo.DiagCode = item.CountryCode
  7705. // tempDiaginfo.DiagName = item.CountryContentName
  7706. // tempDiaginfo.DiagType = "1"
  7707. // tempDiaginfo.MaindiagFlag = "1"
  7708. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7709. // } else {
  7710. //
  7711. // var tempDiaginfo service.DiaginfoStructTwo
  7712. // tempDiaginfo.DiagCode = item.CountryCode
  7713. // tempDiaginfo.DiagName = item.CountryContentName
  7714. // tempDiaginfo.DiagType = "2"
  7715. // tempDiaginfo.MaindiagFlag = "0"
  7716. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7717. // }
  7718. // }
  7719. // struct4101.Diseinfo = tempDiaginfos
  7720. //
  7721. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  7722. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  7723. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  7724. // tempOpspdiseinfo2.OprnOprtCode = ""
  7725. // tempOpspdiseinfo2.OprnOprtName = ""
  7726. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  7727. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  7728. //
  7729. // var iteminfo service.IteminfoStruct
  7730. //
  7731. // var bedCostTotal float64 = 0 //床位总费
  7732. // var bedCostSelfTotal float64 = 0 //床位自费
  7733. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7734. //
  7735. // var examineCostTotal float64 = 0 //诊查总费
  7736. // var examineCostSelfTotal float64 = 0 //诊查自费
  7737. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  7738. //
  7739. // var nursingCostTotal float64 = 0 //护理总费
  7740. // var nursingCostSelfTotal float64 = 0 //护理自费
  7741. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  7742. //
  7743. // var chineseMedicineCostTotal float64 = 0 //中成药
  7744. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  7745. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  7746. //
  7747. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  7748. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  7749. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  7750. //
  7751. // var registerCostTotal float64 = 0 //一般诊疗费
  7752. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  7753. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  7754. //
  7755. // var operationCostTotal float64 = 0 //手术费
  7756. // var operationCostSelfTotal float64 = 0 //手术费
  7757. // var operationCostPartSelfTotal float64 = 0 //手术费
  7758. //
  7759. // var otherCostTotal float64 = 0 //其他费用
  7760. // var otherCostSelfTotal float64 = 0 //其他费用
  7761. // var otherCostPartSelfTotal float64 = 0 //其他费用
  7762. //
  7763. // var materialCostTotal float64 = 0 //材料费
  7764. // var materialCostSelfTotal float64 = 0 //材料费
  7765. // var materialCostPartSelfTotal float64 = 0 //材料费
  7766. //
  7767. // var westernMedicineCostTotal float64 = 0 //西药费
  7768. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  7769. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7770. //
  7771. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7772. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7773. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7774. //
  7775. // var checkCostTotal float64 = 0 //检查费
  7776. // var checkCostSelfTotal float64 = 0 //检查费
  7777. // var checkCostPartSelfTotal float64 = 0 //检查费
  7778. //
  7779. // var laboratoryCostTotal float64 = 0 //化验费
  7780. // var laboratoryCostSelfTotal float64 = 0 //化验费
  7781. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7782. //
  7783. // var treatCostTotal float64 = 0 //治疗费用
  7784. // var treatCostSelfTotal float64 = 0 //治疗费用
  7785. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  7786. //
  7787. // decimal.DivisionPrecision = 2
  7788. //
  7789. // var bed_fulamt_ownpay_amt float64 = 0
  7790. //
  7791. // var examine_fulamt_ownpay_amt float64 = 0
  7792. //
  7793. // var nursing_fulamt_ownpay_amt float64 = 0
  7794. //
  7795. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  7796. //
  7797. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  7798. //
  7799. // var register_fulamt_ownpay_amt float64 = 0
  7800. //
  7801. // var operation_fulamt_ownpay_amt float64 = 0
  7802. // var other_fulamt_ownpay_amt float64 = 0
  7803. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  7804. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  7805. // var check_fulamt_ownpay_amt float64 = 0
  7806. // var material_fulamt_ownpay_amt float64 = 0
  7807. // var laboratory_fulamt_ownpay_amt float64 = 0
  7808. // var treat_fulamt_ownpay_amt float64 = 0
  7809. //
  7810. // var bed_claa_sunmfee float64 = 0
  7811. // var bed_clab_amt float64 = 0
  7812. // var bed_other_amt float64 = 0
  7813. //
  7814. // var examine_claa_sunmfee float64 = 0
  7815. // var examine_clab_amt float64 = 0
  7816. // var examine_other_amt float64 = 0
  7817. //
  7818. // var nursing_claa_sunmfee float64 = 0
  7819. // var nursing_clab_amt float64 = 0
  7820. // var nursing_other_amt float64 = 0
  7821. //
  7822. // var chinese_medicine_claa_sunmfee float64 = 0
  7823. // var chinese_medicine_clab_amt float64 = 0
  7824. // var chinese_medicine_other_amt float64 = 0
  7825. //
  7826. // var commonly_treatment_claa_sunmfee float64 = 0
  7827. // var commonly_treatment_clab_amt float64 = 0
  7828. // var commonly_treatment_other_amt float64 = 0
  7829. //
  7830. // var operation_claa_sunmfee float64 = 0
  7831. // var operation_clab_amt float64 = 0
  7832. // var operation_other_amt float64 = 0
  7833. //
  7834. // var other_claa_sunmfee float64 = 0
  7835. // var other_clab_amt float64 = 0
  7836. // var other_other_amt float64 = 0
  7837. //
  7838. // var westernMedicine_claa_sunmfee float64 = 0
  7839. // var westernMedicine_clab_amt float64 = 0
  7840. // var westernMedicine_other_amt float64 = 0
  7841. //
  7842. // var chineseTraditional_claa_sunmfee float64 = 0
  7843. // var chineseTraditional_clab_amt float64 = 0
  7844. // var chineseTraditional_other_amt float64 = 0
  7845. //
  7846. // var check_claa_sunmfee float64 = 0
  7847. // var check_clab_amt float64 = 0
  7848. // var check_other_amt float64 = 0
  7849. //
  7850. // var material_claa_sunmfee float64 = 0
  7851. // var material_clab_amt float64 = 0
  7852. // var material_other_amt float64 = 0
  7853. //
  7854. // var laboratory_claa_sunmfee float64 = 0
  7855. // var laboratory_clab_amt float64 = 0
  7856. // var laboratory_other_amt float64 = 0
  7857. //
  7858. // var treat_claa_sunmfee float64 = 0
  7859. // var treat_clab_amt float64 = 0
  7860. // var treat_other_amt float64 = 0
  7861. //
  7862. // var register_claa_sunmfee float64 = 0
  7863. // var register_clab_amt float64 = 0
  7864. // var register_other_amt float64 = 0
  7865. //
  7866. // for _, item := range order.HisOrderInfo {
  7867. // if item.MedChrgitmType == "01" { //床位费
  7868. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7869. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7870. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7871. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7872. // if item.ChrgitmLv == "1" {
  7873. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7874. // }
  7875. // if item.ChrgitmLv == "2" {
  7876. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7877. //
  7878. // }
  7879. // if item.ChrgitmLv == "3" {
  7880. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7881. // }
  7882. //
  7883. // }
  7884. //
  7885. // if item.MedChrgitmType == "02" { //诊查
  7886. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7887. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7888. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7889. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7890. // if item.ChrgitmLv == "1" {
  7891. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7892. // }
  7893. // if item.ChrgitmLv == "2" {
  7894. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7895. //
  7896. // }
  7897. // if item.ChrgitmLv == "3" {
  7898. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7899. // }
  7900. //
  7901. // }
  7902. //
  7903. // if item.MedChrgitmType == "03" { //检查费
  7904. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7905. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7906. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7907. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7908. // if item.ChrgitmLv == "1" {
  7909. //
  7910. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7911. //
  7912. // }
  7913. // if item.ChrgitmLv == "2" {
  7914. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7915. //
  7916. // }
  7917. // if item.ChrgitmLv == "3" {
  7918. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7919. // }
  7920. // }
  7921. //
  7922. // if item.MedChrgitmType == "04" { //化验费
  7923. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7924. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7925. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7926. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7927. // if item.ChrgitmLv == "1" {
  7928. //
  7929. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7930. //
  7931. // }
  7932. // if item.ChrgitmLv == "2" {
  7933. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7934. //
  7935. // }
  7936. // if item.ChrgitmLv == "3" {
  7937. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7938. // }
  7939. // }
  7940. //
  7941. // if item.MedChrgitmType == "05" { //治疗费
  7942. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7943. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7944. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7945. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7946. // if item.ChrgitmLv == "1" {
  7947. //
  7948. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7949. //
  7950. // }
  7951. // if item.ChrgitmLv == "2" {
  7952. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7953. //
  7954. // }
  7955. // if item.ChrgitmLv == "3" {
  7956. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7957. // }
  7958. // }
  7959. //
  7960. // if item.MedChrgitmType == "06" { //手术费
  7961. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7962. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7963. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7964. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7965. //
  7966. // if item.ChrgitmLv == "1" {
  7967. //
  7968. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7969. //
  7970. // }
  7971. // if item.ChrgitmLv == "2" {
  7972. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7973. //
  7974. // }
  7975. // if item.ChrgitmLv == "3" {
  7976. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7977. // }
  7978. // }
  7979. //
  7980. // if item.MedChrgitmType == "07" { //手术费
  7981. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7982. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7983. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7984. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7985. //
  7986. // if item.ChrgitmLv == "1" {
  7987. //
  7988. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7989. //
  7990. // }
  7991. // if item.ChrgitmLv == "2" {
  7992. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7993. //
  7994. // }
  7995. // if item.ChrgitmLv == "3" {
  7996. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7997. // }
  7998. // }
  7999. //
  8000. // if item.MedChrgitmType == "08" { //材料费
  8001. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8002. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8003. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8004. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8005. // if item.ChrgitmLv == "1" {
  8006. //
  8007. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8008. //
  8009. // }
  8010. // if item.ChrgitmLv == "2" {
  8011. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8012. //
  8013. // }
  8014. // if item.ChrgitmLv == "3" {
  8015. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8016. // }
  8017. // }
  8018. // if item.MedChrgitmType == "09" { //西药费
  8019. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8020. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8021. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8022. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8023. // if item.ChrgitmLv == "1" {
  8024. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8025. // }
  8026. // if item.ChrgitmLv == "2" {
  8027. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8028. // }
  8029. // if item.ChrgitmLv == "3" {
  8030. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8031. // }
  8032. // }
  8033. // if item.MedChrgitmType == "10" { //中药饮片
  8034. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8035. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8036. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8037. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8038. // if item.ChrgitmLv == "1" {
  8039. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8040. // }
  8041. // if item.ChrgitmLv == "2" {
  8042. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8043. // }
  8044. // if item.ChrgitmLv == "3" {
  8045. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8046. // }
  8047. // }
  8048. //
  8049. // if item.MedChrgitmType == "11" { //中成费
  8050. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8051. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8052. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8053. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8054. // if item.ChrgitmLv == "1" {
  8055. //
  8056. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8057. //
  8058. // }
  8059. // if item.ChrgitmLv == "2" {
  8060. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8061. //
  8062. // }
  8063. // if item.ChrgitmLv == "3" {
  8064. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8065. // }
  8066. // }
  8067. //
  8068. // if item.MedChrgitmType == "12" { //中成费
  8069. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8070. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8071. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8072. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8073. // if item.ChrgitmLv == "1" {
  8074. //
  8075. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8076. //
  8077. // }
  8078. // if item.ChrgitmLv == "2" {
  8079. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8080. //
  8081. // }
  8082. // if item.ChrgitmLv == "3" {
  8083. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8084. // }
  8085. // }
  8086. //
  8087. // if item.MedChrgitmType == "13" { //中成费
  8088. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8089. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8090. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8091. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8092. // if item.ChrgitmLv == "1" {
  8093. //
  8094. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8095. //
  8096. // }
  8097. // if item.ChrgitmLv == "2" {
  8098. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8099. //
  8100. // }
  8101. // if item.ChrgitmLv == "3" {
  8102. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8103. // }
  8104. // }
  8105. //
  8106. // if item.MedChrgitmType == "14" { //其他费
  8107. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8108. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8109. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8110. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8111. // if item.ChrgitmLv == "1" {
  8112. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8113. //
  8114. // }
  8115. // if item.ChrgitmLv == "2" {
  8116. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8117. //
  8118. // }
  8119. // if item.ChrgitmLv == "3" {
  8120. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8121. // }
  8122. // }
  8123. //
  8124. // }
  8125. //
  8126. // var iteminfoStructs []service.IteminfoStruct
  8127. //
  8128. // if bedCostTotal != 0 {
  8129. // iteminfo.MedChrgitm = "01"
  8130. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  8131. // iteminfo.Amt = bedCostTotal
  8132. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  8133. // iteminfo.ClabAmt = bed_clab_amt
  8134. // iteminfo.OthAmt = bed_other_amt
  8135. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8136. // }
  8137. //
  8138. // if examineCostTotal != 0 {
  8139. // iteminfo.MedChrgitm = "02"
  8140. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  8141. // iteminfo.Amt = examineCostTotal
  8142. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  8143. // iteminfo.ClabAmt = examine_clab_amt
  8144. // iteminfo.OthAmt = examine_other_amt
  8145. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8146. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8147. // }
  8148. //
  8149. // if checkCostTotal != 0 {
  8150. // iteminfo.MedChrgitm = "03"
  8151. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  8152. // iteminfo.Amt = checkCostTotal
  8153. // iteminfo.ClaaSumfee = check_claa_sunmfee
  8154. // iteminfo.ClabAmt = check_clab_amt
  8155. // iteminfo.OthAmt = check_other_amt
  8156. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8157. //
  8158. // }
  8159. //
  8160. // if laboratoryCostTotal != 0 {
  8161. // iteminfo.MedChrgitm = "04"
  8162. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  8163. // iteminfo.Amt = laboratoryCostTotal
  8164. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  8165. // iteminfo.ClabAmt = laboratory_clab_amt
  8166. // iteminfo.OthAmt = laboratory_other_amt
  8167. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8168. //
  8169. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8170. //
  8171. // }
  8172. //
  8173. // if treatCostTotal != 0 {
  8174. // iteminfo.MedChrgitm = "05"
  8175. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  8176. // iteminfo.Amt = treatCostTotal
  8177. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  8178. // iteminfo.ClabAmt = treat_clab_amt
  8179. // iteminfo.OthAmt = treat_other_amt
  8180. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8181. // //(struct4101.IteminfoStruct, iteminfo)
  8182. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8183. // }
  8184. //
  8185. // if operationCostTotal != 0 {
  8186. // iteminfo.MedChrgitm = "06"
  8187. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  8188. // iteminfo.Amt = operationCostTotal
  8189. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  8190. // iteminfo.ClabAmt = operation_clab_amt
  8191. // iteminfo.OthAmt = operation_other_amt
  8192. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8193. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8194. // }
  8195. //
  8196. // if nursingCostTotal != 0 {
  8197. // iteminfo.MedChrgitm = "07"
  8198. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  8199. // iteminfo.Amt = nursingCostTotal
  8200. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  8201. // iteminfo.ClabAmt = nursing_clab_amt
  8202. // iteminfo.OthAmt = nursing_other_amt
  8203. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8204. // }
  8205. //
  8206. // if materialCostTotal != 0 {
  8207. // iteminfo.MedChrgitm = "08"
  8208. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  8209. // iteminfo.Amt = materialCostTotal
  8210. // iteminfo.ClaaSumfee = material_claa_sunmfee
  8211. // iteminfo.ClabAmt = material_clab_amt
  8212. // iteminfo.OthAmt = material_other_amt
  8213. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8214. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8215. // }
  8216. //
  8217. // if westernMedicineCostTotal != 0 {
  8218. // iteminfo.MedChrgitm = "09"
  8219. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  8220. // iteminfo.Amt = westernMedicineCostTotal
  8221. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  8222. // iteminfo.ClabAmt = westernMedicine_clab_amt
  8223. // iteminfo.OthAmt = westernMedicine_other_amt
  8224. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8225. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8226. //
  8227. // }
  8228. //
  8229. // if chineseMedicineCostTotal != 0 {
  8230. // iteminfo.MedChrgitm = "10"
  8231. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  8232. // iteminfo.Amt = chineseMedicineCostTotal
  8233. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  8234. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  8235. // iteminfo.OthAmt = chinese_medicine_other_amt
  8236. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8237. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8238. //
  8239. // }
  8240. //
  8241. // if chineseTraditionalMedicineCostTotal != 0 {
  8242. // iteminfo.MedChrgitm = "11"
  8243. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  8244. // iteminfo.Amt = westernMedicineCostTotal
  8245. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  8246. // iteminfo.ClabAmt = westernMedicine_clab_amt
  8247. // iteminfo.OthAmt = westernMedicine_other_amt
  8248. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8249. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8250. //
  8251. // }
  8252. //
  8253. // if commonlyTreatmentCostTotal != 0 {
  8254. // iteminfo.MedChrgitm = "12"
  8255. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  8256. // iteminfo.Amt = commonlyTreatmentCostTotal
  8257. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  8258. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  8259. // iteminfo.OthAmt = commonly_treatment_other_amt
  8260. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8261. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8262. //
  8263. // }
  8264. //
  8265. // if registerCostTotal != 0 {
  8266. // iteminfo.MedChrgitm = "13"
  8267. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  8268. // iteminfo.Amt = registerCostTotal
  8269. // iteminfo.ClaaSumfee = register_claa_sunmfee
  8270. // iteminfo.ClabAmt = register_clab_amt
  8271. // iteminfo.OthAmt = register_other_amt
  8272. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8273. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8274. //
  8275. // }
  8276. //
  8277. // if otherCostTotal != 0 {
  8278. // iteminfo.MedChrgitm = "14"
  8279. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  8280. // iteminfo.Amt = otherCostTotal
  8281. // iteminfo.ClaaSumfee = other_claa_sunmfee
  8282. // iteminfo.ClabAmt = other_clab_amt
  8283. // iteminfo.OthAmt = other_other_amt
  8284. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8285. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8286. //
  8287. // }
  8288. // struct4101.IteminfoStruct = iteminfoStructs
  8289. // time_arr := strings.Split(order.SetlTime, " ")
  8290. // struct4101.AdmTime = time_arr[0]
  8291. // struct4101.AdmEndTime = time_arr[0]
  8292. //
  8293. // struct4101.DoctorName = doctor.UserName
  8294. // struct4101.DoctorCode = doctor.DoctorNumber
  8295. //
  8296. // struct4101.Ntly = "中国"
  8297. // struct4101.AdmCaty = "A03.06"
  8298. // var res ResultSeventeen
  8299. // if miConfig.MdtrtareaAdmvs == "421300" {
  8300. // data := make(map[string]interface{})
  8301. // data["struct4101"] = struct4101
  8302. // data["secret_key"] = miConfig.SecretKey
  8303. // data["org_name"] = miConfig.OrgName
  8304. // data["opera"] = curRoles.UserName
  8305. // data["code"] = miConfig.Code
  8306. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  8307. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8308. //
  8309. // client := &http.Client{}
  8310. // bytesData, _ := json.Marshal(data)
  8311. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  8312. // resp, _ := client.Do(req)
  8313. // defer resp.Body.Close()
  8314. // body, ioErr := ioutil.ReadAll(resp.Body)
  8315. // if ioErr != nil {
  8316. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8317. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8318. // return
  8319. // }
  8320. // var respJSON map[string]interface{}
  8321. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8322. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8323. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8324. // return
  8325. // }
  8326. //
  8327. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8328. // userJSONBytes, _ := json.Marshal(respJSON)
  8329. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8330. // utils.ErrorLog("解析失败:%v", err)
  8331. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8332. // adminUser := c.GetAdminUserInfo()
  8333. // errlog := &models.HisOrderError{
  8334. // UserOrgId: adminUser.CurrentOrgId,
  8335. // Ctime: time.Now().Unix(),
  8336. // Mtime: time.Now().Unix(),
  8337. // ErrMsg: res.ErrMsg + "解析失败",
  8338. // Status: 1,
  8339. // PatientId: order_id,
  8340. // Stage: 10088,
  8341. // }
  8342. // service.CreateErrMsgLog(errlog)
  8343. // continue
  8344. // }
  8345. //
  8346. // } else {
  8347. // result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  8348. // fmt.Println(result)
  8349. //
  8350. // var dat map[string]interface{}
  8351. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8352. // fmt.Println(dat)
  8353. // } else {
  8354. // fmt.Println(err)
  8355. // }
  8356. // userJSONBytes, _ := json.Marshal(dat)
  8357. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8358. // utils.ErrorLog("解析失败:%v", err)
  8359. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8360. // adminUser := c.GetAdminUserInfo()
  8361. // errlog := &models.HisOrderError{
  8362. // UserOrgId: adminUser.CurrentOrgId,
  8363. // Ctime: time.Now().Unix(),
  8364. // Mtime: time.Now().Unix(),
  8365. // ErrMsg: res.ErrMsg + "解析失败",
  8366. // Status: 1,
  8367. // PatientId: order_id,
  8368. // Stage: 10106,
  8369. // }
  8370. // service.CreateErrMsgLog(errlog)
  8371. // continue
  8372. // }
  8373. // }
  8374. //
  8375. // if res.Infcode != 0 {
  8376. // adminUser := c.GetAdminUserInfo()
  8377. // errlog := &models.HisOrderError{
  8378. // UserOrgId: adminUser.CurrentOrgId,
  8379. // Ctime: time.Now().Unix(),
  8380. // Mtime: time.Now().Unix(),
  8381. // ErrMsg: res.ErrMsg,
  8382. // Status: 1,
  8383. // PatientId: order_id,
  8384. // Stage: 10106,
  8385. // }
  8386. // service.CreateErrMsgLog(errlog)
  8387. // continue
  8388. // } else {
  8389. // hisFundSettleListResult := &models.HisFundSettleListResult{
  8390. // Number: res.Output.SetlListId,
  8391. // Status: 1,
  8392. // Ctime: time.Now().Unix(),
  8393. // Mtime: time.Now().Unix(),
  8394. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8395. // IsUpload: 1,
  8396. // OrderId: order_id,
  8397. // }
  8398. // service.CreateUploadRecord(hisFundSettleListResult)
  8399. // continue
  8400. // }
  8401. // }
  8402. //}
  8403. func (c *HisApiController) GetOrgInfo() {
  8404. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  8405. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  8406. }
  8407. func (c *HisApiController) GetHisPatientInfo() {
  8408. medical_insurance_card := c.GetString("medical_insurance_card")
  8409. id_card_type, _ := c.GetInt64("id_card_type")
  8410. id_card := c.GetString("id_card")
  8411. adminInfo := c.GetAdminUserInfo()
  8412. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8413. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8414. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  8415. IdCardNo := ""
  8416. if id_card_type == 1 {
  8417. IdCardNo = medical_insurance_card
  8418. } else if id_card_type == 2 {
  8419. IdCardNo = id_card
  8420. }
  8421. if config.IsOpen == 1 {
  8422. 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
  8423. resp, requestErr := http.Get(api)
  8424. if requestErr != nil {
  8425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8426. return
  8427. }
  8428. defer resp.Body.Close()
  8429. body, ioErr := ioutil.ReadAll(resp.Body)
  8430. if ioErr != nil {
  8431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8433. return
  8434. }
  8435. var respJSON map[string]interface{}
  8436. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8439. return
  8440. }
  8441. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8442. userJSONBytes, _ := json.Marshal(userJSON)
  8443. var res ResultTwo
  8444. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8445. utils.ErrorLog("解析失败:%v", err)
  8446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8447. return
  8448. }
  8449. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8450. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8451. infoStr := string(Iinfos)
  8452. idetinfoStr := string(Idetinfos)
  8453. if res.Infcode == 0 {
  8454. his := models.VMHisPatient{
  8455. Status: 1,
  8456. Ctime: time.Now().Unix(),
  8457. Mtime: time.Now().Unix(),
  8458. PsnNo: res.Output.Baseinfo.PsnNo,
  8459. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8460. Certno: res.Output.Baseinfo.Certno,
  8461. PsnName: res.Output.Baseinfo.PsnName,
  8462. Gend: res.Output.Baseinfo.Gend,
  8463. Naty: res.Output.Baseinfo.Naty,
  8464. Brdy: res.Output.Baseinfo.Brdy,
  8465. Age: res.Output.Baseinfo.Age,
  8466. Iinfo: infoStr,
  8467. Idetinfo: idetinfoStr,
  8468. UserOrgId: adminInfo.CurrentOrgId,
  8469. IsReturn: 1,
  8470. IdCardType: id_card_type,
  8471. }
  8472. c.ServeSuccessJSON(map[string]interface{}{
  8473. "info": his,
  8474. })
  8475. } else {
  8476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8477. return
  8478. }
  8479. }
  8480. }
  8481. //func GetBasBaseInfo() (jsonStr string, err error) {
  8482. //
  8483. // handle := syscall.NewLazyDLL("SSCard.dll")
  8484. // add := handle.NewProc("ReadCardBas")
  8485. // str := make([]byte, 1024)
  8486. // str1 := make([]byte, 1024)
  8487. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  8488. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  8489. //
  8490. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  8491. //
  8492. // fmt.Println("> Add(4,5)的结果为:", ret)
  8493. // handle.Release()
  8494. //
  8495. // return "", nil
  8496. //
  8497. //}
  8498. //func GetQRBaseInfo() (jsonStr string, err error) {
  8499. // handle := syscall.LoadDLL("SSCard.dll")
  8500. // ReadCardBas := handle.FindProc("GetQRBase")
  8501. //
  8502. // str := make([]byte, 256)
  8503. // str1 := make([]byte, 256)
  8504. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  8505. //
  8506. // fmt.Println(string(str))
  8507. // fmt.Println(r)
  8508. // return string(str), nil
  8509. //}
  8510. //func CardInit() int {
  8511. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  8512. // add := DllTestDef.MustFindProc("Init")
  8513. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  8514. // if err != nil {
  8515. // fmt.Println("SSCard的运算结果为:", ret)
  8516. // }
  8517. // result := int(ret)
  8518. // return result
  8519. //}
  8520. //func CardInit() int {
  8521. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  8522. // if err != nil {
  8523. // fmt.Println("SSCard的运算结果为:", ret)
  8524. // }
  8525. // fmt.Println(err)
  8526. // result := int(ret)
  8527. // return result
  8528. //}
  8529. func IntPtr(n int) uintptr {
  8530. return uintptr(n)
  8531. }
  8532. func StrPtr(s string) uintptr {
  8533. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  8534. }
  8535. type Result2001 struct {
  8536. Cainfo interface{} `json:"cainfo"`
  8537. ErrMsg string `json:"err_msg"`
  8538. InfRefmsgid string `json:"inf_refmsgid"`
  8539. Infcode int64 `json:"infcode"`
  8540. Output struct {
  8541. Trtinfo struct {
  8542. PsnNo string `json:"psn_no"`
  8543. TrtChkType string `json:"trt_chk_type"`
  8544. FundPayType string `json:"fund_pay_type"`
  8545. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  8546. Begndate string `json:"begndate"`
  8547. Enddate string `json:"enddate"`
  8548. TrtChkRslt string `json:"trt_chk_rslt"`
  8549. } `json:"trtinfo"`
  8550. } `json:"output"`
  8551. RefmsgTime string `json:"refmsg_time"`
  8552. RespondTime string `json:"respond_time"`
  8553. Signtype interface{} `json:"signtype"`
  8554. WarnMsg interface{} `json:"warn_msg"`
  8555. }
  8556. type Result2001Org10265 struct {
  8557. Cainfo interface{} `json:"cainfo"`
  8558. ErrMsg string `json:"err_msg"`
  8559. InfRefmsgid string `json:"inf_refmsgid"`
  8560. Infcode string `json:"infcode"`
  8561. Output struct {
  8562. Trtinfo struct {
  8563. PsnNo string `json:"psn_no"`
  8564. TrtChkType string `json:"trt_chk_type"`
  8565. FundPayType string `json:"fund_pay_type"`
  8566. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  8567. Begndate string `json:"begndate"`
  8568. Enddate string `json:"enddate"`
  8569. TrtChkRslt string `json:"trt_chk_rslt"`
  8570. } `json:"trtinfo"`
  8571. } `json:"output"`
  8572. RefmsgTime string `json:"refmsg_time"`
  8573. RespondTime string `json:"respond_time"`
  8574. Signtype interface{} `json:"signtype"`
  8575. WarnMsg interface{} `json:"warn_msg"`
  8576. }
  8577. type ResultTwo struct {
  8578. ErrMsg string `json:"err_msg"`
  8579. InfRefmsgid string `json:"inf_refmsgid"`
  8580. Infcode int64 `json:"infcode"`
  8581. Output struct {
  8582. Baseinfo struct {
  8583. Age float64 `json:"age"`
  8584. Brdy string `json:"brdy"`
  8585. Certno string `json:"certno"`
  8586. Gend string `json:"gend"`
  8587. Naty string `json:"naty"`
  8588. PsnCertType string `json:"psn_cert_type"`
  8589. PsnName string `json:"psn_name"`
  8590. PsnNo string `json:"psn_no"`
  8591. } `json:"baseinfo"`
  8592. Idetinfo []interface{} `json:"idetinfo"`
  8593. Iinfo []struct {
  8594. Balc float64 `json:"balc"`
  8595. CvlservFlag string `json:"cvlserv_flag"`
  8596. EmpName string `json:"emp_name"`
  8597. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  8598. Insutype string `json:"insutype"`
  8599. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  8600. PausInsuDate string `json:"paus_insu_date"`
  8601. PsnInsuDate string `json:"psn_insu_date"`
  8602. PsnInsuStas string `json:"psn_insu_stas"`
  8603. PsnType string `json:"psn_type"`
  8604. } `json:"insuinfo"`
  8605. } `json:"output"`
  8606. RefmsgTime string `json:"refmsg_time"`
  8607. RespondTime string `json:"respond_time"`
  8608. Signtype interface{} `json:"signtype"`
  8609. WarnInfo interface{} `json:"warn_info"`
  8610. }
  8611. type ResultTwo10265 struct {
  8612. ErrMsg string `json:"err_msg"`
  8613. InfRefmsgid string `json:"inf_refmsgid"`
  8614. Infcode string `json:"infcode"`
  8615. Output struct {
  8616. Baseinfo struct {
  8617. Age float64 `json:"age"`
  8618. Brdy string `json:"brdy"`
  8619. Certno string `json:"certno"`
  8620. Gend string `json:"gend"`
  8621. Naty string `json:"naty"`
  8622. PsnCertType string `json:"psn_cert_type"`
  8623. PsnName string `json:"psn_name"`
  8624. PsnNo string `json:"psn_no"`
  8625. } `json:"baseinfo"`
  8626. Idetinfo []interface{} `json:"idetinfo"`
  8627. Iinfo []struct {
  8628. Balc float64 `json:"balc"`
  8629. CvlservFlag string `json:"cvlserv_flag"`
  8630. EmpName string `json:"emp_name"`
  8631. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  8632. Insutype string `json:"insutype"`
  8633. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  8634. PausInsuDate string `json:"paus_insu_date"`
  8635. PsnInsuDate string `json:"psn_insu_date"`
  8636. PsnInsuStas string `json:"psn_insu_stas"`
  8637. PsnType string `json:"psn_type"`
  8638. } `json:"insuinfo"`
  8639. } `json:"output"`
  8640. RefmsgTime string `json:"refmsg_time"`
  8641. RespondTime string `json:"respond_time"`
  8642. Signtype interface{} `json:"signtype"`
  8643. WarnInfo interface{} `json:"warn_info"`
  8644. }
  8645. type ResultThree struct {
  8646. Cainfo interface{} `json:"cainfo"`
  8647. ErrMsg string `json:"err_msg"`
  8648. InfRefmsgid string `json:"inf_refmsgid"`
  8649. Infcode int64 `json:"infcode"`
  8650. Output struct {
  8651. Data struct {
  8652. IptOtpNo string `json:"ipt_otp_no"`
  8653. MdtrtID string `json:"mdtrt_id"`
  8654. PsnNo string `json:"psn_no"`
  8655. } `json:"data"`
  8656. } `json:"output"`
  8657. RefmsgTime string `json:"refmsg_time"`
  8658. RespondTime string `json:"respond_time"`
  8659. Signtype interface{} `json:"signtype"`
  8660. WarnMsg interface{} `json:"warn_msg"`
  8661. }
  8662. type ResultThree10265 struct {
  8663. Cainfo interface{} `json:"cainfo"`
  8664. ErrMsg string `json:"err_msg"`
  8665. InfRefmsgid string `json:"inf_refmsgid"`
  8666. Infcode string `json:"infcode"`
  8667. Output struct {
  8668. Data struct {
  8669. IptOtpNo string `json:"ipt_otp_no"`
  8670. MdtrtID string `json:"mdtrt_id"`
  8671. PsnNo string `json:"psn_no"`
  8672. } `json:"data"`
  8673. } `json:"output"`
  8674. RefmsgTime string `json:"refmsg_time"`
  8675. RespondTime string `json:"respond_time"`
  8676. Signtype interface{} `json:"signtype"`
  8677. WarnMsg interface{} `json:"warn_msg"`
  8678. }
  8679. type ResultFour struct {
  8680. Cainfo string `json:"cainfo"`
  8681. ErrMsg string `json:"err_msg"`
  8682. InfRefmsgid string `json:"inf_refmsgid"`
  8683. Infcode int64 `json:"infcode"`
  8684. Output struct {
  8685. Result []struct {
  8686. BasMednFlag string `json:"bas_medn_flag"`
  8687. ChldMedcFlag string `json:"chld_medc_flag"`
  8688. ChrgitmLv string `json:"chrgitm_lv"`
  8689. Cnt float64 `json:"cnt"`
  8690. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  8691. DrtReimFlag string `json:"drt_reim_flag"`
  8692. FeedetlSn string `json:"feedetl_sn"`
  8693. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8694. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  8695. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8696. ListSpItemFlag string `json:"list_sp_item_flag"`
  8697. LmtUsedFlag string `json:"lmt_used_flag"`
  8698. MedChrgitmType string `json:"med_chrgitm_type"`
  8699. Memo string `json:"memo"`
  8700. OverlmtAmt float64 `json:"overlmt_amt"`
  8701. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8702. Pric float64 `json:"pric"`
  8703. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  8704. SelfpayProp float64 `json:"selfpay_prop"`
  8705. } `json:"result"`
  8706. } `json:"output"`
  8707. RefmsgTime string `json:"refmsg_time"`
  8708. RespondTime string `json:"respond_time"`
  8709. Signtype string `json:"signtype"`
  8710. WarnMsg string `json:"warn_msg"`
  8711. }
  8712. type ResultFour10265 struct {
  8713. Cainfo string `json:"cainfo"`
  8714. ErrMsg string `json:"err_msg"`
  8715. InfRefmsgid string `json:"inf_refmsgid"`
  8716. Infcode string `json:"infcode"`
  8717. Output struct {
  8718. Result []struct {
  8719. BasMednFlag string `json:"bas_medn_flag"`
  8720. ChldMedcFlag string `json:"chld_medc_flag"`
  8721. ChrgitmLv string `json:"chrgitm_lv"`
  8722. Cnt float64 `json:"cnt"`
  8723. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  8724. DrtReimFlag string `json:"drt_reim_flag"`
  8725. FeedetlSn string `json:"feedetl_sn"`
  8726. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8727. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  8728. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8729. ListSpItemFlag string `json:"list_sp_item_flag"`
  8730. LmtUsedFlag string `json:"lmt_used_flag"`
  8731. MedChrgitmType string `json:"med_chrgitm_type"`
  8732. Memo string `json:"memo"`
  8733. OverlmtAmt float64 `json:"overlmt_amt"`
  8734. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8735. Pric float64 `json:"pric"`
  8736. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  8737. SelfpayProp float64 `json:"selfpay_prop"`
  8738. } `json:"result"`
  8739. } `json:"output"`
  8740. RefmsgTime string `json:"refmsg_time"`
  8741. RespondTime string `json:"respond_time"`
  8742. Signtype string `json:"signtype"`
  8743. WarnMsg string `json:"warn_msg"`
  8744. }
  8745. type ResultMemo struct {
  8746. InsuAdmdvs string `json:"insuAdmdvs"`
  8747. }
  8748. // [{"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}]
  8749. type ResultIDInfo struct {
  8750. Begntime string `json:"begntime"`
  8751. Endtime string `json:"endtime"`
  8752. Memo string `json:"memo"`
  8753. }
  8754. type ResultFive struct {
  8755. Balc float64 `json:"balc"`
  8756. CvlservFlag string `json:"cvlserv_flag"`
  8757. EmpName string `json:"emp_name"`
  8758. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  8759. Insutype string `json:"insutype"`
  8760. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  8761. PausInsuDate string `json:"paus_insu_date"`
  8762. PsnInsuDate string `json:"psn_insu_date"`
  8763. PsnInsuStas string `json:"psn_insu_stas"`
  8764. PsnType string `json:"psn_type"`
  8765. }
  8766. type ResultSix struct {
  8767. Cainfo interface{} `json:"cainfo"`
  8768. ErrMsg string `json:"err_msg"`
  8769. InfRefmsgid string `json:"inf_refmsgid"`
  8770. Infcode int64 `json:"infcode"`
  8771. Output struct {
  8772. } `json:"output"`
  8773. RefmsgTime string `json:"refmsg_time"`
  8774. RespondTime string `json:"respond_time"`
  8775. Signtype interface{} `json:"signtype"`
  8776. WarnMsg interface{} `json:"warn_msg"`
  8777. }
  8778. type ResultSix10265 struct {
  8779. Cainfo interface{} `json:"cainfo"`
  8780. ErrMsg string `json:"err_msg"`
  8781. InfRefmsgid string `json:"inf_refmsgid"`
  8782. Infcode string `json:"infcode"`
  8783. Output struct {
  8784. } `json:"output"`
  8785. RefmsgTime string `json:"refmsg_time"`
  8786. RespondTime string `json:"respond_time"`
  8787. Signtype interface{} `json:"signtype"`
  8788. WarnMsg interface{} `json:"warn_msg"`
  8789. }
  8790. type ResultSeven struct {
  8791. Cainfo string `json:"cainfo"`
  8792. ErrMsg string `json:"err_msg"`
  8793. InfRefmsgid string `json:"inf_refmsgid"`
  8794. Infcode int64 `json:"infcode"`
  8795. Output struct {
  8796. Setldetail []interface{} `json:"setldetail"`
  8797. Setlinfo struct {
  8798. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  8799. AcctPay float64 `json:"acct_pay"`
  8800. ActPayDedc float64 `json:"act_pay_dedc"`
  8801. Age float64 `json:"age"`
  8802. Balc float64 `json:"balc"`
  8803. Brdy string `json:"brdy"`
  8804. Certno string `json:"certno"`
  8805. ClrOptins string `json:"clr_optins"`
  8806. ClrType string `json:"clr_type"`
  8807. ClrWay string `json:"clr_way"`
  8808. CvlservFlag string `json:"cvlserv_flag"`
  8809. CvlservPay float64 `json:"cvlserv_pay"`
  8810. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8811. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8812. Gend string `json:"gend"`
  8813. HifesPay float64 `json:"hifes_pay"`
  8814. HifmiPay float64 `json:"hifmi_pay"`
  8815. HifpPay float64 `json:"hifp_pay"`
  8816. HospPartAmt float64 `json:"hosp_part_amt"`
  8817. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8818. Insutype string `json:"insutype"`
  8819. MafPay float64 `json:"maf_pay"`
  8820. MdtrtCertType string `json:"mdtrt_cert_type"`
  8821. HifobPay float64 `json:"hifob_pay"`
  8822. MdtrtID string `json:"mdtrt_id"`
  8823. MedType string `json:"med_type"`
  8824. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8825. MedinsSetlID string `json:"medins_setl_id"`
  8826. Naty string `json:"naty"`
  8827. OthPay float64 `json:"oth_pay"`
  8828. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8829. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  8830. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8831. PsnCashPay float64 `json:"psn_cash_pay"`
  8832. PsnCertType string `json:"psn_cert_type"`
  8833. PsnName string `json:"psn_name"`
  8834. PsnNo string `json:"psn_no"`
  8835. PsnPartAmt float64 `json:"psn_part_amt"`
  8836. PsnType string `json:"psn_type"`
  8837. SetlID string `json:"setl_id"`
  8838. SetlTime string `json:"setl_time"`
  8839. } `json:"setlinfo"`
  8840. } `json:"output"`
  8841. RefmsgTime string `json:"refmsg_time"`
  8842. RespondTime string `json:"respond_time"`
  8843. Signtype interface{} `json:"signtype"`
  8844. WarnMsg interface{} `json:"warn_msg"`
  8845. }
  8846. type ResultSeven10265 struct {
  8847. Cainfo string `json:"cainfo"`
  8848. ErrMsg string `json:"err_msg"`
  8849. InfRefmsgid string `json:"inf_refmsgid"`
  8850. Infcode string `json:"infcode"`
  8851. Output struct {
  8852. Setldetail []interface{} `json:"setldetail"`
  8853. Setlinfo struct {
  8854. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  8855. AcctPay float64 `json:"acct_pay"`
  8856. ActPayDedc float64 `json:"act_pay_dedc"`
  8857. Age float64 `json:"age"`
  8858. Balc float64 `json:"balc"`
  8859. Brdy string `json:"brdy"`
  8860. Certno string `json:"certno"`
  8861. ClrOptins string `json:"clr_optins"`
  8862. ClrType string `json:"clr_type"`
  8863. ClrWay string `json:"clr_way"`
  8864. CvlservFlag string `json:"cvlserv_flag"`
  8865. CvlservPay float64 `json:"cvlserv_pay"`
  8866. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8867. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8868. Gend string `json:"gend"`
  8869. HifesPay float64 `json:"hifes_pay"`
  8870. HifmiPay float64 `json:"hifmi_pay"`
  8871. HifpPay float64 `json:"hifp_pay"`
  8872. HospPartAmt float64 `json:"hosp_part_amt"`
  8873. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8874. Insutype string `json:"insutype"`
  8875. MafPay float64 `json:"maf_pay"`
  8876. MdtrtCertType string `json:"mdtrt_cert_type"`
  8877. HifobPay float64 `json:"hifob_pay"`
  8878. MdtrtID string `json:"mdtrt_id"`
  8879. MedType string `json:"med_type"`
  8880. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8881. MedinsSetlID string `json:"medins_setl_id"`
  8882. Naty string `json:"naty"`
  8883. OthPay float64 `json:"oth_pay"`
  8884. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8885. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  8886. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8887. PsnCashPay float64 `json:"psn_cash_pay"`
  8888. PsnCertType string `json:"psn_cert_type"`
  8889. PsnName string `json:"psn_name"`
  8890. PsnNo string `json:"psn_no"`
  8891. PsnPartAmt float64 `json:"psn_part_amt"`
  8892. PsnType string `json:"psn_type"`
  8893. SetlID string `json:"setl_id"`
  8894. SetlTime string `json:"setl_time"`
  8895. } `json:"setlinfo"`
  8896. } `json:"output"`
  8897. RefmsgTime string `json:"refmsg_time"`
  8898. RespondTime string `json:"respond_time"`
  8899. Signtype interface{} `json:"signtype"`
  8900. WarnMsg interface{} `json:"warn_msg"`
  8901. }
  8902. type ResultEight struct {
  8903. Cainfo string `json:"cainfo"`
  8904. ErrMsg string `json:"err_msg"`
  8905. InfRefmsgid string `json:"inf_refmsgid"`
  8906. Infcode int64 `json:"infcode"`
  8907. Output struct {
  8908. Stmtinfo struct {
  8909. SetlOptins string `json:"setl_optins"`
  8910. StmtRslt string `json:"stmt_rslt"`
  8911. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  8912. } `json:"stmtinfo"`
  8913. } `json:"output"`
  8914. RefmsgTime string `json:"refmsg_time"`
  8915. RespondTime string `json:"respond_time"`
  8916. Signtype interface{} `json:"signtype"`
  8917. WarnMsg interface{} `json:"warn_msg"`
  8918. }
  8919. type ResultEightFor10188 struct {
  8920. Cainfo string `json:"cainfo"`
  8921. ErrMsg string `json:"err_msg"`
  8922. InfRefmsgid string `json:"inf_refmsgid"`
  8923. Infcode string `json:"infcode"`
  8924. Output struct {
  8925. Stmtinfo struct {
  8926. SetlOptins string `json:"setl_optins"`
  8927. StmtRslt string `json:"stmt_rslt"`
  8928. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  8929. } `json:"stmtinfo"`
  8930. } `json:"output"`
  8931. RefmsgTime string `json:"refmsg_time"`
  8932. RespondTime string `json:"respond_time"`
  8933. Signtype interface{} `json:"signtype"`
  8934. WarnMsg interface{} `json:"warn_msg"`
  8935. }
  8936. type ResultNine struct {
  8937. Cainfo string `json:"cainfo"`
  8938. ErrMsg string `json:"err_msg"`
  8939. InfRefmsgid string `json:"inf_refmsgid"`
  8940. Infcode int64 `json:"infcode"`
  8941. Output struct {
  8942. FileQuryNo string `json:"file_qury_no"`
  8943. } `json:"output"`
  8944. RefmsgTime string `json:"refmsg_time"`
  8945. RespondTime string `json:"respond_time"`
  8946. Signtype interface{} `json:"signtype"`
  8947. WarnMsg interface{} `json:"warn_msg"`
  8948. }
  8949. type ResultTen struct {
  8950. Cainfo string `json:"cainfo"`
  8951. ErrMsg string `json:"err_msg"`
  8952. InfRefmsgid string `json:"inf_refmsgid"`
  8953. Infcode int64 `json:"infcode"`
  8954. Output struct {
  8955. DldEndtime string `json:"dld_endtime"`
  8956. FileQuryNo string `json:"file_qury_no"`
  8957. Filename string `json:"filename"`
  8958. } `json:"output"`
  8959. RefmsgTime string `json:"refmsg_time"`
  8960. RespondTime string `json:"respond_time"`
  8961. Signtype interface{} `json:"signtype"`
  8962. WarnMsg interface{} `json:"warn_msg"`
  8963. }
  8964. //type Autogenerated struct {
  8965. // Output struct {
  8966. // Setlinfo struct {
  8967. // SetlTime string `json:"setl_time"`
  8968. // CvlservPay float64 `json:"cvlserv_pay"`
  8969. // Year string `json:"year"`
  8970. // MedType string `json:"med_type"`
  8971. // PsnPay float64 `json:"psn_pay"`
  8972. // OpterID string `json:"opter_id"`
  8973. // Begndate string `json:"begndate"`
  8974. // FlxempeFlag string `json:"flxempe_flag"`
  8975. // HifmiPay float64 `json:"hifmi_pay"`
  8976. // PsnNo string `json:"psn_no"`
  8977. // ActPayDedc float64 `json:"act_pay_dedc"`
  8978. // MedinsSetlID interface{} `json:"medins_setl_id"`
  8979. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  8980. // ClrWay string `json:"clr_way"`
  8981. // OthPay float64 `json:"oth_pay"`
  8982. // Gend string `json:"gend"`
  8983. // MdtrtID string `json:"mdtrt_id"`
  8984. // AcctPay float64 `json:"acct_pay"`
  8985. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  8986. // Insutype string `json:"insutype"`
  8987. // Invono interface{} `json:"invono"`
  8988. // Enddate string `json:"enddate"`
  8989. // CashPayamt float64 `json:"cash_payamt"`
  8990. // PsnType string `json:"psn_type"`
  8991. // FixmedinsName string `json:"fixmedins_name"`
  8992. // HifpPay float64 `json:"hifp_pay"`
  8993. // NewFlag interface{} `json:"new_flag"`
  8994. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8995. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  8996. // PayLoc string `json:"pay_loc"`
  8997. // ClrType string `json:"clr_type"`
  8998. // RefdSetlFlag string `json:"refd_setl_flag"`
  8999. // CvlservFlag string `json:"cvlserv_flag"`
  9000. // EmpName string `json:"emp_name"`
  9001. // Brdy string `json:"brdy"`
  9002. // Naty string `json:"naty"`
  9003. // Certno string `json:"certno"`
  9004. // DiseCode string `json:"dise_code"`
  9005. // FixmedinsCode string `json:"fixmedins_code"`
  9006. // DedcHospLv string `json:"dedc_hosp_lv"`
  9007. // OpterName string `json:"opter_name"`
  9008. // Balc float64 `json:"balc"`
  9009. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  9010. // PsnCertType string `json:"psn_cert_type"`
  9011. // HifobPay float64 `json:"hifob_pay"`
  9012. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  9013. // HifesPay float64 `json:"hifes_pay"`
  9014. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9015. // OptTime string `json:"opt_time"`
  9016. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9017. // SetlID string `json:"setl_id"`
  9018. // MafPay float64 `json:"maf_pay"`
  9019. // PsnName string `json:"psn_name"`
  9020. // InsuOptins interface{} `json:"insu_optins"`
  9021. // PrefFundPay interface{} `json:"pref_fund_pay"`
  9022. // ClrOptins string `json:"clr_optins"`
  9023. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  9024. // DiseName string `json:"dise_name"`
  9025. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  9026. // Age float64 `json:"age"`
  9027. // DtrtCertType string `json:"dtrt_cert_type"`
  9028. // HospLv string `json:"hosp_lv"`
  9029. // } `json:"setlinfo"`
  9030. // Setldetail []struct {
  9031. // FundPayType string `json:"fund_pay_type"`
  9032. // FundPayamt float64 `json:"fund_payamt"`
  9033. // SetlProcInfo interface{} `json:"setl_proc_info"`
  9034. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  9035. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  9036. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  9037. // PrefFundPay interface{} `json:"pref_fund_pay"`
  9038. // } `json:"setldetail"`
  9039. // } `json:"output"`
  9040. // Infcode int `json:"infcode"`
  9041. // WarnMsg interface{} `json:"warn_msg"`
  9042. // Cainfo interface{} `json:"cainfo"`
  9043. // ErrMsg interface{} `json:"err_msg"`
  9044. // RefmsgTime string `json:"refmsg_time"`
  9045. // Signtype interface{} `json:"signtype"`
  9046. // RespondTime string `json:"respond_time"`
  9047. // InfRefmsgid string `json:"inf_refmsgid"`
  9048. //}
  9049. type ResultEleven struct {
  9050. Cainfo string `json:"cainfo"`
  9051. ErrMsg string `json:"err_msg"`
  9052. InfRefmsgid string `json:"inf_refmsgid"`
  9053. Infcode int64 `json:"infcode"`
  9054. Output struct {
  9055. Setlinfo struct {
  9056. SetlTime string `json:"setl_time"`
  9057. CvlservPay float64 `json:"cvlserv_pay"`
  9058. Year string `json:"year"`
  9059. MedType string `json:"med_type"`
  9060. PsnPay float64 `json:"psn_pay"`
  9061. OpterID string `json:"opter_id"`
  9062. Begndate string `json:"begndate"`
  9063. FlxempeFlag string `json:"flxempe_flag"`
  9064. HifmiPay float64 `json:"hifmi_pay"`
  9065. PsnNo string `json:"psn_no"`
  9066. ActPayDedc float64 `json:"act_pay_dedc"`
  9067. MedinsSetlID interface{} `json:"medins_setl_id"`
  9068. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  9069. ClrWay string `json:"clr_way"`
  9070. OthPay float64 `json:"oth_pay"`
  9071. Gend string `json:"gend"`
  9072. MdtrtID string `json:"mdtrt_id"`
  9073. AcctPay float64 `json:"acct_pay"`
  9074. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9075. Insutype string `json:"insutype"`
  9076. Invono interface{} `json:"invono"`
  9077. Enddate string `json:"enddate"`
  9078. CashPayamt float64 `json:"cash_payamt"`
  9079. PsnType string `json:"psn_type"`
  9080. FixmedinsName string `json:"fixmedins_name"`
  9081. HifpPay float64 `json:"hifp_pay"`
  9082. NewFlag interface{} `json:"new_flag"`
  9083. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9084. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9085. PayLoc string `json:"pay_loc"`
  9086. ClrType string `json:"clr_type"`
  9087. RefdSetlFlag string `json:"refd_setl_flag"`
  9088. CvlservFlag string `json:"cvlserv_flag"`
  9089. EmpName string `json:"emp_name"`
  9090. Brdy string `json:"brdy"`
  9091. Naty string `json:"naty"`
  9092. Certno string `json:"certno"`
  9093. DiseCode string `json:"dise_code"`
  9094. FixmedinsCode string `json:"fixmedins_code"`
  9095. DedcHospLv string `json:"dedc_hosp_lv"`
  9096. OpterName string `json:"opter_name"`
  9097. Balc float64 `json:"balc"`
  9098. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  9099. PsnCertType string `json:"psn_cert_type"`
  9100. HifobPay float64 `json:"hifob_pay"`
  9101. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9102. HifesPay float64 `json:"hifes_pay"`
  9103. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9104. OptTime string `json:"opt_time"`
  9105. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9106. SetlID string `json:"setl_id"`
  9107. MafPay float64 `json:"maf_pay"`
  9108. PsnName string `json:"psn_name"`
  9109. InsuOptins interface{} `json:"insu_optins"`
  9110. PrefFundPay interface{} `json:"pref_fund_pay"`
  9111. ClrOptins string `json:"clr_optins"`
  9112. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  9113. DiseName string `json:"dise_name"`
  9114. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  9115. Age float64 `json:"age"`
  9116. DtrtCertType string `json:"dtrt_cert_type"`
  9117. HospLv string `json:"hosp_lv"`
  9118. PsnCashPay float64
  9119. } `json:"setlinfo"`
  9120. } `json:"output"`
  9121. RefmsgTime string `json:"refmsg_time"`
  9122. RespondTime string `json:"respond_time"`
  9123. Signtype interface{} `json:"signtype"`
  9124. WarnMsg interface{} `json:"warn_msg"`
  9125. }
  9126. type ResultEleven10265 struct {
  9127. Cainfo string `json:"cainfo"`
  9128. ErrMsg string `json:"err_msg"`
  9129. InfRefmsgid string `json:"inf_refmsgid"`
  9130. Infcode string `json:"infcode"`
  9131. Output struct {
  9132. Setlinfo struct {
  9133. SetlTime string `json:"setl_time"`
  9134. CvlservPay float64 `json:"cvlserv_pay"`
  9135. Year string `json:"year"`
  9136. MedType string `json:"med_type"`
  9137. PsnPay float64 `json:"psn_pay"`
  9138. OpterID string `json:"opter_id"`
  9139. Begndate string `json:"begndate"`
  9140. FlxempeFlag string `json:"flxempe_flag"`
  9141. HifmiPay float64 `json:"hifmi_pay"`
  9142. PsnNo string `json:"psn_no"`
  9143. ActPayDedc float64 `json:"act_pay_dedc"`
  9144. MedinsSetlID interface{} `json:"medins_setl_id"`
  9145. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  9146. ClrWay string `json:"clr_way"`
  9147. OthPay float64 `json:"oth_pay"`
  9148. Gend string `json:"gend"`
  9149. MdtrtID string `json:"mdtrt_id"`
  9150. AcctPay float64 `json:"acct_pay"`
  9151. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9152. Insutype string `json:"insutype"`
  9153. Invono interface{} `json:"invono"`
  9154. Enddate string `json:"enddate"`
  9155. CashPayamt float64 `json:"cash_payamt"`
  9156. PsnType string `json:"psn_type"`
  9157. FixmedinsName string `json:"fixmedins_name"`
  9158. HifpPay float64 `json:"hifp_pay"`
  9159. NewFlag interface{} `json:"new_flag"`
  9160. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9161. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9162. PayLoc string `json:"pay_loc"`
  9163. ClrType string `json:"clr_type"`
  9164. RefdSetlFlag string `json:"refd_setl_flag"`
  9165. CvlservFlag string `json:"cvlserv_flag"`
  9166. EmpName string `json:"emp_name"`
  9167. Brdy string `json:"brdy"`
  9168. Naty string `json:"naty"`
  9169. Certno string `json:"certno"`
  9170. DiseCode string `json:"dise_code"`
  9171. FixmedinsCode string `json:"fixmedins_code"`
  9172. DedcHospLv string `json:"dedc_hosp_lv"`
  9173. OpterName string `json:"opter_name"`
  9174. Balc float64 `json:"balc"`
  9175. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  9176. PsnCertType string `json:"psn_cert_type"`
  9177. HifobPay float64 `json:"hifob_pay"`
  9178. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9179. HifesPay float64 `json:"hifes_pay"`
  9180. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9181. OptTime string `json:"opt_time"`
  9182. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9183. SetlID string `json:"setl_id"`
  9184. MafPay float64 `json:"maf_pay"`
  9185. PsnName string `json:"psn_name"`
  9186. InsuOptins interface{} `json:"insu_optins"`
  9187. PrefFundPay interface{} `json:"pref_fund_pay"`
  9188. ClrOptins string `json:"clr_optins"`
  9189. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  9190. DiseName string `json:"dise_name"`
  9191. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  9192. Age float64 `json:"age"`
  9193. DtrtCertType string `json:"dtrt_cert_type"`
  9194. HospLv string `json:"hosp_lv"`
  9195. PsnCashPay float64
  9196. } `json:"setlinfo"`
  9197. } `json:"output"`
  9198. RefmsgTime string `json:"refmsg_time"`
  9199. RespondTime string `json:"respond_time"`
  9200. Signtype interface{} `json:"signtype"`
  9201. WarnMsg interface{} `json:"warn_msg"`
  9202. }
  9203. type ResultTwelve struct {
  9204. Cainfo string `json:"cainfo"`
  9205. ErrMsg string `json:"err_msg"`
  9206. InfRefmsgid string `json:"inf_refmsgid"`
  9207. Infcode int64 `json:"infcode"`
  9208. Output struct {
  9209. MdtrtId string `json:"mdtrt_id"`
  9210. ChrgBchno string `json:"chrg_bchno"`
  9211. PsnNo string `json:"psn_no"`
  9212. } `json:"output"`
  9213. RefmsgTime string `json:"refmsg_time"`
  9214. RespondTime string `json:"respond_time"`
  9215. Signtype interface{} `json:"signtype"`
  9216. WarnMsg interface{} `json:"warn_msg"`
  9217. }
  9218. type ResultThirteen struct {
  9219. ErrMsg string `json:"err_msg"`
  9220. InfRefmsgid string `json:"inf_refmsgid"`
  9221. Infcode int64 `json:"infcode"`
  9222. Output struct {
  9223. Result struct {
  9224. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  9225. } `json:"result"`
  9226. } `json:"output"`
  9227. RefmsgTime string `json:"refmsg_time"`
  9228. RespondTime string `json:"respond_time"`
  9229. Signtype interface{} `json:"signtype"`
  9230. WarnInfo interface{} `json:"warn_info"`
  9231. }
  9232. type ResultThirteen10265 struct {
  9233. ErrMsg string `json:"err_msg"`
  9234. InfRefmsgid string `json:"inf_refmsgid"`
  9235. Infcode string `json:"infcode"`
  9236. Output struct {
  9237. Result struct {
  9238. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  9239. } `json:"result"`
  9240. } `json:"output"`
  9241. RefmsgTime string `json:"refmsg_time"`
  9242. RespondTime string `json:"respond_time"`
  9243. Signtype interface{} `json:"signtype"`
  9244. WarnInfo interface{} `json:"warn_info"`
  9245. }
  9246. type ResultFourteen struct {
  9247. ErrMsg string `json:"err_msg"`
  9248. InfRefmsgid string `json:"inf_refmsgid"`
  9249. Infcode int64 `json:"infcode"`
  9250. Output struct {
  9251. } `json:"output"`
  9252. RefmsgTime string `json:"refmsg_time"`
  9253. RespondTime string `json:"respond_time"`
  9254. Signtype interface{} `json:"signtype"`
  9255. WarnInfo interface{} `json:"warn_info"`
  9256. }
  9257. type ResultFourteen10265 struct {
  9258. ErrMsg string `json:"err_msg"`
  9259. InfRefmsgid string `json:"inf_refmsgid"`
  9260. Infcode string `json:"infcode"`
  9261. Output struct {
  9262. } `json:"output"`
  9263. RefmsgTime string `json:"refmsg_time"`
  9264. RespondTime string `json:"respond_time"`
  9265. Signtype interface{} `json:"signtype"`
  9266. WarnInfo interface{} `json:"warn_info"`
  9267. }
  9268. type ResultSixteen struct {
  9269. Cainfo string `json:"cainfo"`
  9270. ErrMsg string `json:"err_msg"`
  9271. InfRefmsgid string `json:"inf_refmsgid"`
  9272. Infcode int64 `json:"infcode"`
  9273. Output struct {
  9274. Setldetail []interface{} `json:"setldetail"`
  9275. Setlinfo struct {
  9276. MdtrtID string `json:"mdtrt_id"`
  9277. SetlID string `json:"setl_id"`
  9278. ClrOptins string `json:"clr_optins"`
  9279. SetlTime string `json:"setl_time"`
  9280. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9281. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9282. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9283. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9284. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9285. ActPayDedc float64 `json:"act_pay_dedc"`
  9286. HifpPay float64 `json:"hifp_pay"`
  9287. PoolPropSe float64 `json:"pool_prop_selfpay"`
  9288. Lfpay float64 `json:"selfpay"`
  9289. CvlservPay float64 `json:"cvlserv_pay"`
  9290. HifesPay float64 `json:"hifes_pay"`
  9291. HifmiPay float64 `json:"hifmi_pay"`
  9292. HifobPay float64 `json:"hifob_pay"`
  9293. MafPay float64 `json:"maf_pay"`
  9294. OthPay float64 `json:"oth_pay"`
  9295. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9296. PsnPartAmt float64 `json:"psn_part_amt"`
  9297. AcctPay float64 `json:"acct_pay"`
  9298. Balc float64 `json:"balc"`
  9299. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  9300. HospPartAmt float64 `json:"hosp_part_amt"`
  9301. MedinsSetlID string `json:"medins_setl_id"`
  9302. PdnCashPay string `json:"pdn_cash_pay"`
  9303. } `json:"setlinfo"`
  9304. } `json:"output"`
  9305. RefmsgTime string `json:"refmsg_time"`
  9306. RespondTime string `json:"respond_time"`
  9307. Signtype interface{} `json:"signtype"`
  9308. WarnMsg interface{} `json:"warn_msg"`
  9309. }
  9310. type ResultSixteen10265 struct {
  9311. Cainfo string `json:"cainfo"`
  9312. ErrMsg string `json:"err_msg"`
  9313. InfRefmsgid string `json:"inf_refmsgid"`
  9314. Infcode string `json:"infcode"`
  9315. Output struct {
  9316. Setldetail []interface{} `json:"setldetail"`
  9317. Setlinfo struct {
  9318. MdtrtID string `json:"mdtrt_id"`
  9319. SetlID string `json:"setl_id"`
  9320. ClrOptins string `json:"clr_optins"`
  9321. SetlTime string `json:"setl_time"`
  9322. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9323. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9324. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9325. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9326. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9327. ActPayDedc float64 `json:"act_pay_dedc"`
  9328. HifpPay float64 `json:"hifp_pay"`
  9329. PoolPropSe float64 `json:"pool_prop_selfpay"`
  9330. Lfpay float64 `json:"selfpay"`
  9331. CvlservPay float64 `json:"cvlserv_pay"`
  9332. HifesPay float64 `json:"hifes_pay"`
  9333. HifmiPay float64 `json:"hifmi_pay"`
  9334. HifobPay float64 `json:"hifob_pay"`
  9335. MafPay float64 `json:"maf_pay"`
  9336. OthPay float64 `json:"oth_pay"`
  9337. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9338. PsnPartAmt float64 `json:"psn_part_amt"`
  9339. AcctPay float64 `json:"acct_pay"`
  9340. Balc float64 `json:"balc"`
  9341. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  9342. HospPartAmt float64 `json:"hosp_part_amt"`
  9343. MedinsSetlID string `json:"medins_setl_id"`
  9344. PdnCashPay string `json:"pdn_cash_pay"`
  9345. } `json:"setlinfo"`
  9346. } `json:"output"`
  9347. RefmsgTime string `json:"refmsg_time"`
  9348. RespondTime string `json:"respond_time"`
  9349. Signtype interface{} `json:"signtype"`
  9350. WarnMsg interface{} `json:"warn_msg"`
  9351. }
  9352. type ResultSeventeen struct {
  9353. ErrMsg string `json:"err_msg"`
  9354. InfRefmsgid string `json:"inf_refmsgid"`
  9355. Infcode int64 `json:"infcode"`
  9356. Output struct {
  9357. SetlListId string `json:"setl_list_id"`
  9358. } `json:"output"`
  9359. RefmsgTime string `json:"refmsg_time"`
  9360. RespondTime string `json:"respond_time"`
  9361. Signtype string `json:"signtype"`
  9362. WarnInfo string `json:"warn_info"`
  9363. }
  9364. type ResultSeventeenOther struct {
  9365. ErrMsg string `json:"err_msg"`
  9366. InfRefmsgid string `json:"inf_refmsgid"`
  9367. Infcode string `json:"infcode"`
  9368. Output struct {
  9369. SetlListId string `json:"setl_list_id"`
  9370. } `json:"output"`
  9371. RefmsgTime string `json:"refmsg_time"`
  9372. RespondTime string `json:"respond_time"`
  9373. Signtype string `json:"signtype"`
  9374. WarnInfo string `json:"warn_info"`
  9375. }
  9376. type Result90991 struct {
  9377. ErrMsg string `json:"err_msg"`
  9378. InfRefmsgid string `json:"inf_refmsgid"`
  9379. Infcode int64 `json:"infcode"`
  9380. Output struct {
  9381. Result struct {
  9382. PsnNo string `json:"psn_no"`
  9383. CardStat string `json:"card_stat"`
  9384. Certno string `json:"certno"`
  9385. PsnName string `json:"psn_name"`
  9386. CheckStat string `json:"check_stat"`
  9387. SscnoCheckStat string `json:"sscno_check_stat"`
  9388. } `json:"result"`
  9389. } `json:"output"`
  9390. RefmsgTime string `json:"refmsg_time"`
  9391. RespondTime string `json:"respond_time"`
  9392. Signtype interface{} `json:"signtype"`
  9393. WarnInfo interface{} `json:"warn_info"`
  9394. }
  9395. type Result90100 struct {
  9396. ErrMsg string `json:"err_msg"`
  9397. InfRefmsgid string `json:"inf_refmsgid"`
  9398. Infcode int64 `json:"infcode"`
  9399. Output struct {
  9400. PoolareaNo string `json:"poolarea_no"`
  9401. PoolareaNoName string `json:"poolarea_no_name"`
  9402. Insutype string `json:"insutype"`
  9403. InsutypeName string `json:"insutype_name"`
  9404. ClctType string `json:"clct_type"`
  9405. ClctTypeName string `json:"clct_type_name"`
  9406. ClctFlag string `json:"clct_flag"`
  9407. ClctFlagName string `json:"clct_flag_name"`
  9408. AccrymBegn string `json:"accrym_begn"`
  9409. AccrymEnd string `json:"accrym_end"`
  9410. ClctTime string `json:"clct_time"`
  9411. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  9412. } `json:"output"`
  9413. RefmsgTime string `json:"refmsg_time"`
  9414. RespondTime string `json:"respond_time"`
  9415. Signtype interface{} `json:"signtype"`
  9416. WarnInfo interface{} `json:"warn_info"`
  9417. }
  9418. type Custom struct {
  9419. DetItemFeeSumamt string
  9420. Cut string
  9421. FeedetlSn string
  9422. Price string
  9423. MedListCodg string
  9424. Type int64
  9425. AdviceId int64
  9426. ProjectId int64
  9427. ItemId int64
  9428. }
  9429. type Result5301 struct {
  9430. ErrMsg string `json:"err_msg"`
  9431. InfRefmsgid string `json:"inf_refmsgid"`
  9432. Infcode int64 `json:"infcode"`
  9433. Output struct {
  9434. Result []struct {
  9435. OpspDiseCode string `json:"opsp_dise_code"`
  9436. OpspDiseName string `json:"opsp_dise_name"`
  9437. Begndate string `json:"begndate"`
  9438. Enddate string `json:"enddate"`
  9439. } `json:"feedetail"`
  9440. } `json:"output"`
  9441. RefmsgTime string `json:"refmsg_time"`
  9442. RespondTime string `json:"respond_time"`
  9443. Signtype interface{} `json:"signtype"`
  9444. WarnInfo interface{} `json:"warn_info"`
  9445. }
  9446. type Result5301For10265 struct {
  9447. ErrMsg string `json:"err_msg"`
  9448. InfRefmsgid string `json:"inf_refmsgid"`
  9449. Infcode string `json:"infcode"`
  9450. Output struct {
  9451. Result []struct {
  9452. OpspDiseCode string `json:"opsp_dise_code"`
  9453. OpspDiseName string `json:"opsp_dise_name"`
  9454. Begndate string `json:"begndate"`
  9455. Enddate string `json:"enddate"`
  9456. } `json:"feedetail"`
  9457. } `json:"output"`
  9458. RefmsgTime string `json:"refmsg_time"`
  9459. RespondTime string `json:"respond_time"`
  9460. Signtype interface{} `json:"signtype"`
  9461. WarnInfo interface{} `json:"warn_info"`
  9462. }
  9463. //获取个人信息----挂号-----上传就诊信息
  9464. func (c *HisApiController) GetRegisterInfo() {
  9465. id, _ := c.GetInt64("id")
  9466. record_time := c.GetString("record_time")
  9467. settlementValue, _ := c.GetInt64("settlement_value")
  9468. medical_insurance_card := c.GetString("medical_insurance_card")
  9469. name := c.GetString("name")
  9470. id_card_type, _ := c.GetInt64("id_card_type")
  9471. certificates, _ := c.GetInt64("certificates")
  9472. medical_care, _ := c.GetInt64("medical_care")
  9473. birthday := c.GetString("birthday")
  9474. id_card := c.GetString("id_card")
  9475. register_type, _ := c.GetInt64("register")
  9476. doctor, _ := c.GetInt64("doctor")
  9477. department, _ := c.GetInt64("department")
  9478. gender, _ := c.GetInt64("sex")
  9479. registration_fee, _ := c.GetFloat("registration_fee")
  9480. medical_expenses, _ := c.GetFloat("medical_expenses")
  9481. social_type, _ := c.GetInt64("social_type")
  9482. admin_user_id, _ := c.GetInt64("admin_user_id")
  9483. insuplc_admdvs := c.GetString("insuplc_admdvs")
  9484. mdtrt_type := c.GetString("mdtrt_type")
  9485. timeLayout := "2006-01-02"
  9486. loc, _ := time.LoadLocation("Local")
  9487. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  9488. birthUnix := birthdays.Unix()
  9489. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9490. if err != nil {
  9491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9492. return
  9493. }
  9494. recordDateTime := theTime.Unix()
  9495. adminInfo := c.GetAdminUserInfo()
  9496. var patient service.Patients
  9497. if id == 0 {
  9498. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  9499. } else {
  9500. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  9501. }
  9502. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9503. if patientPrescription.ID == 0 {
  9504. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9505. }
  9506. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9507. if patient.ID == 0 {
  9508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9509. return
  9510. }
  9511. if len(patient.IdCardNo) == 0 {
  9512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9513. return
  9514. }
  9515. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9516. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  9517. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  9518. //就诊结算未完成,不能进行二次挂号
  9519. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  9520. if len(his) >= 1 {
  9521. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  9522. if len(his) >= 1 && order.ID == 0 {
  9523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  9524. return
  9525. }
  9526. }
  9527. //var register_log string
  9528. if config.IsOpen == 1 {
  9529. var res ResultTwo
  9530. var res10265 ResultTwo10265
  9531. var PsnNo string
  9532. var PsnCertType string
  9533. var Certno string
  9534. var PsnName string
  9535. var Gend string
  9536. var Naty string
  9537. var Brdy string
  9538. var Age float64
  9539. var infoStr string
  9540. var idetinfoStr string
  9541. var infocode int64
  9542. var verify_number string
  9543. fmt.Println(verify_number)
  9544. if miConfig.MdtrtareaAdmvs == "421300" {
  9545. psn_info, _ := service.GetPsnByPatientId(id)
  9546. PsnNo = psn_info.PsnNo
  9547. PsnCertType = psn_info.PsnCertType
  9548. Certno = psn_info.Certno
  9549. PsnName = psn_info.PsnName
  9550. Gend = psn_info.Gend
  9551. Naty = psn_info.Naty
  9552. Brdy = psn_info.Brdy
  9553. Age = psn_info.Age
  9554. infoStr = psn_info.Insuinfo
  9555. idetinfoStr = psn_info.Idetinfo
  9556. infocode = 0
  9557. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9558. psn_info, _ := service.GetPsnByPatientId(id)
  9559. PsnNo = psn_info.PsnNo
  9560. PsnCertType = psn_info.PsnCertType
  9561. Certno = psn_info.Certno
  9562. PsnName = psn_info.PsnName
  9563. Gend = psn_info.Gend
  9564. Naty = psn_info.Naty
  9565. Brdy = psn_info.Brdy
  9566. Age = psn_info.Age
  9567. infoStr = psn_info.Insuinfo
  9568. idetinfoStr = psn_info.Idetinfo
  9569. infocode = 0
  9570. verify_number = psn_info.VerifyNumber
  9571. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9572. if id_card_type == 1 {
  9573. psn_info, _ := service.GetPsnByPatientId(id)
  9574. PsnNo = psn_info.PsnNo
  9575. PsnCertType = psn_info.PsnCertType
  9576. Certno = psn_info.Certno
  9577. PsnName = psn_info.PsnName
  9578. Gend = psn_info.Gend
  9579. Naty = psn_info.Naty
  9580. Brdy = psn_info.Brdy
  9581. Age = psn_info.Age
  9582. infoStr = psn_info.Insuinfo
  9583. idetinfoStr = psn_info.Idetinfo
  9584. infocode = 0
  9585. verify_number = psn_info.VerifyNumber
  9586. } else if id_card_type == 2 {
  9587. 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)
  9588. fmt.Println(errMsgLog)
  9589. saveLog(result, requestLog, "1101", "人员基本信息获取")
  9590. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9591. utils.ErrorLog("解析失败:%v", err)
  9592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9593. return
  9594. }
  9595. PsnNo = res.Output.Baseinfo.PsnNo
  9596. PsnCertType = res.Output.Baseinfo.PsnCertType
  9597. Certno = res.Output.Baseinfo.Certno
  9598. PsnName = res.Output.Baseinfo.PsnName
  9599. Gend = res.Output.Baseinfo.Gend
  9600. Naty = res.Output.Baseinfo.Naty
  9601. Brdy = res.Output.Baseinfo.Brdy
  9602. Age = res.Output.Baseinfo.Age
  9603. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9604. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9605. infoStr = string(Iinfos)
  9606. idetinfoStr = string(Idetinfos)
  9607. infocode = res.Infcode
  9608. }
  9609. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9610. if id_card_type == 1 {
  9611. psn_info, _ := service.GetPsnByPatientId(id)
  9612. PsnNo = psn_info.PsnNo
  9613. PsnCertType = psn_info.PsnCertType
  9614. Certno = psn_info.Certno
  9615. PsnName = psn_info.PsnName
  9616. Gend = psn_info.Gend
  9617. Naty = psn_info.Naty
  9618. Brdy = psn_info.Brdy
  9619. Age = psn_info.Age
  9620. infoStr = psn_info.Insuinfo
  9621. idetinfoStr = psn_info.Idetinfo
  9622. infocode = 0
  9623. verify_number = psn_info.VerifyNumber
  9624. } else if id_card_type == 2 {
  9625. 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, "")
  9626. saveLog(result, requestLog, "1101", "人员基本信息获取")
  9627. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9628. utils.ErrorLog("解析失败:%v", err)
  9629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9630. return
  9631. }
  9632. PsnNo = res.Output.Baseinfo.PsnNo
  9633. PsnCertType = res.Output.Baseinfo.PsnCertType
  9634. Certno = res.Output.Baseinfo.Certno
  9635. PsnName = res.Output.Baseinfo.PsnName
  9636. Gend = res.Output.Baseinfo.Gend
  9637. Naty = res.Output.Baseinfo.Naty
  9638. Brdy = res.Output.Baseinfo.Brdy
  9639. Age = res.Output.Baseinfo.Age
  9640. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9641. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9642. infoStr = string(Iinfos)
  9643. idetinfoStr = string(Idetinfos)
  9644. infocode = res.Infcode
  9645. }
  9646. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9647. if id_card_type == 1 {
  9648. psn_info, _ := service.GetPsnByPatientId(id)
  9649. PsnNo = psn_info.PsnNo
  9650. PsnCertType = psn_info.PsnCertType
  9651. Certno = psn_info.Certno
  9652. PsnName = psn_info.PsnName
  9653. Gend = psn_info.Gend
  9654. Naty = psn_info.Naty
  9655. Brdy = psn_info.Brdy
  9656. Age = psn_info.Age
  9657. infoStr = psn_info.Insuinfo
  9658. idetinfoStr = psn_info.Idetinfo
  9659. infocode = 0
  9660. verify_number = psn_info.VerifyNumber
  9661. } else if id_card_type == 2 {
  9662. 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)
  9663. saveLog(result, requestLog, "1101", "人员基本信息获取")
  9664. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9665. utils.ErrorLog("解析失败:%v", err)
  9666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9667. return
  9668. }
  9669. PsnNo = res.Output.Baseinfo.PsnNo
  9670. PsnCertType = res.Output.Baseinfo.PsnCertType
  9671. Certno = res.Output.Baseinfo.Certno
  9672. PsnName = res.Output.Baseinfo.PsnName
  9673. Gend = res.Output.Baseinfo.Gend
  9674. Naty = res.Output.Baseinfo.Naty
  9675. Brdy = res.Output.Baseinfo.Brdy
  9676. Age = res.Output.Baseinfo.Age
  9677. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9678. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9679. infoStr = string(Iinfos)
  9680. idetinfoStr = string(Idetinfos)
  9681. infocode = res.Infcode
  9682. } else if id_card_type == 4 {
  9683. psn_info, _ := service.GetPsnByPatientId(id)
  9684. PsnNo = psn_info.PsnNo
  9685. PsnCertType = psn_info.PsnCertType
  9686. Certno = psn_info.Certno
  9687. PsnName = psn_info.PsnName
  9688. Gend = psn_info.Gend
  9689. Naty = psn_info.Naty
  9690. Brdy = psn_info.Brdy
  9691. Age = psn_info.Age
  9692. infoStr = psn_info.Insuinfo
  9693. idetinfoStr = psn_info.Idetinfo
  9694. infocode = 0
  9695. verify_number = psn_info.VerifyNumber
  9696. }
  9697. } else if miConfig.MdtrtareaAdmvs == "131023" {
  9698. var result string
  9699. var requestLog string
  9700. 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), "")
  9701. if id_card_type == 4 {
  9702. psn_info, _ := service.GetPsnByPatientId(id)
  9703. PsnNo = psn_info.PsnNo
  9704. PsnCertType = psn_info.PsnCertType
  9705. Certno = psn_info.Certno
  9706. PsnName = psn_info.PsnName
  9707. Gend = psn_info.Gend
  9708. Naty = psn_info.Naty
  9709. Brdy = psn_info.Brdy
  9710. Age = psn_info.Age
  9711. infoStr = psn_info.Insuinfo
  9712. idetinfoStr = psn_info.Idetinfo
  9713. infocode = 0
  9714. verify_number = psn_info.VerifyNumber
  9715. } else {
  9716. saveLog(result, requestLog, "1101", "人员基本信息获取")
  9717. if miConfig.Code == "H15049901371" {
  9718. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9719. utils.ErrorLog("解析失败:%v", err)
  9720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9721. return
  9722. }
  9723. res.ErrMsg = res10265.ErrMsg
  9724. res.Output = res10265.Output
  9725. res.InfRefmsgid = res10265.InfRefmsgid
  9726. } else {
  9727. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9728. utils.ErrorLog("解析失败:%v", err)
  9729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9730. return
  9731. }
  9732. }
  9733. PsnNo = res.Output.Baseinfo.PsnNo
  9734. PsnCertType = res.Output.Baseinfo.PsnCertType
  9735. Certno = res.Output.Baseinfo.Certno
  9736. PsnName = res.Output.Baseinfo.PsnName
  9737. Gend = res.Output.Baseinfo.Gend
  9738. Naty = res.Output.Baseinfo.Naty
  9739. Brdy = res.Output.Baseinfo.Brdy
  9740. Age = res.Output.Baseinfo.Age
  9741. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9742. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9743. infoStr = string(Iinfos)
  9744. idetinfoStr = string(Idetinfos)
  9745. if miConfig.Code == "H15049901371" {
  9746. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  9747. } else {
  9748. infocode = res.Infcode
  9749. }
  9750. }
  9751. } else {
  9752. var result string
  9753. var requestLog string
  9754. //if miConfig.UserOrgId == 10138 {
  9755. if id_card_type != 4 || id_card_type != 1 {
  9756. var insa string
  9757. if len(patient.InsuplcAdmdvs) > 0 {
  9758. insa = patient.InsuplcAdmdvs
  9759. } else {
  9760. insa = miConfig.InsuplcAdmdvs
  9761. }
  9762. //psn_info, _ := service.GetPsnByPatientId(id)
  9763. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  9764. 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)
  9765. }
  9766. //}
  9767. //else {
  9768. // var insa string
  9769. // if len(patient.InsuplcAdmdvs) > 0 {
  9770. // insa = patient.InsuplcAdmdvs
  9771. // } else {
  9772. // insa = miConfig.InsuplcAdmdvs
  9773. // }
  9774. // 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)
  9775. //}
  9776. if id_card_type == 4 || id_card_type == 1 {
  9777. psn_info, _ := service.GetPsnByPatientId(id)
  9778. PsnNo = psn_info.PsnNo
  9779. PsnCertType = psn_info.PsnCertType
  9780. Certno = psn_info.Certno
  9781. PsnName = psn_info.PsnName
  9782. Gend = psn_info.Gend
  9783. Naty = psn_info.Naty
  9784. Brdy = psn_info.Brdy
  9785. Age = psn_info.Age
  9786. infoStr = psn_info.Insuinfo
  9787. idetinfoStr = psn_info.Idetinfo
  9788. infocode = 0
  9789. verify_number = psn_info.VerifyNumber
  9790. } else {
  9791. saveLog(result, requestLog, "1101", "人员基本信息获取")
  9792. if miConfig.Code == "H15049901371" {
  9793. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9794. utils.ErrorLog("解析失败:%v", err)
  9795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9796. return
  9797. }
  9798. res.ErrMsg = res10265.ErrMsg
  9799. res.Output = res10265.Output
  9800. res.InfRefmsgid = res10265.InfRefmsgid
  9801. } else {
  9802. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9803. utils.ErrorLog("解析失败:%v", err)
  9804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9805. return
  9806. }
  9807. }
  9808. PsnNo = res.Output.Baseinfo.PsnNo
  9809. PsnCertType = res.Output.Baseinfo.PsnCertType
  9810. Certno = res.Output.Baseinfo.Certno
  9811. PsnName = res.Output.Baseinfo.PsnName
  9812. Gend = res.Output.Baseinfo.Gend
  9813. Naty = res.Output.Baseinfo.Naty
  9814. Brdy = res.Output.Baseinfo.Brdy
  9815. Age = res.Output.Baseinfo.Age
  9816. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9817. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9818. infoStr = string(Iinfos)
  9819. idetinfoStr = string(Idetinfos)
  9820. if miConfig.Code == "H15049901371" {
  9821. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  9822. } else {
  9823. infocode = res.Infcode
  9824. }
  9825. }
  9826. }
  9827. if infocode == 0 {
  9828. his := models.VMHisPatient{
  9829. Name: name,
  9830. Gender: gender,
  9831. Birthday: birthUnix,
  9832. MedicalTreatmentType: medical_care,
  9833. IdType: certificates,
  9834. IdCardNo: id_card,
  9835. BalanceAccountsType: settlementValue,
  9836. SocialType: social_type,
  9837. MedicalInsuranceNumber: medical_insurance_card,
  9838. RegisterType: register_type,
  9839. RegisterCost: registration_fee,
  9840. TreatmentCost: medical_expenses,
  9841. Status: 1,
  9842. Ctime: time.Now().Unix(),
  9843. Mtime: time.Now().Unix(),
  9844. PsnNo: PsnNo,
  9845. PsnCertType: PsnCertType,
  9846. Certno: Certno,
  9847. PsnName: PsnName,
  9848. Gend: Gend,
  9849. Naty: Naty,
  9850. Brdy: Brdy,
  9851. Age: Age,
  9852. Iinfo: infoStr,
  9853. Idetinfo: idetinfoStr,
  9854. PatientId: patient.ID,
  9855. RecordDate: theTime.Unix(),
  9856. UserOrgId: adminInfo.CurrentOrgId,
  9857. AdminUserId: admin_user_id,
  9858. IsReturn: 1,
  9859. IdCardType: id_card_type,
  9860. Doctor: doctor,
  9861. Departments: department,
  9862. MdtrtGrpType: mdtrt_type,
  9863. }
  9864. timestamp := time.Now().Unix()
  9865. tempTime := time.Unix(timestamp, 0)
  9866. timeFormat := tempTime.Format("20060102150405")
  9867. chrgBchno := rand.Intn(100000) + 10000
  9868. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9869. his.Number = ipt_otp_no
  9870. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  9871. department, _ := service.GetDepartMentDetail(department)
  9872. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  9873. IdCardNo := ""
  9874. if id_card_type == 1 {
  9875. // IdCardNo = medical_insurance_card
  9876. IdCardNo = patient.IdCardNo
  9877. } else {
  9878. IdCardNo = patient.IdCardNo
  9879. }
  9880. var rf []*ResultFive
  9881. json.Unmarshal([]byte(his.Iinfo), &rf)
  9882. var insutypes []*ResultFive
  9883. var insutype string
  9884. var insuplc_admdvs_temp string
  9885. var is390 int = 0
  9886. var is310 int = 0
  9887. for _, item := range rf {
  9888. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9889. insutypes = append(insutypes, item)
  9890. }
  9891. }
  9892. if len(insutypes) == 1 {
  9893. insutype = insutypes[0].Insutype
  9894. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9895. } else {
  9896. for _, i := range insutypes {
  9897. if i.Insutype == "390" {
  9898. is390 = 1
  9899. }
  9900. if i.Insutype == "310" {
  9901. is310 = 1
  9902. }
  9903. }
  9904. }
  9905. if is390 == 1 {
  9906. insutype = "390"
  9907. }
  9908. if is310 == 1 {
  9909. insutype = "310"
  9910. }
  9911. fmt.Println(social_type)
  9912. if social_type > 0 {
  9913. insutype = strconv.FormatInt(social_type, 10)
  9914. }
  9915. var infocode int64
  9916. var resThree ResultThree
  9917. var resThree10265 ResultThree10265
  9918. if len(insuplc_admdvs) == 0 {
  9919. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  9920. } else {
  9921. insuplc_admdvs_temp = insuplc_admdvs
  9922. }
  9923. if miConfig.MdtrtareaAdmvs == "421300" {
  9924. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  9925. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  9926. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  9927. "&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
  9928. resp, requestErr := http.Get(api)
  9929. if requestErr != nil {
  9930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9931. return
  9932. }
  9933. body, ioErr := ioutil.ReadAll(resp.Body)
  9934. if ioErr != nil {
  9935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9937. return
  9938. }
  9939. var respJSON map[string]interface{}
  9940. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9943. return
  9944. }
  9945. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9946. result, _ := json.Marshal(respJSON)
  9947. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  9948. utils.ErrorLog("解析失败:%v", err)
  9949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9950. return
  9951. }
  9952. infocode = resThree.Infcode
  9953. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9954. psn_info, _ := service.GetPsnByPatientId(id)
  9955. his.PsnNo = psn_info.PsnNo
  9956. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9957. var cert_no string
  9958. if id_card_type == 3 {
  9959. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  9960. cert_no = IdCardNo
  9961. } else if id_card_type == 4 {
  9962. cert_no = IdCardNo
  9963. psn_info.VerifyNumber = psn_info.VerifyNumber
  9964. } else {
  9965. bas := strings.Split(psn_info.CardInfo, "|")
  9966. cert_no = bas[2]
  9967. }
  9968. var hisPrescription []*models.HisPrescription
  9969. for _, item := range rf {
  9970. if item.Insutype == insutype {
  9971. //insuplc_admdvs = item.InsuplcAdmdvs
  9972. his.InsuplcAdmdvs = insuplc_admdvs
  9973. }
  9974. }
  9975. his.Insutype = insutype
  9976. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  9977. fmt.Println(res3101)
  9978. fmt.Println(res3101.Infcode)
  9979. if res3101.Infcode == "0" {
  9980. fmt.Println("33333333")
  9981. if len(res3101.Output.Result) > 0 {
  9982. fmt.Println("222222")
  9983. for _, item := range res3101.Output.Result {
  9984. if len(res3101.ErrMsg) == 0 {
  9985. res3101.ErrMsg = item.VolaCont
  9986. } else {
  9987. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  9988. }
  9989. }
  9990. c.ServeSuccessJSON(map[string]interface{}{
  9991. "failed_code": -10,
  9992. "msg": res3101.ErrMsg,
  9993. })
  9994. return
  9995. } else {
  9996. fmt.Println("11111")
  9997. var api string
  9998. if miConfig.MdtrtareaAdmvs == "320921" {
  9999. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  10000. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  10001. "&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
  10002. } else {
  10003. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  10004. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  10005. "&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
  10006. }
  10007. resp, requestErr := http.Get(api)
  10008. if requestErr != nil {
  10009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10010. return
  10011. }
  10012. body, ioErr := ioutil.ReadAll(resp.Body)
  10013. if ioErr != nil {
  10014. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10016. return
  10017. }
  10018. var respJSON map[string]interface{}
  10019. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10022. return
  10023. }
  10024. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10025. result, _ := json.Marshal(respJSON)
  10026. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  10027. utils.ErrorLog("解析失败:%v", err)
  10028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10029. return
  10030. }
  10031. resThree.ErrMsg = resThree10265.ErrMsg
  10032. resThree.Output = resThree10265.Output
  10033. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  10034. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  10035. }
  10036. } else if res3101.Infcode != "0" {
  10037. c.ServeSuccessJSON(map[string]interface{}{
  10038. "failed_code": -10,
  10039. "msg": res3101.ErrMsg,
  10040. })
  10041. return
  10042. }
  10043. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10044. psn_info, _ := service.GetPsnByPatientId(id)
  10045. var cert_no string
  10046. if id_card_type == 1 {
  10047. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10048. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  10049. } else if id_card_type == 4 {
  10050. cert_no = psn_info.VerifyNumber
  10051. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  10052. } else {
  10053. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  10054. cert_no = psn_info.VerifyNumber
  10055. }
  10056. 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)
  10057. saveLog(result, requestLog, "2201", "挂号")
  10058. if miConfig.Code == "H15049901371" {
  10059. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  10060. utils.ErrorLog("解析失败:%v", err)
  10061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10062. return
  10063. }
  10064. resThree.ErrMsg = resThree10265.ErrMsg
  10065. resThree.Output = resThree10265.Output
  10066. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  10067. } else {
  10068. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10069. utils.ErrorLog("解析失败:%v", err)
  10070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10071. return
  10072. }
  10073. }
  10074. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  10075. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  10076. psn_info, _ := service.GetPsnByPatientId(id)
  10077. var result string
  10078. var requestLog string
  10079. if id_card_type == 1 {
  10080. bas := strings.Split(psn_info.CardInfo, "|")
  10081. basNumber := bas[2]
  10082. card_sn := bas[3]
  10083. 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)
  10084. saveLog(result, requestLog, "2201A", "挂号")
  10085. } else if id_card_type == 2 {
  10086. 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, "", "")
  10087. saveLog(result, requestLog, "2201A", "挂号")
  10088. } else {
  10089. 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, "", "")
  10090. saveLog(result, requestLog, "2201A", "挂号")
  10091. }
  10092. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10093. utils.ErrorLog("解析失败:%v", err)
  10094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10095. return
  10096. }
  10097. infocode = resThree.Infcode
  10098. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  10099. psn_info, _ := service.GetPsnByPatientId(id)
  10100. var result string
  10101. var requestLog string
  10102. if id_card_type == 1 {
  10103. bas := strings.Split(psn_info.CardInfo, "|")
  10104. basNumber := bas[2]
  10105. card_sn := bas[3]
  10106. 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)
  10107. saveLog(result, requestLog, "2201A", "挂号")
  10108. } else if id_card_type == 2 {
  10109. 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, "", "")
  10110. saveLog(result, requestLog, "2201A", "挂号")
  10111. } else {
  10112. 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, "", "")
  10113. saveLog(result, requestLog, "2201A", "挂号")
  10114. }
  10115. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10116. utils.ErrorLog("解析失败:%v", err)
  10117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10118. return
  10119. }
  10120. infocode = resThree.Infcode
  10121. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10122. psn_info, _ := service.GetPsnByPatientId(id)
  10123. 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)
  10124. saveLog(result, requestLog, "2201A", "挂号")
  10125. if miConfig.Code == "H15049901371" {
  10126. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  10127. utils.ErrorLog("解析失败:%v", err)
  10128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10129. return
  10130. }
  10131. resThree.ErrMsg = resThree10265.ErrMsg
  10132. resThree.Output = resThree10265.Output
  10133. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  10134. } else {
  10135. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10136. utils.ErrorLog("解析失败:%v", err)
  10137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10138. return
  10139. }
  10140. }
  10141. if miConfig.Code == "H15049901371" {
  10142. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  10143. } else {
  10144. infocode = resThree.Infcode
  10145. }
  10146. } else {
  10147. psn_info, _ := service.GetPsnByPatientId(id)
  10148. if id_card_type == 4 || id_card_type == 1 {
  10149. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  10150. }
  10151. var rf []*ResultFive
  10152. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  10153. var insutypes []*ResultFive
  10154. var insutype string
  10155. var is390 int = 0
  10156. var is310 int = 0
  10157. for _, item := range rf {
  10158. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10159. insutypes = append(insutypes, item)
  10160. }
  10161. }
  10162. if len(insutypes) == 1 {
  10163. insutype = insutypes[0].Insutype
  10164. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10165. } else {
  10166. for _, i := range insutypes {
  10167. if i.Insutype == "390" {
  10168. is390 = 1
  10169. }
  10170. if i.Insutype == "310" {
  10171. is310 = 1
  10172. }
  10173. }
  10174. }
  10175. if is390 == 1 {
  10176. insutype = "390"
  10177. }
  10178. if is310 == 1 {
  10179. insutype = "310"
  10180. }
  10181. fmt.Println(len(insutypes))
  10182. if len(insutypes) == 0 {
  10183. for index, item := range rf {
  10184. if index == 0 {
  10185. insutype = item.Insutype
  10186. insuplc_admdvs = item.InsuplcAdmdvs
  10187. }
  10188. }
  10189. fmt.Println(insutype)
  10190. fmt.Println(insuplc_admdvs)
  10191. }
  10192. if social_type > 0 {
  10193. insutype = strconv.FormatInt(social_type, 10)
  10194. }
  10195. result, requestLog := service.Gdyb2201A(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)
  10196. saveLog(result, requestLog, "2201A", "挂号")
  10197. if miConfig.Code == "H15049901371" {
  10198. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  10199. utils.ErrorLog("解析失败:%v", err)
  10200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10201. return
  10202. }
  10203. resThree.ErrMsg = resThree10265.ErrMsg
  10204. resThree.Output = resThree10265.Output
  10205. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  10206. } else {
  10207. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10208. utils.ErrorLog("解析失败:%v", err)
  10209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10210. return
  10211. }
  10212. }
  10213. if miConfig.Code == "H15049901371" {
  10214. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  10215. } else {
  10216. infocode = resThree.Infcode
  10217. }
  10218. }
  10219. if infocode != 0 {
  10220. adminUser := c.GetAdminUserInfo()
  10221. errlog := &models.HisOrderError{
  10222. UserOrgId: adminUser.CurrentOrgId,
  10223. Ctime: time.Now().Unix(),
  10224. Mtime: time.Now().Unix(),
  10225. ErrMsg: resThree.ErrMsg,
  10226. Status: 1,
  10227. PatientId: id,
  10228. RecordTime: recordDateTime,
  10229. Stage: 2,
  10230. }
  10231. service.CreateErrMsgLog(errlog)
  10232. c.ServeSuccessJSON(map[string]interface{}{
  10233. "failed_code": -10,
  10234. "msg": resThree.ErrMsg,
  10235. })
  10236. return
  10237. }
  10238. his.Number = resThree.Output.Data.MdtrtID
  10239. his.PsnNo = resThree.Output.Data.PsnNo
  10240. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  10241. his.IdCardNo = patient.IdCardNo
  10242. his.PhoneNumber = patient.Phone
  10243. his.UserOrgId = adminInfo.CurrentOrgId
  10244. his.Insutype = insutype
  10245. his.Ctime = time.Now().Unix()
  10246. his.Mtime = time.Now().Unix()
  10247. his.InsuplcAdmdvs = insuplc_admdvs_temp
  10248. his.Status = 1
  10249. his.MdtrtGrpType = mdtrt_type
  10250. service.UpdateHisPatientStatus(&his)
  10251. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  10252. c.ServeSuccessJSON(map[string]interface{}{
  10253. "his_info": his,
  10254. })
  10255. } else {
  10256. adminUser := c.GetAdminUserInfo()
  10257. errlog := &models.HisOrderError{
  10258. UserOrgId: adminUser.CurrentOrgId,
  10259. Ctime: time.Now().Unix(),
  10260. Mtime: time.Now().Unix(),
  10261. ErrMsg: res.ErrMsg,
  10262. Status: 1,
  10263. PatientId: id,
  10264. RecordTime: recordDateTime,
  10265. Stage: 1,
  10266. }
  10267. service.CreateErrMsgLog(errlog)
  10268. c.ServeSuccessJSON(map[string]interface{}{
  10269. "failed_code": -10,
  10270. "msg": res.ErrMsg,
  10271. })
  10272. return
  10273. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  10274. }
  10275. }
  10276. }
  10277. func (c *HisApiController) GetUploadInfo() {
  10278. id, _ := c.GetInt64("id")
  10279. record_time := c.GetString("record_time")
  10280. his_patient_id, _ := c.GetInt64("his_patient_id")
  10281. order_id, _ := c.GetInt64("order_id")
  10282. pay_way, _ := c.GetInt64("pay_way")
  10283. pay_ways := c.GetString("pay_ways")
  10284. oth_desc := c.GetString("oth_desc")
  10285. pay_price, _ := c.GetFloat("pay_price")
  10286. pay_card_no := c.GetString("pay_card_no")
  10287. discount_price, _ := c.GetFloat("discount_price")
  10288. preferential_price, _ := c.GetFloat("preferential_price")
  10289. reality_price, _ := c.GetFloat("reality_price")
  10290. found_price, _ := c.GetFloat("found_price")
  10291. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  10292. private_price, _ := c.GetFloat("private_price")
  10293. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  10294. admin_user_id, _ := c.GetInt64("admin_user_id")
  10295. fapiao_code := c.GetString("fapiao_code")
  10296. fapiao_number := c.GetString("fapiao_number")
  10297. diagnosis_id := c.GetString("diagnosis")
  10298. sick_type, _ := c.GetInt64("sick_type")
  10299. reg_type, _ := c.GetInt64("p_type")
  10300. begin_time := c.GetString("begin_time")
  10301. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  10302. cash_pay := c.GetString("cash_pay")
  10303. band_card_pay := c.GetString("band_card_pay")
  10304. wechat_pay := c.GetString("wechat_pay")
  10305. ali_pay := c.GetString("ali_pay")
  10306. jifen_pay := c.GetString("jifen_pay")
  10307. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  10308. fmt.Println(acct_used_flag)
  10309. id_str := c.GetString("ids")
  10310. ids_arr := strings.Split(id_str, ",")
  10311. timeLayout := "2006-01-02"
  10312. loc, _ := time.LoadLocation("Local")
  10313. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10314. if err != nil {
  10315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10316. return
  10317. }
  10318. recordDateTime := theTime.Unix()
  10319. adminUser := c.GetAdminUserInfo()
  10320. var tempOrder models.HisOrder
  10321. tempOrder, _ = service.GetHisOrderByID(order_id)
  10322. var prescriptions []*models.HisPrescription
  10323. var start_time int64
  10324. var end_time int64
  10325. //押金模块
  10326. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  10327. tmp_decimal := c.GetString("tmp_decimal")
  10328. var decimal float64 //本次使用的押金
  10329. var errmsg error
  10330. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  10331. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  10332. return
  10333. }
  10334. if len(tmp_decimal) > 0 {
  10335. if tmp_decimal[0] == 45 {
  10336. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  10337. return
  10338. }
  10339. }
  10340. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  10341. fmt.Println(errs)
  10342. decimal = tt
  10343. //if adminUser.CurrentOrgId == 10106{
  10344. // if len(fapiao_code) == 0{
  10345. // fapiao_code = "144072080589"
  10346. // }
  10347. // if len(fapiao_number) == 0{
  10348. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  10349. // if order.ID == 0{
  10350. // fapiao_number = "00001520"
  10351. // }else{
  10352. // //fapiao_code = "00001520"
  10353. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  10354. // var zero string
  10355. // if fpNumber >= 1000{
  10356. // zero = "0000" + strconv.Itoa(fpNumber)
  10357. // }else if fpNumber >= 10000{
  10358. // zero = "000" + strconv.Itoa(fpNumber)
  10359. // } else if fpNumber >= 100000{
  10360. // zero = "00" + strconv.Itoa(fpNumber)
  10361. // } else if fpNumber >= 1000000{
  10362. // zero = "0" + strconv.Itoa(fpNumber)
  10363. // }else {
  10364. // zero = strconv.Itoa(fpNumber)
  10365. // }
  10366. // fapiao_number = zero
  10367. // }
  10368. // }
  10369. //}
  10370. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10371. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10372. var patientPrescription models.HisPrescriptionInfo
  10373. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10374. if patientPrescription.ID == 0 {
  10375. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10376. }
  10377. //if patientPrescription.Do
  10378. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10379. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10380. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10381. diagnosis_ids := strings.Split(diagnosis_id, ",")
  10382. var config []*models.HisXtDiagnoseConfig
  10383. for _, item := range diagnosis_ids {
  10384. id, _ := strconv.ParseInt(item, 10, 64)
  10385. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10386. config = append(config, &diagnosisConfig)
  10387. }
  10388. sickConfig, _ := service.FindSickById(sick_type)
  10389. //if tempOrder.ID == 0 {
  10390. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  10391. //}
  10392. if tempOrder.ID == 0 {
  10393. var result string
  10394. var requestLog string
  10395. var res2 ResultSix
  10396. var ressix10265 ResultSix10265
  10397. if miConfig.MdtrtareaAdmvs == "421300" {
  10398. data := make(map[string]interface{})
  10399. client := &http.Client{}
  10400. data["psn_no"] = his.PsnNo
  10401. data["mdtrt_id"] = his.Number
  10402. data["opter"] = roles.UserName
  10403. data["org_name"] = miConfig.OrgName
  10404. data["med_type"] = strconv.FormatInt(reg_type, 10)
  10405. data["doctor_id"] = doctor_info.DoctorNumber
  10406. data["doctor_name"] = doctor_info.UserName
  10407. data["department"] = department.Name
  10408. data["fixmedins_code"] = miConfig.Code
  10409. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  10410. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10411. data["secret_key"] = miConfig.SecretKey
  10412. data["sick_code"] = sickConfig.CountryCode
  10413. data["sick_name"] = sickConfig.ClassName
  10414. data["dept"] = strconv.FormatInt(department.ID, 10)
  10415. data["config"] = config
  10416. data["begin_time"] = begin_time
  10417. bytesData, _ := json.Marshal(data)
  10418. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  10419. resp, _ := client.Do(req)
  10420. defer resp.Body.Close()
  10421. body, ioErr := ioutil.ReadAll(resp.Body)
  10422. if ioErr != nil {
  10423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10425. return
  10426. }
  10427. var respJSON map[string]interface{}
  10428. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10431. return
  10432. }
  10433. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10434. userJSONBytes, _ := json.Marshal(respJSON)
  10435. fmt.Println("log")
  10436. fmt.Println(string(userJSONBytes))
  10437. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10438. utils.ErrorLog("解析失败:%v", err)
  10439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10440. return
  10441. }
  10442. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10443. data := make(map[string]interface{})
  10444. client := &http.Client{}
  10445. data["psn_no"] = his.PsnNo
  10446. data["mdtrt_id"] = his.Number
  10447. data["doctor"] = roles.UserName
  10448. data["department"] = department.Name
  10449. data["org_name"] = miConfig.OrgName
  10450. data["med_type"] = strconv.FormatInt(reg_type, 10)
  10451. data["doctor_id"] = doctor_info.DoctorNumber
  10452. data["new_doctor_name"] = doctor_info.UserName
  10453. data["fixmedins_code"] = miConfig.Code
  10454. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  10455. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10456. data["secret_key"] = miConfig.SecretKey
  10457. data["sick_code"] = sickConfig.CountryCode
  10458. data["sick_name"] = sickConfig.ClassName
  10459. data["url"] = miConfig.Url
  10460. data["ak"] = miConfig.AccessKey
  10461. data["begin_time"] = begin_time
  10462. data["cainfo"] = miConfig.Cainfo
  10463. data["dept"] = strconv.FormatInt(department.ID, 10)
  10464. data["config"] = config
  10465. bytesData, _ := json.Marshal(data)
  10466. var req *http.Request
  10467. if miConfig.MdtrtareaAdmvs == "320921" {
  10468. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  10469. //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 +
  10470. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  10471. } else {
  10472. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  10473. }
  10474. resp, _ := client.Do(req)
  10475. defer resp.Body.Close()
  10476. body, ioErr := ioutil.ReadAll(resp.Body)
  10477. if ioErr != nil {
  10478. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10480. return
  10481. }
  10482. var respJSON map[string]interface{}
  10483. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10486. return
  10487. }
  10488. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10489. userJSONBytes, _ := json.Marshal(respJSON)
  10490. fmt.Println("log")
  10491. fmt.Println(string(userJSONBytes))
  10492. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  10493. utils.ErrorLog("解析失败:%v", err)
  10494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10495. return
  10496. }
  10497. res2.InfRefmsgid = ressix10265.InfRefmsgid
  10498. res2.Output = ressix10265.Output
  10499. res2.ErrMsg = ressix10265.ErrMsg
  10500. res2.Cainfo = ressix10265.Cainfo
  10501. res2.WarnMsg = ressix10265.WarnMsg
  10502. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  10503. res2.Infcode = infocode
  10504. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10505. 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)
  10506. saveLog(result, requestLog, "2203", "上传就诊信息")
  10507. var respJSON2 map[string]interface{}
  10508. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10511. return
  10512. }
  10513. userJSONBytes2, _ := json.Marshal(respJSON2)
  10514. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10515. utils.ErrorLog("解析失败:%v", err)
  10516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10517. return
  10518. }
  10519. 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)
  10520. fmt.Println(result2)
  10521. fmt.Println(src_request)
  10522. } else {
  10523. if miConfig.MdtrtareaAdmvs == "440781" { //
  10524. 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)
  10525. } else {
  10526. if miConfig.Code == "H15049901371" {
  10527. //赤峰地区国家医保医疗类别
  10528. //职工透析:医疗类别选特殊情况门诊990502
  10529. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10530. var med_type string
  10531. if his.Insutype == "390" {
  10532. if reg_type == 14 {
  10533. med_type = "9933"
  10534. } else if reg_type == 11 {
  10535. med_type = "11"
  10536. }
  10537. } else if his.Insutype == "310" {
  10538. if reg_type == 14 {
  10539. med_type = "990502"
  10540. } else if reg_type == 11 {
  10541. med_type = "11"
  10542. }
  10543. }
  10544. 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)
  10545. } else {
  10546. 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)
  10547. }
  10548. }
  10549. saveLog(result, requestLog, "2203", "上传就诊信息")
  10550. var respJSON2 map[string]interface{}
  10551. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10554. return
  10555. }
  10556. userJSONBytes2, _ := json.Marshal(respJSON2)
  10557. if miConfig.Code == "H15049901371" {
  10558. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  10559. utils.ErrorLog("解析失败:%v", err)
  10560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10561. return
  10562. }
  10563. res2.InfRefmsgid = ressix10265.InfRefmsgid
  10564. res2.Output = ressix10265.Output
  10565. res2.ErrMsg = ressix10265.ErrMsg
  10566. res2.Cainfo = ressix10265.Cainfo
  10567. res2.WarnMsg = ressix10265.WarnMsg
  10568. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  10569. res2.Infcode = infocode
  10570. } else {
  10571. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10572. utils.ErrorLog("解析失败:%v", err)
  10573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10574. return
  10575. }
  10576. }
  10577. }
  10578. if res2.Infcode != 0 {
  10579. adminUser := c.GetAdminUserInfo()
  10580. errlog := &models.HisOrderError{
  10581. UserOrgId: adminUser.CurrentOrgId,
  10582. Ctime: time.Now().Unix(),
  10583. Mtime: time.Now().Unix(),
  10584. ErrMsg: res2.ErrMsg,
  10585. Status: 1,
  10586. PatientId: id,
  10587. RecordTime: recordDateTime,
  10588. Stage: 3,
  10589. }
  10590. service.CreateErrMsgLog(errlog)
  10591. c.ServeSuccessJSON(map[string]interface{}{
  10592. "failed_code": -10,
  10593. "msg": res2.ErrMsg,
  10594. })
  10595. return
  10596. } else {
  10597. his.Diagnosis = diagnosis_id
  10598. his.SickType = sickConfig.ID
  10599. //var p_type int64
  10600. //if reg_type == 1111 || reg_type == 1112 {
  10601. // p_type = 11
  10602. //
  10603. //}
  10604. his.PType = fmt.Sprintf("%d", reg_type)
  10605. service.UpdateHisPatientThree(&his)
  10606. data := make(map[string]interface{})
  10607. if settle_accounts_type == 1 { //日结
  10608. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  10609. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  10610. } else {
  10611. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  10612. }
  10613. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  10614. data["pre"] = prescriptions
  10615. } else { //月结
  10616. start_time_str := c.GetString("start_time")
  10617. end_time_str := c.GetString("end_time")
  10618. timeLayout := "2006-01-02"
  10619. loc, _ := time.LoadLocation("Local")
  10620. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  10621. if err != nil {
  10622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10623. return
  10624. }
  10625. recordStartTime := theStartTime.Unix()
  10626. start_time = recordStartTime
  10627. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  10628. if err != nil {
  10629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10630. return
  10631. }
  10632. recordEndTime := theEndTime.Unix()
  10633. end_time = recordEndTime
  10634. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  10635. data["pre"] = prescriptions
  10636. }
  10637. timestamp := time.Now().Unix()
  10638. tempTime := time.Unix(timestamp, 0)
  10639. timeFormat := tempTime.Format("20060102150405")
  10640. chrgBchno := rand.Intn(100000) + 10000
  10641. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  10642. strconv.FormatInt(his.PatientId, 10)
  10643. client := &http.Client{}
  10644. data["psn_no"] = his.PsnNo
  10645. data["mdtrt_id"] = his.Number
  10646. data["chrg_bchno"] = chrg_bchno
  10647. data["org_name"] = miConfig.OrgName
  10648. data["doctor"] = doctor_info.UserName
  10649. data["doctor_id"] = doctor_info.DoctorNumber
  10650. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  10651. data["fixmedins_code"] = miConfig.Code
  10652. data["opter"] = roles.UserName
  10653. data["dept_code"] = department.Number
  10654. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  10655. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10656. data["secret_key"] = miConfig.SecretKey
  10657. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  10658. data["url"] = miConfig.Url
  10659. data["ak"] = miConfig.AccessKey
  10660. data["new_doctor_name"] = patientPrescription.Doctor
  10661. data["diag_code"] = sickConfig.CountryCode
  10662. data["cainfo"] = miConfig.Cainfo
  10663. data["opter"] = roles.UserName
  10664. var ids []int64
  10665. for _, item := range prescriptions {
  10666. ids = append(ids, item.ID)
  10667. }
  10668. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10669. if config.IsOpen == 1 { //对接了医保,走医保流程
  10670. var res ResultFour
  10671. var resFour10265 ResultFour10265
  10672. if miConfig.MdtrtareaAdmvs == "421300" {
  10673. bytesData, _ := json.Marshal(data)
  10674. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  10675. resp, _ := client.Do(req)
  10676. defer resp.Body.Close()
  10677. body, ioErr := ioutil.ReadAll(resp.Body)
  10678. if ioErr != nil {
  10679. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10681. return
  10682. }
  10683. var respJSON map[string]interface{}
  10684. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10685. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10687. return
  10688. }
  10689. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10690. userJSONBytes, _ := json.Marshal(respJSON)
  10691. fmt.Println("log")
  10692. fmt.Println(string(userJSONBytes))
  10693. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10694. utils.ErrorLog("解析失败:%v", err)
  10695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10696. return
  10697. }
  10698. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10699. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  10700. if result3101.Infcode == "0" {
  10701. if len(result3101.Output.Result) > 0 {
  10702. var errMsgs []string
  10703. for _, item := range result3101.Output.Result {
  10704. errMsgs = append(errMsgs, item.VolaCont)
  10705. }
  10706. c.ServeSuccessJSON(map[string]interface{}{
  10707. "failed_code": -10,
  10708. "msg": errMsgs,
  10709. })
  10710. return
  10711. }
  10712. }
  10713. if miConfig.MdtrtareaAdmvs == "320921" {
  10714. data["doctor_id"] = "D320923012139"
  10715. } else {
  10716. data["doctor_id"] = "D371621008686"
  10717. }
  10718. bytesData, _ := json.Marshal(data)
  10719. var req *http.Request
  10720. if miConfig.MdtrtareaAdmvs == "320921" {
  10721. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10722. } else {
  10723. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10724. }
  10725. resp, _ := client.Do(req)
  10726. defer resp.Body.Close()
  10727. body, ioErr := ioutil.ReadAll(resp.Body)
  10728. if ioErr != nil {
  10729. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10731. return
  10732. }
  10733. var respJSON map[string]interface{}
  10734. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10737. return
  10738. }
  10739. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10740. userJSONBytes, _ := json.Marshal(respJSON)
  10741. fmt.Println("log")
  10742. fmt.Println(string(userJSONBytes))
  10743. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  10744. utils.ErrorLog("解析失败:%v", err)
  10745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10746. return
  10747. }
  10748. res.InfRefmsgid = resFour10265.InfRefmsgid
  10749. res.Output = resFour10265.Output
  10750. res.ErrMsg = resFour10265.ErrMsg
  10751. res.Cainfo = resFour10265.Cainfo
  10752. res.WarnMsg = resFour10265.WarnMsg
  10753. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  10754. res.Infcode = infocode
  10755. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10756. 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)
  10757. var dat map[string]interface{}
  10758. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10759. fmt.Println(dat)
  10760. } else {
  10761. fmt.Println(err)
  10762. }
  10763. saveLog(result, request_log, "2204", "上传费用明细")
  10764. userJSONBytes, _ := json.Marshal(dat)
  10765. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  10766. utils.ErrorLog("解析失败:%v", err)
  10767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10768. return
  10769. }
  10770. res.InfRefmsgid = resFour10265.InfRefmsgid
  10771. res.Output = resFour10265.Output
  10772. res.ErrMsg = resFour10265.ErrMsg
  10773. res.Cainfo = resFour10265.Cainfo
  10774. res.WarnMsg = resFour10265.WarnMsg
  10775. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  10776. res.Infcode = infocode
  10777. } else {
  10778. if miConfig.Code == "H15049901371" {
  10779. 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)
  10780. var dat map[string]interface{}
  10781. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10782. fmt.Println(dat)
  10783. } else {
  10784. fmt.Println(err)
  10785. }
  10786. saveLog(result, request_log, "2204", "上传费用明细")
  10787. userJSONBytes, _ := json.Marshal(dat)
  10788. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  10789. utils.ErrorLog("解析失败:%v", err)
  10790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10791. return
  10792. }
  10793. res.InfRefmsgid = resFour10265.InfRefmsgid
  10794. res.Output = resFour10265.Output
  10795. res.ErrMsg = resFour10265.ErrMsg
  10796. res.Cainfo = resFour10265.Cainfo
  10797. res.WarnMsg = resFour10265.WarnMsg
  10798. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  10799. res.Infcode = infocode
  10800. } else {
  10801. 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)
  10802. var dat map[string]interface{}
  10803. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10804. fmt.Println(dat)
  10805. } else {
  10806. fmt.Println(err)
  10807. }
  10808. saveLog(result, request_log, "2204", "上传费用明细")
  10809. userJSONBytes, _ := json.Marshal(dat)
  10810. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10811. utils.ErrorLog("解析失败:%v", err)
  10812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10813. return
  10814. }
  10815. }
  10816. }
  10817. if res.Infcode == 0 {
  10818. order := &models.HisOrder{
  10819. UserOrgId: adminUser.CurrentOrgId,
  10820. HisPatientId: his.ID,
  10821. PatientId: his.PatientId,
  10822. SettleAccountsDate: recordDateTime,
  10823. MdtrtId: his.Number,
  10824. PsnNo: his.PsnNo,
  10825. MedType: strconv.FormatInt(reg_type, 10),
  10826. Ctime: time.Now().Unix(),
  10827. Mtime: time.Now().Unix(),
  10828. Status: 1,
  10829. Number: chrg_bchno,
  10830. Infcode: res.Infcode,
  10831. WarnMsg: res.WarnMsg,
  10832. Cainfo: res.Cainfo,
  10833. ErrMsg: res.ErrMsg,
  10834. RespondTime: res.RefmsgTime,
  10835. InfRefmsgid: res.InfRefmsgid,
  10836. OrderStatus: 1,
  10837. PayWay: pay_way,
  10838. PayWays: pay_ways,
  10839. OthDesc: oth_desc,
  10840. PayPrice: pay_price,
  10841. PayCardNo: pay_card_no,
  10842. DiscountPrice: discount_price,
  10843. PreferentialPrice: preferential_price,
  10844. RealityPrice: reality_price,
  10845. FoundPrice: found_price,
  10846. MedicalInsurancePrice: medical_insurance_price,
  10847. PrivatePrice: private_price,
  10848. IsMedicineInsurance: 1,
  10849. SettleType: settle_accounts_type,
  10850. SettleStartTime: start_time,
  10851. SettleEndTime: end_time,
  10852. Creator: roles.AdminUserId,
  10853. Modify: roles.AdminUserId,
  10854. FaPiaoNumber: fapiao_number,
  10855. FaPiaoCode: fapiao_code,
  10856. PType: 2,
  10857. Diagnosis: diagnosis_id,
  10858. CashPay: cash_pay,
  10859. WechatPay: wechat_pay,
  10860. AliPay: ali_pay,
  10861. JifenPay: jifen_pay,
  10862. BandCardPay: band_card_pay,
  10863. }
  10864. err = service.CreateOrder(order)
  10865. if err != nil {
  10866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  10867. return
  10868. }
  10869. for _, item := range res.Output.Result {
  10870. temp := strings.Split(item.FeedetlSn, "-")
  10871. var advice_id int64 = 0
  10872. var project_id int64 = 0
  10873. var types int64 = 0
  10874. id, _ := strconv.ParseInt(temp[2], 10, 64)
  10875. types, _ = strconv.ParseInt(temp[1], 10, 64)
  10876. if temp[1] == "1" {
  10877. advice_id = id
  10878. project_id = 0
  10879. } else if temp[1] == "2" {
  10880. advice_id = 0
  10881. project_id = id
  10882. }
  10883. if item.MedChrgitmType == "9" {
  10884. item.MedChrgitmType = "09"
  10885. }
  10886. info := &models.HisOrderInfo{
  10887. OrderNumber: order.Number,
  10888. FeedetlSn: item.FeedetlSn,
  10889. UploadDate: time.Now().Unix(),
  10890. AdviceId: advice_id,
  10891. DetItemFeeSumamt: item.DetItemFeeSumamt,
  10892. Cnt: item.Cnt,
  10893. Pric: float64(item.Pric),
  10894. PatientId: his.PatientId,
  10895. PricUplmtAmt: item.PricUplmtAmt,
  10896. SelfpayProp: item.SelfpayProp,
  10897. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  10898. OverlmtAmt: item.OverlmtAmt,
  10899. PreselfpayAmt: item.PreselfpayAmt,
  10900. BasMednFlag: item.BasMednFlag,
  10901. MedChrgitmType: item.MedChrgitmType,
  10902. HiNegoDrugFlag: item.HiNegoDrugFlag,
  10903. Status: 1,
  10904. Memo: item.Memo,
  10905. Mtime: time.Now().Unix(),
  10906. InscpScpAmt: item.InscpScpAmt,
  10907. DrtReimFlag: item.DrtReimFlag,
  10908. Ctime: time.Now().Unix(),
  10909. ListSpItemFlag: item.ListSpItemFlag,
  10910. ChldMedcFlag: item.ChldMedcFlag,
  10911. LmtUsedFlag: item.LmtUsedFlag,
  10912. ChrgitmLv: item.ChrgitmLv,
  10913. UserOrgId: adminUser.CurrentOrgId,
  10914. HisPatientId: his.ID,
  10915. OrderId: order.ID,
  10916. ProjectId: project_id,
  10917. Type: types,
  10918. }
  10919. service.CreateOrderInfo(info)
  10920. }
  10921. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10922. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  10923. var total float64
  10924. for _, item := range prescriptions {
  10925. if item.Type == 1 { //药品
  10926. for _, subItem := range item.HisDoctorAdviceInfo {
  10927. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  10928. total_one := price * subItem.PrescribingNumber
  10929. total = total + total_one
  10930. }
  10931. }
  10932. if item.Type == 2 { //项目
  10933. for _, subItem := range item.HisPrescriptionProject {
  10934. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10935. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  10936. total_one := price * cnt
  10937. total = total + total_one
  10938. }
  10939. }
  10940. }
  10941. allTotal := fmt.Sprintf("%f", total)
  10942. //if adminUser.CurrentOrgId == 9919 {
  10943. //
  10944. // allTotal = fmt.Sprintf("%.2f", total)
  10945. //
  10946. //} else {
  10947. //
  10948. // allTotal = fmt.Sprintf("%.2f", total)
  10949. //
  10950. //}
  10951. if res.Infcode == 0 {
  10952. var rf []*ResultFive
  10953. json.Unmarshal([]byte(his.Iinfo), &rf)
  10954. chrg_bchno := chrg_bchno
  10955. cert_no := his.Certno
  10956. var insutypes []string
  10957. var insutype string
  10958. var is390 int = 0
  10959. var is310 int = 0
  10960. for _, item := range rf {
  10961. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10962. insutypes = append(insutypes, item.Insutype)
  10963. }
  10964. }
  10965. if len(insutypes) == 1 {
  10966. insutype = insutypes[0]
  10967. } else {
  10968. for _, i := range insutypes {
  10969. if i == "390" {
  10970. is390 = 1
  10971. }
  10972. if i == "310" {
  10973. is310 = 1
  10974. }
  10975. }
  10976. }
  10977. if is390 == 1 {
  10978. insutype = "390"
  10979. }
  10980. if is310 == 1 {
  10981. insutype = "310"
  10982. }
  10983. if len(insutypes) == 0 {
  10984. insutype = "310"
  10985. }
  10986. if len(insutypes) == 2 {
  10987. insutype = strconv.FormatInt(his.SocialType, 10)
  10988. }
  10989. insutype = strconv.FormatInt(his.SocialType, 10)
  10990. //insutype = "390"
  10991. if his.IdCardType == 1 {
  10992. // cert_no = his.MedicalInsuranceNumber
  10993. cert_no = his.Certno
  10994. } else {
  10995. cert_no = his.Certno
  10996. }
  10997. var res ResultSeven
  10998. var resSeven10265 ResultSeven10265
  10999. var src_resquest string
  11000. var result2 string
  11001. if miConfig.MdtrtareaAdmvs == "421300" {
  11002. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11003. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11004. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11005. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11006. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11007. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11008. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  11009. resp, requestErr := http.Get(api)
  11010. if requestErr != nil {
  11011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11012. return
  11013. }
  11014. body, ioErr := ioutil.ReadAll(resp.Body)
  11015. if ioErr != nil {
  11016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11018. return
  11019. }
  11020. var respJSON map[string]interface{}
  11021. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11024. return
  11025. }
  11026. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11027. result, _ := json.Marshal(respJSON)
  11028. if miConfig.Code == "H15049901371" {
  11029. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  11030. utils.ErrorLog("解析失败:%v", err)
  11031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11032. return
  11033. }
  11034. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11035. res.Output = resSeven10265.Output
  11036. res.ErrMsg = resSeven10265.ErrMsg
  11037. res.Cainfo = resSeven10265.Cainfo
  11038. res.WarnMsg = resSeven10265.WarnMsg
  11039. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11040. res.Infcode = infocode
  11041. } else {
  11042. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11043. utils.ErrorLog("解析失败:%v", err)
  11044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11045. return
  11046. }
  11047. }
  11048. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11049. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  11050. if result3101.Infcode == "0" {
  11051. if len(result3101.Output.Result) > 0 {
  11052. var errMsgs []string
  11053. for _, item := range result3101.Output.Result {
  11054. errMsgs = append(errMsgs, item.VolaCont)
  11055. }
  11056. c.ServeSuccessJSON(map[string]interface{}{
  11057. "failed_code": -10,
  11058. "msg": errMsgs,
  11059. })
  11060. return
  11061. } else {
  11062. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11063. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  11064. bas := strings.Split(psn_info.CardInfo, "|")
  11065. if his.IdCardType == 1 {
  11066. cert_no = bas[2]
  11067. } else if his.IdCardType == 3 {
  11068. cert_no = his.Certno
  11069. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  11070. } else if his.IdCardType == 4 {
  11071. cert_no = his.Certno
  11072. psn_info.VerifyNumber = psn_info.VerifyNumber
  11073. }
  11074. var api string
  11075. if miConfig.MdtrtareaAdmvs == "320921" {
  11076. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11077. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11078. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11079. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11080. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11081. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11082. "&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
  11083. } else {
  11084. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11085. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11086. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11087. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11088. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11089. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11090. "&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
  11091. }
  11092. resp, requestErr := http.Get(api)
  11093. if requestErr != nil {
  11094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11095. return
  11096. }
  11097. body, ioErr := ioutil.ReadAll(resp.Body)
  11098. if ioErr != nil {
  11099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11101. return
  11102. }
  11103. var respJSON map[string]interface{}
  11104. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11107. return
  11108. }
  11109. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11110. result, _ := json.Marshal(respJSON)
  11111. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  11112. utils.ErrorLog("解析失败:%v", err)
  11113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11114. return
  11115. }
  11116. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11117. res.Output = resSeven10265.Output
  11118. res.ErrMsg = resSeven10265.ErrMsg
  11119. res.Cainfo = resSeven10265.Cainfo
  11120. res.WarnMsg = resSeven10265.WarnMsg
  11121. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11122. res.Infcode = infocode
  11123. }
  11124. }
  11125. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11126. var cert_no string
  11127. if his.IdCardType == 4 {
  11128. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11129. cert_no = psn_info.VerifyNumber
  11130. 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)
  11131. } else if his.IdCardType == 1 {
  11132. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11133. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  11134. 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)
  11135. }
  11136. //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)
  11137. var dat map[string]interface{}
  11138. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11139. fmt.Println(dat)
  11140. } else {
  11141. fmt.Println(err)
  11142. }
  11143. saveLog(result2, src_resquest, "2207", "结算")
  11144. userJSONBytes, _ := json.Marshal(dat)
  11145. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  11146. utils.ErrorLog("解析失败:%v", err)
  11147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11148. return
  11149. }
  11150. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11151. res.Output = resSeven10265.Output
  11152. res.ErrMsg = resSeven10265.ErrMsg
  11153. res.Cainfo = resSeven10265.Cainfo
  11154. res.WarnMsg = resSeven10265.WarnMsg
  11155. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11156. res.Infcode = infocode
  11157. } else {
  11158. if miConfig.Code == "H15049901371" {
  11159. //赤峰地区国家医保医疗类别
  11160. //职工透析:医疗类别选特殊情况门诊990502
  11161. //居民定额血透门慢: 医疗类别选门诊慢病140104
  11162. var med_type string
  11163. if his.Insutype == "390" {
  11164. if reg_type == 14 {
  11165. med_type = "9933"
  11166. } else if reg_type == 11 {
  11167. med_type = "11"
  11168. }
  11169. } else if his.Insutype == "310" {
  11170. if reg_type == 14 {
  11171. med_type = "990502"
  11172. } else if reg_type == 11 {
  11173. med_type = "11"
  11174. }
  11175. }
  11176. 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, "")
  11177. } else {
  11178. if his.IdCardType == 4 {
  11179. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11180. var token string
  11181. token = psn_info.VerifyNumber
  11182. 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)
  11183. } else {
  11184. 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, "")
  11185. }
  11186. }
  11187. //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)
  11188. var dat map[string]interface{}
  11189. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11190. fmt.Println(dat)
  11191. } else {
  11192. fmt.Println(err)
  11193. }
  11194. saveLog(result2, src_resquest, "2207", "结算")
  11195. userJSONBytes, _ := json.Marshal(dat)
  11196. if miConfig.Code == "H15049901371" {
  11197. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  11198. utils.ErrorLog("解析失败:%v", err)
  11199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11200. return
  11201. }
  11202. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11203. res.Output = resSeven10265.Output
  11204. res.ErrMsg = resSeven10265.ErrMsg
  11205. res.Cainfo = resSeven10265.Cainfo
  11206. res.WarnMsg = resSeven10265.WarnMsg
  11207. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11208. res.Infcode = infocode
  11209. } else {
  11210. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11211. utils.ErrorLog("解析失败:%v", err)
  11212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11213. return
  11214. }
  11215. }
  11216. }
  11217. if res.Infcode != 0 {
  11218. errlog := &models.HisOrderError{
  11219. UserOrgId: adminUser.CurrentOrgId,
  11220. Ctime: time.Now().Unix(),
  11221. Mtime: time.Now().Unix(),
  11222. Number: chrg_bchno,
  11223. ErrMsg: res.ErrMsg,
  11224. Status: 1,
  11225. PatientId: id,
  11226. RecordTime: recordDateTime,
  11227. Stage: 6,
  11228. }
  11229. service.CreateErrMsgLog(errlog)
  11230. c.ServeSuccessJSON(map[string]interface{}{
  11231. "failed_code": -10,
  11232. "msg": res.ErrMsg,
  11233. })
  11234. return
  11235. } else {
  11236. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  11237. order.OrderStatus = 2
  11238. order.Status = 1
  11239. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  11240. order.SetlId = res.Output.Setlinfo.SetlID
  11241. order.PsnNo = res.Output.Setlinfo.PsnNo
  11242. order.PsnName = res.Output.Setlinfo.PsnName
  11243. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  11244. order.Certno = res.Output.Setlinfo.Certno
  11245. order.Gend = res.Output.Setlinfo.Gend
  11246. order.Naty = res.Output.Setlinfo.Naty
  11247. order.Age = res.Output.Setlinfo.Age
  11248. order.Insutype = res.Output.Setlinfo.Insutype
  11249. order.PsnType = res.Output.Setlinfo.PsnType
  11250. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  11251. order.SetlTime = res.Output.Setlinfo.SetlTime
  11252. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  11253. if res.Output.Setlinfo.MedType == "140101" {
  11254. order.MedType = "14"
  11255. } else {
  11256. order.MedType = res.Output.Setlinfo.MedType
  11257. }
  11258. if reg_type == 1112 {
  11259. order.MedType = "1112"
  11260. }
  11261. if reg_type == 1111 {
  11262. order.MedType = "1111"
  11263. }
  11264. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  11265. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  11266. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  11267. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  11268. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  11269. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  11270. order.HifpPay = res.Output.Setlinfo.HifpPay
  11271. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  11272. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  11273. order.HifesPay = res.Output.Setlinfo.HifesPay
  11274. order.HifobPay = res.Output.Setlinfo.HifobPay
  11275. order.MafPay = res.Output.Setlinfo.MafPay
  11276. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  11277. order.OthPay = res.Output.Setlinfo.OthPay
  11278. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  11279. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  11280. order.AcctPay = res.Output.Setlinfo.AcctPay
  11281. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  11282. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  11283. order.Balc = res.Output.Setlinfo.Balc
  11284. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  11285. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  11286. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  11287. order.ClrType = res.Output.Setlinfo.ClrType
  11288. order.ClrWay = res.Output.Setlinfo.ClrWay
  11289. order.Creator = order.Creator
  11290. order.Modify = roles.AdminUserId
  11291. order.RequestLog = src_resquest
  11292. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  11293. detailStr := string(setlDetail)
  11294. order.SetlDetail = detailStr
  11295. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  11296. err = service.UpDateOrder(order)
  11297. if err == nil {
  11298. //判断是否使用了押金
  11299. if dec_way == "true" {
  11300. tmpstring := strconv.FormatInt(order.ID, 10)
  11301. order.Decimal = decimal
  11302. service.UpDateOrder(order)
  11303. //扣押金
  11304. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  11305. if errmsg != nil {
  11306. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  11307. return
  11308. }
  11309. }
  11310. c.ServeSuccessJSON(map[string]interface{}{
  11311. "msg": "结算成功",
  11312. })
  11313. } else {
  11314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  11315. return
  11316. }
  11317. }
  11318. } else {
  11319. adminUser := c.GetAdminUserInfo()
  11320. errlog := &models.HisOrderError{
  11321. UserOrgId: adminUser.CurrentOrgId,
  11322. Ctime: time.Now().Unix(),
  11323. Mtime: time.Now().Unix(),
  11324. ErrMsg: res.ErrMsg,
  11325. Status: 1,
  11326. PatientId: id,
  11327. RecordTime: recordDateTime,
  11328. Stage: 4,
  11329. }
  11330. service.CreateErrMsgLog(errlog)
  11331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  11332. return
  11333. }
  11334. } else {
  11335. adminUser := c.GetAdminUserInfo()
  11336. errlog := &models.HisOrderError{
  11337. UserOrgId: adminUser.CurrentOrgId,
  11338. Ctime: time.Now().Unix(),
  11339. Mtime: time.Now().Unix(),
  11340. ErrMsg: res.ErrMsg,
  11341. Status: 1,
  11342. PatientId: id,
  11343. RecordTime: recordDateTime,
  11344. Stage: 4,
  11345. }
  11346. service.CreateErrMsgLog(errlog)
  11347. c.ServeSuccessJSON(map[string]interface{}{
  11348. "failed_code": -10,
  11349. "msg": res.ErrMsg,
  11350. })
  11351. return
  11352. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  11353. //return
  11354. }
  11355. }
  11356. }
  11357. } else if tempOrder.ID > 0 {
  11358. if tempOrder.IsPre == 1 {
  11359. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  11360. var rf []*ResultFive
  11361. json.Unmarshal([]byte(his.Iinfo), &rf)
  11362. chrg_bchno := tempOrder.Number
  11363. cert_no := his.Certno
  11364. var insutypes []string
  11365. var insutype string
  11366. var is390 int = 0
  11367. var is310 int = 0
  11368. for _, item := range rf {
  11369. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11370. insutypes = append(insutypes, item.Insutype)
  11371. }
  11372. }
  11373. if len(insutypes) == 1 {
  11374. insutype = insutypes[0]
  11375. } else {
  11376. for _, i := range insutypes {
  11377. if i == "390" {
  11378. is390 = 1
  11379. }
  11380. if i == "310" {
  11381. is310 = 1
  11382. }
  11383. }
  11384. }
  11385. if is390 == 1 {
  11386. insutype = "390"
  11387. }
  11388. if is310 == 1 {
  11389. insutype = "310"
  11390. }
  11391. if len(insutypes) == 0 {
  11392. insutype = "310"
  11393. }
  11394. if len(insutypes) == 2 {
  11395. insutype = strconv.FormatInt(his.SocialType, 10)
  11396. }
  11397. //insutype = "390"
  11398. if his.IdCardType == 1 {
  11399. // cert_no = his.MedicalInsuranceNumber
  11400. cert_no = his.Certno
  11401. } else {
  11402. cert_no = his.Certno
  11403. }
  11404. var res ResultSeven
  11405. var resSeven10265 ResultSeven10265
  11406. var src_resquest string
  11407. var result2 string
  11408. if miConfig.MdtrtareaAdmvs == "421300" {
  11409. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11410. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11411. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11412. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11413. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11414. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11415. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  11416. resp, requestErr := http.Get(api)
  11417. if requestErr != nil {
  11418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11419. return
  11420. }
  11421. body, ioErr := ioutil.ReadAll(resp.Body)
  11422. if ioErr != nil {
  11423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11425. return
  11426. }
  11427. var respJSON map[string]interface{}
  11428. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11431. return
  11432. }
  11433. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11434. result, _ := json.Marshal(respJSON)
  11435. fmt.Println("log")
  11436. fmt.Println(string(result))
  11437. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11438. utils.ErrorLog("解析失败:%v", err)
  11439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11440. return
  11441. }
  11442. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11443. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  11444. if result3101.Infcode == "0" {
  11445. if len(result3101.Output.Result) > 0 {
  11446. var errMsgs []string
  11447. for _, item := range result3101.Output.Result {
  11448. errMsgs = append(errMsgs, item.VolaCont)
  11449. }
  11450. c.ServeSuccessJSON(map[string]interface{}{
  11451. "failed_code": -10,
  11452. "msg": errMsgs,
  11453. })
  11454. return
  11455. } else {
  11456. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11457. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  11458. bas := strings.Split(psn_info.CardInfo, "|")
  11459. if his.IdCardType == 1 {
  11460. cert_no = bas[2]
  11461. } else if his.IdCardType == 3 {
  11462. cert_no = his.Certno
  11463. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  11464. } else if his.IdCardType == 4 {
  11465. cert_no = his.Certno
  11466. psn_info.VerifyNumber = psn_info.VerifyNumber
  11467. }
  11468. //江苏地区国家医保医疗类别
  11469. //职工透析:医疗类别选特殊情况门诊9933
  11470. //居民血透门慢: 医疗类别选门诊慢病1402
  11471. //var med_type string
  11472. //if his.Insutype == "310" {
  11473. // if reg_type == 14 {
  11474. // med_type = "9933"
  11475. // } else if reg_type == 11 {
  11476. // med_type = "11"
  11477. //
  11478. // }
  11479. //} else if his.Insutype == "390" {
  11480. // if reg_type == 14 {
  11481. // med_type = "1402"
  11482. // } else if reg_type == 11 {
  11483. // med_type = "11"
  11484. // }
  11485. //}
  11486. var api string
  11487. if miConfig.MdtrtareaAdmvs == "320921" {
  11488. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11489. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11490. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11491. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11492. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11493. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11494. "&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
  11495. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11496. } else {
  11497. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11498. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11499. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11500. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11501. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11502. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11503. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11504. "&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
  11505. }
  11506. resp, requestErr := http.Get(api)
  11507. if requestErr != nil {
  11508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11509. return
  11510. }
  11511. body, ioErr := ioutil.ReadAll(resp.Body)
  11512. if ioErr != nil {
  11513. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11515. return
  11516. }
  11517. var respJSON map[string]interface{}
  11518. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11521. return
  11522. }
  11523. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11524. result, _ := json.Marshal(respJSON)
  11525. fmt.Println("log")
  11526. fmt.Println(string(result))
  11527. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  11528. utils.ErrorLog("解析失败:%v", err)
  11529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11530. return
  11531. }
  11532. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11533. res.Output = resSeven10265.Output
  11534. res.ErrMsg = resSeven10265.ErrMsg
  11535. res.Cainfo = resSeven10265.Cainfo
  11536. res.WarnMsg = resSeven10265.WarnMsg
  11537. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11538. res.Infcode = infocode
  11539. }
  11540. }
  11541. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11542. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11543. var cert_no string
  11544. if his.IdCardType == 1 {
  11545. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  11546. } else {
  11547. cert_no = psn_info.VerifyNumber
  11548. }
  11549. 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)
  11550. var dat map[string]interface{}
  11551. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11552. fmt.Println(dat)
  11553. } else {
  11554. fmt.Println(err)
  11555. }
  11556. saveLog(result2, src_resquest, "2207", "结算")
  11557. userJSONBytes, _ := json.Marshal(dat)
  11558. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11559. utils.ErrorLog("解析失败:%v", err)
  11560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11561. return
  11562. }
  11563. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11564. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11565. var cert_no string
  11566. if his.IdCardType == 1 {
  11567. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  11568. } else if his.IdCardType == 2 {
  11569. cert_no = his.IdCardNo
  11570. } else {
  11571. cert_no = psn_info.VerifyNumber
  11572. }
  11573. 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, "")
  11574. var dat map[string]interface{}
  11575. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11576. fmt.Println(dat)
  11577. } else {
  11578. fmt.Println(err)
  11579. }
  11580. saveLog(result2, src_resquest, "2207", "结算")
  11581. userJSONBytes, _ := json.Marshal(dat)
  11582. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11583. utils.ErrorLog("解析失败:%v", err)
  11584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11585. return
  11586. }
  11587. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11588. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11589. var cert_no string
  11590. if his.IdCardType == 1 {
  11591. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  11592. } else if his.IdCardType == 2 {
  11593. cert_no = his.IdCardNo
  11594. } else {
  11595. cert_no = psn_info.VerifyNumber
  11596. }
  11597. 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, "")
  11598. var dat map[string]interface{}
  11599. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11600. fmt.Println(dat)
  11601. } else {
  11602. fmt.Println(err)
  11603. }
  11604. saveLog(result2, src_resquest, "2207", "结算")
  11605. userJSONBytes, _ := json.Marshal(dat)
  11606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11607. utils.ErrorLog("解析失败:%v", err)
  11608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11609. return
  11610. }
  11611. } else {
  11612. var src_resquest string
  11613. if miConfig.Code == "H15049901371" {
  11614. //赤峰地区国家医保医疗类别
  11615. //职工透析:医疗类别选特殊情况门诊990502
  11616. //居民定额血透门慢: 医疗类别选门诊慢病140104
  11617. var med_type string
  11618. if his.Insutype == "390" {
  11619. if reg_type == 14 {
  11620. med_type = "9933"
  11621. } else if reg_type == 11 {
  11622. med_type = "11"
  11623. }
  11624. } else if his.Insutype == "310" {
  11625. if reg_type == 14 {
  11626. med_type = "990502"
  11627. } else if reg_type == 11 {
  11628. med_type = "11"
  11629. }
  11630. }
  11631. 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, "")
  11632. } else {
  11633. if his.IdCardType == 4 {
  11634. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11635. token := psn_info.VerifyNumber
  11636. 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)
  11637. } else {
  11638. 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, "")
  11639. }
  11640. }
  11641. var dat map[string]interface{}
  11642. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11643. fmt.Println(dat)
  11644. } else {
  11645. fmt.Println(err)
  11646. }
  11647. saveLog(result2, src_resquest, "2207", "结算")
  11648. userJSONBytes, _ := json.Marshal(dat)
  11649. if miConfig.Code == "H15049901371" {
  11650. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  11651. utils.ErrorLog("解析失败:%v", err)
  11652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11653. return
  11654. }
  11655. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11656. res.Output = resSeven10265.Output
  11657. res.ErrMsg = resSeven10265.ErrMsg
  11658. res.Cainfo = resSeven10265.Cainfo
  11659. res.WarnMsg = resSeven10265.WarnMsg
  11660. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11661. res.Infcode = infocode
  11662. } else {
  11663. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11664. utils.ErrorLog("解析失败:%v", err)
  11665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11666. return
  11667. }
  11668. }
  11669. }
  11670. if res.Infcode != 0 {
  11671. errlog := &models.HisOrderError{
  11672. UserOrgId: adminUser.CurrentOrgId,
  11673. Ctime: time.Now().Unix(),
  11674. Mtime: time.Now().Unix(),
  11675. Number: chrg_bchno,
  11676. ErrMsg: res.ErrMsg,
  11677. Status: 1,
  11678. PatientId: id,
  11679. RecordTime: recordDateTime,
  11680. Stage: 6,
  11681. }
  11682. service.CreateErrMsgLog(errlog)
  11683. c.ServeSuccessJSON(map[string]interface{}{
  11684. "failed_code": -10,
  11685. "msg": res.ErrMsg,
  11686. })
  11687. return
  11688. } else {
  11689. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  11690. order.OrderStatus = 2
  11691. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  11692. order.SetlId = res.Output.Setlinfo.SetlID
  11693. order.PsnNo = res.Output.Setlinfo.PsnNo
  11694. order.PsnName = res.Output.Setlinfo.PsnName
  11695. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  11696. order.Certno = res.Output.Setlinfo.Certno
  11697. order.Gend = res.Output.Setlinfo.Gend
  11698. order.Naty = res.Output.Setlinfo.Naty
  11699. order.Age = res.Output.Setlinfo.Age
  11700. order.Insutype = res.Output.Setlinfo.Insutype
  11701. order.PsnType = res.Output.Setlinfo.PsnType
  11702. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  11703. order.SetlTime = res.Output.Setlinfo.SetlTime
  11704. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  11705. order.PayWays = pay_ways
  11706. order.AcctUsedFlag = acct_used_flag
  11707. order.WechatPay = wechat_pay
  11708. order.AliPay = ali_pay
  11709. order.JifenPay = jifen_pay
  11710. order.BandCardPay = band_card_pay
  11711. order.CashPay = cash_pay
  11712. order.OthDesc = oth_desc
  11713. //order.MedType = res.Output.Setlinfo.MedType
  11714. if reg_type == 1112 {
  11715. order.MedType = "1112"
  11716. }
  11717. if reg_type == 1111 {
  11718. order.MedType = "1111"
  11719. }
  11720. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  11721. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  11722. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  11723. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  11724. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  11725. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  11726. order.HifpPay = res.Output.Setlinfo.HifpPay
  11727. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  11728. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  11729. order.HifesPay = res.Output.Setlinfo.HifesPay
  11730. order.HifobPay = res.Output.Setlinfo.HifobPay
  11731. order.MafPay = res.Output.Setlinfo.MafPay
  11732. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  11733. order.OthPay = res.Output.Setlinfo.OthPay
  11734. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  11735. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  11736. order.AcctPay = res.Output.Setlinfo.AcctPay
  11737. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  11738. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  11739. order.Balc = res.Output.Setlinfo.Balc
  11740. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  11741. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  11742. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  11743. order.ClrWay = res.Output.Setlinfo.ClrWay
  11744. order.Creator = order.Creator
  11745. order.Modify = roles.AdminUserId
  11746. order.RequestLog = src_resquest
  11747. order.Diagnosis = diagnosis_id
  11748. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  11749. detailStr := string(setlDetail)
  11750. order.SetlDetail = detailStr
  11751. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  11752. err = service.UpDateOrder(order)
  11753. if err == nil {
  11754. //判断是否使用了押金
  11755. if dec_way == "true" {
  11756. tmpstring := strconv.FormatInt(order.ID, 10)
  11757. //扣押金
  11758. order.Decimal = decimal
  11759. service.UpDateOrder(order)
  11760. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  11761. if errmsg != nil {
  11762. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  11763. return
  11764. }
  11765. }
  11766. c.ServeSuccessJSON(map[string]interface{}{
  11767. "msg": "结算成功",
  11768. })
  11769. } else {
  11770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  11771. return
  11772. }
  11773. }
  11774. }
  11775. }
  11776. }
  11777. //func (c *HisApiController) GetPreUploadInfo() {
  11778. // id, _ := c.GetInt64("id")
  11779. // record_time := c.GetString("record_time")
  11780. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  11781. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11782. //
  11783. // timeLayout := "2006-01-02"
  11784. // loc, _ := time.LoadLocation("Local")
  11785. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11786. // if err != nil {
  11787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11788. // return
  11789. // }
  11790. // recordDateTime := theTime.Unix()
  11791. // adminUser := c.GetAdminUserInfo()
  11792. //
  11793. // var prescriptions []*models.HisPrescription
  11794. //
  11795. // var start_time int64
  11796. // var end_time int64
  11797. //
  11798. // data := make(map[string]interface{})
  11799. // if settle_accounts_type == 1 { //日结
  11800. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  11801. // data["pre"] = prescriptions
  11802. //
  11803. // } else { //月结
  11804. // start_time_str := c.GetString("start_time")
  11805. // end_time_str := c.GetString("end_time")
  11806. // timeLayout := "2006-01-02"
  11807. // loc, _ := time.LoadLocation("Local")
  11808. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  11809. // if err != nil {
  11810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11811. // return
  11812. // }
  11813. // recordStartTime := theStartTime.Unix()
  11814. // start_time = recordStartTime
  11815. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  11816. // if err != nil {
  11817. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11818. // return
  11819. // }
  11820. // recordEndTime := theEndTime.Unix()
  11821. // end_time = recordEndTime
  11822. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  11823. // data["pre"] = prescriptions
  11824. //
  11825. // }
  11826. //
  11827. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11828. //
  11829. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  11830. // timestamp := time.Now().Unix()
  11831. // tempTime := time.Unix(timestamp, 0)
  11832. // timeFormat := tempTime.Format("20060102150405")
  11833. // chrgBchno := rand.Intn(100000) + 10000
  11834. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  11835. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11836. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  11837. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11838. // strconv.FormatInt(his.PatientId, 10)
  11839. // client := &http.Client{}
  11840. // data["psn_no"] = his.PsnNo
  11841. // data["mdtrt_id"] = his.Number
  11842. // data["chrg_bchno"] = chrg_bchno
  11843. // data["org_name"] = miConfig.OrgName
  11844. // data["doctor"] = roles.UserName
  11845. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  11846. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  11847. // data["fixmedins_code"] = miConfig.Code
  11848. // data["dept_code"] = department.Number
  11849. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  11850. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11851. // data["secret_key"] = miConfig.SecretKey
  11852. // var ids []int64
  11853. //
  11854. // for _, item := range prescriptions {
  11855. // ids = append(ids, item.ID)
  11856. // }
  11857. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11858. // if config.IsOpen == 1 { //对接了医保,走医保流程
  11859. // bytesData, _ := json.Marshal(data)
  11860. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  11861. // resp, _ := client.Do(req)
  11862. // defer resp.Body.Close()
  11863. // body, ioErr := ioutil.ReadAll(resp.Body)
  11864. // if ioErr != nil {
  11865. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11866. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11867. // return
  11868. // }
  11869. // var respJSON map[string]interface{}
  11870. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11871. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11872. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11873. // return
  11874. // }
  11875. //
  11876. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11877. // userJSONBytes, _ := json.Marshal(respJSON)
  11878. // var res ResultFour
  11879. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11880. // utils.ErrorLog("解析失败:%v", err)
  11881. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11882. // return
  11883. // }
  11884. //
  11885. // if res.Infcode == 0 {
  11886. // order := &models.HisOrder{
  11887. // UserOrgId: adminUser.CurrentOrgId,
  11888. // HisPatientId: his.ID,
  11889. // PatientId: his.PatientId,
  11890. // SettleAccountsDate: recordDateTime,
  11891. // Ctime: time.Now().Unix(),
  11892. // Mtime: time.Now().Unix(),
  11893. // Status: 1,
  11894. // Number: chrg_bchno,
  11895. // Infcode: res.Infcode,
  11896. // WarnMsg: res.WarnMsg,
  11897. // Cainfo: res.Cainfo,
  11898. // ErrMsg: res.ErrMsg,
  11899. // RespondTime: res.RefmsgTime,
  11900. // InfRefmsgid: res.InfRefmsgid,
  11901. // OrderStatus: 1,
  11902. // IsMedicineInsurance: 1,
  11903. // SettleType: settle_accounts_type,
  11904. // SettleStartTime: start_time,
  11905. // SettleEndTime: end_time,
  11906. // Creator: roles.ID,
  11907. // Modify: roles.ID,
  11908. // PType: 2,
  11909. // }
  11910. // err = service.CreateOrder(order)
  11911. // if err != nil {
  11912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  11913. // return
  11914. // }
  11915. //
  11916. // for _, item := range res.Output.Result {
  11917. // temp := strings.Split(item.FeedetlSn, "-")
  11918. // var advice_id int64 = 0
  11919. // var project_id int64 = 0
  11920. // var types int64 = 0
  11921. //
  11922. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  11923. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  11924. //
  11925. // if temp[1] == "1" {
  11926. // advice_id = id
  11927. // project_id = 0
  11928. // } else if temp[1] == "2" {
  11929. // advice_id = 0
  11930. // project_id = id
  11931. // }
  11932. //
  11933. // info := &models.HisOrderInfo{
  11934. // OrderNumber: order.Number,
  11935. // FeedetlSn: item.FeedetlSn,
  11936. // UploadDate: time.Now().Unix(),
  11937. // AdviceId: advice_id,
  11938. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  11939. // Cnt: item.Cnt,
  11940. // Pric: float64(item.Pric),
  11941. // PatientId: his.PatientId,
  11942. // PricUplmtAmt: item.PricUplmtAmt,
  11943. // SelfpayProp: item.SelfpayProp,
  11944. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  11945. // OverlmtAmt: item.OverlmtAmt,
  11946. // PreselfpayAmt: item.PreselfpayAmt,
  11947. // BasMednFlag: item.BasMednFlag,
  11948. // MedChrgitmType: item.MedChrgitmType,
  11949. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  11950. // Status: 1,
  11951. // Memo: item.Memo,
  11952. // Mtime: time.Now().Unix(),
  11953. // InscpScpAmt: item.InscpScpAmt,
  11954. // DrtReimFlag: item.DrtReimFlag,
  11955. // Ctime: time.Now().Unix(),
  11956. // ListSpItemFlag: item.ListSpItemFlag,
  11957. // ChldMedcFlag: item.ChldMedcFlag,
  11958. // LmtUsedFlag: item.LmtUsedFlag,
  11959. // ChrgitmLv: item.ChrgitmLv,
  11960. // UserOrgId: adminUser.CurrentOrgId,
  11961. // HisPatientId: his.ID,
  11962. // OrderId: order.ID,
  11963. // ProjectId: project_id,
  11964. // Type: types,
  11965. // }
  11966. // service.CreateOrderInfo(info)
  11967. //
  11968. // }
  11969. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11970. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  11971. //
  11972. // var total float64
  11973. // for _, item := range prescriptions {
  11974. // if item.Type == 1 { //药品
  11975. // for _, subItem := range item.HisDoctorAdviceInfo {
  11976. // total = total + (subItem.Price * subItem.PrescribingNumber)
  11977. // }
  11978. // }
  11979. // if item.Type == 2 { //项目
  11980. // for _, subItem := range item.HisPrescriptionProject {
  11981. // total = total + (subItem.Price * float64(subItem.Count))
  11982. // }
  11983. // }
  11984. // }
  11985. //
  11986. // for _, item := range prescriptions {
  11987. // for _, subItem := range item.HisAdditionalCharge {
  11988. // total = total + (subItem.Price * float64(subItem.Count))
  11989. // }
  11990. // }
  11991. //
  11992. // allTotal := fmt.Sprintf("%.2f", total)
  11993. // if res.Infcode == 0 {
  11994. // var rf []*ResultFive
  11995. // json.Unmarshal([]byte(his.Iinfo), &rf)
  11996. // psn_no := his.PsnNo
  11997. // mdtrt_id := his.Number
  11998. // chrg_bchno := chrg_bchno
  11999. // cert_no := his.Certno
  12000. // insutype := rf[0].Insutype
  12001. //
  12002. // if his.IdCardType == 1 {
  12003. // cert_no = his.MedicalInsuranceNumber
  12004. //
  12005. // } else {
  12006. //
  12007. // cert_no = his.Certno
  12008. //
  12009. // }
  12010. //
  12011. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  12012. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  12013. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  12014. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  12015. // resp, requestErr := http.Get(api)
  12016. // if requestErr != nil {
  12017. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12018. // return
  12019. // }
  12020. // defer resp.Body.Close()
  12021. // body, ioErr := ioutil.ReadAll(resp.Body)
  12022. // if ioErr != nil {
  12023. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12024. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12025. // return
  12026. // }
  12027. // var respJSON map[string]interface{}
  12028. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12029. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12030. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12031. // return
  12032. // }
  12033. // fmt.Println(respJSON)
  12034. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12035. // userJSONBytes, _ := json.Marshal(respJSON)
  12036. // var res ResultSeven
  12037. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12038. // utils.ErrorLog("解析失败:%v", err)
  12039. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12040. // return
  12041. // }
  12042. // if res.Infcode != 0 {
  12043. // errlog := &models.HisOrderError{
  12044. // UserOrgId: adminUser.CurrentOrgId,
  12045. // Ctime: time.Now().Unix(),
  12046. // Mtime: time.Now().Unix(),
  12047. // Number: chrg_bchno,
  12048. // ErrMsg: res.ErrMsg,
  12049. // Status: 1,
  12050. // PatientId: id,
  12051. // RecordTime: recordDateTime,
  12052. // Stage: 7,
  12053. // }
  12054. // service.CreateErrMsgLog(errlog)
  12055. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  12056. // return
  12057. // } else {
  12058. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  12059. // order.OrderStatus = 1
  12060. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  12061. // order.SetlId = res.Output.Setlinfo.SetlID
  12062. // order.PsnNo = res.Output.Setlinfo.PsnNo
  12063. // order.PsnName = res.Output.Setlinfo.PsnName
  12064. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  12065. // order.Certno = res.Output.Setlinfo.Certno
  12066. // order.Gend = res.Output.Setlinfo.Gend
  12067. // order.Naty = res.Output.Setlinfo.Naty
  12068. // order.Age = res.Output.Setlinfo.Age
  12069. // order.Insutype = res.Output.Setlinfo.Insutype
  12070. // order.PsnType = res.Output.Setlinfo.PsnType
  12071. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  12072. // order.SetlTime = res.Output.Setlinfo.SetlTime
  12073. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  12074. // order.MedType = res.Output.Setlinfo.MedType
  12075. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  12076. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  12077. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  12078. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  12079. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  12080. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  12081. // order.HifpPay = res.Output.Setlinfo.HifpPay
  12082. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  12083. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  12084. // order.HifesPay = res.Output.Setlinfo.HifesPay
  12085. // order.HifobPay = res.Output.Setlinfo.HifobPay
  12086. // order.MafPay = res.Output.Setlinfo.MafPay
  12087. // order.OthPay = res.Output.Setlinfo.OthPay
  12088. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  12089. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  12090. // order.AcctPay = res.Output.Setlinfo.AcctPay
  12091. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  12092. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  12093. // order.Balc = res.Output.Setlinfo.Balc
  12094. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  12095. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  12096. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  12097. // order.ClrWay = res.Output.Setlinfo.ClrWay
  12098. // order.Creator = order.Creator
  12099. // order.Modify = roles.ID
  12100. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  12101. // detailStr := string(setlDetail)
  12102. // order.SetlDetail = detailStr
  12103. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  12104. // err = service.UpDateOrder(order)
  12105. // if err == nil {
  12106. // c.ServeSuccessJSON(map[string]interface{}{
  12107. // "msg": "预结算成功",
  12108. // })
  12109. // } else {
  12110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  12111. // return
  12112. // }
  12113. // }
  12114. // } else {
  12115. // adminUser := c.GetAdminUserInfo()
  12116. // errlog := &models.HisOrderError{
  12117. // UserOrgId: adminUser.CurrentOrgId,
  12118. // Ctime: time.Now().Unix(),
  12119. // Mtime: time.Now().Unix(),
  12120. // ErrMsg: res.ErrMsg,
  12121. // Status: 1,
  12122. // PatientId: id,
  12123. // RecordTime: recordDateTime,
  12124. // Stage: 4,
  12125. // }
  12126. // service.CreateErrMsgLog(errlog)
  12127. //
  12128. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  12129. // return
  12130. // }
  12131. // } else {
  12132. // adminUser := c.GetAdminUserInfo()
  12133. // errlog := &models.HisOrderError{
  12134. // UserOrgId: adminUser.CurrentOrgId,
  12135. // Ctime: time.Now().Unix(),
  12136. // Mtime: time.Now().Unix(),
  12137. // ErrMsg: res.ErrMsg,
  12138. // Status: 1,
  12139. // PatientId: id,
  12140. // RecordTime: recordDateTime,
  12141. // Stage: 4,
  12142. // }
  12143. // service.CreateErrMsgLog(errlog)
  12144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  12145. // return
  12146. // }
  12147. //
  12148. // } else {
  12149. // var total float64
  12150. // for _, item := range prescriptions {
  12151. // if item.Type == 1 { //药品
  12152. // for _, subItem := range item.HisDoctorAdviceInfo {
  12153. // total = total + (subItem.Price * subItem.PrescribingNumber)
  12154. // }
  12155. // }
  12156. // if item.Type == 2 { //项目
  12157. // for _, subItem := range item.HisPrescriptionProject {
  12158. // total = total + (subItem.Price * float64(subItem.Count))
  12159. // }
  12160. // }
  12161. //
  12162. // for _, subItem := range item.HisAdditionalCharge {
  12163. // total = total + (subItem.Price * float64(subItem.Count))
  12164. // }
  12165. // }
  12166. //
  12167. // allTotal := fmt.Sprintf("%.2f", total)
  12168. // totals, _ := strconv.ParseFloat(allTotal, 64)
  12169. // order := &models.HisOrder{
  12170. // UserOrgId: adminUser.CurrentOrgId,
  12171. // HisPatientId: his.ID,
  12172. // PatientId: id,
  12173. // SettleAccountsDate: recordDateTime,
  12174. // Ctime: time.Now().Unix(),
  12175. // Mtime: time.Now().Unix(),
  12176. // Status: 1,
  12177. // OrderStatus: 2,
  12178. // Number: chrg_bchno,
  12179. // MedfeeSumamt: totals,
  12180. // }
  12181. // err = service.CreateOrder(order)
  12182. // if err != nil {
  12183. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  12184. // return
  12185. // }
  12186. //
  12187. // var customs []*Custom
  12188. // for _, item := range prescriptions {
  12189. //
  12190. // if item.Type == 1 { //药品
  12191. // for _, subItem := range item.HisDoctorAdviceInfo {
  12192. // cus := &Custom{
  12193. // AdviceId: subItem.ID,
  12194. // ProjectId: 0,
  12195. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  12196. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  12197. // FeedetlSn: subItem.FeedetlSn,
  12198. // Price: fmt.Sprintf("%.2f", subItem.Price),
  12199. // MedListCodg: subItem.MedListCodg,
  12200. // Type: 1,
  12201. // }
  12202. // customs = append(customs, cus)
  12203. // }
  12204. // }
  12205. //
  12206. // if item.Type == 2 { //项目
  12207. // for _, subItem := range item.HisPrescriptionProject {
  12208. //
  12209. // cus := &Custom{
  12210. // AdviceId: 0,
  12211. // ProjectId: subItem.ID,
  12212. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  12213. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  12214. // FeedetlSn: subItem.FeedetlSn,
  12215. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  12216. // MedListCodg: subItem.MedListCodg,
  12217. // Type: 2,
  12218. // }
  12219. //
  12220. // customs = append(customs, cus)
  12221. // }
  12222. // }
  12223. //
  12224. // for _, item := range item.HisAdditionalCharge {
  12225. // cus := &Custom{
  12226. // ItemId: item.ID,
  12227. // AdviceId: 0,
  12228. // ProjectId: 0,
  12229. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  12230. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  12231. // FeedetlSn: item.FeedetlSn,
  12232. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  12233. // MedListCodg: item.XtHisAddtionConfig.Code,
  12234. // Type: 3,
  12235. // }
  12236. //
  12237. // customs = append(customs, cus)
  12238. // }
  12239. //
  12240. // }
  12241. //
  12242. // for _, item := range customs {
  12243. // var advice_id int64 = 0
  12244. // var project_id int64 = 0
  12245. // var item_id int64 = 0
  12246. //
  12247. // var types int64 = 0
  12248. //
  12249. // if item.Type == 1 {
  12250. // advice_id = item.AdviceId
  12251. // project_id = 0
  12252. // item_id = 0
  12253. // } else if item.Type == 2 {
  12254. // advice_id = 0
  12255. // item_id = 0
  12256. //
  12257. // project_id = item.ProjectId
  12258. // } else if item.Type == 3 {
  12259. // advice_id = 0
  12260. // item_id = item.ItemId
  12261. // project_id = 0
  12262. // }
  12263. //
  12264. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  12265. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  12266. // pric, _ := strconv.ParseFloat(item.Price, 32)
  12267. //
  12268. // info := &models.HisOrderInfo{
  12269. // OrderNumber: order.Number,
  12270. // UploadDate: time.Now().Unix(),
  12271. // AdviceId: advice_id,
  12272. // DetItemFeeSumamt: detItemFeeSumamt,
  12273. // Cnt: cut,
  12274. // Pric: pric,
  12275. // PatientId: id,
  12276. // Status: 1,
  12277. // Mtime: time.Now().Unix(),
  12278. // Ctime: time.Now().Unix(),
  12279. // UserOrgId: adminUser.CurrentOrgId,
  12280. // HisPatientId: his.ID,
  12281. // OrderId: order.ID,
  12282. // ProjectId: project_id,
  12283. // Type: types,
  12284. // ItemId: item_id,
  12285. // }
  12286. // service.CreateOrderInfo(info)
  12287. // }
  12288. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  12289. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  12290. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  12291. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  12292. // if err == nil {
  12293. // c.ServeSuccessJSON(map[string]interface{}{
  12294. // "msg": "结算成功",
  12295. // })
  12296. // } else {
  12297. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  12298. // return
  12299. // }
  12300. // }
  12301. //}
  12302. // 上传明细-预结算-
  12303. func (c *HisApiController) GetPreUploadInfo() {
  12304. id, _ := c.GetInt64("id")
  12305. record_time := c.GetString("record_time")
  12306. his_patient_id, _ := c.GetInt64("his_patient_id")
  12307. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  12308. admin_user_id, _ := c.GetInt64("admin_user_id")
  12309. diagnosis_id := c.GetString("diagnosis")
  12310. sick_type, _ := c.GetInt64("sick_type")
  12311. reg_type, _ := c.GetInt64("p_type")
  12312. begin_time := c.GetString("begin_time")
  12313. acct_used_flag := c.GetString("acct_used_flag")
  12314. id_str := c.GetString("ids")
  12315. ids_arr := strings.Split(id_str, ",")
  12316. timeLayout := "2006-01-02"
  12317. loc, _ := time.LoadLocation("Local")
  12318. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12319. if err != nil {
  12320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12321. return
  12322. }
  12323. recordDateTime := theTime.Unix()
  12324. adminUser := c.GetAdminUserInfo()
  12325. diagnosis_ids := strings.Split(diagnosis_id, ",")
  12326. var config []*models.HisXtDiagnoseConfig
  12327. for _, item := range diagnosis_ids {
  12328. id, _ := strconv.ParseInt(item, 10, 64)
  12329. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12330. config = append(config, &diagnosisConfig)
  12331. }
  12332. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  12333. sickConfig, _ := service.FindSickById(sick_type)
  12334. var prescriptions []*models.HisPrescription
  12335. var start_time int64
  12336. var end_time int64
  12337. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12338. fmt.Println(his_patient_id)
  12339. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12340. timestamp := time.Now().Unix()
  12341. tempTime := time.Unix(timestamp, 0)
  12342. timeFormat := tempTime.Format("20060102150405")
  12343. chrgBchno := rand.Intn(100000) + 10000
  12344. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  12345. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12346. var patientPrescription models.HisPrescriptionInfo
  12347. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12348. if patientPrescription.ID == 0 {
  12349. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  12350. }
  12351. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12352. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12353. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12354. strconv.FormatInt(his.PatientId, 10)
  12355. var res2 ResultSix
  12356. var resSix10265 ResultSix10265
  12357. //var time_stamp string
  12358. if miConfig.MdtrtareaAdmvs == "421300" {
  12359. data := make(map[string]interface{})
  12360. client := &http.Client{}
  12361. data["psn_no"] = his.PsnNo
  12362. data["mdtrt_id"] = his.Number
  12363. data["department"] = department.Name
  12364. data["org_name"] = miConfig.OrgName
  12365. data["med_type"] = strconv.FormatInt(reg_type, 10)
  12366. data["doctor_id"] = doctor_info.DoctorNumber
  12367. data["doctor_name"] = roles.UserName
  12368. data["fixmedins_code"] = miConfig.Code
  12369. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  12370. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  12371. data["secret_key"] = miConfig.SecretKey
  12372. data["sick_code"] = sickConfig.CountryCode
  12373. data["sick_name"] = sickConfig.ClassName
  12374. data["begin_time"] = begin_time
  12375. data["dept"] = strconv.FormatInt(department.ID, 10)
  12376. data["config"] = config
  12377. data["opter"] = roles.UserName
  12378. fmt.Println(data)
  12379. bytesData, _ := json.Marshal(data)
  12380. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  12381. resp, _ := client.Do(req)
  12382. defer resp.Body.Close()
  12383. body, ioErr := ioutil.ReadAll(resp.Body)
  12384. if ioErr != nil {
  12385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12387. return
  12388. }
  12389. var respJSON map[string]interface{}
  12390. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12393. return
  12394. }
  12395. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12396. userJSONBytes, _ := json.Marshal(respJSON)
  12397. fmt.Println("log")
  12398. fmt.Println(string(userJSONBytes))
  12399. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12400. utils.ErrorLog("解析失败:%v", err)
  12401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12402. return
  12403. }
  12404. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12405. data := make(map[string]interface{})
  12406. client := &http.Client{}
  12407. data["psn_no"] = his.PsnNo
  12408. data["mdtrt_id"] = his.Number
  12409. data["doctor"] = roles.UserName
  12410. data["department"] = department.Name
  12411. data["org_name"] = miConfig.OrgName
  12412. data["med_type"] = strconv.FormatInt(reg_type, 10)
  12413. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  12414. data["fixmedins_code"] = miConfig.Code
  12415. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  12416. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  12417. data["secret_key"] = miConfig.SecretKey
  12418. data["sick_code"] = sickConfig.CountryCode
  12419. data["sick_name"] = sickConfig.ClassName
  12420. data["begin_time"] = begin_time
  12421. data["dept"] = strconv.FormatInt(department.ID, 10)
  12422. data["config"] = config
  12423. data["url"] = miConfig.Url
  12424. data["ak"] = miConfig.AccessKey
  12425. data["cainfo"] = miConfig.Cainfo
  12426. bytesData, _ := json.Marshal(data)
  12427. var req *http.Request
  12428. if miConfig.MdtrtareaAdmvs == "320921" {
  12429. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  12430. } else {
  12431. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  12432. }
  12433. resp, _ := client.Do(req)
  12434. defer resp.Body.Close()
  12435. body, ioErr := ioutil.ReadAll(resp.Body)
  12436. if ioErr != nil {
  12437. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12439. return
  12440. }
  12441. var respJSON map[string]interface{}
  12442. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12445. return
  12446. }
  12447. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  12448. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  12449. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  12450. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12451. userJSONBytes, _ := json.Marshal(respJSON)
  12452. fmt.Println("log")
  12453. fmt.Println(string(userJSONBytes))
  12454. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  12455. utils.ErrorLog("解析失败:%v", err)
  12456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12457. return
  12458. }
  12459. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12460. res2.Output = resSix10265.Output
  12461. res2.ErrMsg = resSix10265.ErrMsg
  12462. res2.Cainfo = resSix10265.Cainfo
  12463. res2.WarnMsg = resSix10265.WarnMsg
  12464. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12465. res2.Infcode = infocode
  12466. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12467. 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)
  12468. saveLog(result, requestLog, "2203", "上传就诊信息")
  12469. var respJSON2 map[string]interface{}
  12470. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  12471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12473. return
  12474. }
  12475. userJSONBytes2, _ := json.Marshal(respJSON2)
  12476. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12477. utils.ErrorLog("解析失败:%v", err)
  12478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12479. return
  12480. }
  12481. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12482. var result string
  12483. var requestLog string
  12484. 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, "")
  12485. saveLog(result, requestLog, "2203", "上传就诊信息")
  12486. var respJSON2 map[string]interface{}
  12487. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  12488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12490. return
  12491. }
  12492. userJSONBytes2, _ := json.Marshal(respJSON2)
  12493. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12494. utils.ErrorLog("解析失败:%v", err)
  12495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12496. return
  12497. }
  12498. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12499. var result string
  12500. var requestLog string
  12501. 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, "")
  12502. saveLog(result, requestLog, "2203", "上传就诊信息")
  12503. var respJSON2 map[string]interface{}
  12504. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  12505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12507. return
  12508. }
  12509. userJSONBytes2, _ := json.Marshal(respJSON2)
  12510. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12511. utils.ErrorLog("解析失败:%v", err)
  12512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12513. return
  12514. }
  12515. } else {
  12516. var result string
  12517. var requestLog string
  12518. if miConfig.MdtrtareaAdmvs == "440781" { //
  12519. 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)
  12520. } else {
  12521. if miConfig.Code == "H15049901371" {
  12522. //赤峰地区国家医保医疗类别
  12523. //职工透析:医疗类别选特殊情况门诊990502
  12524. //居民定额血透门慢: 医疗类别选门诊慢病140104
  12525. var med_type string
  12526. if his.Insutype == "390" {
  12527. if reg_type == 14 {
  12528. med_type = "9933"
  12529. } else if reg_type == 11 {
  12530. med_type = "11"
  12531. }
  12532. } else if his.Insutype == "310" {
  12533. if reg_type == 14 {
  12534. med_type = "990502"
  12535. } else if reg_type == 11 {
  12536. med_type = "11"
  12537. }
  12538. }
  12539. 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)
  12540. } else {
  12541. 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)
  12542. }
  12543. saveLog(result, requestLog, "2203", "上传就诊信息")
  12544. var respJSON2 map[string]interface{}
  12545. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  12546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12548. return
  12549. }
  12550. userJSONBytes2, _ := json.Marshal(respJSON2)
  12551. if miConfig.Code == "H15049901371" {
  12552. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  12553. utils.ErrorLog("解析失败:%v", err)
  12554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12555. return
  12556. }
  12557. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12558. res2.Output = resSix10265.Output
  12559. res2.ErrMsg = resSix10265.ErrMsg
  12560. res2.Cainfo = resSix10265.Cainfo
  12561. res2.WarnMsg = resSix10265.WarnMsg
  12562. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12563. res2.Infcode = infocode
  12564. } else {
  12565. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12566. utils.ErrorLog("解析失败:%v", err)
  12567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12568. return
  12569. }
  12570. }
  12571. }
  12572. }
  12573. if res2.Infcode != 0 {
  12574. adminUser := c.GetAdminUserInfo()
  12575. errlog := &models.HisOrderError{
  12576. UserOrgId: adminUser.CurrentOrgId,
  12577. Ctime: time.Now().Unix(),
  12578. Mtime: time.Now().Unix(),
  12579. ErrMsg: res2.ErrMsg,
  12580. Status: 1,
  12581. PatientId: id,
  12582. RecordTime: recordDateTime,
  12583. Stage: 3,
  12584. }
  12585. service.CreateErrMsgLog(errlog)
  12586. c.ServeSuccessJSON(map[string]interface{}{
  12587. "failed_code": -10,
  12588. "msg": res2.ErrMsg,
  12589. })
  12590. return
  12591. } else {
  12592. his.Diagnosis = diagnosis_id
  12593. his.SickType = sickConfig.ID
  12594. his.PType = fmt.Sprintf("%d", reg_type)
  12595. service.UpdateHisPatientThree(&his)
  12596. data := make(map[string]interface{})
  12597. if settle_accounts_type == 1 { //日结
  12598. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  12599. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  12600. } else {
  12601. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  12602. }
  12603. data["pre"] = prescriptions
  12604. } else { //月结
  12605. start_time_str := c.GetString("start_time")
  12606. end_time_str := c.GetString("end_time")
  12607. timeLayout := "2006-01-02"
  12608. loc, _ := time.LoadLocation("Local")
  12609. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  12610. if err != nil {
  12611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12612. return
  12613. }
  12614. recordStartTime := theStartTime.Unix()
  12615. start_time = recordStartTime
  12616. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  12617. if err != nil {
  12618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12619. return
  12620. }
  12621. recordEndTime := theEndTime.Unix()
  12622. end_time = recordEndTime
  12623. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  12624. data["pre"] = prescriptions
  12625. }
  12626. client := &http.Client{}
  12627. data["psn_no"] = his.PsnNo
  12628. data["mdtrt_id"] = his.Number
  12629. data["chrg_bchno"] = chrg_bchno
  12630. data["org_name"] = miConfig.OrgName
  12631. data["doctor"] = doctor_info.UserName
  12632. data["doctor_id"] = doctor_info.DoctorNumber
  12633. data["dept"] = department.Name
  12634. data["fixmedins_code"] = miConfig.Code
  12635. data["opter"] = roles.UserName
  12636. data["dept_code"] = department.Number
  12637. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  12638. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  12639. data["secret_key"] = miConfig.SecretKey
  12640. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  12641. data["url"] = miConfig.Url
  12642. data["ak"] = miConfig.AccessKey
  12643. data["new_doctor_name"] = patientPrescription.Doctor
  12644. data["diag_code"] = sickConfig.CountryCode
  12645. data["cainfo"] = miConfig.Cainfo
  12646. data["opter"] = roles.UserName
  12647. var ids []int64
  12648. for _, item := range prescriptions {
  12649. ids = append(ids, item.ID)
  12650. }
  12651. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12652. if config.IsOpen == 1 { //对接了医保,走医保流程
  12653. var res ResultFour
  12654. var resFour10265 ResultFour10265
  12655. if miConfig.MdtrtareaAdmvs == "421300" {
  12656. bytesData, _ := json.Marshal(data)
  12657. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  12658. resp, _ := client.Do(req)
  12659. defer resp.Body.Close()
  12660. body, ioErr := ioutil.ReadAll(resp.Body)
  12661. if ioErr != nil {
  12662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12664. return
  12665. }
  12666. var respJSON map[string]interface{}
  12667. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12670. return
  12671. }
  12672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12673. userJSONBytes, _ := json.Marshal(respJSON)
  12674. fmt.Println("log")
  12675. fmt.Println(string(userJSONBytes))
  12676. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12677. utils.ErrorLog("解析失败:%v", err)
  12678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12679. return
  12680. }
  12681. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12682. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  12683. if result3101.Infcode == "0" {
  12684. if len(result3101.Output.Result) > 0 {
  12685. var errMsgs []string
  12686. for _, item := range result3101.Output.Result {
  12687. errMsgs = append(errMsgs, item.VolaCont)
  12688. }
  12689. c.ServeSuccessJSON(map[string]interface{}{
  12690. "failed_code": -10,
  12691. "msg": errMsgs,
  12692. })
  12693. return
  12694. } else {
  12695. if miConfig.MdtrtareaAdmvs == "320921" {
  12696. data["doctor_id"] = "D320923012139"
  12697. } else {
  12698. data["doctor_id"] = "D371621008686"
  12699. }
  12700. bytesData, _ := json.Marshal(data)
  12701. var req *http.Request
  12702. if miConfig.MdtrtareaAdmvs == "320921" {
  12703. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12704. } else {
  12705. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12706. }
  12707. resp, _ := client.Do(req)
  12708. defer resp.Body.Close()
  12709. body, ioErr := ioutil.ReadAll(resp.Body)
  12710. if ioErr != nil {
  12711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12713. return
  12714. }
  12715. var respJSON map[string]interface{}
  12716. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12719. return
  12720. }
  12721. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12722. userJSONBytes, _ := json.Marshal(respJSON)
  12723. fmt.Println("log")
  12724. fmt.Println(string(userJSONBytes))
  12725. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  12726. utils.ErrorLog("解析失败:%v", err)
  12727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12728. return
  12729. }
  12730. res.InfRefmsgid = resFour10265.InfRefmsgid
  12731. res.Output = resFour10265.Output
  12732. res.ErrMsg = resFour10265.ErrMsg
  12733. res.Cainfo = resFour10265.Cainfo
  12734. res.WarnMsg = resFour10265.WarnMsg
  12735. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  12736. res.Infcode = infocode
  12737. }
  12738. }
  12739. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12740. 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)
  12741. var dat map[string]interface{}
  12742. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12743. fmt.Println(dat)
  12744. } else {
  12745. fmt.Println(err)
  12746. }
  12747. saveLog(result, request_log, "2204", "上传费用明细")
  12748. userJSONBytes, _ := json.Marshal(dat)
  12749. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12750. utils.ErrorLog("解析失败:%v", err)
  12751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12752. return
  12753. }
  12754. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12755. 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, "", "")
  12756. var dat map[string]interface{}
  12757. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12758. fmt.Println(dat)
  12759. } else {
  12760. fmt.Println(err)
  12761. }
  12762. saveLog(result, request_log, "2204", "上传费用明细")
  12763. userJSONBytes, _ := json.Marshal(dat)
  12764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12765. utils.ErrorLog("解析失败:%v", err)
  12766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12767. return
  12768. }
  12769. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12770. 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, "", "")
  12771. var dat map[string]interface{}
  12772. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12773. fmt.Println(dat)
  12774. } else {
  12775. fmt.Println(err)
  12776. }
  12777. saveLog(result, request_log, "2204", "上传费用明细")
  12778. userJSONBytes, _ := json.Marshal(dat)
  12779. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12780. utils.ErrorLog("解析失败:%v", err)
  12781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12782. return
  12783. }
  12784. } else {
  12785. if miConfig.Code == "H15049901371" {
  12786. 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)
  12787. var dat map[string]interface{}
  12788. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12789. fmt.Println(dat)
  12790. } else {
  12791. fmt.Println(err)
  12792. }
  12793. saveLog(result, request_log, "2204", "上传费用明细")
  12794. userJSONBytes, _ := json.Marshal(dat)
  12795. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  12796. utils.ErrorLog("解析失败:%v", err)
  12797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12798. return
  12799. }
  12800. res.InfRefmsgid = resFour10265.InfRefmsgid
  12801. res.Output = resFour10265.Output
  12802. res.ErrMsg = resFour10265.ErrMsg
  12803. res.Cainfo = resFour10265.Cainfo
  12804. res.WarnMsg = resFour10265.WarnMsg
  12805. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  12806. res.Infcode = infocode
  12807. } else {
  12808. 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)
  12809. var dat map[string]interface{}
  12810. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12811. fmt.Println(dat)
  12812. } else {
  12813. fmt.Println(err)
  12814. }
  12815. saveLog(result, request_log, "2204", "上传费用明细")
  12816. userJSONBytes, _ := json.Marshal(dat)
  12817. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12818. utils.ErrorLog("解析失败:%v", err)
  12819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12820. return
  12821. }
  12822. }
  12823. }
  12824. var total_two float64
  12825. if res.Infcode == 0 {
  12826. order := &models.HisOrder{
  12827. UserOrgId: adminUser.CurrentOrgId,
  12828. HisPatientId: his.ID,
  12829. PatientId: his.PatientId,
  12830. SettleAccountsDate: recordDateTime,
  12831. Ctime: time.Now().Unix(),
  12832. Mtime: time.Now().Unix(),
  12833. MdtrtId: his.Number,
  12834. PsnNo: his.PsnNo,
  12835. MedType: strconv.FormatInt(reg_type, 10),
  12836. Status: 1,
  12837. Number: chrg_bchno,
  12838. Infcode: res.Infcode,
  12839. WarnMsg: res.WarnMsg,
  12840. Cainfo: res.Cainfo,
  12841. ErrMsg: res.ErrMsg,
  12842. RespondTime: res.RefmsgTime,
  12843. InfRefmsgid: res.InfRefmsgid,
  12844. OrderStatus: 1,
  12845. IsMedicineInsurance: 1,
  12846. SettleType: settle_accounts_type,
  12847. SettleStartTime: start_time,
  12848. SettleEndTime: end_time,
  12849. Creator: roles.AdminUserId,
  12850. Modify: roles.AdminUserId,
  12851. PType: 2,
  12852. Diagnosis: diagnosis_id,
  12853. }
  12854. err = service.CreateOrder(order)
  12855. if err != nil {
  12856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  12857. return
  12858. }
  12859. for _, item := range res.Output.Result {
  12860. temp := strings.Split(item.FeedetlSn, "-")
  12861. var advice_id int64 = 0
  12862. var project_id int64 = 0
  12863. var types int64 = 0
  12864. id, _ := strconv.ParseInt(temp[2], 10, 64)
  12865. types, _ = strconv.ParseInt(temp[1], 10, 64)
  12866. if temp[1] == "1" {
  12867. advice_id = id
  12868. project_id = 0
  12869. } else if temp[1] == "2" {
  12870. advice_id = 0
  12871. project_id = id
  12872. }
  12873. total_two = total_two + item.DetItemFeeSumamt
  12874. info := &models.HisOrderInfo{
  12875. OrderNumber: order.Number,
  12876. FeedetlSn: item.FeedetlSn,
  12877. UploadDate: time.Now().Unix(),
  12878. AdviceId: advice_id,
  12879. DetItemFeeSumamt: item.DetItemFeeSumamt,
  12880. Cnt: item.Cnt,
  12881. Pric: float64(item.Pric),
  12882. PatientId: his.PatientId,
  12883. PricUplmtAmt: item.PricUplmtAmt,
  12884. SelfpayProp: item.SelfpayProp,
  12885. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  12886. OverlmtAmt: item.OverlmtAmt,
  12887. PreselfpayAmt: item.PreselfpayAmt,
  12888. BasMednFlag: item.BasMednFlag,
  12889. MedChrgitmType: item.MedChrgitmType,
  12890. HiNegoDrugFlag: item.HiNegoDrugFlag,
  12891. Status: 1,
  12892. Memo: item.Memo,
  12893. Mtime: time.Now().Unix(),
  12894. InscpScpAmt: item.InscpScpAmt,
  12895. DrtReimFlag: item.DrtReimFlag,
  12896. Ctime: time.Now().Unix(),
  12897. ListSpItemFlag: item.ListSpItemFlag,
  12898. ChldMedcFlag: item.ChldMedcFlag,
  12899. LmtUsedFlag: item.LmtUsedFlag,
  12900. ChrgitmLv: item.ChrgitmLv,
  12901. UserOrgId: adminUser.CurrentOrgId,
  12902. HisPatientId: his.ID,
  12903. OrderId: order.ID,
  12904. ProjectId: project_id,
  12905. Type: types,
  12906. }
  12907. service.CreateOrderInfo(info)
  12908. }
  12909. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  12910. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  12911. var total float64
  12912. for _, item := range prescriptions {
  12913. if item.Type == 1 { //药品
  12914. for _, subItem := range item.HisDoctorAdviceInfo {
  12915. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  12916. total_one := price * subItem.PrescribingNumber
  12917. fmt.Println("subItem")
  12918. fmt.Println(subItem.Price)
  12919. fmt.Println("price")
  12920. fmt.Println(price)
  12921. fmt.Println("total_one")
  12922. fmt.Println(total_one)
  12923. total = total + total_one
  12924. fmt.Println(total)
  12925. }
  12926. }
  12927. if item.Type == 2 { //项目
  12928. for _, subItem := range item.HisPrescriptionProject {
  12929. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12930. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  12931. total_one := price * cnt
  12932. total = total + total_one
  12933. }
  12934. }
  12935. }
  12936. allTotal := fmt.Sprintf("%2f", total)
  12937. if res.Infcode == 0 {
  12938. var rf []*ResultFive
  12939. json.Unmarshal([]byte(his.Iinfo), &rf)
  12940. chrg_bchno := chrg_bchno
  12941. cert_no := his.Certno
  12942. var insutypes []string
  12943. var insutype string
  12944. var is390 int = 0
  12945. var is310 int = 0
  12946. for _, item := range rf {
  12947. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12948. insutypes = append(insutypes, item.Insutype)
  12949. }
  12950. }
  12951. if len(insutypes) == 1 {
  12952. insutype = insutypes[0]
  12953. } else {
  12954. for _, i := range insutypes {
  12955. if i == "390" {
  12956. is390 = 1
  12957. }
  12958. if i == "310" {
  12959. is310 = 1
  12960. }
  12961. }
  12962. }
  12963. if is390 == 1 {
  12964. insutype = "390"
  12965. }
  12966. if is310 == 1 {
  12967. insutype = "310"
  12968. }
  12969. if len(insutypes) == 0 {
  12970. insutype = "390"
  12971. }
  12972. if len(insutypes) == 2 {
  12973. insutype = strconv.FormatInt(his.SocialType, 10)
  12974. }
  12975. //insutype = "390"
  12976. if his.IdCardType == 1 {
  12977. cert_no = his.MedicalInsuranceNumber
  12978. } else {
  12979. cert_no = his.Certno
  12980. }
  12981. var res ResultSeven
  12982. var resSeven10265 ResultSeven10265
  12983. if miConfig.MdtrtareaAdmvs == "421300" {
  12984. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12985. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12986. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12987. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12988. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12989. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12990. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  12991. resp, requestErr := http.Get(api)
  12992. if requestErr != nil {
  12993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12994. return
  12995. }
  12996. body, ioErr := ioutil.ReadAll(resp.Body)
  12997. if ioErr != nil {
  12998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13000. return
  13001. }
  13002. var respJSON map[string]interface{}
  13003. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13006. return
  13007. }
  13008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13009. result, _ := json.Marshal(respJSON)
  13010. fmt.Println("log")
  13011. fmt.Println(string(result))
  13012. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13013. utils.ErrorLog("解析失败:%v", err)
  13014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13015. return
  13016. }
  13017. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13018. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  13019. if result3101.Infcode == "0" {
  13020. if len(result3101.Output.Result) > 0 {
  13021. var errMsgs []string
  13022. for _, item := range result3101.Output.Result {
  13023. errMsgs = append(errMsgs, item.VolaCont)
  13024. }
  13025. c.ServeSuccessJSON(map[string]interface{}{
  13026. "failed_code": -10,
  13027. "msg": errMsgs,
  13028. })
  13029. return
  13030. } else {
  13031. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  13032. if his.IdCardType != 4 {
  13033. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  13034. bas := strings.Split(psn_info.CardInfo, "|")
  13035. if his.IdCardType == 1 {
  13036. cert_no = bas[2]
  13037. } else {
  13038. cert_no = bas[1]
  13039. }
  13040. } else {
  13041. cert_no = his.Certno
  13042. }
  13043. //江苏地区国家医保医疗类别
  13044. //职工透析:医疗类别选特殊情况门诊9933
  13045. //居民血透门慢: 医疗类别选门诊慢病1402
  13046. //var med_type string
  13047. //if his.Insutype == "310" {
  13048. // if reg_type == 14 {
  13049. // med_type = "9933"
  13050. // } else if reg_type == 11 {
  13051. // med_type = "11"
  13052. //
  13053. // }
  13054. //} else if his.Insutype == "390" {
  13055. // if reg_type == 14 {
  13056. // med_type = "1402"
  13057. // } else if reg_type == 11 {
  13058. // med_type = "11"
  13059. // }
  13060. //}
  13061. var api string
  13062. if miConfig.MdtrtareaAdmvs == "320921" {
  13063. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  13064. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  13065. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13066. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13067. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  13068. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  13069. "&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
  13070. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13071. } else {
  13072. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13073. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  13074. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  13075. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13076. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13077. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  13078. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  13079. "&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
  13080. }
  13081. resp, requestErr := http.Get(api)
  13082. if requestErr != nil {
  13083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13084. return
  13085. }
  13086. body, ioErr := ioutil.ReadAll(resp.Body)
  13087. if ioErr != nil {
  13088. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13090. return
  13091. }
  13092. var respJSON map[string]interface{}
  13093. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13096. return
  13097. }
  13098. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13099. result, _ := json.Marshal(respJSON)
  13100. fmt.Println("log")
  13101. fmt.Println(string(result))
  13102. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  13103. utils.ErrorLog("解析失败:%v", err)
  13104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13105. return
  13106. }
  13107. res.InfRefmsgid = resSeven10265.InfRefmsgid
  13108. res.Output = resSeven10265.Output
  13109. res.ErrMsg = resSeven10265.ErrMsg
  13110. res.Cainfo = resSeven10265.Cainfo
  13111. res.WarnMsg = resSeven10265.WarnMsg
  13112. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  13113. res.Infcode = infocode
  13114. }
  13115. }
  13116. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13117. acct_used_flag := "1"
  13118. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  13119. var result string
  13120. var request_log string
  13121. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  13122. 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)
  13123. } else {
  13124. 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)
  13125. }
  13126. var dat map[string]interface{}
  13127. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13128. fmt.Println(dat)
  13129. } else {
  13130. fmt.Println(err)
  13131. }
  13132. saveLog(result, request_log, "2206", "预结算")
  13133. userJSONBytes, _ := json.Marshal(dat)
  13134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13135. utils.ErrorLog("解析失败:%v", err)
  13136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13137. return
  13138. }
  13139. } else if miConfig.MdtrtareaAdmvs == "360399" {
  13140. var result string
  13141. var request_log string
  13142. if his.IdCardType == 2 {
  13143. 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, "")
  13144. } else if his.IdCardType == 1 {
  13145. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  13146. bas := strings.Split(psn_info.CardInfo, "|")
  13147. basNumber := bas[2]
  13148. card_sn := bas[3]
  13149. 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)
  13150. } else {
  13151. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  13152. 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, "")
  13153. }
  13154. var dat map[string]interface{}
  13155. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13156. fmt.Println(dat)
  13157. } else {
  13158. fmt.Println(err)
  13159. }
  13160. saveLog(result, request_log, "2206", "预结算")
  13161. userJSONBytes, _ := json.Marshal(dat)
  13162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13163. utils.ErrorLog("解析失败:%v", err)
  13164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13165. return
  13166. }
  13167. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13168. var result string
  13169. var request_log string
  13170. if his.IdCardType == 2 {
  13171. 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")
  13172. } else if his.IdCardType == 1 {
  13173. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  13174. bas := strings.Split(psn_info.CardInfo, "|")
  13175. basNumber := bas[2]
  13176. card_sn := bas[3]
  13177. 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")
  13178. } else {
  13179. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  13180. 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")
  13181. }
  13182. var dat map[string]interface{}
  13183. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13184. fmt.Println(dat)
  13185. } else {
  13186. fmt.Println(err)
  13187. }
  13188. saveLog(result, request_log, "2206", "预结算")
  13189. userJSONBytes, _ := json.Marshal(dat)
  13190. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13191. utils.ErrorLog("解析失败:%v", err)
  13192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13193. return
  13194. }
  13195. } else {
  13196. var result string
  13197. var request_log string
  13198. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  13199. allTotal = fmt.Sprintf("%2f", total_two)
  13200. if his.IdCardType == 4 {
  13201. 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)
  13202. } else {
  13203. 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)
  13204. }
  13205. var dat map[string]interface{}
  13206. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13207. fmt.Println(dat)
  13208. } else {
  13209. fmt.Println(err)
  13210. }
  13211. saveLog(result, request_log, "2206", "预结算")
  13212. //userJSONBytes, _ := json.Marshal(dat)
  13213. //
  13214. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13215. // utils.ErrorLog("解析失败:%v", err)
  13216. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13217. // return
  13218. //}
  13219. userJSONBytes, _ := json.Marshal(dat)
  13220. if miConfig.Code == "H15049901371" {
  13221. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  13222. utils.ErrorLog("解析失败:%v", err)
  13223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13224. return
  13225. }
  13226. res.InfRefmsgid = resSeven10265.InfRefmsgid
  13227. res.Output = resSeven10265.Output
  13228. res.ErrMsg = resSeven10265.ErrMsg
  13229. res.Cainfo = resSeven10265.Cainfo
  13230. res.WarnMsg = resSeven10265.WarnMsg
  13231. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  13232. res.Infcode = infocode
  13233. } else {
  13234. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13235. utils.ErrorLog("解析失败:%v", err)
  13236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13237. return
  13238. }
  13239. }
  13240. }
  13241. if res.Infcode != 0 {
  13242. errlog := &models.HisOrderError{
  13243. UserOrgId: adminUser.CurrentOrgId,
  13244. Ctime: time.Now().Unix(),
  13245. Mtime: time.Now().Unix(),
  13246. Number: chrg_bchno,
  13247. ErrMsg: res.ErrMsg,
  13248. Status: 1,
  13249. PatientId: id,
  13250. RecordTime: recordDateTime,
  13251. Stage: 20,
  13252. }
  13253. service.CreateErrMsgLog(errlog)
  13254. c.ServeSuccessJSON(map[string]interface{}{
  13255. "failed_code": -10,
  13256. "msg": res.ErrMsg,
  13257. })
  13258. return
  13259. } else {
  13260. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  13261. order.OrderStatus = 1
  13262. order.IsPre = 1
  13263. order.Status = 1
  13264. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  13265. order.SetlId = res.Output.Setlinfo.SetlID
  13266. order.PsnNo = res.Output.Setlinfo.PsnNo
  13267. order.PsnName = res.Output.Setlinfo.PsnName
  13268. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  13269. order.Certno = res.Output.Setlinfo.Certno
  13270. order.Gend = res.Output.Setlinfo.Gend
  13271. order.Naty = res.Output.Setlinfo.Naty
  13272. order.Age = res.Output.Setlinfo.Age
  13273. order.Insutype = res.Output.Setlinfo.Insutype
  13274. order.PsnType = res.Output.Setlinfo.PsnType
  13275. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  13276. order.SetlTime = res.Output.Setlinfo.SetlTime
  13277. order.AcctUsedFlag = acct_used_flag
  13278. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  13279. if res.Output.Setlinfo.MedType == "140101" {
  13280. order.MedType = "14"
  13281. } else {
  13282. order.MedType = res.Output.Setlinfo.MedType
  13283. }
  13284. if reg_type == 1112 {
  13285. order.MedType = "1112"
  13286. }
  13287. if reg_type == 1111 {
  13288. order.MedType = "1111"
  13289. }
  13290. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  13291. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  13292. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  13293. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  13294. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  13295. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  13296. order.HifpPay = res.Output.Setlinfo.HifpPay
  13297. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  13298. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  13299. order.HifesPay = res.Output.Setlinfo.HifesPay
  13300. order.HifobPay = res.Output.Setlinfo.HifobPay
  13301. order.MafPay = res.Output.Setlinfo.MafPay
  13302. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  13303. order.OthPay = res.Output.Setlinfo.OthPay
  13304. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  13305. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  13306. order.AcctPay = res.Output.Setlinfo.AcctPay
  13307. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  13308. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  13309. order.Balc = res.Output.Setlinfo.Balc
  13310. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  13311. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  13312. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  13313. order.ClrWay = res.Output.Setlinfo.ClrWay
  13314. order.Creator = order.Creator
  13315. order.Modify = roles.AdminUserId
  13316. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  13317. detailStr := string(setlDetail)
  13318. order.SetlDetail = detailStr
  13319. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  13320. err = service.UpDateOrder(order)
  13321. if err == nil {
  13322. c.ServeSuccessJSON(map[string]interface{}{
  13323. "msg": "预结算成功",
  13324. })
  13325. } else {
  13326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  13327. return
  13328. }
  13329. }
  13330. } else {
  13331. adminUser := c.GetAdminUserInfo()
  13332. errlog := &models.HisOrderError{
  13333. UserOrgId: adminUser.CurrentOrgId,
  13334. Ctime: time.Now().Unix(),
  13335. Mtime: time.Now().Unix(),
  13336. ErrMsg: res.ErrMsg,
  13337. Status: 1,
  13338. PatientId: id,
  13339. RecordTime: recordDateTime,
  13340. Stage: 4,
  13341. }
  13342. service.CreateErrMsgLog(errlog)
  13343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  13344. return
  13345. }
  13346. } else {
  13347. adminUser := c.GetAdminUserInfo()
  13348. errlog := &models.HisOrderError{
  13349. UserOrgId: adminUser.CurrentOrgId,
  13350. Ctime: time.Now().Unix(),
  13351. Mtime: time.Now().Unix(),
  13352. ErrMsg: res.ErrMsg,
  13353. Status: 1,
  13354. PatientId: id,
  13355. RecordTime: recordDateTime,
  13356. Stage: 4,
  13357. }
  13358. service.CreateErrMsgLog(errlog)
  13359. c.ServeSuccessJSON(map[string]interface{}{
  13360. "failed_code": -10,
  13361. "msg": res.ErrMsg,
  13362. })
  13363. return
  13364. }
  13365. }
  13366. }
  13367. }
  13368. // 退款
  13369. func (c *HisApiController) Refund() {
  13370. order_id, _ := c.GetInt64("order_id")
  13371. admin_user_id, _ := c.GetInt64("admin_user_id")
  13372. adminUser := c.GetAdminUserInfo()
  13373. var order models.HisOrder
  13374. order, _ = service.GetHisOrderByID(order_id)
  13375. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13376. if order.ID == 0 {
  13377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13378. return
  13379. }
  13380. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13381. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13382. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13383. if config.IsOpen == 1 { //对接了医保,走医保流程
  13384. var res ResultSixteen
  13385. var resSixteen10265 ResultSixteen10265
  13386. var src_resquest string
  13387. var result string
  13388. if miConfig.MdtrtareaAdmvs == "421300" {
  13389. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  13390. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13391. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13392. resp3, requestErr3 := http.Get(api3)
  13393. if requestErr3 != nil {
  13394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13395. return
  13396. }
  13397. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13398. if ioErr3 != nil {
  13399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13401. return
  13402. }
  13403. var respJSON3 map[string]interface{}
  13404. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13407. return
  13408. }
  13409. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13410. userJSONBytes3, _ := json.Marshal(respJSON3)
  13411. fmt.Println("log")
  13412. fmt.Println(string(userJSONBytes3))
  13413. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  13414. utils.ErrorLog("解析失败:%v", err)
  13415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13416. return
  13417. }
  13418. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13419. var api3 string
  13420. if miConfig.MdtrtareaAdmvs == "320921" {
  13421. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  13422. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13423. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13424. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13425. } else {
  13426. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13427. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  13428. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13429. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13430. }
  13431. resp3, requestErr3 := http.Get(api3)
  13432. if requestErr3 != nil {
  13433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13434. return
  13435. }
  13436. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13437. if ioErr3 != nil {
  13438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13440. return
  13441. }
  13442. var respJSON3 map[string]interface{}
  13443. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13446. return
  13447. }
  13448. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13449. userJSONBytes3, _ := json.Marshal(respJSON3)
  13450. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  13451. utils.ErrorLog("解析失败:%v", err)
  13452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13453. return
  13454. }
  13455. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  13456. res.Output = resSixteen10265.Output
  13457. res.ErrMsg = resSixteen10265.ErrMsg
  13458. res.Cainfo = resSixteen10265.Cainfo
  13459. res.WarnMsg = resSixteen10265.WarnMsg
  13460. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  13461. res.Infcode = infocode
  13462. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13463. 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)
  13464. var dat map[string]interface{}
  13465. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13466. fmt.Println(dat)
  13467. } else {
  13468. fmt.Println(err)
  13469. }
  13470. saveLog(result, src_resquest, "2208", "退费")
  13471. userJSONBytes, _ := json.Marshal(dat)
  13472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13473. utils.ErrorLog("解析失败:%v", err)
  13474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13475. return
  13476. }
  13477. } else if miConfig.MdtrtareaAdmvs == "360399" {
  13478. 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, "")
  13479. var dat map[string]interface{}
  13480. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13481. fmt.Println(dat)
  13482. } else {
  13483. fmt.Println(err)
  13484. }
  13485. saveLog(result, src_resquest, "2208", "退费")
  13486. userJSONBytes, _ := json.Marshal(dat)
  13487. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13488. utils.ErrorLog("解析失败:%v", err)
  13489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13490. return
  13491. }
  13492. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13493. 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, "")
  13494. var dat map[string]interface{}
  13495. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13496. fmt.Println(dat)
  13497. } else {
  13498. fmt.Println(err)
  13499. }
  13500. saveLog(result, src_resquest, "2208", "退费")
  13501. userJSONBytes, _ := json.Marshal(dat)
  13502. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13503. utils.ErrorLog("解析失败:%v", err)
  13504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13505. return
  13506. }
  13507. } else {
  13508. if miConfig.Code == "H15049901371" {
  13509. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  13510. var dat map[string]interface{}
  13511. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13512. fmt.Println(dat)
  13513. } else {
  13514. fmt.Println(err)
  13515. }
  13516. saveLog(result, src_resquest, "2208", "退费")
  13517. userJSONBytes, _ := json.Marshal(dat)
  13518. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  13519. utils.ErrorLog("解析失败:%v", err)
  13520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13521. return
  13522. }
  13523. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  13524. res.Output = resSixteen10265.Output
  13525. res.ErrMsg = resSixteen10265.ErrMsg
  13526. res.Cainfo = resSixteen10265.Cainfo
  13527. res.WarnMsg = resSixteen10265.WarnMsg
  13528. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  13529. res.Infcode = infocode
  13530. } else {
  13531. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  13532. var dat map[string]interface{}
  13533. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13534. fmt.Println(dat)
  13535. } else {
  13536. fmt.Println(err)
  13537. }
  13538. saveLog(result, src_resquest, "2208", "退费")
  13539. userJSONBytes, _ := json.Marshal(dat)
  13540. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13541. utils.ErrorLog("解析失败:%v", err)
  13542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13543. return
  13544. }
  13545. }
  13546. }
  13547. if res.Infcode == 0 {
  13548. var res2 ResultSix
  13549. var resSix10265 ResultSix10265
  13550. if miConfig.MdtrtareaAdmvs == "421300" {
  13551. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  13552. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13553. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13554. resp3, requestErr3 := http.Get(api3)
  13555. if requestErr3 != nil {
  13556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13557. return
  13558. }
  13559. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13560. if ioErr3 != nil {
  13561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13563. return
  13564. }
  13565. var respJSON3 map[string]interface{}
  13566. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13569. return
  13570. }
  13571. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13572. userJSONBytes3, _ := json.Marshal(respJSON3)
  13573. fmt.Println("log")
  13574. fmt.Println(string(userJSONBytes3))
  13575. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  13576. utils.ErrorLog("解析失败:%v", err)
  13577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13578. return
  13579. }
  13580. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13581. var api3 string
  13582. if miConfig.MdtrtareaAdmvs == "320921" {
  13583. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  13584. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13585. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13586. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13587. } else {
  13588. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13589. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  13590. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13591. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13592. }
  13593. resp3, requestErr3 := http.Get(api3)
  13594. if requestErr3 != nil {
  13595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13596. return
  13597. }
  13598. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13599. if ioErr3 != nil {
  13600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13602. return
  13603. }
  13604. var respJSON3 map[string]interface{}
  13605. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13608. return
  13609. }
  13610. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13611. userJSONBytes3, _ := json.Marshal(respJSON3)
  13612. fmt.Println("log")
  13613. fmt.Println(string(userJSONBytes3))
  13614. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  13615. utils.ErrorLog("解析失败:%v", err)
  13616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13617. return
  13618. }
  13619. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13620. res2.Output = resSix10265.Output
  13621. res2.ErrMsg = resSix10265.ErrMsg
  13622. res2.Cainfo = resSix10265.Cainfo
  13623. res2.WarnMsg = resSix10265.WarnMsg
  13624. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13625. res2.Infcode = infocode
  13626. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13627. result2, src_request, _ := service.FJyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  13628. var dat map[string]interface{}
  13629. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  13630. fmt.Println(dat)
  13631. } else {
  13632. fmt.Println(err)
  13633. }
  13634. saveLog(result2, src_request, "2205", "撤销明细")
  13635. userJSONBytes, _ := json.Marshal(dat)
  13636. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13637. utils.ErrorLog("解析失败:%v", err)
  13638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13639. return
  13640. }
  13641. } else if miConfig.MdtrtareaAdmvs == "360399" {
  13642. 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, "")
  13643. var dat map[string]interface{}
  13644. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  13645. fmt.Println(dat)
  13646. } else {
  13647. fmt.Println(err)
  13648. }
  13649. saveLog(result2, src_request, "2205", "撤销明细")
  13650. userJSONBytes, _ := json.Marshal(dat)
  13651. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13652. utils.ErrorLog("解析失败:%v", err)
  13653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13654. return
  13655. }
  13656. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13657. 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, "")
  13658. var dat map[string]interface{}
  13659. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  13660. fmt.Println(dat)
  13661. } else {
  13662. fmt.Println(err)
  13663. }
  13664. saveLog(result2, src_request, "2205", "撤销明细")
  13665. userJSONBytes, _ := json.Marshal(dat)
  13666. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13667. utils.ErrorLog("解析失败:%v", err)
  13668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13669. return
  13670. }
  13671. } else {
  13672. if miConfig.Code == "H15049901371" {
  13673. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  13674. var dat map[string]interface{}
  13675. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  13676. fmt.Println(dat)
  13677. } else {
  13678. fmt.Println(err)
  13679. }
  13680. saveLog(result2, src_request, "2205", "撤销明细")
  13681. userJSONBytes, _ := json.Marshal(dat)
  13682. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  13683. utils.ErrorLog("解析失败:%v", err)
  13684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13685. return
  13686. }
  13687. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13688. res2.Output = resSix10265.Output
  13689. res2.ErrMsg = resSix10265.ErrMsg
  13690. res2.Cainfo = resSix10265.Cainfo
  13691. res2.WarnMsg = resSix10265.WarnMsg
  13692. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13693. res2.Infcode = infocode
  13694. } else {
  13695. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  13696. var dat map[string]interface{}
  13697. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  13698. fmt.Println(dat)
  13699. } else {
  13700. fmt.Println(err)
  13701. }
  13702. saveLog(result2, src_request, "2205", "撤销明细")
  13703. userJSONBytes, _ := json.Marshal(dat)
  13704. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13705. utils.ErrorLog("解析失败:%v", err)
  13706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13707. return
  13708. }
  13709. }
  13710. }
  13711. if res2.Infcode == 0 {
  13712. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  13713. if err == nil {
  13714. //当押金不为零时产生退费记录
  13715. if order.Decimal != 0 {
  13716. tmp := strconv.FormatInt(order.ID, 10)
  13717. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  13718. if err != nil {
  13719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13720. return
  13721. }
  13722. }
  13723. c.ServeSuccessJSON(map[string]interface{}{
  13724. "msg": "退费成功",
  13725. })
  13726. } else {
  13727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13728. return
  13729. }
  13730. } else {
  13731. c.ServeSuccessJSON(map[string]interface{}{
  13732. "code": -10,
  13733. "msg": res2.ErrMsg,
  13734. })
  13735. }
  13736. } else {
  13737. c.ServeSuccessJSON(map[string]interface{}{
  13738. "code": -10,
  13739. "msg": res.ErrMsg,
  13740. })
  13741. }
  13742. }
  13743. }
  13744. func (c *HisApiController) RefundNumber() {
  13745. record_time := c.GetString("record_time")
  13746. //patient_id, _ := c.GetInt64("patient_id")
  13747. admin_user_id, _ := c.GetInt64("admin_user_id")
  13748. his_patient_id, _ := c.GetInt64("id")
  13749. timeLayout := "2006-01-02"
  13750. loc, _ := time.LoadLocation("Local")
  13751. adminUser := c.GetAdminUserInfo()
  13752. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13753. fmt.Println(err)
  13754. if err != nil {
  13755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13756. return
  13757. }
  13758. recordDateTime := theTime.Unix()
  13759. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  13760. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  13761. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  13762. //order, _ := service.GetHisOrderByID(order_id)
  13763. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13764. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13765. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13766. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  13767. if count > 0 {
  13768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  13769. return
  13770. }
  13771. if config.IsOpen == 1 { //对接了医保,走医保流程
  13772. var res2 ResultSix
  13773. var resSix10265 ResultSix10265
  13774. if miConfig.MdtrtareaAdmvs == "421300" {
  13775. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  13776. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13777. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13778. resp3, requestErr3 := http.Get(api3)
  13779. if requestErr3 != nil {
  13780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13781. return
  13782. }
  13783. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13784. if ioErr3 != nil {
  13785. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13787. return
  13788. }
  13789. var respJSON3 map[string]interface{}
  13790. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13791. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13793. return
  13794. }
  13795. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13796. userJSONBytes3, _ := json.Marshal(respJSON3)
  13797. fmt.Println("log")
  13798. fmt.Println(string(userJSONBytes3))
  13799. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  13800. utils.ErrorLog("解析失败:%v", err)
  13801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13802. return
  13803. }
  13804. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13805. var api3 string
  13806. if miConfig.MdtrtareaAdmvs == "320921" {
  13807. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  13808. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13809. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13810. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13811. } else {
  13812. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13813. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  13814. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13815. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13816. }
  13817. resp3, requestErr3 := http.Get(api3)
  13818. if requestErr3 != nil {
  13819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13820. return
  13821. }
  13822. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13823. if ioErr3 != nil {
  13824. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13826. return
  13827. }
  13828. var respJSON3 map[string]interface{}
  13829. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13830. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13832. return
  13833. }
  13834. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13835. userJSONBytes3, _ := json.Marshal(respJSON3)
  13836. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  13837. utils.ErrorLog("解析失败:%v", err)
  13838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13839. return
  13840. }
  13841. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13842. res2.Output = resSix10265.Output
  13843. res2.ErrMsg = resSix10265.ErrMsg
  13844. res2.Cainfo = resSix10265.Cainfo
  13845. res2.WarnMsg = resSix10265.WarnMsg
  13846. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13847. res2.Infcode = infocode
  13848. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13849. 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)
  13850. var dat map[string]interface{}
  13851. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13852. fmt.Println(dat)
  13853. } else {
  13854. fmt.Println(err)
  13855. }
  13856. saveLog(result, request, "2202", "退号")
  13857. userJSONBytes, _ := json.Marshal(dat)
  13858. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13859. utils.ErrorLog("解析失败:%v", err)
  13860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13861. return
  13862. }
  13863. } else if miConfig.MdtrtareaAdmvs == "360399" {
  13864. 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, "")
  13865. var dat map[string]interface{}
  13866. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13867. fmt.Println(dat)
  13868. } else {
  13869. fmt.Println(err)
  13870. }
  13871. saveLog(result, request, "2202", "退号")
  13872. userJSONBytes, _ := json.Marshal(dat)
  13873. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13874. utils.ErrorLog("解析失败:%v", err)
  13875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13876. return
  13877. }
  13878. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13879. 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, "")
  13880. var dat map[string]interface{}
  13881. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13882. fmt.Println(dat)
  13883. } else {
  13884. fmt.Println(err)
  13885. }
  13886. saveLog(result, request, "2202", "退号")
  13887. userJSONBytes, _ := json.Marshal(dat)
  13888. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13889. utils.ErrorLog("解析失败:%v", err)
  13890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13891. return
  13892. }
  13893. } else {
  13894. var api3 string
  13895. if miConfig.Code == "H15049901371" {
  13896. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  13897. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13898. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13899. } else {
  13900. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  13901. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13902. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13903. }
  13904. resp3, requestErr3 := http.Get(api3)
  13905. if requestErr3 != nil {
  13906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13907. return
  13908. }
  13909. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13910. if ioErr3 != nil {
  13911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13913. return
  13914. }
  13915. var respJSON3 map[string]interface{}
  13916. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13919. return
  13920. }
  13921. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13922. userJSONBytes3, _ := json.Marshal(respJSON3)
  13923. if miConfig.Code == "H15049901371" {
  13924. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  13925. utils.ErrorLog("解析失败:%v", err)
  13926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13927. return
  13928. }
  13929. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13930. res2.Output = resSix10265.Output
  13931. res2.ErrMsg = resSix10265.ErrMsg
  13932. res2.Cainfo = resSix10265.Cainfo
  13933. res2.WarnMsg = resSix10265.WarnMsg
  13934. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13935. res2.Infcode = infocode
  13936. } else {
  13937. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  13938. utils.ErrorLog("解析失败:%v", err)
  13939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13940. return
  13941. }
  13942. }
  13943. }
  13944. if res2.Infcode == 0 {
  13945. if err == nil {
  13946. c.ServeSuccessJSON(map[string]interface{}{
  13947. "msg": "退号成功",
  13948. })
  13949. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  13950. } else {
  13951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13952. return
  13953. }
  13954. } else {
  13955. c.ServeSuccessJSON(map[string]interface{}{
  13956. "code": -10,
  13957. "msg": res2.ErrMsg,
  13958. })
  13959. }
  13960. } else {
  13961. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  13962. //if err == nil {
  13963. // c.ServeSuccessJSON(map[string]interface{}{
  13964. // "msg": "退费成功",
  13965. // })
  13966. //} else {
  13967. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13968. // return
  13969. //}
  13970. }
  13971. }
  13972. func (c *HisApiController) RefundDetail() {
  13973. order_id, _ := c.GetInt64("order_id")
  13974. admin_user_id, _ := c.GetInt64("admin_user_id")
  13975. //his_patient_id, _ := c.GetInt64("his_patient_id")
  13976. number := c.GetString("number")
  13977. record_time := c.GetString("record_time")
  13978. patient_id, _ := c.GetInt64("patient_id")
  13979. //med_type, _ := c.GetInt64("med_type")
  13980. timeLayout := "2006-01-02"
  13981. loc, _ := time.LoadLocation("Local")
  13982. adminUser := c.GetAdminUserInfo()
  13983. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13984. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13985. fmt.Println(err)
  13986. if err != nil {
  13987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13988. return
  13989. }
  13990. recordDateTime := theTime.Unix()
  13991. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  13992. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  13993. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13994. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13995. var order models.HisOrder
  13996. order, _ = service.GetHisOrderByID(order_id)
  13997. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13998. if config.IsOpen == 1 { //对接了医保,走医保流程
  13999. var res2 ResultSix
  14000. if miConfig.MdtrtareaAdmvs == "421300" {
  14001. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  14002. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14003. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14004. resp3, requestErr3 := http.Get(api3)
  14005. if requestErr3 != nil {
  14006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14007. return
  14008. }
  14009. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  14010. if ioErr3 != nil {
  14011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  14012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14013. return
  14014. }
  14015. var respJSON3 map[string]interface{}
  14016. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  14017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14019. return
  14020. }
  14021. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14022. userJSONBytes3, _ := json.Marshal(respJSON3)
  14023. fmt.Println("log")
  14024. fmt.Println(string(userJSONBytes3))
  14025. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  14026. utils.ErrorLog("解析失败:%v", err)
  14027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14028. return
  14029. }
  14030. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  14031. if err == nil {
  14032. c.ServeSuccessJSON(map[string]interface{}{
  14033. "msg": "撤销明细成功",
  14034. })
  14035. return
  14036. } else {
  14037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14038. return
  14039. }
  14040. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14041. var resSix10265 ResultSix10265
  14042. var api3 string
  14043. if miConfig.MdtrtareaAdmvs == "320921" {
  14044. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  14045. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14046. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14047. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14048. } else {
  14049. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14050. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  14051. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14052. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14053. }
  14054. resp3, requestErr3 := http.Get(api3)
  14055. if requestErr3 != nil {
  14056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14057. return
  14058. }
  14059. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  14060. if ioErr3 != nil {
  14061. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  14062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14063. return
  14064. }
  14065. var respJSON3 map[string]interface{}
  14066. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  14067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14069. return
  14070. }
  14071. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14072. userJSONBytes3, _ := json.Marshal(respJSON3)
  14073. fmt.Println("log")
  14074. fmt.Println(string(userJSONBytes3))
  14075. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  14076. utils.ErrorLog("解析失败:%v", err)
  14077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14078. return
  14079. }
  14080. res2.InfRefmsgid = resSix10265.InfRefmsgid
  14081. res2.Output = resSix10265.Output
  14082. res2.ErrMsg = resSix10265.ErrMsg
  14083. res2.Cainfo = resSix10265.Cainfo
  14084. res2.WarnMsg = resSix10265.WarnMsg
  14085. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14086. res2.Infcode = infocode
  14087. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  14088. if err == nil {
  14089. c.ServeSuccessJSON(map[string]interface{}{
  14090. "msg": "撤销明细成功",
  14091. })
  14092. return
  14093. } else {
  14094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14095. return
  14096. }
  14097. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14098. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  14099. var dat map[string]interface{}
  14100. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14101. fmt.Println(dat)
  14102. } else {
  14103. fmt.Println(err)
  14104. }
  14105. saveLog(result2, src_request, "2205", "撤销明细")
  14106. userJSONBytes, _ := json.Marshal(dat)
  14107. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14108. utils.ErrorLog("解析失败:%v", err)
  14109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14110. return
  14111. }
  14112. if res2.Infcode == 0 {
  14113. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  14114. if err == nil {
  14115. c.ServeSuccessJSON(map[string]interface{}{
  14116. "msg": "撤销明细成功",
  14117. })
  14118. return
  14119. } else {
  14120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14121. return
  14122. }
  14123. } else {
  14124. c.ServeSuccessJSON(map[string]interface{}{
  14125. "code": -10,
  14126. "msg": res2.ErrMsg,
  14127. })
  14128. }
  14129. } else if miConfig.MdtrtareaAdmvs == "360399" {
  14130. 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, "")
  14131. var dat map[string]interface{}
  14132. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14133. fmt.Println(dat)
  14134. } else {
  14135. fmt.Println(err)
  14136. }
  14137. saveLog(result2, src_request, "2205", "撤销明细")
  14138. userJSONBytes, _ := json.Marshal(dat)
  14139. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14140. utils.ErrorLog("解析失败:%v", err)
  14141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14142. return
  14143. }
  14144. if res2.Infcode == 0 {
  14145. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  14146. if err == nil {
  14147. c.ServeSuccessJSON(map[string]interface{}{
  14148. "msg": "撤销明细成功",
  14149. })
  14150. return
  14151. } else {
  14152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14153. return
  14154. }
  14155. } else {
  14156. c.ServeSuccessJSON(map[string]interface{}{
  14157. "code": -10,
  14158. "msg": res2.ErrMsg,
  14159. })
  14160. }
  14161. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14162. 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, "")
  14163. var dat map[string]interface{}
  14164. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14165. fmt.Println(dat)
  14166. } else {
  14167. fmt.Println(err)
  14168. }
  14169. saveLog(result2, src_request, "2205", "撤销明细")
  14170. userJSONBytes, _ := json.Marshal(dat)
  14171. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14172. utils.ErrorLog("解析失败:%v", err)
  14173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14174. return
  14175. }
  14176. if res2.Infcode == 0 {
  14177. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  14178. if err == nil {
  14179. c.ServeSuccessJSON(map[string]interface{}{
  14180. "msg": "撤销明细成功",
  14181. })
  14182. return
  14183. } else {
  14184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14185. return
  14186. }
  14187. } else {
  14188. c.ServeSuccessJSON(map[string]interface{}{
  14189. "code": -10,
  14190. "msg": res2.ErrMsg,
  14191. })
  14192. }
  14193. } else {
  14194. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  14195. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14196. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14197. resp2, requestErr2 := http.Get(api2)
  14198. if requestErr2 != nil {
  14199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14200. return
  14201. }
  14202. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  14203. if ioErr2 != nil {
  14204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  14205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14206. return
  14207. }
  14208. var respJSON2 map[string]interface{}
  14209. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  14210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14212. return
  14213. }
  14214. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  14215. if err == nil {
  14216. c.ServeSuccessJSON(map[string]interface{}{
  14217. "msg": "撤销明细成功",
  14218. })
  14219. return
  14220. } else {
  14221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14222. return
  14223. }
  14224. }
  14225. } else {
  14226. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  14227. if err == nil {
  14228. c.ServeSuccessJSON(map[string]interface{}{
  14229. "msg": "退费成功",
  14230. })
  14231. } else {
  14232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14233. return
  14234. }
  14235. }
  14236. }
  14237. // 对账
  14238. func (c *HisApiController) GetCheckAccount() {
  14239. start_time := c.GetString("start_time")
  14240. end_time := c.GetString("end_time")
  14241. insutype := c.GetString("insutype")
  14242. clr_type := c.GetString("clr_type")
  14243. clr_org := c.GetString("clr_optins")
  14244. admin_user_id, _ := c.GetInt64("admin_user_id")
  14245. adminUser := c.GetAdminUserInfo()
  14246. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14247. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14248. if len(clr_org) == 0 {
  14249. clr_org = miConfig.MdtrtareaAdmvs
  14250. }
  14251. timeLayout := "2006-01-02"
  14252. loc, _ := time.LoadLocation("Local")
  14253. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  14254. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  14255. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  14256. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  14257. fixmedins_setl_cnt := int64(len(orders))
  14258. var medfee_sumamt float64
  14259. var acct_pay float64
  14260. var fund_pay_sumamt float64
  14261. for _, item := range orders {
  14262. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  14263. acct_pay = acct_pay + item.AcctPay
  14264. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  14265. }
  14266. var user_name string
  14267. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14268. if role.ID == 0 {
  14269. user_name = "xxx"
  14270. } else {
  14271. user_name = role.UserName
  14272. }
  14273. var res ResultEight
  14274. var res10188 ResultEightFor10188
  14275. if config.IsOpen == 1 {
  14276. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14277. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  14278. "insutype=" + insutype +
  14279. "&clr_type=" + clr_type +
  14280. "&setl_optins=" + clr_org +
  14281. "&stmt_begndate=" + start_time +
  14282. "&stm_enddate=" + end_time +
  14283. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  14284. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  14285. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  14286. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  14287. "&fixmedins_code=" + miConfig.Code +
  14288. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  14289. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14290. "&secret_key=" + miConfig.SecretKey +
  14291. "&org_name=" + miConfig.OrgName +
  14292. "&doctor=" + user_name +
  14293. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14294. fmt.Println(api)
  14295. resp, requestErr := http.Get(api)
  14296. if requestErr != nil {
  14297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14298. return
  14299. }
  14300. body, ioErr := ioutil.ReadAll(resp.Body)
  14301. fmt.Println(body)
  14302. if ioErr != nil {
  14303. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14305. return
  14306. }
  14307. var respJSON map[string]interface{}
  14308. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14311. return
  14312. }
  14313. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14314. userJSONBytes, _ := json.Marshal(respJSON)
  14315. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14316. utils.ErrorLog("解析失败:%v", err)
  14317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14318. return
  14319. }
  14320. res.InfRefmsgid = res10188.InfRefmsgid
  14321. res.Output = res10188.Output
  14322. res.ErrMsg = res10188.ErrMsg
  14323. res.Cainfo = res10188.Cainfo
  14324. res.WarnMsg = res10188.WarnMsg
  14325. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  14326. res.Infcode = infocode
  14327. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14328. if clr_type == "11" {
  14329. fixmedins_setl_cnt = 0
  14330. }
  14331. //if clr_type == "21" {
  14332. // clr_type = "22"
  14333. //}
  14334. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  14335. "insutype=" + insutype +
  14336. "&clr_type=" + clr_type +
  14337. "&setl_optins=" + clr_org +
  14338. "&stmt_begndate=" + start_time +
  14339. "&stm_enddate=" + end_time +
  14340. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  14341. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  14342. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  14343. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  14344. "&fixmedins_code=" + miConfig.Code +
  14345. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  14346. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14347. "&secret_key=" + miConfig.SecretKey +
  14348. "&org_name=" + miConfig.OrgName +
  14349. "&doctor=" + user_name
  14350. resp, requestErr := http.Get(api)
  14351. if requestErr != nil {
  14352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14353. return
  14354. }
  14355. body, ioErr := ioutil.ReadAll(resp.Body)
  14356. if ioErr != nil {
  14357. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14359. return
  14360. }
  14361. var respJSON map[string]interface{}
  14362. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14365. return
  14366. }
  14367. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14368. result, _ := json.Marshal(respJSON)
  14369. fmt.Println("log")
  14370. fmt.Println(string(result))
  14371. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  14372. utils.ErrorLog("解析失败:%v", err)
  14373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14374. return
  14375. }
  14376. res.InfRefmsgid = res10188.InfRefmsgid
  14377. res.Output = res10188.Output
  14378. res.ErrMsg = res10188.ErrMsg
  14379. res.Cainfo = res10188.Cainfo
  14380. res.WarnMsg = res10188.WarnMsg
  14381. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  14382. res.Infcode = infocode
  14383. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14384. var baseParams models.BaseParams
  14385. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14386. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14387. baseParams.SecretKey = miConfig.SecretKey
  14388. baseParams.OrgName = miConfig.OrgName
  14389. baseParams.FixmedinsCode = miConfig.Code
  14390. baseParams.EncKey = miConfig.EncKey
  14391. baseParams.AppSecret = miConfig.AppSecret
  14392. baseParams.SignKey = miConfig.SignKey
  14393. baseParams.AppID = miConfig.Code
  14394. baseParams.Doctor = role.UserName
  14395. baseParams.RequestUrl = miConfig.Url
  14396. businessParams := models.BusinessParams{
  14397. Insutype: insutype,
  14398. ClrType: clr_type,
  14399. SetlOptins: clr_org,
  14400. StmtBegndate: start_time,
  14401. StmtEnddate: end_time,
  14402. MedfeeSumamt: medfee_sumamt,
  14403. FundPaySumamt: fund_pay_sumamt,
  14404. AcctPay: acct_pay,
  14405. FixmedinsSetlCnt: fixmedins_setl_cnt,
  14406. }
  14407. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  14408. fmt.Println(requestLog)
  14409. fmt.Println(result)
  14410. fmt.Println(err_msg)
  14411. var dat map[string]interface{}
  14412. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14413. fmt.Println(dat)
  14414. } else {
  14415. fmt.Println(err)
  14416. }
  14417. userJSONBytes, _ := json.Marshal(dat)
  14418. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14419. utils.ErrorLog("解析失败:%v", err)
  14420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14421. return
  14422. }
  14423. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14424. var baseParams models.BaseParams
  14425. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14426. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14427. baseParams.SecretKey = miConfig.SecretKey
  14428. baseParams.OrgName = miConfig.OrgName
  14429. baseParams.FixmedinsCode = miConfig.Code
  14430. baseParams.EncKey = miConfig.EncKey
  14431. baseParams.AppSecret = miConfig.AppSecret
  14432. baseParams.SignKey = miConfig.SignKey
  14433. baseParams.AppID = miConfig.Code
  14434. baseParams.Doctor = role.UserName
  14435. baseParams.RequestUrl = miConfig.Url
  14436. baseParams.AccessKey = miConfig.AccessKey
  14437. businessParams := models.BusinessParams{
  14438. Insutype: insutype,
  14439. ClrType: clr_type,
  14440. SetlOptins: "430822",
  14441. StmtBegndate: start_time,
  14442. StmtEnddate: end_time,
  14443. MedfeeSumamt: medfee_sumamt,
  14444. FundPaySumamt: fund_pay_sumamt,
  14445. AcctPay: acct_pay,
  14446. FixmedinsSetlCnt: fixmedins_setl_cnt,
  14447. }
  14448. 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)
  14449. fmt.Println(requestLog)
  14450. fmt.Println(result)
  14451. var dat map[string]interface{}
  14452. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14453. fmt.Println(dat)
  14454. } else {
  14455. fmt.Println(err)
  14456. }
  14457. userJSONBytes, _ := json.Marshal(dat)
  14458. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14459. utils.ErrorLog("解析失败:%v", err)
  14460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14461. return
  14462. }
  14463. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14464. var baseParams models.BaseParams
  14465. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14466. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14467. baseParams.SecretKey = miConfig.SecretKey
  14468. baseParams.OrgName = miConfig.OrgName
  14469. baseParams.FixmedinsCode = miConfig.Code
  14470. baseParams.EncKey = miConfig.EncKey
  14471. baseParams.AppSecret = miConfig.AppSecret
  14472. baseParams.SignKey = miConfig.SignKey
  14473. baseParams.AppID = miConfig.Code
  14474. baseParams.Doctor = role.UserName
  14475. baseParams.RequestUrl = miConfig.Url
  14476. businessParams := models.BusinessParams{
  14477. Insutype: insutype,
  14478. ClrType: clr_type,
  14479. SetlOptins: clr_org,
  14480. StmtBegndate: start_time,
  14481. StmtEnddate: end_time,
  14482. MedfeeSumamt: medfee_sumamt,
  14483. FundPaySumamt: fund_pay_sumamt,
  14484. AcctPay: acct_pay,
  14485. FixmedinsSetlCnt: fixmedins_setl_cnt,
  14486. }
  14487. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  14488. fmt.Println(requestLog)
  14489. fmt.Println(result)
  14490. fmt.Println(err_msg)
  14491. var dat map[string]interface{}
  14492. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14493. fmt.Println(dat)
  14494. } else {
  14495. fmt.Println(err)
  14496. }
  14497. userJSONBytes, _ := json.Marshal(dat)
  14498. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14499. utils.ErrorLog("解析失败:%v", err)
  14500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14501. return
  14502. }
  14503. } else {
  14504. if len(clr_type) == 0 {
  14505. clr_type = "11"
  14506. }
  14507. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  14508. "insutype=" + insutype +
  14509. "&clr_type=" + clr_type +
  14510. "&setl_optins=" + clr_org +
  14511. "&stmt_begndate=" + start_time +
  14512. "&stm_enddate=" + end_time +
  14513. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  14514. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  14515. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  14516. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  14517. "&fixmedins_code=" + miConfig.Code +
  14518. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  14519. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14520. "&secret_key=" + miConfig.SecretKey +
  14521. "&org_name=" + miConfig.OrgName +
  14522. "&doctor=" + user_name
  14523. fmt.Println(api)
  14524. resp, requestErr := http.Get(api)
  14525. if requestErr != nil {
  14526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14527. return
  14528. }
  14529. body, ioErr := ioutil.ReadAll(resp.Body)
  14530. fmt.Println(body)
  14531. if ioErr != nil {
  14532. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14534. return
  14535. }
  14536. var respJSON map[string]interface{}
  14537. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14540. return
  14541. }
  14542. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14543. userJSONBytes, _ := json.Marshal(respJSON)
  14544. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14545. utils.ErrorLog("解析失败:%v", err)
  14546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14547. return
  14548. }
  14549. }
  14550. if res.Infcode == 0 {
  14551. if res.Output.Stmtinfo.StmtRslt == "0" {
  14552. micc := &models.MedicalInsuranceCostCompare{
  14553. StartTime: startime.Unix(),
  14554. EndTime: endtime.Unix(),
  14555. Insutype: insutype,
  14556. CheckType: 1,
  14557. Num: fixmedins_setl_cnt,
  14558. Mtime: time.Now().Unix(),
  14559. Status: 1,
  14560. UserOrgId: adminUser.CurrentOrgId,
  14561. CostTotal: medfee_sumamt,
  14562. FuncTotal: fund_pay_sumamt,
  14563. PsnPay: acct_pay,
  14564. Creator: admin_user_id,
  14565. Ctime: time.Now().Unix(),
  14566. ClrType: clr_type,
  14567. }
  14568. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  14569. if err == nil {
  14570. c.ServeSuccessJSON(map[string]interface{}{
  14571. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  14572. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  14573. })
  14574. } else {
  14575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14576. }
  14577. } else {
  14578. c.ServeSuccessJSON(map[string]interface{}{
  14579. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  14580. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  14581. })
  14582. }
  14583. } else {
  14584. c.ServeSuccessJSON(map[string]interface{}{
  14585. "code": -10,
  14586. "msg": res.ErrMsg,
  14587. })
  14588. }
  14589. }
  14590. }
  14591. func (c *HisApiController) Check310() {
  14592. adminUser := c.GetAdminUserInfo()
  14593. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14594. var user_name string
  14595. user_name = "高慧裕"
  14596. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  14597. "insutype=" + "310" +
  14598. "&clr_type=" + "" +
  14599. "&setl_optins=" + "441202" +
  14600. "&stmt_begndate=" + "2022-03-01" +
  14601. "&stm_enddate=" + "2022-03-31" +
  14602. "&medfee_sumamt=" + "194930.12" +
  14603. "&fund_pay_sumamt=" + "188741.46" +
  14604. "&acct_pay=" + "0" +
  14605. "&fixmedins_setl_cnt=" + "452" +
  14606. "&fixmedins_code=" + miConfig.Code +
  14607. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  14608. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14609. "&secret_key=" + miConfig.SecretKey +
  14610. "&org_name=" + miConfig.OrgName +
  14611. "&doctor=" + user_name
  14612. fmt.Println(api)
  14613. resp, requestErr := http.Get(api)
  14614. if requestErr != nil {
  14615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14616. return
  14617. }
  14618. body, ioErr := ioutil.ReadAll(resp.Body)
  14619. fmt.Println(body)
  14620. if ioErr != nil {
  14621. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14623. return
  14624. }
  14625. var respJSON map[string]interface{}
  14626. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14627. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14629. return
  14630. }
  14631. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14632. userJSONBytes, _ := json.Marshal(respJSON)
  14633. var res ResultEight
  14634. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14635. utils.ErrorLog("解析失败:%v", err)
  14636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14637. return
  14638. }
  14639. }
  14640. func (c *HisApiController) Check390() {
  14641. adminUser := c.GetAdminUserInfo()
  14642. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14643. var user_name string
  14644. user_name = "高慧裕"
  14645. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  14646. "insutype=" + "390" +
  14647. "&clr_type=" + "" +
  14648. "&setl_optins=" + "441202" +
  14649. "&stmt_begndate=" + "2022-03-01" +
  14650. "&stm_enddate=" + "2022-03-31" +
  14651. "&medfee_sumamt=" + "1068448.89" +
  14652. "&fund_pay_sumamt=" + "1014677.62" +
  14653. "&acct_pay=" + "0" +
  14654. "&fixmedins_setl_cnt=" + "1950" +
  14655. "&fixmedins_code=" + miConfig.Code +
  14656. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  14657. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14658. "&secret_key=" + miConfig.SecretKey +
  14659. "&org_name=" + miConfig.OrgName +
  14660. "&doctor=" + user_name
  14661. fmt.Println(api)
  14662. resp, requestErr := http.Get(api)
  14663. if requestErr != nil {
  14664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14665. return
  14666. }
  14667. body, ioErr := ioutil.ReadAll(resp.Body)
  14668. fmt.Println(body)
  14669. if ioErr != nil {
  14670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14672. return
  14673. }
  14674. var respJSON map[string]interface{}
  14675. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14678. return
  14679. }
  14680. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14681. userJSONBytes, _ := json.Marshal(respJSON)
  14682. var res ResultEight
  14683. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14684. utils.ErrorLog("解析失败:%v", err)
  14685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14686. return
  14687. }
  14688. }
  14689. // 对账明细
  14690. func (c *HisApiController) GetCheckDetailAccount() {
  14691. start_time := c.GetString("start_time")
  14692. end_time := c.GetString("end_time")
  14693. admin_user_id, _ := c.GetInt64("admin_user_id")
  14694. adminUser := c.GetAdminUserInfo()
  14695. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14696. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14697. timeLayout := "2006-01-02"
  14698. loc, _ := time.LoadLocation("Local")
  14699. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  14700. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  14701. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  14702. rand.Seed(time.Now().UnixNano())
  14703. num := rand.Intn(30000)
  14704. Mkdir(miConfig.OrgName)
  14705. file := strconv.FormatInt(int64(num), 10)
  14706. file_name := file + ".txt"
  14707. zip_name := file + ".zip"
  14708. zip_path := miConfig.OrgName + "/" + zip_name
  14709. file_path := miConfig.OrgName + "/" + file_name
  14710. decimal.DivisionPrecision = 2
  14711. var medfee_sumamt float64
  14712. var psn_cash_pay float64
  14713. var fund_pay_sumamt float64
  14714. fixmedins_setl_cnt := int64(len(orders))
  14715. for _, item := range orders {
  14716. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  14717. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  14718. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  14719. }
  14720. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  14721. defer f.Close()
  14722. if err != nil {
  14723. fmt.Println(err.Error())
  14724. } else {
  14725. for _, item := range orders {
  14726. var refd_setl_flag string
  14727. if item.OrderStatus == 2 {
  14728. refd_setl_flag = "0"
  14729. var str string
  14730. str = item.SetlId + " " +
  14731. item.MdtrtId + " " +
  14732. item.PsnNo + " " +
  14733. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  14734. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  14735. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  14736. _, err = f.Write([]byte(str))
  14737. }
  14738. if item.OrderStatus == 3 {
  14739. var str string
  14740. str = item.SetlId + " " +
  14741. item.MdtrtId + " " +
  14742. item.PsnNo + " " +
  14743. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  14744. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  14745. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  14746. _, err = f.Write([]byte(str))
  14747. var str2 string
  14748. str2 = item.SetlId + " " +
  14749. item.MdtrtId + " " +
  14750. item.PsnNo + " " +
  14751. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  14752. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  14753. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  14754. _, err = f.Write([]byte(str2))
  14755. }
  14756. }
  14757. }
  14758. Zip(file_path, zip_path)
  14759. fmt.Println(ReadFile(zip_path))
  14760. fmt.Println(string(ReadFile(zip_path)))
  14761. if config.IsOpen == 1 {
  14762. var user_name string
  14763. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14764. if role.ID == 0 {
  14765. user_name = "管理员"
  14766. } else {
  14767. user_name = role.UserName
  14768. }
  14769. baseParams := models.BaseParams{
  14770. SecretKey: miConfig.SecretKey,
  14771. FixmedinsCode: miConfig.Code,
  14772. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14773. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14774. OrgName: miConfig.OrgName,
  14775. Doctor: user_name,
  14776. }
  14777. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  14778. var dat map[string]interface{}
  14779. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14780. fmt.Println(dat)
  14781. } else {
  14782. fmt.Println(err)
  14783. }
  14784. userJSONBytes, _ := json.Marshal(dat)
  14785. var res ResultNine
  14786. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14787. utils.ErrorLog("解析失败:%v", err)
  14788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14789. return
  14790. }
  14791. if res.Infcode == 0 {
  14792. fileNo := res.Output.FileQuryNo
  14793. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  14794. "file_qury_no=" + fileNo +
  14795. "&setl_optins=" + "定点医保中心" +
  14796. "&stmt_begndate=" + start_time +
  14797. "&stm_enddate=" + end_time +
  14798. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  14799. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  14800. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  14801. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  14802. "&fixmedins_code=" + miConfig.Code +
  14803. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  14804. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14805. "&secret_key=" + miConfig.SecretKey +
  14806. "&org_name=" + miConfig.OrgName +
  14807. "&doctor=" + user_name
  14808. resp, requestErr := http.Get(api)
  14809. if requestErr != nil {
  14810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14811. return
  14812. }
  14813. body, ioErr := ioutil.ReadAll(resp.Body)
  14814. if ioErr != nil {
  14815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14817. return
  14818. }
  14819. var respJSON map[string]interface{}
  14820. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14823. return
  14824. }
  14825. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14826. userJSONBytes, _ := json.Marshal(respJSON)
  14827. var res ResultTen
  14828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14829. utils.ErrorLog("解析失败:%v", err)
  14830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14831. return
  14832. }
  14833. if res.Infcode == 0 {
  14834. service.Gdyb9102(baseParams, zip_name, fileNo)
  14835. micc := &models.MedicalInsuranceCostCompare{
  14836. StartTime: startime.Unix(),
  14837. EndTime: endtime.Unix(),
  14838. Insutype: "0",
  14839. CheckType: 2,
  14840. Num: fixmedins_setl_cnt,
  14841. Mtime: time.Now().Unix(),
  14842. Status: 1,
  14843. UserOrgId: adminUser.CurrentOrgId,
  14844. CostTotal: medfee_sumamt,
  14845. FuncTotal: fund_pay_sumamt,
  14846. PsnPay: psn_cash_pay,
  14847. Creator: admin_user_id,
  14848. Ctime: time.Now().Unix(),
  14849. }
  14850. service.CreateMedicalInsuranceCostCompareRecord(micc)
  14851. c.ServeSuccessJSON(map[string]interface{}{
  14852. "msg": "明细对账成功",
  14853. })
  14854. }
  14855. } else {
  14856. }
  14857. }
  14858. }
  14859. type CustomOrderInfo struct {
  14860. Name string
  14861. Spec string
  14862. Unit string
  14863. Count float64
  14864. Price float64
  14865. Total float64
  14866. }
  14867. func (c *HisApiController) GetBatchSettleAccounts() {
  14868. admin_user_id, _ := c.GetInt64("admin_user_id")
  14869. order_ids := c.GetString("order_ids")
  14870. order_ids_arr := strings.Split(order_ids, ",")
  14871. data3 := []map[string]interface{}{}
  14872. for _, item := range order_ids_arr {
  14873. id, _ := strconv.ParseInt(item, 10, 64)
  14874. order_id := id
  14875. adminUser := c.GetAdminUserInfo()
  14876. order, _ := service.GetHisOrderByID(order_id)
  14877. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  14878. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  14879. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  14880. orderInfos = append(orderInfos, orderInfos_two...)
  14881. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  14882. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  14883. var diagnosis_ids []string
  14884. if his.ID > 0 {
  14885. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  14886. } else {
  14887. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  14888. }
  14889. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  14890. var dia_config []*models.HisXtDiagnoseConfig
  14891. var name string
  14892. for _, item := range diagnosis_ids {
  14893. id, _ := strconv.ParseInt(item, 10, 64)
  14894. diagnosisConfig, _ := service.FindDiagnoseById(id)
  14895. dia_config = append(dia_config, &diagnosisConfig)
  14896. if len(name) == 0 {
  14897. name = diagnosisConfig.ClassName
  14898. } else {
  14899. name = name + "," + diagnosisConfig.ClassName
  14900. }
  14901. }
  14902. var bedCostTotal float64 = 0 //床位总费
  14903. var bedCostSelfTotal float64 = 0 //床位自费
  14904. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14905. var bedSelfTotal float64 = 0 //床位部分项目自费
  14906. var bedInscpTotal float64 = 0 //床位部分项目自费
  14907. var operationCostTotal float64 = 0 //手术费
  14908. var operationCostSelfTotal float64 = 0 //手术费
  14909. var operationCostPartSelfTotal float64 = 0 //手术费
  14910. var operationSelfTotal float64 = 0 //床位部分项目自费
  14911. var operationInscpTotal float64 = 0 //床位部分项目自费
  14912. var otherCostTotal float64 = 0 //其他费用
  14913. var otherCostSelfTotal float64 = 0 //其他费用
  14914. var otherCostPartSelfTotal float64 = 0 //其他费用
  14915. var otherSelfTotal float64 = 0 //床位部分项目自费
  14916. var otherInscpTotal float64 = 0 //床位部分项目自费
  14917. var materialCostTotal float64 = 0 //材料费
  14918. var materialCostSelfTotal float64 = 0 //材料费
  14919. var materialCostPartSelfTotal float64 = 0 //材料费
  14920. var materialSelfTotal float64 = 0 //床位部分项目自费
  14921. var materialInscpTotal float64 = 0 //床位部分项目自费
  14922. var westernMedicineCostTotal float64 = 0 //西药费
  14923. var westernMedicineCostSelfTotal float64 = 0 //西药费
  14924. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14925. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  14926. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  14927. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14928. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14929. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14930. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  14931. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  14932. var checkCostTotal float64 = 0 //检查费
  14933. var checkCostSelfTotal float64 = 0 //检查费
  14934. var checkCostPartSelfTotal float64 = 0 //检查费
  14935. var checkSelfTotal float64 = 0 //床位部分项目自费
  14936. var checkInscpTotal float64 = 0 //床位部分项目自费
  14937. var laboratoryCostTotal float64 = 0 //化验费
  14938. var laboratoryCostSelfTotal float64 = 0 //化验费
  14939. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14940. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  14941. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  14942. var treatCostTotal float64 = 0 //治疗费用
  14943. var treatCostSelfTotal float64 = 0 //治疗费用
  14944. var treatCostPartSelfTotal float64 = 0 //治疗费用
  14945. var treatSelfTotal float64 = 0 //床位部分项目自费
  14946. var treatInscpTotal float64 = 0 //床位部分项目自费
  14947. decimal.DivisionPrecision = 2
  14948. for _, item := range orderInfos {
  14949. if item.MedChrgitmType == "01" { //床位费
  14950. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14951. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14952. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14953. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14954. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14955. }
  14956. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  14957. if item.MedChrgitmType == "03" { //检查费
  14958. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14959. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14960. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14961. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14962. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14963. }
  14964. } else {
  14965. if item.MedChrgitmType == "03" { //检查费
  14966. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14967. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14968. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14969. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14970. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14971. }
  14972. }
  14973. if item.MedChrgitmType == "04" { //化验费
  14974. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14975. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14976. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14977. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14978. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14979. }
  14980. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  14981. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14982. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14983. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14984. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14985. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14986. }
  14987. if item.MedChrgitmType == "06" { //手术费
  14988. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14989. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14990. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14991. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14992. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14993. }
  14994. if item.MedChrgitmType == "08" { //材料费
  14995. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14996. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14997. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14998. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14999. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15000. }
  15001. if item.MedChrgitmType == "09" { //西药费
  15002. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15003. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15004. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15005. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15006. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15007. }
  15008. if item.MedChrgitmType == "11" { //中成费
  15009. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15010. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15011. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15012. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15013. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15014. }
  15015. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  15016. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15017. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15018. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15019. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15020. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15021. }
  15022. }
  15023. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15024. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15025. var user_name string
  15026. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15027. if role.ID == 0 {
  15028. user_name = "管理员"
  15029. } else {
  15030. user_name = role.UserName
  15031. }
  15032. baseParams := models.BaseParams{
  15033. SecretKey: miConfig.SecretKey,
  15034. FixmedinsCode: miConfig.Code,
  15035. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  15036. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  15037. OrgName: miConfig.OrgName,
  15038. Doctor: user_name,
  15039. RequestUrl: miConfig.Url,
  15040. AccessKey: miConfig.AccessKey,
  15041. }
  15042. businessParams := models.BusinessParams{
  15043. PsnNo: order.PsnNo,
  15044. MdtrtId: order.MdtrtId,
  15045. SetlId: order.SetlId,
  15046. }
  15047. var res ResultEleven
  15048. var resEleven10265 ResultEleven10265
  15049. if config.IsOpen == 1 {
  15050. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  15051. result := service.Gdyb5203(baseParams, businessParams)
  15052. //service.Gdyb5204(baseParams, businessParams)
  15053. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  15054. var dat map[string]interface{}
  15055. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15056. fmt.Println(dat)
  15057. } else {
  15058. fmt.Println(err)
  15059. }
  15060. userJSONBytes, _ := json.Marshal(dat)
  15061. if miConfig.Code == "H15049901371" {
  15062. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  15063. utils.ErrorLog("解析失败:%v", err)
  15064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15065. return
  15066. }
  15067. res.InfRefmsgid = resEleven10265.InfRefmsgid
  15068. res.Output = resEleven10265.Output
  15069. res.ErrMsg = resEleven10265.ErrMsg
  15070. res.Cainfo = resEleven10265.Cainfo
  15071. res.WarnMsg = resEleven10265.WarnMsg
  15072. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  15073. res.Infcode = infocode
  15074. } else {
  15075. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15076. utils.ErrorLog("解析失败:%v", err)
  15077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15078. return
  15079. }
  15080. }
  15081. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15082. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  15083. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  15084. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  15085. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  15086. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15087. var doctor_name string
  15088. if roles.ID == 0 {
  15089. doctor_name = "管理员"
  15090. } else {
  15091. doctor_name = roles.UserName
  15092. }
  15093. yiliao_leibie := ""
  15094. switch order.MedType {
  15095. case "11":
  15096. yiliao_leibie = "普通门诊"
  15097. break
  15098. case "12":
  15099. yiliao_leibie = "门诊挂号"
  15100. break
  15101. case "13":
  15102. yiliao_leibie = "急诊"
  15103. break
  15104. case "14":
  15105. yiliao_leibie = "门诊特殊病"
  15106. break
  15107. case "15":
  15108. yiliao_leibie = "门诊统筹"
  15109. break
  15110. case "16":
  15111. yiliao_leibie = "门诊慢性病"
  15112. break
  15113. case "21":
  15114. yiliao_leibie = "普通住院"
  15115. break
  15116. }
  15117. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  15118. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  15119. if res.Infcode == 0 {
  15120. data2 := map[string]interface{}{
  15121. "diagnosis": name,
  15122. "order_infos": orderInfos,
  15123. "number": order.MdtrtId,
  15124. "date": order.SettleAccountsDate,
  15125. "charge_admin": charge_admin,
  15126. "printor_admin": printor_admin,
  15127. "info": res.Output.Setlinfo,
  15128. "order": order,
  15129. "bedCostTotal": bedCostTotal,
  15130. "bedCostSelfTotal": bedCostSelfTotal,
  15131. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  15132. "bedSelfTotal": bedSelfTotal,
  15133. "bedInscpTotal": bedInscpTotal,
  15134. "operationCostTotal": operationCostTotal,
  15135. "operationCostSelfTotal": operationCostSelfTotal,
  15136. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  15137. "operationSelfTotal": operationSelfTotal,
  15138. "operationInscpTotal": operationInscpTotal,
  15139. "otherCostTotal": otherCostTotal,
  15140. "otherCostSelfTotal": otherCostSelfTotal,
  15141. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  15142. "otherSelfTotal": otherSelfTotal,
  15143. "otherInscpTotal": otherInscpTotal,
  15144. "materialCostTotal": materialCostTotal,
  15145. "materialCostSelfTotal": materialCostSelfTotal,
  15146. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  15147. "materialSelfTotal": materialSelfTotal,
  15148. "materialInscpTotal": materialInscpTotal,
  15149. "westernMedicineCostTotal": westernMedicineCostTotal,
  15150. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  15151. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  15152. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  15153. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  15154. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  15155. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  15156. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  15157. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  15158. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  15159. "checkCostTotal": checkCostTotal,
  15160. "checkCostSelfTotal": checkCostSelfTotal,
  15161. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  15162. "checkSelfTotal": checkSelfTotal,
  15163. "checkInscpTotal": checkInscpTotal,
  15164. "laboratoryCostTotal": laboratoryCostTotal,
  15165. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  15166. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  15167. "laboratorySelfTotal": laboratorySelfTotal,
  15168. "laboratoryInscpTotal": laboratoryInscpTotal,
  15169. "treatCostTotal": treatCostTotal,
  15170. "treatCostSelfTotal": treatCostSelfTotal,
  15171. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  15172. "treatSelfTotal": treatSelfTotal,
  15173. "treatInscpTotal": treatInscpTotal,
  15174. "doctor_info": doctor_info,
  15175. "doctor_code": adminRole_two.DoctorCode,
  15176. "doctor_name": doctor_name,
  15177. "health_card_no": order.PsnNo,
  15178. "department": departments.Name,
  15179. "yiliao_leibie": yiliao_leibie,
  15180. "after_money": order.AccountPrice,
  15181. "patient": patient,
  15182. "org_name": miConfig.OrgName,
  15183. "org_code": miConfig.Code,
  15184. "order_number": order.Number,
  15185. "his_hospital": his_hospital,
  15186. "his": his,
  15187. "dia_config": dia_config,
  15188. "psn_cash_pay": order.PsnCashPay,
  15189. //"check_order_info": cus_slice,
  15190. }
  15191. data3 = append(data3, data2)
  15192. }
  15193. }
  15194. }
  15195. c.ServeSuccessJSON(map[string]interface{}{
  15196. "infos": data3,
  15197. })
  15198. }
  15199. func (c *HisApiController) GetSettleAccounts() {
  15200. //id, _ := c.GetInt64("id")
  15201. //record_time := c.GetString("record_time")
  15202. order_id, _ := c.GetInt64("order_id")
  15203. admin_user_id, _ := c.GetInt64("admin_user_id")
  15204. //timeLayout := "2006-01-02"
  15205. //loc, _ := time.LoadLocation("Local")
  15206. //
  15207. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  15208. //if err != nil {
  15209. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  15210. // return
  15211. //}
  15212. //recordDateTime := theTime.Unix()
  15213. adminUser := c.GetAdminUserInfo()
  15214. order, _ := service.GetHisOrderByID(order_id)
  15215. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  15216. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  15217. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  15218. orderInfos = append(orderInfos, orderInfos_two...)
  15219. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  15220. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  15221. var diagnosis_ids []string
  15222. if his.ID > 0 {
  15223. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  15224. } else {
  15225. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  15226. }
  15227. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  15228. var dia_config []*models.HisXtDiagnoseConfig
  15229. var name string
  15230. for _, item := range diagnosis_ids {
  15231. id, _ := strconv.ParseInt(item, 10, 64)
  15232. diagnosisConfig, _ := service.FindDiagnoseById(id)
  15233. dia_config = append(dia_config, &diagnosisConfig)
  15234. if len(name) == 0 {
  15235. name = diagnosisConfig.ClassName
  15236. } else {
  15237. name = name + "," + diagnosisConfig.ClassName
  15238. }
  15239. }
  15240. var bedCostTotal float64 = 0 //床位总费
  15241. var bedCostSelfTotal float64 = 0 //床位自费
  15242. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  15243. var bedSelfTotal float64 = 0 //床位部分项目自费
  15244. var bedInscpTotal float64 = 0 //床位部分项目自费
  15245. var operationCostTotal float64 = 0 //手术费
  15246. var operationCostSelfTotal float64 = 0 //手术费
  15247. var operationCostPartSelfTotal float64 = 0 //手术费
  15248. var operationSelfTotal float64 = 0 //床位部分项目自费
  15249. var operationInscpTotal float64 = 0 //床位部分项目自费
  15250. var otherCostTotal float64 = 0 //其他费用
  15251. var otherCostSelfTotal float64 = 0 //其他费用
  15252. var otherCostPartSelfTotal float64 = 0 //其他费用
  15253. var otherSelfTotal float64 = 0 //床位部分项目自费
  15254. var otherInscpTotal float64 = 0 //床位部分项目自费
  15255. var materialCostTotal float64 = 0 //材料费
  15256. var materialCostSelfTotal float64 = 0 //材料费
  15257. var materialCostPartSelfTotal float64 = 0 //材料费
  15258. var materialSelfTotal float64 = 0 //床位部分项目自费
  15259. var materialInscpTotal float64 = 0 //床位部分项目自费
  15260. var westernMedicineCostTotal float64 = 0 //西药费
  15261. var westernMedicineCostSelfTotal float64 = 0 //西药费
  15262. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  15263. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  15264. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  15265. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  15266. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  15267. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  15268. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  15269. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  15270. var checkCostTotal float64 = 0 //检查费
  15271. var checkCostSelfTotal float64 = 0 //检查费
  15272. var checkCostPartSelfTotal float64 = 0 //检查费
  15273. var checkSelfTotal float64 = 0 //床位部分项目自费
  15274. var checkInscpTotal float64 = 0 //床位部分项目自费
  15275. var laboratoryCostTotal float64 = 0 //化验费
  15276. var laboratoryCostSelfTotal float64 = 0 //化验费
  15277. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  15278. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  15279. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  15280. var treatCostTotal float64 = 0 //治疗费用
  15281. var treatCostSelfTotal float64 = 0 //治疗费用
  15282. var treatCostPartSelfTotal float64 = 0 //治疗费用
  15283. var treatSelfTotal float64 = 0 //床位部分项目自费
  15284. var treatInscpTotal float64 = 0 //床位部分项目自费
  15285. decimal.DivisionPrecision = 2
  15286. for _, item := range orderInfos {
  15287. if item.MedChrgitmType == "01" { //床位费
  15288. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15289. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15290. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15291. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15292. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15293. }
  15294. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  15295. if item.MedChrgitmType == "03" { //检查费
  15296. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15297. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15298. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15299. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15300. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15301. }
  15302. } else {
  15303. if item.MedChrgitmType == "03" { //检查费
  15304. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15305. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15306. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15307. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15308. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15309. }
  15310. }
  15311. if item.MedChrgitmType == "04" { //化验费
  15312. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15313. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15314. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15315. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15316. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15317. }
  15318. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  15319. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15320. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15321. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15322. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15323. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15324. }
  15325. if item.MedChrgitmType == "06" { //手术费
  15326. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15327. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15328. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15329. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15330. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15331. }
  15332. if item.MedChrgitmType == "08" { //材料费
  15333. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15334. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15335. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15336. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15337. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15338. }
  15339. if item.MedChrgitmType == "09" { //西药费
  15340. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15341. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15342. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15343. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15344. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15345. }
  15346. if item.MedChrgitmType == "11" { //中成费
  15347. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15348. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15349. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15350. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15351. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15352. }
  15353. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  15354. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15355. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15356. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15357. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15358. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15359. }
  15360. }
  15361. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15362. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15363. var user_name string
  15364. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15365. if role.ID == 0 {
  15366. user_name = "管理员"
  15367. } else {
  15368. user_name = role.UserName
  15369. }
  15370. baseParams := models.BaseParams{
  15371. SecretKey: miConfig.SecretKey,
  15372. FixmedinsCode: miConfig.Code,
  15373. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  15374. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  15375. OrgName: miConfig.OrgName,
  15376. Doctor: user_name,
  15377. RequestUrl: miConfig.Url,
  15378. AccessKey: miConfig.AccessKey,
  15379. }
  15380. businessParams := models.BusinessParams{
  15381. PsnNo: order.PsnNo,
  15382. MdtrtId: order.MdtrtId,
  15383. SetlId: order.SetlId,
  15384. }
  15385. var res ResultEleven
  15386. var resEleven10265 ResultEleven10265
  15387. if config.IsOpen == 1 {
  15388. if miConfig.MdtrtareaAdmvs == "421300" {
  15389. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  15390. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  15391. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  15392. resp, requestErr := http.Get(api)
  15393. if requestErr != nil {
  15394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15395. return
  15396. }
  15397. body, ioErr := ioutil.ReadAll(resp.Body)
  15398. if ioErr != nil {
  15399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15401. return
  15402. }
  15403. var respJSON map[string]interface{}
  15404. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15407. return
  15408. }
  15409. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15410. result, _ := json.Marshal(respJSON)
  15411. fmt.Println("log")
  15412. fmt.Println(string(result))
  15413. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15414. utils.ErrorLog("解析失败:%v", err)
  15415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15416. return
  15417. }
  15418. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15419. var api string
  15420. if miConfig.MdtrtareaAdmvs == "320921" {
  15421. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  15422. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  15423. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15424. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  15425. } else {
  15426. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  15427. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  15428. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  15429. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15430. }
  15431. resp, requestErr := http.Get(api)
  15432. if requestErr != nil {
  15433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15434. return
  15435. }
  15436. body, ioErr := ioutil.ReadAll(resp.Body)
  15437. if ioErr != nil {
  15438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15440. return
  15441. }
  15442. var respJSON map[string]interface{}
  15443. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15446. return
  15447. }
  15448. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15449. result, _ := json.Marshal(respJSON)
  15450. fmt.Println("log")
  15451. fmt.Println(string(result))
  15452. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  15453. utils.ErrorLog("解析失败:%v", err)
  15454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15455. return
  15456. }
  15457. res.InfRefmsgid = resEleven10265.InfRefmsgid
  15458. res.Output = resEleven10265.Output
  15459. res.ErrMsg = resEleven10265.ErrMsg
  15460. res.Cainfo = resEleven10265.Cainfo
  15461. res.WarnMsg = resEleven10265.WarnMsg
  15462. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  15463. res.Infcode = infocode
  15464. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15465. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  15466. saveLog(result, requestLog, "5203", "结算单")
  15467. var dat map[string]interface{}
  15468. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15469. fmt.Println(dat)
  15470. } else {
  15471. fmt.Println(err)
  15472. }
  15473. userJSONBytes, _ := json.Marshal(dat)
  15474. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15475. utils.ErrorLog("解析失败:%v", err)
  15476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15477. return
  15478. }
  15479. } else if miConfig.MdtrtareaAdmvs == "360399" {
  15480. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  15481. saveLog(result, requestLog, "5203", "结算单")
  15482. var dat map[string]interface{}
  15483. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15484. fmt.Println(dat)
  15485. } else {
  15486. fmt.Println(err)
  15487. }
  15488. userJSONBytes, _ := json.Marshal(dat)
  15489. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15490. utils.ErrorLog("解析失败:%v", err)
  15491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15492. return
  15493. }
  15494. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15495. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  15496. saveLog(result, requestLog, "5203", "结算单")
  15497. var dat map[string]interface{}
  15498. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15499. fmt.Println(dat)
  15500. } else {
  15501. fmt.Println(err)
  15502. }
  15503. userJSONBytes, _ := json.Marshal(dat)
  15504. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15505. utils.ErrorLog("解析失败:%v", err)
  15506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15507. return
  15508. }
  15509. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15510. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  15511. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  15512. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  15513. resp, requestErr := http.Get(api)
  15514. if requestErr != nil {
  15515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15516. return
  15517. }
  15518. body, ioErr := ioutil.ReadAll(resp.Body)
  15519. if ioErr != nil {
  15520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15522. return
  15523. }
  15524. var respJSON map[string]interface{}
  15525. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15528. return
  15529. }
  15530. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15531. result, _ := json.Marshal(respJSON)
  15532. fmt.Println("log")
  15533. fmt.Println(string(result))
  15534. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  15535. utils.ErrorLog("解析失败:%v", err)
  15536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15537. return
  15538. }
  15539. res.InfRefmsgid = resEleven10265.InfRefmsgid
  15540. res.Output = resEleven10265.Output
  15541. res.ErrMsg = resEleven10265.ErrMsg
  15542. res.Cainfo = resEleven10265.Cainfo
  15543. res.WarnMsg = resEleven10265.WarnMsg
  15544. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  15545. res.Infcode = infocode
  15546. } else {
  15547. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  15548. result := service.Gdyb5203(baseParams, businessParams)
  15549. //service.Gdyb5204(baseParams, businessParams)
  15550. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  15551. var dat map[string]interface{}
  15552. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15553. fmt.Println(dat)
  15554. } else {
  15555. fmt.Println(err)
  15556. }
  15557. userJSONBytes, _ := json.Marshal(dat)
  15558. if miConfig.Code == "H15049901371" {
  15559. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  15560. utils.ErrorLog("解析失败:%v", err)
  15561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15562. return
  15563. }
  15564. res.InfRefmsgid = resEleven10265.InfRefmsgid
  15565. res.Output = resEleven10265.Output
  15566. res.ErrMsg = resEleven10265.ErrMsg
  15567. res.Cainfo = resEleven10265.Cainfo
  15568. res.WarnMsg = resEleven10265.WarnMsg
  15569. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  15570. res.Infcode = infocode
  15571. } else {
  15572. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15573. utils.ErrorLog("解析失败:%v", err)
  15574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15575. return
  15576. }
  15577. }
  15578. }
  15579. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15580. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  15581. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  15582. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  15583. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  15584. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15585. var doctor_name string
  15586. if roles.ID == 0 {
  15587. doctor_name = "管理员"
  15588. } else {
  15589. doctor_name = roles.UserName
  15590. }
  15591. yiliao_leibie := ""
  15592. switch order.MedType {
  15593. case "11":
  15594. yiliao_leibie = "普通门诊"
  15595. break
  15596. case "12":
  15597. yiliao_leibie = "门诊挂号"
  15598. break
  15599. case "13":
  15600. yiliao_leibie = "急诊"
  15601. break
  15602. case "14":
  15603. yiliao_leibie = "门诊特殊病"
  15604. break
  15605. case "15":
  15606. yiliao_leibie = "门诊统筹"
  15607. break
  15608. case "16":
  15609. yiliao_leibie = "门诊慢性病"
  15610. break
  15611. case "21":
  15612. yiliao_leibie = "普通住院"
  15613. break
  15614. }
  15615. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  15616. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  15617. if res.Infcode == 0 {
  15618. c.ServeSuccessJSON(map[string]interface{}{
  15619. "diagnosis": name,
  15620. "order_infos": orderInfos,
  15621. "number": order.MdtrtId,
  15622. "date": order.SettleAccountsDate,
  15623. "charge_admin": charge_admin,
  15624. "printor_admin": printor_admin,
  15625. "info": res.Output.Setlinfo,
  15626. "order": order,
  15627. "bedCostTotal": bedCostTotal,
  15628. "bedCostSelfTotal": bedCostSelfTotal,
  15629. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  15630. "bedSelfTotal": bedSelfTotal,
  15631. "bedInscpTotal": bedInscpTotal,
  15632. "operationCostTotal": operationCostTotal,
  15633. "operationCostSelfTotal": operationCostSelfTotal,
  15634. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  15635. "operationSelfTotal": operationSelfTotal,
  15636. "operationInscpTotal": operationInscpTotal,
  15637. "otherCostTotal": otherCostTotal,
  15638. "otherCostSelfTotal": otherCostSelfTotal,
  15639. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  15640. "otherSelfTotal": otherSelfTotal,
  15641. "otherInscpTotal": otherInscpTotal,
  15642. "materialCostTotal": materialCostTotal,
  15643. "materialCostSelfTotal": materialCostSelfTotal,
  15644. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  15645. "materialSelfTotal": materialSelfTotal,
  15646. "materialInscpTotal": materialInscpTotal,
  15647. "westernMedicineCostTotal": westernMedicineCostTotal,
  15648. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  15649. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  15650. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  15651. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  15652. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  15653. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  15654. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  15655. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  15656. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  15657. "checkCostTotal": checkCostTotal,
  15658. "checkCostSelfTotal": checkCostSelfTotal,
  15659. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  15660. "checkSelfTotal": checkSelfTotal,
  15661. "checkInscpTotal": checkInscpTotal,
  15662. "laboratoryCostTotal": laboratoryCostTotal,
  15663. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  15664. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  15665. "laboratorySelfTotal": laboratorySelfTotal,
  15666. "laboratoryInscpTotal": laboratoryInscpTotal,
  15667. "treatCostTotal": treatCostTotal,
  15668. "treatCostSelfTotal": treatCostSelfTotal,
  15669. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  15670. "treatSelfTotal": treatSelfTotal,
  15671. "treatInscpTotal": treatInscpTotal,
  15672. "doctor_info": doctor_info,
  15673. "doctor_code": adminRole_two.DoctorCode,
  15674. "doctor_name": doctor_name,
  15675. "health_card_no": order.PsnNo,
  15676. "department": departments.Name,
  15677. "yiliao_leibie": yiliao_leibie,
  15678. "after_money": order.AccountPrice,
  15679. "patient": patient,
  15680. "org_name": miConfig.OrgName,
  15681. "org_code": miConfig.Code,
  15682. "order_number": order.Number,
  15683. "his_hospital": his_hospital,
  15684. "his": his,
  15685. "dia_config": dia_config,
  15686. "psn_cash_pay": order.PsnCashPay,
  15687. //"check_order_info": cus_slice,
  15688. })
  15689. }
  15690. }
  15691. }
  15692. func (c *HisApiController) CheckTreatment() {
  15693. patient_id, _ := c.GetInt64("patient_id")
  15694. id_card_no := c.GetString("id_card_no")
  15695. insutype := c.GetString("insutype")
  15696. med_type := c.GetString("med_type")
  15697. admin_user_id, _ := c.GetInt64("admin_user_id")
  15698. adminUser := c.GetAdminUserInfo()
  15699. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  15700. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15701. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15702. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15703. if miConfig.MdtrtareaAdmvs == "421300" {
  15704. var res ResultTwo
  15705. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  15706. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15707. "&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)
  15708. resp, requestErr := http.Get(api)
  15709. if requestErr != nil {
  15710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15711. return
  15712. }
  15713. body, ioErr := ioutil.ReadAll(resp.Body)
  15714. if ioErr != nil {
  15715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15717. return
  15718. }
  15719. var respJSON map[string]interface{}
  15720. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15723. return
  15724. }
  15725. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15726. result, _ := json.Marshal(respJSON)
  15727. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15728. utils.ErrorLog("解析失败:%v", err)
  15729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15730. return
  15731. }
  15732. if res.Infcode == 0 {
  15733. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  15734. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15735. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  15736. resp, requestErr := http.Get(api)
  15737. if requestErr != nil {
  15738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15739. return
  15740. }
  15741. body, ioErr := ioutil.ReadAll(resp.Body)
  15742. if ioErr != nil {
  15743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15745. return
  15746. }
  15747. var respJSON map[string]interface{}
  15748. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15751. return
  15752. }
  15753. var res Result2001
  15754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15755. result2, _ := json.Marshal(respJSON)
  15756. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15757. utils.ErrorLog("解析失败:%v", err)
  15758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15759. return
  15760. }
  15761. if res.Infcode == 0 {
  15762. c.ServeSuccessJSON(map[string]interface{}{
  15763. "msg": res.Output.Trtinfo,
  15764. })
  15765. }
  15766. } else {
  15767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15768. return
  15769. }
  15770. } else {
  15771. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  15772. var dat map[string]interface{}
  15773. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15774. fmt.Println(dat)
  15775. } else {
  15776. fmt.Println(err)
  15777. }
  15778. userJSONBytes, _ := json.Marshal(dat)
  15779. var res ResultTwo
  15780. var res10265 ResultTwo10265
  15781. if miConfig.Code == "H15049901371" {
  15782. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  15783. utils.ErrorLog("解析失败:%v", err)
  15784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15785. return
  15786. }
  15787. res.ErrMsg = res10265.ErrMsg
  15788. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15789. res.Infcode = infocode
  15790. res.Output = res10265.Output
  15791. res.InfRefmsgid = res10265.InfRefmsgid
  15792. } else {
  15793. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15794. utils.ErrorLog("解析失败:%v", err)
  15795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15796. return
  15797. }
  15798. }
  15799. var user_name string
  15800. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  15801. if role.ID == 0 {
  15802. user_name = "xxx"
  15803. } else {
  15804. user_name = role.UserName
  15805. }
  15806. baseParams := models.BaseParams{
  15807. SecretKey: miConfig.SecretKey,
  15808. FixmedinsCode: miConfig.Code,
  15809. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  15810. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  15811. OrgName: miConfig.OrgName,
  15812. Doctor: user_name,
  15813. }
  15814. if config.IsOpen == 1 {
  15815. if miConfig.Code == "H15049901371" {
  15816. if med_type == "14" {
  15817. if insutype == "390" {
  15818. med_type = "9933"
  15819. } else if insutype == "310" {
  15820. med_type = "990502"
  15821. }
  15822. } else if med_type == "11" {
  15823. med_type = "11"
  15824. }
  15825. }
  15826. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  15827. var dat map[string]interface{}
  15828. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15829. fmt.Println(dat)
  15830. } else {
  15831. fmt.Println(err)
  15832. }
  15833. var res Result2001
  15834. var res10265 Result2001Org10265
  15835. if miConfig.Code == "H15049901371" {
  15836. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15837. utils.ErrorLog("解析失败:%v", err)
  15838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15839. return
  15840. }
  15841. res.ErrMsg = res10265.ErrMsg
  15842. res.Output = res10265.Output
  15843. res.InfRefmsgid = res10265.InfRefmsgid
  15844. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15845. res.Infcode = infocode
  15846. } else {
  15847. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15848. utils.ErrorLog("解析失败:%v", err)
  15849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15850. return
  15851. }
  15852. }
  15853. if res.Infcode == 0 {
  15854. c.ServeSuccessJSON(map[string]interface{}{
  15855. "msg": res.Output.Trtinfo,
  15856. })
  15857. }
  15858. }
  15859. }
  15860. }
  15861. //func (c *HisApiController) PutRecord() {
  15862. // id, _ := c.GetInt64("id")
  15863. // record_time := c.GetString("record_time")
  15864. // timeLayout := "2006-01-02"
  15865. // loc, _ := time.LoadLocation("Local")
  15866. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  15867. // if err != nil {
  15868. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  15869. // return
  15870. // }
  15871. // recordDateTime := theTime.Unix()
  15872. //
  15873. // adminInfo := c.GetAdminUserInfo()
  15874. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  15875. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  15876. //
  15877. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  15878. //
  15879. // fmt.Println(miConfig.SecretKey)
  15880. //
  15881. // if patient == nil {
  15882. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  15883. // return
  15884. // }
  15885. // if len(patient.IdCardNo) == 0 {
  15886. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  15887. // return
  15888. // }
  15889. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  15890. // if config.IsOpen == 1 {
  15891. // 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
  15892. // resp, requestErr := http.Get(api)
  15893. // if requestErr != nil {
  15894. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15895. // return
  15896. // }
  15897. // defer resp.Body.Close()
  15898. // body, ioErr := ioutil.ReadAll(resp.Body)
  15899. // if ioErr != nil {
  15900. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15901. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15902. // return
  15903. // }
  15904. // var respJSON map[string]interface{}
  15905. //
  15906. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15907. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15908. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15909. // return
  15910. // }
  15911. //
  15912. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15913. // userJSONBytes, _ := json.Marshal(userJSON)
  15914. // var res ResultTwo
  15915. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15916. // utils.ErrorLog("解析失败:%v", err)
  15917. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15918. // return
  15919. // }
  15920. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15921. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15922. // infoStr := string(Iinfos)
  15923. // idetinfoStr := string(Idetinfos)
  15924. //
  15925. // if res.Infcode == 0 {
  15926. // his := models.VMHisPatient{
  15927. // Status: 1,
  15928. // Ctime: time.Now().Unix(),
  15929. // Mtime: time.Now().Unix(),
  15930. // PsnNo: res.Output.Baseinfo.PsnNo,
  15931. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  15932. // Certno: res.Output.Baseinfo.Certno,
  15933. // PsnName: res.Output.Baseinfo.PsnName,
  15934. // Gend: res.Output.Baseinfo.Gend,
  15935. // Naty: res.Output.Baseinfo.Naty,
  15936. // Brdy: res.Output.Baseinfo.Brdy,
  15937. // Age: res.Output.Baseinfo.Age,
  15938. // Iinfo: infoStr,
  15939. // Idetinfo: idetinfoStr,
  15940. // PatientId: patient.ID,
  15941. // RecordDate: theTime.Unix(),
  15942. // UserOrgId: adminInfo.CurrentOrgId,
  15943. // AdminUserId: adminInfo.AdminUser.Id,
  15944. // IsReturn: 1,
  15945. // }
  15946. //
  15947. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  15948. // //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")
  15949. // //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")
  15950. //
  15951. // //var dat map[string]interface{}
  15952. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15953. // // fmt.Println(dat)
  15954. // //} else {
  15955. // // fmt.Println(err)
  15956. // //}
  15957. //
  15958. // var dat2 map[string]interface{}
  15959. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  15960. // fmt.Println(dat2)
  15961. // } else {
  15962. // fmt.Println(err)
  15963. // }
  15964. //
  15965. // } else {
  15966. // adminUser := c.GetAdminUserInfo()
  15967. // errlog := &models.HisOrderError{
  15968. // UserOrgId: adminUser.CurrentOrgId,
  15969. // Ctime: time.Now().Unix(),
  15970. // Mtime: time.Now().Unix(),
  15971. // ErrMsg: res.ErrMsg,
  15972. // Status: 1,
  15973. // PatientId: id,
  15974. // RecordTime: recordDateTime,
  15975. // Stage: 1,
  15976. // }
  15977. // service.CreateErrMsgLog(errlog)
  15978. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  15979. // return
  15980. // }
  15981. // }
  15982. //
  15983. //}
  15984. //func (c *HisApiController) GetUploadDiag() {
  15985. // id, _ := c.GetInt64("id")
  15986. // record_time := c.GetString("record_time")
  15987. //
  15988. // diagnosis_id, _ := c.GetInt64("diagnosis")
  15989. // sick_type, _ := c.GetInt64("sick_type")
  15990. // reg_type, _ := c.GetInt64("reg_type")
  15991. //
  15992. // timeLayout := "2006-01-02"
  15993. // loc, _ := time.LoadLocation("Local")
  15994. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  15995. // if err != nil {
  15996. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  15997. // return
  15998. // }
  15999. //
  16000. // var patientPrescription models.HisPrescriptionInfo
  16001. // recordDateTime := theTime.Unix()
  16002. // adminInfo := c.GetAdminUserInfo()
  16003. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16004. //
  16005. // if patientPrescription.ID == 0 {
  16006. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16007. // }
  16008. //
  16009. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  16010. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  16011. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16012. // sickConfig, _ := service.FindSickById(sick_type)
  16013. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  16014. //
  16015. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  16016. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  16017. // "&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 +
  16018. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  16019. // resp2, requestErr2 := http.Get(api2)
  16020. // if requestErr2 != nil {
  16021. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16022. // return
  16023. // }
  16024. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  16025. // if ioErr2 != nil {
  16026. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  16027. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16028. // return
  16029. // }
  16030. // var respJSON2 map[string]interface{}
  16031. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  16032. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16033. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16034. // return
  16035. // }
  16036. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16037. // userJSONBytes2, _ := json.Marshal(respJSON2)
  16038. //
  16039. // var res2 ResultSix
  16040. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  16041. // utils.ErrorLog("解析失败:%v", err)
  16042. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16043. // return
  16044. // }
  16045. // if res2.Infcode != 0 {
  16046. // adminUser := c.GetAdminUserInfo()
  16047. // errlog := &models.HisOrderError{
  16048. // UserOrgId: adminUser.CurrentOrgId,
  16049. // Ctime: time.Now().Unix(),
  16050. // Mtime: time.Now().Unix(),
  16051. // ErrMsg: res2.ErrMsg,
  16052. // Status: 1,
  16053. // PatientId: id,
  16054. // RecordTime: recordDateTime,
  16055. // Stage: 3,
  16056. // }
  16057. // service.CreateErrMsgLog(errlog)
  16058. //
  16059. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  16060. // return
  16061. // }
  16062. //
  16063. // c.ServeSuccessJSON(map[string]interface{}{
  16064. // "msg": "上传成功",
  16065. // })
  16066. //
  16067. //}
  16068. type QueryResult struct {
  16069. ID int64
  16070. Name string
  16071. Code string
  16072. List_type_code string
  16073. }
  16074. func (c *HisApiController) GetCheckCode() {
  16075. ids_str := c.GetString("ids")
  16076. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  16077. ids_arr := strings.Split(ids_str, ",")
  16078. var queryResult []QueryResult
  16079. ids := make([]int64, 0)
  16080. for _, item := range ids_arr {
  16081. id, _ := strconv.ParseInt(item, 10, 64)
  16082. ids = append(ids, id)
  16083. }
  16084. if record_type == 1 {
  16085. drugs, _ := service.GetBatchDrugList(ids)
  16086. for _, item := range drugs {
  16087. result := QueryResult{
  16088. ID: item.ID,
  16089. Name: item.DrugName,
  16090. Code: item.MedicalInsuranceNumber,
  16091. List_type_code: "101",
  16092. }
  16093. queryResult = append(queryResult, result)
  16094. }
  16095. } else if record_type == 2 {
  16096. goods, _ := service.GetBatchGoodInformationList(ids)
  16097. for _, item := range goods {
  16098. result := QueryResult{
  16099. ID: item.ID,
  16100. Name: item.GoodName,
  16101. Code: item.MedicalInsuranceNumber,
  16102. List_type_code: "301",
  16103. }
  16104. queryResult = append(queryResult, result)
  16105. }
  16106. } else if record_type == 3 {
  16107. projects, _ := service.GetBathchMyPorjecgList(ids)
  16108. for _, item := range projects {
  16109. result := QueryResult{
  16110. ID: item.ID,
  16111. Name: item.ProjectName,
  16112. Code: item.MedicalCode,
  16113. List_type_code: "201",
  16114. }
  16115. queryResult = append(queryResult, result)
  16116. }
  16117. }
  16118. admin_user_id, _ := c.GetInt64("admin_user_id")
  16119. adminUser := c.GetAdminUserInfo()
  16120. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16121. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16122. var user_name string
  16123. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16124. if role.ID == 0 {
  16125. user_name = "xxx"
  16126. } else {
  16127. user_name = role.UserName
  16128. }
  16129. baseParams := &models.BaseParams{
  16130. SecretKey: miConfig.SecretKey,
  16131. FixmedinsCode: miConfig.Code,
  16132. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  16133. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  16134. OrgName: miConfig.OrgName,
  16135. Doctor: user_name,
  16136. }
  16137. if config.IsOpen == 1 {
  16138. for _, item := range queryResult {
  16139. var result string
  16140. if record_type == 1 {
  16141. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  16142. } else if record_type == 2 {
  16143. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  16144. } else if record_type == 3 {
  16145. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  16146. }
  16147. var dat map[string]interface{}
  16148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16149. fmt.Println(dat)
  16150. } else {
  16151. fmt.Println(err)
  16152. }
  16153. userJSONBytes, _ := json.Marshal(dat)
  16154. var res ResultSix
  16155. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16156. utils.ErrorLog("解析失败:%v", err)
  16157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16158. return
  16159. }
  16160. if res.Infcode == 0 {
  16161. if record_type == 1 {
  16162. service.UpdateBaseDrugById(item.ID)
  16163. } else if record_type == 2 {
  16164. service.UpdateGoodInformaitonByDetail(item.ID)
  16165. } else if record_type == 3 {
  16166. service.UpdateProjectById(item.ID)
  16167. }
  16168. c.ServeSuccessJSON(map[string]interface{}{
  16169. "failed_code": 0,
  16170. "msg": "目录对照成功",
  16171. })
  16172. } else {
  16173. c.ServeSuccessJSON(map[string]interface{}{
  16174. "failed_code": -10,
  16175. "msg": res.ErrMsg,
  16176. })
  16177. }
  16178. }
  16179. }
  16180. }
  16181. func (c *HisApiController) UnCheckCode() {
  16182. ids_str := c.GetString("ids")
  16183. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  16184. admin_user_id, _ := c.GetInt64("admin_user_id")
  16185. ids_arr := strings.Split(ids_str, ",")
  16186. var queryResult []QueryResult
  16187. ids := make([]int64, 0)
  16188. for _, item := range ids_arr {
  16189. id, _ := strconv.ParseInt(item, 10, 64)
  16190. ids = append(ids, id)
  16191. }
  16192. if record_type == 1 {
  16193. drugs, _ := service.GetBatchDrugList(ids)
  16194. for _, item := range drugs {
  16195. result := QueryResult{
  16196. ID: item.ID,
  16197. Name: item.DrugName,
  16198. Code: item.MedicalInsuranceNumber,
  16199. List_type_code: "101",
  16200. }
  16201. queryResult = append(queryResult, result)
  16202. }
  16203. } else if record_type == 2 {
  16204. goods, _ := service.GetBatchGoodInformationList(ids)
  16205. for _, item := range goods {
  16206. result := QueryResult{
  16207. ID: item.ID,
  16208. Name: item.GoodName,
  16209. Code: item.MedicalInsuranceNumber,
  16210. List_type_code: "301",
  16211. }
  16212. queryResult = append(queryResult, result)
  16213. }
  16214. } else if record_type == 3 {
  16215. projects, _ := service.GetBathchMyPorjecgList(ids)
  16216. for _, item := range projects {
  16217. result := QueryResult{
  16218. ID: item.ID,
  16219. Name: item.ProjectName,
  16220. Code: item.MedicalCode,
  16221. List_type_code: "201",
  16222. }
  16223. queryResult = append(queryResult, result)
  16224. }
  16225. }
  16226. adminUser := c.GetAdminUserInfo()
  16227. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16228. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16229. var user_name string
  16230. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16231. if role.ID == 0 {
  16232. user_name = "xxx"
  16233. } else {
  16234. user_name = role.UserName
  16235. }
  16236. baseParams := &models.BaseParams{
  16237. SecretKey: miConfig.SecretKey,
  16238. FixmedinsCode: miConfig.Code,
  16239. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  16240. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  16241. OrgName: miConfig.OrgName,
  16242. Doctor: user_name,
  16243. }
  16244. if config.IsOpen == 1 {
  16245. for _, item := range queryResult {
  16246. var result string
  16247. if record_type == 1 {
  16248. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  16249. } else if record_type == 2 {
  16250. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  16251. } else if record_type == 3 {
  16252. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  16253. }
  16254. var dat2 map[string]interface{}
  16255. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  16256. fmt.Println(dat2)
  16257. } else {
  16258. fmt.Println(err)
  16259. }
  16260. userJSONBytes, _ := json.Marshal(dat2)
  16261. var res ResultSix
  16262. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16263. utils.ErrorLog("解析失败:%v", err)
  16264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16265. return
  16266. }
  16267. if res.Infcode == 0 {
  16268. if record_type == 1 {
  16269. service.UpdateDrugByIdDetail(item.ID)
  16270. } else if record_type == 2 {
  16271. service.UpdateGoodInfoById(item.ID)
  16272. } else if record_type == 3 {
  16273. service.UpdateMyProjectById(item.ID)
  16274. }
  16275. c.ServeSuccessJSON(map[string]interface{}{
  16276. "failed_code": 0,
  16277. "msg": "撤销目录对照成功",
  16278. })
  16279. } else {
  16280. c.ServeSuccessJSON(map[string]interface{}{
  16281. "failed_code": -10,
  16282. "msg": res.ErrMsg,
  16283. })
  16284. }
  16285. }
  16286. }
  16287. }
  16288. func (c *HisApiController) GetPatientInfo() {
  16289. id_card_no := c.GetString("id_card_no")
  16290. admin_user_id, _ := c.GetInt64("admin_user_id")
  16291. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  16292. if patient.ID == 0 {
  16293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  16294. return
  16295. }
  16296. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16297. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16298. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  16299. if config.IsOpen == 1 {
  16300. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  16301. var dat map[string]interface{}
  16302. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16303. fmt.Println(dat)
  16304. } else {
  16305. fmt.Println(err)
  16306. }
  16307. userJSONBytes, _ := json.Marshal(dat)
  16308. var res ResultTwo
  16309. var res10265 ResultTwo10265
  16310. if miConfig.Code == "H15049901371" {
  16311. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  16312. utils.ErrorLog("解析失败:%v", err)
  16313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16314. return
  16315. }
  16316. res.ErrMsg = res10265.ErrMsg
  16317. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16318. res.Infcode = infocode
  16319. res.Output = res10265.Output
  16320. res.InfRefmsgid = res10265.InfRefmsgid
  16321. } else {
  16322. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16323. utils.ErrorLog("解析失败:%v", err)
  16324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16325. return
  16326. }
  16327. }
  16328. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16329. // utils.ErrorLog("解析失败:%v", err)
  16330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16331. // return
  16332. //}
  16333. for index, item := range res.Output.Iinfo {
  16334. if item.PsnInsuStas == "2" {
  16335. fmt.Println("--------")
  16336. res.Output.Iinfo[index].Insutype = "300"
  16337. res.Output.Iinfo[index].PsnInsuStas = "1"
  16338. }
  16339. }
  16340. fmt.Println(res.Output.Iinfo)
  16341. if res.Infcode != 0 {
  16342. c.ServeSuccessJSON(map[string]interface{}{
  16343. "failed_code": -10,
  16344. "msg": res.ErrMsg,
  16345. })
  16346. } else {
  16347. c.ServeSuccessJSON(map[string]interface{}{
  16348. "failed_code": 0,
  16349. "info": res,
  16350. })
  16351. }
  16352. }
  16353. }
  16354. func (c *HisApiController) PsnPutOnRecord() {
  16355. record_type, _ := c.GetInt64("type")
  16356. patient_id, _ := c.GetInt64("patient_id")
  16357. admin_user_id, _ := c.GetInt64("admin_user_id")
  16358. start_time := c.GetString("start_time")
  16359. end_time := c.GetString("end_time")
  16360. adminUser := c.GetAdminUserInfo()
  16361. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16362. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16363. var patients []*models.Patients
  16364. if record_type == 1 { //全部备案
  16365. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  16366. patients = append(patients, patient...)
  16367. } else { //单个备案
  16368. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  16369. patients = append(patients, patient)
  16370. }
  16371. var user_name string
  16372. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16373. if role.ID == 0 {
  16374. user_name = "xxx"
  16375. } else {
  16376. user_name = role.UserName
  16377. }
  16378. if config.IsOpen == 1 {
  16379. for _, item := range patients {
  16380. 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
  16381. resp, requestErr := http.Get(api)
  16382. if requestErr != nil {
  16383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16384. return
  16385. }
  16386. defer resp.Body.Close()
  16387. body, ioErr := ioutil.ReadAll(resp.Body)
  16388. if ioErr != nil {
  16389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16391. return
  16392. }
  16393. var respJSON map[string]interface{}
  16394. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16397. return
  16398. }
  16399. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16400. userJSONBytes, _ := json.Marshal(userJSON)
  16401. var res ResultTwo
  16402. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16403. utils.ErrorLog("解析失败:%v", err)
  16404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16405. return
  16406. }
  16407. if res.Infcode == 0 {
  16408. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  16409. var dat map[string]interface{}
  16410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16411. fmt.Println(dat)
  16412. } else {
  16413. fmt.Println(err)
  16414. }
  16415. userJSONBytes, _ := json.Marshal(dat)
  16416. var res2 ResultThirteen
  16417. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16418. utils.ErrorLog("解析失败:%v", err)
  16419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16420. return
  16421. }
  16422. if res2.Infcode == 0 {
  16423. psnResult := &models.GdybPsnRecord{
  16424. UserOrgId: adminUser.CurrentOrgId,
  16425. PatientId: item.ID,
  16426. PsnNo: res.Output.Baseinfo.PsnNo,
  16427. Ctime: time.Now().Unix(),
  16428. Mtime: time.Now().Unix(),
  16429. Status: 1,
  16430. IsCancel: 1,
  16431. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  16432. }
  16433. service.CreatePsnRecord(psnResult)
  16434. } else {
  16435. c.ServeSuccessJSON(map[string]interface{}{
  16436. "failed_code": -10,
  16437. "msg": res2.ErrMsg,
  16438. })
  16439. return
  16440. }
  16441. }
  16442. }
  16443. }
  16444. }
  16445. func (c *HisApiController) PsnUnPutOnRecord() {
  16446. id, _ := c.GetInt64("id")
  16447. //record_type, _ := c.GetInt64("type")
  16448. admin_user_id, _ := c.GetInt64("admin_user_id")
  16449. adminUser := c.GetAdminUserInfo()
  16450. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16451. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16452. var user_name string
  16453. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16454. if role.ID == 0 {
  16455. user_name = "xxx"
  16456. } else {
  16457. user_name = role.UserName
  16458. }
  16459. psn_record, _ := service.GetPsnRecordById(id)
  16460. if psn_record.ID == 0 {
  16461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  16462. return
  16463. }
  16464. if config.IsOpen == 1 {
  16465. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  16466. var dat map[string]interface{}
  16467. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16468. fmt.Println(dat)
  16469. } else {
  16470. fmt.Println(err)
  16471. }
  16472. userJSONBytes, _ := json.Marshal(dat)
  16473. var res ResultFourteen
  16474. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16475. utils.ErrorLog("解析失败:%v", err)
  16476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16477. return
  16478. }
  16479. if res.Infcode == 0 {
  16480. psn_record.IsCancel = 2
  16481. service.CreatePsnRecord(&psn_record)
  16482. } else {
  16483. c.ServeSuccessJSON(map[string]interface{}{
  16484. "failed_code": -10,
  16485. "msg": res.ErrMsg,
  16486. })
  16487. return
  16488. }
  16489. }
  16490. }
  16491. func (c *HisApiController) PsnPutNCDSOnRecord() {
  16492. patient_id, _ := c.GetInt64("patient_id")
  16493. insutype_two := c.GetString("insutype")
  16494. psn_no := c.GetString("psn_no")
  16495. doctor_id, _ := c.GetInt64("doctor_id")
  16496. sick_id, _ := c.GetInt64("sick_id")
  16497. department_id, _ := c.GetInt64("department_id")
  16498. start_time := c.GetString("start_time")
  16499. end_time := c.GetString("end_time")
  16500. check_time := c.GetString("check_time")
  16501. hospital_code := c.GetString("hospital_code")
  16502. hospital_name := c.GetString("hospital_name")
  16503. adminUser := c.GetAdminUserInfo()
  16504. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  16505. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16506. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16507. sick, _ := service.FindSickById(sick_id)
  16508. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  16509. if len(hospital_code) == 0 {
  16510. hospital_code = miConfig.Code
  16511. }
  16512. if len(hospital_name) == 0 {
  16513. hospital_name = miConfig.OrgName
  16514. }
  16515. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  16516. var res ResultTwo
  16517. var res10265 ResultTwo10265
  16518. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16519. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  16520. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  16521. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  16522. "&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
  16523. resp, requestErr := http.Get(api)
  16524. if requestErr != nil {
  16525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16526. return
  16527. }
  16528. body, ioErr := ioutil.ReadAll(resp.Body)
  16529. if ioErr != nil {
  16530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16532. return
  16533. }
  16534. var respJSON map[string]interface{}
  16535. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16538. return
  16539. }
  16540. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16541. result, _ := json.Marshal(respJSON)
  16542. fmt.Println("log")
  16543. fmt.Println(string(result))
  16544. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16545. utils.ErrorLog("解析失败:%v", err)
  16546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16547. return
  16548. }
  16549. res.ErrMsg = res10265.ErrMsg
  16550. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16551. res.Infcode = infocode
  16552. res.Output = res10265.Output
  16553. res.InfRefmsgid = res10265.InfRefmsgid
  16554. } else {
  16555. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  16556. if miConfig.Code == "H15049901371" {
  16557. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16558. utils.ErrorLog("解析失败:%v", err)
  16559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16560. return
  16561. }
  16562. res.ErrMsg = res10265.ErrMsg
  16563. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16564. res.Infcode = infocode
  16565. res.Output = res10265.Output
  16566. res.InfRefmsgid = res10265.InfRefmsgid
  16567. } else {
  16568. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16569. utils.ErrorLog("解析失败:%v", err)
  16570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16571. return
  16572. }
  16573. }
  16574. }
  16575. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16576. infoStr := string(Iinfos)
  16577. var rf []*ResultFive
  16578. json.Unmarshal([]byte(infoStr), &rf)
  16579. var insuplc_admdvs string
  16580. var insutype string
  16581. var is390 int = 0
  16582. var is310 int = 0
  16583. var insutypes []*ResultFive
  16584. for _, item := range rf {
  16585. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16586. insutypes = append(insutypes, item)
  16587. }
  16588. }
  16589. if len(insutypes) == 1 {
  16590. insutype = insutypes[0].Insutype
  16591. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16592. } else {
  16593. for _, i := range insutypes {
  16594. if i.Insutype == "390" {
  16595. is390 = 1
  16596. }
  16597. if i.Insutype == "310" {
  16598. is310 = 1
  16599. }
  16600. }
  16601. }
  16602. if is390 == 1 {
  16603. insutype = "390"
  16604. }
  16605. if is310 == 1 {
  16606. insutype = "310"
  16607. }
  16608. if len(insutypes) == 2 {
  16609. insutype = insutype_two
  16610. }
  16611. if len(insutypes) == 0 {
  16612. insutype = "310"
  16613. }
  16614. insutype = insutype_two
  16615. fmt.Println(insutype)
  16616. for _, item := range rf {
  16617. fmt.Println(item.Insutype)
  16618. fmt.Println(insutype)
  16619. if item.Insutype == insutype {
  16620. fmt.Println(item.Insutype)
  16621. fmt.Println(insutype)
  16622. insuplc_admdvs = item.InsuplcAdmdvs
  16623. }
  16624. }
  16625. fmt.Println(insuplc_admdvs)
  16626. var res2 ResultThirteen
  16627. var res10265_2 ResultThirteen10265
  16628. if config.IsOpen == 1 {
  16629. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16630. } else {
  16631. 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)
  16632. var dat map[string]interface{}
  16633. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16634. fmt.Println(dat)
  16635. } else {
  16636. fmt.Println(err)
  16637. }
  16638. userJSONBytes, _ := json.Marshal(dat)
  16639. if miConfig.Code == "H15049901371" {
  16640. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  16641. utils.ErrorLog("解析失败:%v", err)
  16642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16643. return
  16644. }
  16645. res2.ErrMsg = res10265_2.ErrMsg
  16646. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  16647. res2.Infcode = infocode
  16648. res2.Output = res10265_2.Output
  16649. res2.InfRefmsgid = res10265_2.InfRefmsgid
  16650. } else {
  16651. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16652. utils.ErrorLog("解析失败:%v", err)
  16653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16654. return
  16655. }
  16656. }
  16657. }
  16658. if res2.Infcode == 0 {
  16659. psnResult := &models.GdybPsnNcdsRecord{
  16660. UserOrgId: adminUser.CurrentOrgId,
  16661. PatientId: patient.ID,
  16662. PsnNo: psn_no,
  16663. DoctorId: doctor.AdminUserId,
  16664. DepartmentId: department_id,
  16665. SickType: sick_id,
  16666. Insutype: insutype,
  16667. Ctime: time.Now().Unix(),
  16668. Mtime: time.Now().Unix(),
  16669. Status: 1,
  16670. IsCancel: 1,
  16671. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  16672. }
  16673. service.CreatePsnNCDSRecord(psnResult)
  16674. c.ServeSuccessJSON(map[string]interface{}{
  16675. "failed_code": 0,
  16676. "msg": "备案成功",
  16677. "result": psnResult,
  16678. })
  16679. } else {
  16680. c.ServeSuccessJSON(map[string]interface{}{
  16681. "failed_code": -10,
  16682. "msg": res2.ErrMsg,
  16683. })
  16684. return
  16685. }
  16686. }
  16687. }
  16688. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  16689. id, _ := c.GetInt64("id")
  16690. admin_user_id, _ := c.GetInt64("admin_user_id")
  16691. adminUser := c.GetAdminUserInfo()
  16692. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16693. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16694. //config, _ := service.Ge(adminUser.CurrentOrgId)
  16695. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  16696. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16697. //var user_name string
  16698. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16699. //if role.ID == 0 {
  16700. // user_name = "xxx"
  16701. //} else {
  16702. // user_name = role.UserName
  16703. //}
  16704. psn_record, _ := service.GetPsnNCDSRecordById(id)
  16705. if psn_record.ID == 0 {
  16706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  16707. return
  16708. }
  16709. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  16710. var res ResultTwo
  16711. var res10265 ResultTwo10265
  16712. if miConfig.Code == "H15049901371" {
  16713. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16714. utils.ErrorLog("解析失败:%v", err)
  16715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16716. return
  16717. }
  16718. res.ErrMsg = res10265.ErrMsg
  16719. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16720. res.Infcode = infocode
  16721. res.Output = res10265.Output
  16722. res.InfRefmsgid = res10265.InfRefmsgid
  16723. } else {
  16724. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16725. utils.ErrorLog("解析失败:%v", err)
  16726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16727. return
  16728. }
  16729. }
  16730. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16731. infoStr := string(Iinfos)
  16732. var rf []*ResultFive
  16733. json.Unmarshal([]byte(infoStr), &rf)
  16734. var insuplc_admdvs string
  16735. var insutype string
  16736. var is390 int = 0
  16737. var is310 int = 0
  16738. var insutypes []*ResultFive
  16739. for _, item := range rf {
  16740. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16741. insutypes = append(insutypes, item)
  16742. }
  16743. }
  16744. if len(insutypes) == 1 {
  16745. insutype = insutypes[0].Insutype
  16746. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16747. } else {
  16748. for _, i := range insutypes {
  16749. if i.Insutype == "390" {
  16750. is390 = 1
  16751. }
  16752. if i.Insutype == "310" {
  16753. is310 = 1
  16754. }
  16755. }
  16756. }
  16757. if is390 == 1 {
  16758. insutype = "390"
  16759. }
  16760. if is310 == 1 {
  16761. insutype = "310"
  16762. }
  16763. if len(insutypes) == 0 {
  16764. insutype = "310"
  16765. }
  16766. insutype = psn_record.Insutype
  16767. for _, item := range rf {
  16768. if item.Insutype == insutype {
  16769. insuplc_admdvs = item.InsuplcAdmdvs
  16770. }
  16771. }
  16772. if config.IsOpen == 1 {
  16773. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  16774. var dat map[string]interface{}
  16775. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16776. fmt.Println(dat)
  16777. } else {
  16778. fmt.Println(err)
  16779. }
  16780. userJSONBytes, _ := json.Marshal(dat)
  16781. var res ResultFourteen
  16782. var res10265 ResultFourteen10265
  16783. if miConfig.Code == "H15049901371" {
  16784. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  16785. utils.ErrorLog("解析失败:%v", err)
  16786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16787. return
  16788. }
  16789. res.ErrMsg = res10265.ErrMsg
  16790. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16791. res.Infcode = infocode
  16792. res.Output = res10265.Output
  16793. res.InfRefmsgid = res10265.InfRefmsgid
  16794. } else {
  16795. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16796. utils.ErrorLog("解析失败:%v", err)
  16797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16798. return
  16799. }
  16800. }
  16801. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16802. // utils.ErrorLog("解析失败:%v", err)
  16803. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16804. // return
  16805. //}
  16806. if res.Infcode == 0 {
  16807. psn_record.IsCancel = 2
  16808. service.CreatePsnNCDSRecord(&psn_record)
  16809. c.ServeSuccessJSON(map[string]interface{}{
  16810. "failed_code": 0,
  16811. "msg": "撤销备案成功",
  16812. })
  16813. } else {
  16814. c.ServeSuccessJSON(map[string]interface{}{
  16815. "failed_code": -10,
  16816. "msg": res.ErrMsg,
  16817. })
  16818. return
  16819. }
  16820. }
  16821. }
  16822. func (c *HisApiController) TestTest() {
  16823. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  16824. fmt.Println(patient.Iinfo)
  16825. }
  16826. type CustomData struct {
  16827. MsgId string
  16828. PsnNo string
  16829. Info string
  16830. }
  16831. func (c *HisApiController) ReversalData() {
  16832. var customData []*CustomData
  16833. custom := &CustomData{
  16834. MsgId: "H44022900158202103301714472004",
  16835. PsnNo: "44020000001101329945",
  16836. Info: "2207",
  16837. }
  16838. customData = append(customData, custom)
  16839. custom1 := &CustomData{
  16840. MsgId: "H4402290015820210330172057803",
  16841. PsnNo: "44020000001101161813",
  16842. Info: "2207",
  16843. }
  16844. customData = append(customData, custom1)
  16845. custom2 := &CustomData{
  16846. MsgId: "H44022900158202103301705198813",
  16847. PsnNo: "44190000133097375417",
  16848. Info: "2207",
  16849. }
  16850. customData = append(customData, custom2)
  16851. custom3 := &CustomData{
  16852. MsgId: "H44022900158202103301715524756",
  16853. PsnNo: "44020000001100187221",
  16854. Info: "2207",
  16855. }
  16856. customData = append(customData, custom3)
  16857. custom4 := &CustomData{
  16858. MsgId: "H44022900158202103301730376224",
  16859. PsnNo: "44020000001101959155",
  16860. Info: "2207",
  16861. }
  16862. customData = append(customData, custom4)
  16863. custom5 := &CustomData{
  16864. MsgId: "H44022900158202103301748008725",
  16865. PsnNo: "44020000001104246641",
  16866. Info: "2207",
  16867. }
  16868. customData = append(customData, custom5)
  16869. custom6 := &CustomData{
  16870. MsgId: "H44022900158202103301718096755",
  16871. PsnNo: "44020000001102211860",
  16872. Info: "2207",
  16873. }
  16874. customData = append(customData, custom6)
  16875. custom7 := &CustomData{
  16876. MsgId: "H44022900158202103301736551640",
  16877. PsnNo: "44020000001102687718",
  16878. Info: "2207",
  16879. }
  16880. customData = append(customData, custom7)
  16881. custom8 := &CustomData{
  16882. MsgId: "H44022900158202103301743097676",
  16883. PsnNo: "44020000001102127785",
  16884. Info: "2207",
  16885. }
  16886. customData = append(customData, custom8)
  16887. custom9 := &CustomData{
  16888. MsgId: "H44022900158202103301712304203",
  16889. PsnNo: "44020000001101518097",
  16890. Info: "2207",
  16891. }
  16892. customData = append(customData, custom9)
  16893. custom10 := &CustomData{
  16894. MsgId: "H44022900158202103301738448785",
  16895. PsnNo: "44020000001100500813",
  16896. Info: "2207",
  16897. }
  16898. customData = append(customData, custom10)
  16899. custom11 := &CustomData{
  16900. MsgId: "H44022900158202103301732455843",
  16901. PsnNo: "44020000001102690557",
  16902. Info: "2207",
  16903. }
  16904. customData = append(customData, custom11)
  16905. custom12 := &CustomData{
  16906. MsgId: "H44022900158202103301745421708",
  16907. PsnNo: "44020000001102211928",
  16908. Info: "2207",
  16909. }
  16910. customData = append(customData, custom12)
  16911. custom1212 := &CustomData{
  16912. MsgId: "H440229001582021033017351627",
  16913. PsnNo: "44020000001102481733",
  16914. Info: "2207",
  16915. }
  16916. customData = append(customData, custom1212)
  16917. custom13 := &CustomData{
  16918. MsgId: "H44022900158202103301740327951",
  16919. PsnNo: "44020000001103174866",
  16920. Info: "2207",
  16921. }
  16922. customData = append(customData, custom13)
  16923. custom14 := &CustomData{
  16924. MsgId: "H4402290015820210330174922668",
  16925. PsnNo: "44020000001102927272",
  16926. Info: "2207",
  16927. }
  16928. customData = append(customData, custom14)
  16929. custom15 := &CustomData{
  16930. MsgId: "H44022900158202103301752362273",
  16931. PsnNo: "44020000001102942890",
  16932. Info: "2207",
  16933. }
  16934. customData = append(customData, custom15)
  16935. custom16 := &CustomData{
  16936. MsgId: "H44022900158202103301751082917",
  16937. PsnNo: "44020000001101662162",
  16938. Info: "2207",
  16939. }
  16940. customData = append(customData, custom16)
  16941. custom17 := &CustomData{
  16942. MsgId: "H44022900158202103301754147728",
  16943. PsnNo: "44020000000229014511",
  16944. Info: "2207",
  16945. }
  16946. customData = append(customData, custom17)
  16947. adminUser := c.GetAdminUserInfo()
  16948. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16949. for _, item := range customData {
  16950. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  16951. fmt.Println(result)
  16952. }
  16953. }
  16954. func (c *HisApiController) GetAllopatry() {
  16955. year := c.GetString("year")
  16956. month := c.GetString("month")
  16957. admin_user_id, _ := c.GetInt64("admin_user_id")
  16958. adminUser := c.GetAdminUserInfo()
  16959. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16960. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16961. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  16962. var dat map[string]interface{}
  16963. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16964. fmt.Println(dat)
  16965. } else {
  16966. fmt.Println(err)
  16967. }
  16968. userJSONBytes, _ := json.Marshal(dat)
  16969. var res models.Result9001
  16970. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16971. utils.ErrorLog("解析失败:%v", err)
  16972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16973. return
  16974. }
  16975. fmt.Println(res.Output.Signinoutb)
  16976. fmt.Println(res.Output.Signinoutb.SignNo)
  16977. fmt.Println(string(userJSONBytes))
  16978. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  16979. var dat3 map[string]interface{}
  16980. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  16981. fmt.Println(dat3)
  16982. } else {
  16983. fmt.Println(err)
  16984. }
  16985. userJSONBytes3, _ := json.Marshal(dat3)
  16986. var res3 models.Result3260
  16987. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  16988. utils.ErrorLog("解析失败:%v", err)
  16989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16990. return
  16991. }
  16992. var curpage int
  16993. var pagesize int = 100
  16994. var start int = 1
  16995. //var stop int
  16996. //pagecount := 10
  16997. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  16998. for curpage = 1; curpage <= pagecount; curpage++ {
  16999. if curpage == 1 {
  17000. start = 0
  17001. } else {
  17002. start = (curpage-1)*pagesize + 1
  17003. }
  17004. fmt.Println(start)
  17005. //stop = curpage * pagesize
  17006. //if stop > int(res3.Output.Totalrow) {
  17007. // stop =int(res3.Output.Totalrow)
  17008. //}
  17009. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  17010. var dat2 map[string]interface{}
  17011. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  17012. fmt.Println(dat)
  17013. } else {
  17014. fmt.Println(err)
  17015. }
  17016. userJSONBytes2, _ := json.Marshal(dat2)
  17017. var res2 models.Result3260
  17018. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  17019. utils.ErrorLog("解析失败:%v", err)
  17020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17021. return
  17022. }
  17023. if res2.Infcode == 0 {
  17024. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  17025. var dat2 map[string]interface{}
  17026. if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  17027. fmt.Println(dat)
  17028. } else {
  17029. fmt.Println(err)
  17030. }
  17031. //c.ServeSuccessJSON(map[string]interface{}{
  17032. // "list": res2.Output.Data,
  17033. //})
  17034. //continue
  17035. }
  17036. }
  17037. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  17038. //var dat2 map[string]interface{}
  17039. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  17040. // fmt.Println(dat)
  17041. //} else {
  17042. // fmt.Println(err)
  17043. //}
  17044. //userJSONBytes2, _ := json.Marshal(dat2)
  17045. //var res2 models.Result3260
  17046. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  17047. // utils.ErrorLog("解析失败:%v", err)
  17048. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17049. // return
  17050. //}
  17051. //if res2.Infcode == 0 {
  17052. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  17053. // var dat2 map[string]interface{}
  17054. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  17055. // fmt.Println(dat)
  17056. // } else {
  17057. // fmt.Println(err)
  17058. // }
  17059. // c.ServeSuccessJSON(map[string]interface{}{
  17060. // "list": res2.Output.Data,
  17061. // })
  17062. //}
  17063. }
  17064. func (c *HisApiController) ComfirmAllopatry() {
  17065. year := c.GetString("year")
  17066. month := c.GetString("month")
  17067. admin_user_id, _ := c.GetInt64("admin_user_id")
  17068. adminUser := c.GetAdminUserInfo()
  17069. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17070. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17071. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  17072. var dat map[string]interface{}
  17073. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17074. fmt.Println(dat)
  17075. } else {
  17076. fmt.Println(err)
  17077. }
  17078. userJSONBytes, _ := json.Marshal(dat)
  17079. var res models.Result9001
  17080. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17081. utils.ErrorLog("解析失败:%v", err)
  17082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17083. return
  17084. }
  17085. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  17086. var dat2 map[string]interface{}
  17087. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  17088. fmt.Println(dat)
  17089. } else {
  17090. fmt.Println(err)
  17091. }
  17092. userJSONBytes2, _ := json.Marshal(dat2)
  17093. var res2 models.Result3260
  17094. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  17095. utils.ErrorLog("解析失败:%v", err)
  17096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17097. return
  17098. }
  17099. //if res2.Infcode == 0 {
  17100. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  17101. // var dat map[string]interface{}
  17102. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17103. // fmt.Println(dat)
  17104. // } else {
  17105. // fmt.Println(err)
  17106. // }
  17107. // userJSONBytes, _ := json.Marshal(dat)
  17108. // var res3 models.Result3261
  17109. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  17110. // utils.ErrorLog("解析失败:%v", err)
  17111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17112. // return
  17113. // }
  17114. //
  17115. // if res3.Infcode == 0 {
  17116. // record := &models.HisYidiClearRecord{
  17117. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17118. // Ctime: time.Now().Unix(),
  17119. // Mtime: time.Now().Unix(),
  17120. // Status: 1,
  17121. // MsgId: msgId,
  17122. // }
  17123. // service.SaveClearRecord(record)
  17124. // c.ServeSuccessJSON(map[string]interface{}{
  17125. // "msg": "提取成功",
  17126. // })
  17127. // }
  17128. //}
  17129. }
  17130. func (c *HisApiController) RefundAllopatry() {
  17131. year := c.GetString("year")
  17132. month := c.GetString("month")
  17133. //id, _ := c.GetInt64("id")
  17134. admin_user_id, _ := c.GetInt64("admin_user_id")
  17135. adminUser := c.GetAdminUserInfo()
  17136. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17137. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17138. //record, _ := service.GetClearRecordById(id)
  17139. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  17140. var dat map[string]interface{}
  17141. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  17142. fmt.Println(dat)
  17143. } else {
  17144. fmt.Println(err)
  17145. }
  17146. userJSONBytes, _ := json.Marshal(dat)
  17147. var res models.Result9001
  17148. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17149. utils.ErrorLog("解析失败:%v", err)
  17150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17151. return
  17152. }
  17153. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  17154. var dat2 map[string]interface{}
  17155. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  17156. fmt.Println(dat)
  17157. } else {
  17158. fmt.Println(err)
  17159. }
  17160. userJSONBytes2, _ := json.Marshal(dat2)
  17161. var empty ResultFourteen
  17162. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  17163. utils.ErrorLog("解析失败:%v", err)
  17164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17165. return
  17166. }
  17167. if empty.Infcode == 0 {
  17168. c.ServeSuccessJSON(map[string]interface{}{
  17169. "msg": "撤销成功",
  17170. })
  17171. return
  17172. }
  17173. }
  17174. func (c *HisApiController) ReversalOtherData() {
  17175. var customData []*CustomData
  17176. custom := &CustomData{
  17177. MsgId: "H44022900158202103301714472004",
  17178. PsnNo: "44020000001101329945",
  17179. Info: "2208",
  17180. }
  17181. customData = append(customData, custom)
  17182. custom1 := &CustomData{
  17183. MsgId: "H4402290015820210330172057803",
  17184. PsnNo: "44020000001101161813",
  17185. Info: "2208",
  17186. }
  17187. customData = append(customData, custom1)
  17188. custom2 := &CustomData{
  17189. MsgId: "H44022900158202103301705198813",
  17190. PsnNo: "44190000133097375417",
  17191. Info: "2208",
  17192. }
  17193. customData = append(customData, custom2)
  17194. custom3 := &CustomData{
  17195. MsgId: "H44022900158202103301715524756",
  17196. PsnNo: "44020000001100187221",
  17197. Info: "2208",
  17198. }
  17199. customData = append(customData, custom3)
  17200. custom4 := &CustomData{
  17201. MsgId: "H44022900158202103301730376224",
  17202. PsnNo: "44020000001101959155",
  17203. Info: "2208",
  17204. }
  17205. customData = append(customData, custom4)
  17206. custom5 := &CustomData{
  17207. MsgId: "H44022900158202103301748008725",
  17208. PsnNo: "44020000001104246641",
  17209. Info: "2208",
  17210. }
  17211. customData = append(customData, custom5)
  17212. custom6 := &CustomData{
  17213. MsgId: "H44022900158202103301718096755",
  17214. PsnNo: "44020000001102211860",
  17215. Info: "2208",
  17216. }
  17217. customData = append(customData, custom6)
  17218. custom7 := &CustomData{
  17219. MsgId: "H44022900158202103301736551640",
  17220. PsnNo: "44020000001102687718",
  17221. Info: "2208",
  17222. }
  17223. customData = append(customData, custom7)
  17224. custom8 := &CustomData{
  17225. MsgId: "H44022900158202103301743097676",
  17226. PsnNo: "44020000001102127785",
  17227. Info: "2208",
  17228. }
  17229. customData = append(customData, custom8)
  17230. custom9 := &CustomData{
  17231. MsgId: "H44022900158202103301712304203",
  17232. PsnNo: "44020000001101518097",
  17233. Info: "2208",
  17234. }
  17235. customData = append(customData, custom9)
  17236. custom10 := &CustomData{
  17237. MsgId: "H44022900158202103301738448785",
  17238. PsnNo: "44020000001100500813",
  17239. Info: "2208",
  17240. }
  17241. customData = append(customData, custom10)
  17242. custom11 := &CustomData{
  17243. MsgId: "H44022900158202103301732455843",
  17244. PsnNo: "44020000001102690557",
  17245. Info: "2208",
  17246. }
  17247. customData = append(customData, custom11)
  17248. custom12 := &CustomData{
  17249. MsgId: "H44022900158202103301745421708",
  17250. PsnNo: "44020000001102211928",
  17251. Info: "2208",
  17252. }
  17253. customData = append(customData, custom12)
  17254. custom1212 := &CustomData{
  17255. MsgId: "H440229001582021033017351627",
  17256. PsnNo: "44020000001102481733",
  17257. Info: "2208",
  17258. }
  17259. customData = append(customData, custom1212)
  17260. custom13 := &CustomData{
  17261. MsgId: "H44022900158202103301740327951",
  17262. PsnNo: "44020000001103174866",
  17263. Info: "2208",
  17264. }
  17265. customData = append(customData, custom13)
  17266. custom14 := &CustomData{
  17267. MsgId: "H4402290015820210330174922668",
  17268. PsnNo: "44020000001102927272",
  17269. Info: "2208",
  17270. }
  17271. customData = append(customData, custom14)
  17272. custom15 := &CustomData{
  17273. MsgId: "H44022900158202103301752362273",
  17274. PsnNo: "44020000001102942890",
  17275. Info: "2208",
  17276. }
  17277. customData = append(customData, custom15)
  17278. custom16 := &CustomData{
  17279. MsgId: "H44022900158202103301751082917",
  17280. PsnNo: "44020000001101662162",
  17281. Info: "2208",
  17282. }
  17283. customData = append(customData, custom16)
  17284. custom17 := &CustomData{
  17285. MsgId: "H44022900158202103301754147728",
  17286. PsnNo: "44020000000229014511",
  17287. Info: "2208",
  17288. }
  17289. customData = append(customData, custom17)
  17290. adminUser := c.GetAdminUserInfo()
  17291. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17292. for _, item := range customData {
  17293. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  17294. fmt.Println(result)
  17295. }
  17296. }
  17297. func PathExists(path string) (bool, error) {
  17298. _, err := os.Stat(path)
  17299. if err == nil {
  17300. return true, nil
  17301. }
  17302. if os.IsNotExist(err) {
  17303. return false, nil
  17304. }
  17305. return false, err
  17306. }
  17307. // 创建文件夹
  17308. func Mkdir(dir string) {
  17309. // 创建文件夹
  17310. exist, err := PathExists(dir)
  17311. if err != nil {
  17312. fmt.Println(err.Error())
  17313. } else {
  17314. if exist {
  17315. fmt.Println(dir + "文件夹已存在!")
  17316. } else {
  17317. // 文件夹名称,权限
  17318. err := os.Mkdir(dir, os.ModePerm)
  17319. if err != nil {
  17320. fmt.Println(dir+"文件夹创建失败:", err.Error())
  17321. } else {
  17322. fmt.Println(dir + "文件夹创建成功!")
  17323. }
  17324. }
  17325. }
  17326. }
  17327. // 压缩文件
  17328. func Zip(srcFile string, destZip string) error {
  17329. zipfile, err := os.Create(destZip)
  17330. if err != nil {
  17331. return err
  17332. }
  17333. defer zipfile.Close()
  17334. archive := zip.NewWriter(zipfile)
  17335. defer archive.Close()
  17336. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  17337. if err != nil {
  17338. return err
  17339. }
  17340. header, err := zip.FileInfoHeader(info)
  17341. if err != nil {
  17342. return err
  17343. }
  17344. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  17345. // header.Name = path
  17346. if info.IsDir() {
  17347. header.Name += "/"
  17348. } else {
  17349. header.Method = zip.Deflate
  17350. }
  17351. writer, err := archive.CreateHeader(header)
  17352. if err != nil {
  17353. return err
  17354. }
  17355. if !info.IsDir() {
  17356. file, err := os.Open(path)
  17357. if err != nil {
  17358. return err
  17359. }
  17360. defer file.Close()
  17361. _, err = io.Copy(writer, file)
  17362. }
  17363. return err
  17364. })
  17365. return err
  17366. }
  17367. func ReadFile(filePath string) []byte {
  17368. f, err := os.Open(filePath)
  17369. if err != nil {
  17370. fmt.Println("read file fail", err)
  17371. return nil
  17372. }
  17373. defer f.Close()
  17374. fd, err := ioutil.ReadAll(f)
  17375. if err != nil {
  17376. fmt.Println("read to fd fail", err)
  17377. return nil
  17378. }
  17379. return fd
  17380. }
  17381. func saveLog(result string, request string, infno string, desc string) {
  17382. org_id, _ := beego.AppConfig.Int64("org_id")
  17383. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17384. dir := miConfig.OrgName + "日志"
  17385. utils.Mkdir(dir)
  17386. month := time.Unix(1557042972, 0).Format("1")
  17387. year := time.Now().Format("2006")
  17388. month = time.Now().Format("01")
  17389. day := time.Now().Format("02")
  17390. hour := time.Now().Format("15")
  17391. min := time.Now().Format("04")
  17392. sec := time.Now().Format("05")
  17393. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  17394. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  17395. file_name := file + ".txt"
  17396. file_path := miConfig.OrgName + "日志" + "/" + file_name
  17397. exist, _ := utils.PathExists(file_path)
  17398. if exist { //存在
  17399. fmt.Println("存在")
  17400. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  17401. if err != nil {
  17402. fmt.Println("read fail")
  17403. }
  17404. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  17405. n, _ := f.Seek(0, 2)
  17406. _, err = f.WriteAt([]byte(content), n)
  17407. } else { //不存在
  17408. fmt.Println("文件不存在,创建文件")
  17409. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  17410. defer f.Close()
  17411. if err != nil {
  17412. } else {
  17413. _, err = f.Write([]byte("记录日志"))
  17414. }
  17415. }
  17416. }
  17417. type Charset string
  17418. const (
  17419. UTF8 = Charset("UTF-8")
  17420. GB18030 = Charset("GB18030")
  17421. )
  17422. func ConvertToString(src string, srcCode string, tagCode string) string {
  17423. srcCoder := mahonia.NewDecoder(srcCode)
  17424. srcResult := srcCoder.ConvertString(src)
  17425. tagCoder := mahonia.NewDecoder(tagCode)
  17426. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  17427. result := string(cdata)
  17428. return result
  17429. }
  17430. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  17431. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  17432. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17433. var token string
  17434. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17435. var api string
  17436. if miConfig.MdtrtareaAdmvs == "320921" {
  17437. 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 +
  17438. "&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
  17439. fmt.Println(api)
  17440. } else {
  17441. 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 +
  17442. "&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
  17443. }
  17444. resp, requestErr := http.Get(api)
  17445. if requestErr != nil {
  17446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17447. return ""
  17448. }
  17449. body, ioErr := ioutil.ReadAll(resp.Body)
  17450. if ioErr != nil {
  17451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17453. return ""
  17454. }
  17455. var respJSON map[string]interface{}
  17456. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17459. return ""
  17460. }
  17461. var status string
  17462. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17463. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17464. var res ResultTwo //1101结果
  17465. var res10265 ResultTwo10265 //1101结果
  17466. if status == "0" { //读卡成功
  17467. var card_info string //卡信息
  17468. var busi_card_info string
  17469. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17470. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17471. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17472. fmt.Println(card_info)
  17473. fmt.Println(busi_card_info)
  17474. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17475. result, _ := json.Marshal(respJSON)
  17476. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17477. utils.ErrorLog("解析失败:%v", err)
  17478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17479. return ""
  17480. }
  17481. res.ErrMsg = res10265.ErrMsg
  17482. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17483. res.Infcode = infocode
  17484. res.Output = res10265.Output
  17485. res.InfRefmsgid = res10265.InfRefmsgid
  17486. if res.Infcode == 0 {
  17487. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17488. if err == gorm.ErrRecordNotFound {
  17489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17490. return ""
  17491. } else if err != nil {
  17492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17493. return ""
  17494. } else {
  17495. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17496. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17497. infoStr := string(Iinfos)
  17498. idetinfoStr := string(Idetinfos)
  17499. psn := &models.HisPsn{
  17500. PsnNo: res.Output.Baseinfo.PsnNo,
  17501. Age: res.Output.Baseinfo.Age,
  17502. PatientId: patient.ID,
  17503. Certno: res.Output.Baseinfo.Certno,
  17504. Brdy: res.Output.Baseinfo.Brdy,
  17505. Gend: res.Output.Baseinfo.Gend,
  17506. Naty: res.Output.Baseinfo.Naty,
  17507. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17508. PsnName: res.Output.Baseinfo.PsnName,
  17509. Idetinfo: idetinfoStr,
  17510. Insuinfo: infoStr,
  17511. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17512. CardInfo: card_info,
  17513. VerifyNumber: token,
  17514. }
  17515. service.CreateHisPsn(psn)
  17516. return token
  17517. }
  17518. }
  17519. } else {
  17520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17521. return ""
  17522. }
  17523. } else { //读卡失败
  17524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17525. return ""
  17526. }
  17527. return token
  17528. }
  17529. func DeleteExtraSpaceTwo(s string) string {
  17530. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  17531. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  17532. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  17533. reg, _ := regexp.Compile(regstr) //编译正则表达式
  17534. s2 := make([]byte, len(s1)) //定义字符数组切片
  17535. copy(s2, s1) //将字符串复制到切片
  17536. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  17537. for len(spc_index) > 0 { //找到适配项
  17538. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  17539. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  17540. }
  17541. return string(s2)
  17542. }
  17543. func Remove0000(s string) string {
  17544. str := make([]rune, 0, len(s))
  17545. for _, v := range []rune(s) {
  17546. if v == 0 {
  17547. continue
  17548. }
  17549. str = append(str, v)
  17550. }
  17551. return string(str)
  17552. }
  17553. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  17554. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  17555. readCard := DllDef.MustFindProc("EcQuery")
  17556. pCardInfo := make([]byte, 8192)
  17557. pBusiCardInfo := make([]byte, 8192)
  17558. data := make(map[string]interface{})
  17559. //pData := make(map[string]interface{})
  17560. inputData := make(map[string]interface{})
  17561. inputData["orgId"] = code
  17562. inputData["businessType"] = "01101"
  17563. inputData["operatorId"] = operator_id
  17564. inputData["operatorName"] = operator_name
  17565. inputData["officeId"] = "001"
  17566. inputData["officeName"] = "血透室"
  17567. //
  17568. data["data"] = inputData
  17569. data["transType"] = "ec.query"
  17570. data["orgId"] = code
  17571. bytesData, _ := json.Marshal(data)
  17572. pCardInfo = bytesData
  17573. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17574. fmt.Println(ret2)
  17575. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  17576. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17577. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  17578. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17579. if ret2 != 0 {
  17580. return "", ""
  17581. }
  17582. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  17583. }
  17584. func DeleteExtraSpace(s string) string {
  17585. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  17586. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  17587. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  17588. reg, _ := regexp.Compile(regstr) //编译正则表达式
  17589. s2 := make([]byte, len(s1)) //定义字符数组切片
  17590. copy(s2, s1) //将字符串复制到切片
  17591. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  17592. for len(spc_index) > 0 { //找到适配项
  17593. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  17594. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  17595. }
  17596. return string(s2)
  17597. }
  17598. // 对账
  17599. func (c *HisApiController) Post3202() {
  17600. start_time := c.GetString("start_time")
  17601. end_time := c.GetString("end_time")
  17602. //insutype := c.GetString("insutype")
  17603. clr_type := c.GetString("clr_type")
  17604. clr_org := c.GetString("clr_optins")
  17605. admin_user_id, _ := c.GetInt64("admin_user_id")
  17606. adminUser := c.GetAdminUserInfo()
  17607. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17608. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17609. if len(clr_org) == 0 {
  17610. clr_org = miConfig.MdtrtareaAdmvs
  17611. }
  17612. timeLayout := "2006-01-02"
  17613. loc, _ := time.LoadLocation("Local")
  17614. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  17615. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  17616. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  17617. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  17618. //fixmedins_setl_cnt := int64(len(orders))
  17619. var medfee_sumamt float64
  17620. var acct_pay float64
  17621. var fund_pay_sumamt float64
  17622. for _, item := range orders {
  17623. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  17624. acct_pay = acct_pay + item.AcctPay
  17625. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  17626. }
  17627. //var medfee_sumamt_two float64
  17628. //var acct_pay_two float64
  17629. //var fund_pay_sumamt_two float64
  17630. //for _, item := range orders_two {
  17631. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  17632. // acct_pay_two = acct_pay_two + item.AcctPay
  17633. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  17634. //}
  17635. //var user_name string
  17636. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17637. //if role.ID == 0 {
  17638. // user_name = "xxx"
  17639. //} else {
  17640. // user_name = role.UserName
  17641. //}
  17642. var res ResultSix
  17643. if config.IsOpen == 1 {
  17644. var bps []*models.BusinessParamsTwo
  17645. var bp models.BusinessParamsTwo
  17646. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  17647. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  17648. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  17649. bp.MedfeeSumamt = medfee_sumamt_str
  17650. bp.AcctPay = acct_pay_str
  17651. bp.FundPaySumamt = fund_pay_sumamt_str
  17652. bp.Insutype = "390"
  17653. bp.StmtBegndate = start_time
  17654. bp.ClrType = clr_type
  17655. bp.SetlOptins = clr_org
  17656. bp.StmtEnddate = end_time
  17657. bps = append(bps, &bp)
  17658. data := make(map[string]interface{})
  17659. data["bps"] = bps
  17660. data["org_name"] = miConfig.OrgName
  17661. data["doctor"] = role.UserName
  17662. data["fixmedins_code"] = miConfig.Code
  17663. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  17664. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17665. if miConfig.MdtrtareaAdmvs == "421300" {
  17666. client := &http.Client{}
  17667. bytesData, _ := json.Marshal(data)
  17668. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  17669. resp, _ := client.Do(req)
  17670. defer resp.Body.Close()
  17671. body, ioErr := ioutil.ReadAll(resp.Body)
  17672. if ioErr != nil {
  17673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17675. return
  17676. }
  17677. var respJSON map[string]interface{}
  17678. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17681. return
  17682. }
  17683. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17684. userJSONBytes, _ := json.Marshal(respJSON)
  17685. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17686. utils.ErrorLog("解析失败:%v", err)
  17687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17688. return
  17689. }
  17690. }
  17691. if res.Infcode == 0 {
  17692. c.ServeSuccessJSON(map[string]interface{}{
  17693. "msg": "发起成功",
  17694. })
  17695. } else {
  17696. c.ServeSuccessJSON(map[string]interface{}{
  17697. "code": -10,
  17698. "msg": res.ErrMsg,
  17699. })
  17700. }
  17701. }
  17702. }
  17703. func (c *HisApiController) Post3501() {
  17704. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17705. data := make(map[string]interface{})
  17706. var struct3501s []models.Struct3501
  17707. var struct3501 models.Struct3501
  17708. struct3501.OrgName = miConfig.OrgName
  17709. struct3501.AccessKey = miConfig.AccessKey
  17710. struct3501.RequestUrl = miConfig.Url
  17711. struct3501.SecretKey = miConfig.SecretKey
  17712. struct3501.ManuDate = "2022-08-17"
  17713. struct3501.FixmedinsBchno = ""
  17714. struct3501.ManuLotnum = ""
  17715. struct3501.RxFlag = "0"
  17716. struct3501.ExpyEnd = "2022-08-17"
  17717. struct3501.Invdate = "2022-08-17"
  17718. struct3501.InvCnt = "20.25"
  17719. struct3501.Memo = ""
  17720. struct3501.MedListCodg = "XB01ABD056B002020200517"
  17721. struct3501.FixmedinsHilistId = miConfig.Code
  17722. struct3501.FixmedinsHilistName = miConfig.OrgName
  17723. struct3501s = append(struct3501s, struct3501)
  17724. data["struct_3501s"] = struct3501s
  17725. client := &http.Client{}
  17726. bytesData, _ := json.Marshal(data)
  17727. var req *http.Request
  17728. if miConfig.MdtrtareaAdmvs == "320921" {
  17729. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17730. } else {
  17731. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17732. }
  17733. resp, _ := client.Do(req)
  17734. defer resp.Body.Close()
  17735. body, ioErr := ioutil.ReadAll(resp.Body)
  17736. if ioErr != nil {
  17737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17739. return
  17740. }
  17741. var respJSON map[string]interface{}
  17742. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17745. return
  17746. }
  17747. var res ResultSix
  17748. var resSix10265 ResultSix10265 //1101结果
  17749. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17750. result, _ := json.Marshal(respJSON)
  17751. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17752. utils.ErrorLog("解析失败:%v", err)
  17753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17754. return
  17755. }
  17756. res.InfRefmsgid = resSix10265.InfRefmsgid
  17757. res.Output = resSix10265.Output
  17758. res.ErrMsg = resSix10265.ErrMsg
  17759. res.Cainfo = resSix10265.Cainfo
  17760. res.WarnMsg = resSix10265.WarnMsg
  17761. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17762. res.Infcode = infocode
  17763. if infocode == 0 {
  17764. c.ServeSuccessJSON(map[string]interface{}{
  17765. "msg": "上传成功",
  17766. })
  17767. return
  17768. } else {
  17769. c.ServeSuccessJSON(map[string]interface{}{
  17770. "failed_code": -10,
  17771. "msg": res.ErrMsg,
  17772. })
  17773. return
  17774. }
  17775. }
  17776. func (c *HisApiController) Post3502() {
  17777. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17778. data := make(map[string]interface{})
  17779. var struct3502s []models.Struct3502
  17780. var struct3502 models.Struct3502
  17781. struct3502.OrgName = miConfig.OrgName
  17782. struct3502.AccessKey = miConfig.AccessKey
  17783. struct3502.RequestUrl = miConfig.Url
  17784. struct3502.SecretKey = miConfig.SecretKey
  17785. struct3502.ManuDate = "2022-08-15"
  17786. struct3502.FixmedinsBchno = ""
  17787. struct3502.ManuLotnum = ""
  17788. struct3502.RxFlag = "0"
  17789. struct3502.ExpyEnd = "2022-08-15"
  17790. struct3502.Invdate = "2022-08-15"
  17791. struct3502.InvCnt = "20.25"
  17792. struct3502.Memo = ""
  17793. struct3502.MedListCodg = "XB01ABD056B002020200517"
  17794. struct3502.FixmedinsHilistId = miConfig.Code
  17795. struct3502.FixmedinsHilistName = miConfig.OrgName
  17796. struct3502s = append(struct3502s, struct3502)
  17797. data["struct_3502s"] = struct3502s
  17798. client := &http.Client{}
  17799. bytesData, _ := json.Marshal(data)
  17800. var req *http.Request
  17801. if miConfig.MdtrtareaAdmvs == "320921" {
  17802. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17803. } else {
  17804. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17805. }
  17806. resp, _ := client.Do(req)
  17807. defer resp.Body.Close()
  17808. body, ioErr := ioutil.ReadAll(resp.Body)
  17809. if ioErr != nil {
  17810. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17812. return
  17813. }
  17814. var respJSON map[string]interface{}
  17815. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17816. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17818. return
  17819. }
  17820. var res ResultSix
  17821. var resSix10265 ResultSix10265 //1101结果
  17822. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17823. result, _ := json.Marshal(respJSON)
  17824. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17825. utils.ErrorLog("解析失败:%v", err)
  17826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17827. return
  17828. }
  17829. res.InfRefmsgid = resSix10265.InfRefmsgid
  17830. res.Output = resSix10265.Output
  17831. res.ErrMsg = resSix10265.ErrMsg
  17832. res.Cainfo = resSix10265.Cainfo
  17833. res.WarnMsg = resSix10265.WarnMsg
  17834. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17835. res.Infcode = infocode
  17836. if infocode == 0 {
  17837. c.ServeSuccessJSON(map[string]interface{}{
  17838. "msg": "上传成功",
  17839. })
  17840. return
  17841. } else {
  17842. c.ServeSuccessJSON(map[string]interface{}{
  17843. "failed_code": -10,
  17844. "msg": res.ErrMsg,
  17845. })
  17846. return
  17847. }
  17848. }
  17849. func (c *HisApiController) Post3503() {
  17850. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17851. data := make(map[string]interface{})
  17852. var struct3501s []models.Struct3501
  17853. var struct3501 models.Struct3501
  17854. struct3501.OrgName = miConfig.OrgName
  17855. struct3501.AccessKey = miConfig.AccessKey
  17856. struct3501.RequestUrl = miConfig.Url
  17857. struct3501.SecretKey = miConfig.SecretKey
  17858. struct3501.ManuDate = "2022-08-15"
  17859. struct3501.FixmedinsBchno = ""
  17860. struct3501.ManuLotnum = ""
  17861. struct3501.RxFlag = "0"
  17862. struct3501.ExpyEnd = "2022-08-15"
  17863. struct3501.Invdate = "2022-08-15"
  17864. struct3501.InvCnt = "20.25"
  17865. struct3501.Memo = ""
  17866. struct3501.MedListCodg = "XB01ABD056B002020200517"
  17867. struct3501.FixmedinsHilistId = miConfig.Code
  17868. struct3501.FixmedinsHilistName = miConfig.OrgName
  17869. struct3501s = append(struct3501s, struct3501)
  17870. data["struct_3501s"] = struct3501s
  17871. client := &http.Client{}
  17872. bytesData, _ := json.Marshal(data)
  17873. var req *http.Request
  17874. if miConfig.MdtrtareaAdmvs == "320921" {
  17875. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17876. } else {
  17877. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17878. }
  17879. resp, _ := client.Do(req)
  17880. defer resp.Body.Close()
  17881. body, ioErr := ioutil.ReadAll(resp.Body)
  17882. if ioErr != nil {
  17883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17885. return
  17886. }
  17887. var respJSON map[string]interface{}
  17888. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17891. return
  17892. }
  17893. var res ResultSix
  17894. var resSix10265 ResultSix10265 //1101结果
  17895. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17896. result, _ := json.Marshal(respJSON)
  17897. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17898. utils.ErrorLog("解析失败:%v", err)
  17899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17900. return
  17901. }
  17902. res.InfRefmsgid = resSix10265.InfRefmsgid
  17903. res.Output = resSix10265.Output
  17904. res.ErrMsg = resSix10265.ErrMsg
  17905. res.Cainfo = resSix10265.Cainfo
  17906. res.WarnMsg = resSix10265.WarnMsg
  17907. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17908. res.Infcode = infocode
  17909. if infocode == 0 {
  17910. c.ServeSuccessJSON(map[string]interface{}{
  17911. "msg": "上传成功",
  17912. })
  17913. return
  17914. } else {
  17915. c.ServeSuccessJSON(map[string]interface{}{
  17916. "failed_code": -10,
  17917. "msg": res.ErrMsg,
  17918. })
  17919. return
  17920. }
  17921. }
  17922. func (c *HisApiController) Post3504() {
  17923. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17924. data := make(map[string]interface{})
  17925. var struct3501s []models.Struct3501
  17926. var struct3501 models.Struct3501
  17927. struct3501.OrgName = miConfig.OrgName
  17928. struct3501.AccessKey = miConfig.AccessKey
  17929. struct3501.RequestUrl = miConfig.Url
  17930. struct3501.SecretKey = miConfig.SecretKey
  17931. struct3501.ManuDate = "2022-08-15"
  17932. struct3501.FixmedinsBchno = ""
  17933. struct3501.ManuLotnum = ""
  17934. struct3501.RxFlag = "0"
  17935. struct3501.ExpyEnd = "2022-08-15"
  17936. struct3501.Invdate = "2022-08-15"
  17937. struct3501.InvCnt = "20.25"
  17938. struct3501.Memo = ""
  17939. struct3501.MedListCodg = "XB01ABD056B002020200517"
  17940. struct3501.FixmedinsHilistId = miConfig.Code
  17941. struct3501.FixmedinsHilistName = miConfig.OrgName
  17942. struct3501s = append(struct3501s, struct3501)
  17943. data["struct_3501s"] = struct3501s
  17944. client := &http.Client{}
  17945. bytesData, _ := json.Marshal(data)
  17946. var req *http.Request
  17947. if miConfig.MdtrtareaAdmvs == "320921" {
  17948. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17949. } else {
  17950. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17951. }
  17952. resp, _ := client.Do(req)
  17953. defer resp.Body.Close()
  17954. body, ioErr := ioutil.ReadAll(resp.Body)
  17955. if ioErr != nil {
  17956. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17958. return
  17959. }
  17960. var respJSON map[string]interface{}
  17961. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17964. return
  17965. }
  17966. var res ResultSix
  17967. var resSix10265 ResultSix10265 //1101结果
  17968. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17969. result, _ := json.Marshal(respJSON)
  17970. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17971. utils.ErrorLog("解析失败:%v", err)
  17972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17973. return
  17974. }
  17975. res.InfRefmsgid = resSix10265.InfRefmsgid
  17976. res.Output = resSix10265.Output
  17977. res.ErrMsg = resSix10265.ErrMsg
  17978. res.Cainfo = resSix10265.Cainfo
  17979. res.WarnMsg = resSix10265.WarnMsg
  17980. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17981. res.Infcode = infocode
  17982. if infocode == 0 {
  17983. c.ServeSuccessJSON(map[string]interface{}{
  17984. "msg": "上传成功",
  17985. })
  17986. return
  17987. } else {
  17988. c.ServeSuccessJSON(map[string]interface{}{
  17989. "failed_code": -10,
  17990. "msg": res.ErrMsg,
  17991. })
  17992. return
  17993. }
  17994. }
  17995. func (c *HisApiController) Post3505() {
  17996. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17997. data := make(map[string]interface{})
  17998. var struct3501s []models.Struct3501
  17999. var struct3501 models.Struct3501
  18000. struct3501.OrgName = miConfig.OrgName
  18001. struct3501.AccessKey = miConfig.AccessKey
  18002. struct3501.RequestUrl = miConfig.Url
  18003. struct3501.SecretKey = miConfig.SecretKey
  18004. struct3501.ManuDate = "2022-08-15"
  18005. struct3501.FixmedinsBchno = ""
  18006. struct3501.ManuLotnum = ""
  18007. struct3501.RxFlag = "0"
  18008. struct3501.ExpyEnd = "2022-08-15"
  18009. struct3501.Invdate = "2022-08-15"
  18010. struct3501.InvCnt = "20.25"
  18011. struct3501.Memo = ""
  18012. struct3501.MedListCodg = "XB01ABD056B002020200517"
  18013. struct3501.FixmedinsHilistId = miConfig.Code
  18014. struct3501.FixmedinsHilistName = miConfig.OrgName
  18015. struct3501s = append(struct3501s, struct3501)
  18016. data["struct_3501s"] = struct3501s
  18017. client := &http.Client{}
  18018. bytesData, _ := json.Marshal(data)
  18019. var req *http.Request
  18020. if miConfig.MdtrtareaAdmvs == "320921" {
  18021. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  18022. } else {
  18023. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  18024. }
  18025. resp, _ := client.Do(req)
  18026. defer resp.Body.Close()
  18027. body, ioErr := ioutil.ReadAll(resp.Body)
  18028. if ioErr != nil {
  18029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18031. return
  18032. }
  18033. var respJSON map[string]interface{}
  18034. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18037. return
  18038. }
  18039. var res ResultSix
  18040. var resSix10265 ResultSix10265 //1101结果
  18041. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18042. result, _ := json.Marshal(respJSON)
  18043. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  18044. utils.ErrorLog("解析失败:%v", err)
  18045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18046. return
  18047. }
  18048. res.InfRefmsgid = resSix10265.InfRefmsgid
  18049. res.Output = resSix10265.Output
  18050. res.ErrMsg = resSix10265.ErrMsg
  18051. res.Cainfo = resSix10265.Cainfo
  18052. res.WarnMsg = resSix10265.WarnMsg
  18053. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  18054. res.Infcode = infocode
  18055. if infocode == 0 {
  18056. c.ServeSuccessJSON(map[string]interface{}{
  18057. "msg": "上传成功",
  18058. })
  18059. return
  18060. } else {
  18061. c.ServeSuccessJSON(map[string]interface{}{
  18062. "failed_code": -10,
  18063. "msg": res.ErrMsg,
  18064. })
  18065. return
  18066. }
  18067. }
  18068. func (c *HisApiController) Post3506() {
  18069. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18070. data := make(map[string]interface{})
  18071. var struct3501s []models.Struct3501
  18072. var struct3501 models.Struct3501
  18073. struct3501.OrgName = miConfig.OrgName
  18074. struct3501.AccessKey = miConfig.AccessKey
  18075. struct3501.RequestUrl = miConfig.Url
  18076. struct3501.SecretKey = miConfig.SecretKey
  18077. struct3501.ManuDate = "2022-08-15"
  18078. struct3501.FixmedinsBchno = ""
  18079. struct3501.ManuLotnum = ""
  18080. struct3501.RxFlag = "0"
  18081. struct3501.ExpyEnd = "2022-08-15"
  18082. struct3501.Invdate = "2022-08-15"
  18083. struct3501.InvCnt = "20.25"
  18084. struct3501.Memo = ""
  18085. struct3501.MedListCodg = "XB01ABD056B002020200517"
  18086. struct3501.FixmedinsHilistId = miConfig.Code
  18087. struct3501.FixmedinsHilistName = miConfig.OrgName
  18088. struct3501s = append(struct3501s, struct3501)
  18089. data["struct_3501s"] = struct3501s
  18090. client := &http.Client{}
  18091. bytesData, _ := json.Marshal(data)
  18092. var req *http.Request
  18093. if miConfig.MdtrtareaAdmvs == "320921" {
  18094. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  18095. } else {
  18096. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  18097. }
  18098. resp, _ := client.Do(req)
  18099. defer resp.Body.Close()
  18100. body, ioErr := ioutil.ReadAll(resp.Body)
  18101. if ioErr != nil {
  18102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18104. return
  18105. }
  18106. var respJSON map[string]interface{}
  18107. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18110. return
  18111. }
  18112. var res ResultSix
  18113. var resSix10265 ResultSix10265 //1101结果
  18114. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18115. result, _ := json.Marshal(respJSON)
  18116. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  18117. utils.ErrorLog("解析失败:%v", err)
  18118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18119. return
  18120. }
  18121. res.InfRefmsgid = resSix10265.InfRefmsgid
  18122. res.Output = resSix10265.Output
  18123. res.ErrMsg = resSix10265.ErrMsg
  18124. res.Cainfo = resSix10265.Cainfo
  18125. res.WarnMsg = resSix10265.WarnMsg
  18126. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  18127. res.Infcode = infocode
  18128. if infocode == 0 {
  18129. c.ServeSuccessJSON(map[string]interface{}{
  18130. "msg": "上传成功",
  18131. })
  18132. return
  18133. } else {
  18134. c.ServeSuccessJSON(map[string]interface{}{
  18135. "failed_code": -10,
  18136. "msg": res.ErrMsg,
  18137. })
  18138. return
  18139. }
  18140. }
  18141. func (c *HisApiController) Post3507() {
  18142. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18143. data := make(map[string]interface{})
  18144. var struct3501s []models.Struct3501
  18145. var struct3501 models.Struct3501
  18146. struct3501.OrgName = miConfig.OrgName
  18147. struct3501.AccessKey = miConfig.AccessKey
  18148. struct3501.RequestUrl = miConfig.Url
  18149. struct3501.SecretKey = miConfig.SecretKey
  18150. struct3501.ManuDate = "2022-08-15"
  18151. struct3501.FixmedinsBchno = ""
  18152. struct3501.ManuLotnum = ""
  18153. struct3501.RxFlag = "0"
  18154. struct3501.ExpyEnd = "2022-08-15"
  18155. struct3501.Invdate = "2022-08-15"
  18156. struct3501.InvCnt = "20.25"
  18157. struct3501.Memo = ""
  18158. struct3501.MedListCodg = "XB01ABD056B002020200517"
  18159. struct3501.FixmedinsHilistId = miConfig.Code
  18160. struct3501.FixmedinsHilistName = miConfig.OrgName
  18161. struct3501s = append(struct3501s, struct3501)
  18162. data["struct_3501s"] = struct3501s
  18163. client := &http.Client{}
  18164. bytesData, _ := json.Marshal(data)
  18165. var req *http.Request
  18166. if miConfig.MdtrtareaAdmvs == "320921" {
  18167. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  18168. } else {
  18169. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  18170. }
  18171. resp, _ := client.Do(req)
  18172. defer resp.Body.Close()
  18173. body, ioErr := ioutil.ReadAll(resp.Body)
  18174. if ioErr != nil {
  18175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18177. return
  18178. }
  18179. var respJSON map[string]interface{}
  18180. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18183. return
  18184. }
  18185. var res ResultSix
  18186. var resSix10265 ResultSix10265 //1101结果
  18187. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18188. result, _ := json.Marshal(respJSON)
  18189. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  18190. utils.ErrorLog("解析失败:%v", err)
  18191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18192. return
  18193. }
  18194. res.InfRefmsgid = resSix10265.InfRefmsgid
  18195. res.Output = resSix10265.Output
  18196. res.ErrMsg = resSix10265.ErrMsg
  18197. res.Cainfo = resSix10265.Cainfo
  18198. res.WarnMsg = resSix10265.WarnMsg
  18199. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  18200. res.Infcode = infocode
  18201. if infocode == 0 {
  18202. c.ServeSuccessJSON(map[string]interface{}{
  18203. "msg": "上传成功",
  18204. })
  18205. return
  18206. } else {
  18207. c.ServeSuccessJSON(map[string]interface{}{
  18208. "failed_code": -10,
  18209. "msg": res.ErrMsg,
  18210. })
  18211. return
  18212. }
  18213. }
  18214. func GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  18215. // WebSocket服务器地址
  18216. serverURL := "ws://127.0.0.1:8899"
  18217. // 解析WebSocket服务器地址
  18218. u, err := url.Parse(serverURL)
  18219. if err != nil {
  18220. }
  18221. // 建立WebSocket连接
  18222. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  18223. if err != nil {
  18224. }
  18225. defer conn.Close()
  18226. input2 := make(map[string]interface{})
  18227. input := make(map[string]interface{})
  18228. inputData := make(map[string]interface{})
  18229. inputData["orgId"] = code
  18230. inputData["businessType"] = "01101"
  18231. inputData["operatorId"] = operator_id
  18232. inputData["operatorName"] = operator_name
  18233. inputData["officeId"] = "001"
  18234. inputData["officeName"] = "血透室"
  18235. inputData["deviceType"] = ""
  18236. input["data"] = inputData
  18237. input["orgId"] = code
  18238. input["transType"] = "ec.query"
  18239. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  18240. input2["indata"] = input
  18241. bytesData, _ := json.Marshal(input2)
  18242. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  18243. if err != nil {
  18244. fmt.Println(err)
  18245. }
  18246. // 接收消息
  18247. _, receivedMessage, err := conn.ReadMessage()
  18248. if err != nil {
  18249. fmt.Println(err)
  18250. }
  18251. return "", string(receivedMessage)
  18252. }
  18253. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  18254. // WebSocket服务器地址
  18255. serverURL := "ws://127.0.0.1:8899"
  18256. // 解析WebSocket服务器地址
  18257. u, err := url.Parse(serverURL)
  18258. if err != nil {
  18259. }
  18260. // 建立WebSocket连接
  18261. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  18262. if err != nil {
  18263. }
  18264. defer conn.Close()
  18265. input2 := make(map[string]interface{})
  18266. input := make(map[string]interface{})
  18267. inputData := make(map[string]interface{})
  18268. inputData["orgId"] = code
  18269. inputData["businessType"] = "01301"
  18270. inputData["operatorId"] = operator_id
  18271. inputData["operatorName"] = operator_name
  18272. inputData["officeId"] = "001"
  18273. inputData["officeName"] = "血透室"
  18274. inputData["deviceType"] = ""
  18275. input["data"] = inputData
  18276. input["orgId"] = code
  18277. input["transType"] = "ec.query"
  18278. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  18279. input2["indata"] = input
  18280. bytesData, _ := json.Marshal(input2)
  18281. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  18282. if err != nil {
  18283. fmt.Println(err)
  18284. }
  18285. // 接收消息
  18286. _, receivedMessage, err := conn.ReadMessage()
  18287. if err != nil {
  18288. fmt.Println(err)
  18289. }
  18290. return "", string(receivedMessage)
  18291. }