his_api_controller.go 590KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  79. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  80. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  81. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  82. //beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  83. //beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  84. //beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  85. //beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  86. //beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  87. //beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  88. //beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  89. //
  90. }
  91. func (c *HisApiController) Get2505() {
  92. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  93. 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")
  94. }
  95. //func (c *HisApiController) Get4201A(){
  96. // order_id, _ := c.GetInt64("order_id")
  97. // admin_user_id, _ := c.GetInt64("admin_user_id")
  98. // order, _ := service.GetHisOrderByIDTwo(order_id)
  99. // his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  100. // order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  101. // order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  102. // order_info = append(order_info, order_info_two...)
  103. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  104. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  105. //
  106. // department,_ := service.GetDepartMentDetail(his.Departments)
  107. //
  108. //
  109. //
  110. //
  111. // if order.ID == 0 {
  112. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  113. // return
  114. // }
  115. // var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  116. // for _,items := range order_info{
  117. // var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  118. // fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  119. // fsiOPFLD.MedType = "14"
  120. // fsiOPFLD.BkkpSn = items.OrderNumber
  121. // fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime,0).Format("2006-01-02 15:04:05")
  122. // fsiOPFLD.FixmedinsCode = miConfig.Code
  123. // fsiOPFLD.FixmedinsName = miConfig.OrgName
  124. // fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  125. // fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  126. // fsiOPFLD.MedChrgitmType = "09"
  127. // fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.AdviceName
  128. // fsiOPFLD.BilgDeptCodg = department.Number
  129. // fsiOPFLD.BilgDeptName = department.Name
  130. //
  131. //
  132. //
  133. //
  134. //
  135. //
  136. // }
  137. //
  138. //
  139. //
  140. //
  141. //
  142. //
  143. //}
  144. //func (c *HisApiController) Get4202(){
  145. // order_id, _ := c.GetInt64("order_id")
  146. // admin_user_id, _ := c.GetInt64("admin_user_id")
  147. // order, _ := service.GetHisOrderByIDTwo(order_id)
  148. // his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  149. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  150. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  151. //
  152. // if order.ID == 0 {
  153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  154. // return
  155. // }
  156. //
  157. // var struct4202 models.Struct4202
  158. // struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  159. // struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  160. // struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  161. // struct4202.OwnPayPatnMdtrtD.PsnCertType ="01"
  162. // struct4202.OwnPayPatnMdtrtD.Certno =his.IdCardNo
  163. // struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  164. // struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  165. // struct4202.OwnPayPatnMdtrtD.MedType = "14"
  166. // struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  167. // struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f",order.MedfeeSumamt)
  168. //
  169. //
  170. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  171. // var config []*models.HisXtDiagnoseConfig
  172. // for _, item := range diagnosis_ids {
  173. // id, _ := strconv.ParseInt(item, 10, 64)
  174. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  175. // config = append(config, &diagnosisConfig)
  176. // }
  177. // var tempDiaginfos []models.OwnPayPatnDiagListD
  178. // for index, item := range config {
  179. // if index == 0 {
  180. // var tempDiaginfo models.OwnPayPatnDiagListD
  181. // tempDiaginfo.InoutDiagType = "1"
  182. // tempDiaginfo.DiagCode = item.CountryCode
  183. // tempDiaginfo.DiagName = item.CountryContentName
  184. // tempDiaginfo.DiagType = "1"
  185. // tempDiaginfo.DiagSrtNo = "1"
  186. // tempDiaginfo.MaindiagFlag = "1"
  187. // tempDiaginfo.ValiFlag = "1"
  188. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  189. // } else {
  190. //
  191. // var tempDiaginfo models.OwnPayPatnDiagListD
  192. // tempDiaginfo.DiagCode = item.CountryCode
  193. // tempDiaginfo.DiagName = item.CountryContentName
  194. // tempDiaginfo.DiagType = "2"
  195. // tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1),10)
  196. // tempDiaginfo.MaindiagFlag = "0"
  197. // tempDiaginfo.ValiFlag = "1"
  198. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  199. // }
  200. // }
  201. // struct4202.ODiagListD = tempDiaginfos
  202. // service.Gdyb4202(miConfig.OrgName,curRoles.UserName,miConfig.Code,miConfig.InsuplcAdmdvs,miConfig.MdtrtareaAdmvs,miConfig.SecretKey,struct4202)
  203. //
  204. //
  205. //
  206. //
  207. //}
  208. //func (c *HisApiController) Get4203(){
  209. //
  210. //
  211. //}
  212. //func (c *HisApiController) Get4205(){
  213. //
  214. //
  215. //}
  216. //func (c *HisApiController) Get4207(){
  217. //
  218. //
  219. //}
  220. //func (c *HisApiController) Get4208(){
  221. //
  222. //
  223. //}
  224. //func (c *HisApiController) Get4209(){
  225. //
  226. //
  227. //}
  228. type Result3101 struct {
  229. Infcode string `json:"infcode"`
  230. InfRefmsgid string `json:"inf_refmsgid"`
  231. RefmsgTime string `json:"refmsg_time"`
  232. RespondTime string `json:"respond_time"`
  233. Enctype string `json:"enctype"`
  234. Signtype string `json:"signtype"`
  235. ErrMsg string `json:"err_msg"`
  236. Output struct {
  237. Result []struct {
  238. JudgeResultDetailDtos []struct {
  239. VolaItemType string `json:"vola_item_type"`
  240. MdtrtID string `json:"mdtrt_id"`
  241. JrdID string `json:"jrd_id"`
  242. PatnID string `json:"patn_id"`
  243. RxID string `json:"rx_id"`
  244. VolaAmt interface{} `json:"vola_amt"`
  245. } `json:"judge_result_detail_dtos"`
  246. RuleID string `json:"rule_id"`
  247. VolaEvid string `json:"vola_evid"`
  248. MdtrtID string `json:"mdtrt_id"`
  249. RuleName string `json:"rule_name"`
  250. VolaAmtStas string `json:"vola_amt_stas"`
  251. JrID string `json:"jr_id"`
  252. PatnID string `json:"patn_id"`
  253. SevDeg string `json:"sev_deg"`
  254. VolaAmt float64 `json:"vola_amt"`
  255. VolaBhvrType string `json:"vola_bhvr_type"`
  256. VolaCont string `json:"vola_cont"`
  257. } `json:"result"`
  258. } `json:"output"`
  259. }
  260. func (c *HisApiController) ReadEleToken() {
  261. admin_user_id, _ := c.GetInt64("admin_user_id")
  262. his_patient_id, _ := c.GetInt64("his_patient_id")
  263. adminUser := c.GetAdminUserInfo()
  264. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  265. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  266. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  267. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  268. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  269. if len(tokens) > 0 {
  270. c.ServeSuccessJSON(map[string]interface{}{
  271. "msg": "读取成功",
  272. })
  273. } else {
  274. c.ServeSuccessJSON(map[string]interface{}{
  275. "failed_code": -10,
  276. "msg": "读取失败",
  277. })
  278. }
  279. } else if miConfig.MdtrtareaAdmvs == "440305" || miConfig.MdtrtareaAdmvs == "440305" || miConfig.MdtrtareaAdmvs == "441202" {
  280. if initFlag == 0 {
  281. c.TestGetBasBaseInit()
  282. }
  283. token := c.GetEleBaseInfo()
  284. token = Remove0000(token)
  285. if len(token) > 0 {
  286. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  287. saveLog(result2, requestLog2, "1101", "获取人员信息")
  288. var res ResultTwo
  289. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  290. utils.ErrorLog("解析失败:%v", err)
  291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  292. return
  293. }
  294. if res.Infcode == 0 {
  295. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  296. if err == gorm.ErrRecordNotFound {
  297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  298. return
  299. } else if err != nil {
  300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  301. return
  302. } else {
  303. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  304. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  305. infoStr := string(Iinfos)
  306. idetinfoStr := string(Idetinfos)
  307. psn := &models.HisPsn{
  308. PsnNo: res.Output.Baseinfo.PsnNo,
  309. Age: res.Output.Baseinfo.Age,
  310. PatientId: patient.ID,
  311. Certno: res.Output.Baseinfo.Certno,
  312. Brdy: res.Output.Baseinfo.Brdy,
  313. Gend: res.Output.Baseinfo.Gend,
  314. Naty: res.Output.Baseinfo.Naty,
  315. PsnCertType: res.Output.Baseinfo.PsnCertType,
  316. PsnName: res.Output.Baseinfo.PsnName,
  317. Idetinfo: idetinfoStr,
  318. Insuinfo: infoStr,
  319. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  320. CardInfo: "",
  321. VerifyNumber: token,
  322. }
  323. service.CreateHisPsn(psn)
  324. c.ServeSuccessJSON(map[string]interface{}{
  325. "msg": "读取成功",
  326. })
  327. }
  328. } else {
  329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  330. return
  331. }
  332. } else {
  333. c.ServeSuccessJSON(map[string]interface{}{
  334. "failed_code": -10,
  335. "msg": "读取失败",
  336. })
  337. }
  338. } else if miConfig.MdtrtareaAdmvs == "350500" {
  339. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  340. if len(errMsg) == 0 {
  341. type ELeData struct {
  342. Data struct {
  343. IdNo string `json:"idNo"`
  344. IdType string `json:"idType"`
  345. UserName string `json:"userName"`
  346. EcToken string `json:"ecToken"`
  347. InsuOrg string `json:"insuOrg"`
  348. Gender string `json:"gender"`
  349. Birthday string `json:"birthday"`
  350. Nationality string `json:"nationality"`
  351. Email string `json:"email"`
  352. Extra string `json:"extra"`
  353. } `json:"data"`
  354. Code int `json:"code"`
  355. Message string `json:"message"`
  356. }
  357. var ele ELeData
  358. err := json.Unmarshal([]byte(outPutInfo), &ele)
  359. if err != nil {
  360. utils.ErrorLog("解析失败:%v", err)
  361. }
  362. token := ele.Data.EcToken
  363. if len(token) > 0 {
  364. psn := &models.HisPsn{
  365. PsnNo: his.PsnNo,
  366. Age: 0,
  367. PatientId: his.PatientId,
  368. Certno: his.Certno,
  369. Brdy: his.Brdy,
  370. Gend: his.Gend,
  371. Naty: his.Naty,
  372. PsnCertType: his.PsnCertType,
  373. PsnName: his.PsnName,
  374. Idetinfo: his.Idetinfo,
  375. Insuinfo: his.Iinfo,
  376. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  377. CardInfo: outPutInfo,
  378. VerifyNumber: token,
  379. }
  380. service.CreateHisPsn(psn)
  381. }
  382. if len(token) > 0 {
  383. c.ServeSuccessJSON(map[string]interface{}{
  384. "msg": "读取成功",
  385. })
  386. } else {
  387. c.ServeSuccessJSON(map[string]interface{}{
  388. "failed_code": -10,
  389. "msg": "读取失败",
  390. })
  391. }
  392. }
  393. } else if miConfig.MdtrtareaAdmvs == "360399" {
  394. if initFlag == 0 {
  395. c.TestGetJiangXiBasBaseInit()
  396. }
  397. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  398. type ELeData struct {
  399. Data struct {
  400. IdNo string `json:"idNo"`
  401. IdType string `json:"idType"`
  402. UserName string `json:"userName"`
  403. EcToken string `json:"ecToken"`
  404. InsuOrg string `json:"insuOrg"`
  405. Gender string `json:"gender"`
  406. Birthday string `json:"birthday"`
  407. Nationality string `json:"nationality"`
  408. Email string `json:"email"`
  409. Extra string `json:"extra"`
  410. } `json:"data"`
  411. Code int `json:"code"`
  412. Message string `json:"message"`
  413. }
  414. var ele ELeData
  415. err := json.Unmarshal([]byte(json_result), &ele)
  416. if err != nil {
  417. utils.ErrorLog("解析失败:%v", err)
  418. }
  419. token := ele.Data.EcToken
  420. token = Remove0000(token)
  421. fmt.Println(ele.Data.UserName)
  422. 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)
  423. saveLog(result2, requestLog2, "1101", "获取人员信息")
  424. var res ResultTwo
  425. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  426. utils.ErrorLog("解析失败:%v", err)
  427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  428. return
  429. }
  430. if res.Infcode == 0 {
  431. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  432. if err == gorm.ErrRecordNotFound {
  433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  434. return
  435. } else if err != nil {
  436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  437. return
  438. } else {
  439. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  440. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  441. infoStr := string(Iinfos)
  442. idetinfoStr := string(Idetinfos)
  443. psn := &models.HisPsn{
  444. PsnNo: res.Output.Baseinfo.PsnNo,
  445. Age: res.Output.Baseinfo.Age,
  446. PatientId: patient.ID,
  447. Certno: res.Output.Baseinfo.Certno,
  448. Brdy: res.Output.Baseinfo.Brdy,
  449. Gend: res.Output.Baseinfo.Gend,
  450. Naty: res.Output.Baseinfo.Naty,
  451. PsnCertType: res.Output.Baseinfo.PsnCertType,
  452. PsnName: res.Output.Baseinfo.PsnName,
  453. Idetinfo: idetinfoStr,
  454. Insuinfo: infoStr,
  455. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  456. CardInfo: "",
  457. VerifyNumber: token,
  458. }
  459. service.CreateHisPsn(psn)
  460. c.ServeSuccessJSON(map[string]interface{}{
  461. "patient": patient,
  462. "number": token,
  463. })
  464. }
  465. } else {
  466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  467. return
  468. }
  469. } else if miConfig.MdtrtareaAdmvs == "430800" {
  470. if initFlag == 0 {
  471. c.TestGetJiangXiBasBaseInit()
  472. }
  473. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  474. type ELeData struct {
  475. Data struct {
  476. IdNo string `json:"idNo"`
  477. IdType string `json:"idType"`
  478. UserName string `json:"userName"`
  479. EcToken string `json:"ecToken"`
  480. InsuOrg string `json:"insuOrg"`
  481. Gender string `json:"gender"`
  482. Birthday string `json:"birthday"`
  483. Nationality string `json:"nationality"`
  484. Email string `json:"email"`
  485. Extra string `json:"extra"`
  486. } `json:"data"`
  487. Code int `json:"code"`
  488. Message string `json:"message"`
  489. }
  490. var ele ELeData
  491. err := json.Unmarshal([]byte(json_result), &ele)
  492. if err != nil {
  493. utils.ErrorLog("解析失败:%v", err)
  494. }
  495. token := ele.Data.EcToken
  496. token = Remove0000(token)
  497. fmt.Println(ele.Data.UserName)
  498. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  499. saveLog(result2, requestLog2, "1101", "获取人员信息")
  500. var res ResultTwo
  501. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  502. utils.ErrorLog("解析失败:%v", err)
  503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  504. return
  505. }
  506. if res.Infcode == 0 {
  507. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  508. if err == gorm.ErrRecordNotFound {
  509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  510. return
  511. } else if err != nil {
  512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  513. return
  514. } else {
  515. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  516. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  517. infoStr := string(Iinfos)
  518. idetinfoStr := string(Idetinfos)
  519. psn := &models.HisPsn{
  520. PsnNo: res.Output.Baseinfo.PsnNo,
  521. Age: res.Output.Baseinfo.Age,
  522. PatientId: patient.ID,
  523. Certno: res.Output.Baseinfo.Certno,
  524. Brdy: res.Output.Baseinfo.Brdy,
  525. Gend: res.Output.Baseinfo.Gend,
  526. Naty: res.Output.Baseinfo.Naty,
  527. PsnCertType: res.Output.Baseinfo.PsnCertType,
  528. PsnName: res.Output.Baseinfo.PsnName,
  529. Idetinfo: idetinfoStr,
  530. Insuinfo: infoStr,
  531. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  532. CardInfo: "",
  533. VerifyNumber: token,
  534. }
  535. service.CreateHisPsn(psn)
  536. c.ServeSuccessJSON(map[string]interface{}{
  537. "patient": patient,
  538. "number": token,
  539. })
  540. }
  541. } else {
  542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  543. return
  544. }
  545. }
  546. }
  547. func (c *HisApiController) Get9001() {
  548. adminUser := c.GetAdminUserInfo()
  549. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  550. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  551. if miConfig.MdtrtareaAdmvs == "350500" {
  552. service.GetFjAuthorizationInfo(miConfig.Code)
  553. } else if miConfig.MdtrtareaAdmvs == "131023" {
  554. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  555. var dat map[string]interface{}
  556. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  557. fmt.Println(dat)
  558. } else {
  559. fmt.Println(err)
  560. }
  561. userJSONBytes, _ := json.Marshal(dat)
  562. var res models.Result9001
  563. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  564. utils.ErrorLog("解析失败:%v", err)
  565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  566. return
  567. }
  568. } else {
  569. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  570. var dat map[string]interface{}
  571. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  572. fmt.Println(dat)
  573. } else {
  574. fmt.Println(err)
  575. }
  576. userJSONBytes, _ := json.Marshal(dat)
  577. var res models.Result9001
  578. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  579. utils.ErrorLog("解析失败:%v", err)
  580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  581. return
  582. }
  583. }
  584. }
  585. 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) {
  586. var res Result3101
  587. adminUser := c.GetAdminUserInfo()
  588. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  589. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  590. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  591. //record_time := c.GetString("record_time")
  592. //trig_scen := c.GetString("trig_scen")
  593. timeLayout := "2006-01-02"
  594. loc, _ := time.LoadLocation("Local")
  595. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  596. if err != nil {
  597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  598. return res
  599. }
  600. recordDateTime := theTime.Unix()
  601. var patientPrescription models.HisPrescriptionInfo
  602. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  603. //if patientPrescription.ID == 0 {
  604. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  605. //}
  606. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  607. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  608. //
  609. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  610. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  611. var pp models.PublicParams
  612. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  613. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  614. pp.FixmedinsName = miConfig.OrgName
  615. pp.FixmedinsCode = miConfig.Code
  616. pp.RequestUrl = miConfig.Url
  617. pp.Cainfo = miConfig.Cainfo
  618. pp.SecretKey = miConfig.SecretKey
  619. pp.AccessKey = miConfig.AccessKey
  620. pp.OpterName = roles.UserName
  621. var config []*models.HisXtDiagnoseConfig
  622. for _, item := range diagnosis_ids {
  623. id, _ := strconv.ParseInt(item, 10, 64)
  624. diagnosisConfig, _ := service.FindDiagnoseById(id)
  625. config = append(config, &diagnosisConfig)
  626. }
  627. var pd models.PatientDtos
  628. pd.PatnID = his.PsnNo
  629. pd.PatnName = his.Name
  630. pd.Gend = his.Gend
  631. pd.Brdy = his.Brdy
  632. pd.Poolarea = miConfig.MdtrtareaAdmvs
  633. pd.CurrMdtrtID = his.Number
  634. var fed models.FsiEncounterDtos
  635. fed.MdtrtID = his.Number
  636. fed.MedinsID = miConfig.Code
  637. fed.MedinsName = miConfig.OrgName
  638. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  639. fed.MedMdtrtType = "1"
  640. fed.MedinsType = "1"
  641. fed.MedinsLv = "11"
  642. tm := time.Unix(his.RecordDate, 0)
  643. s_tm := tm.Format("2006-01-02 15:04:05")
  644. fed.AdmDate = s_tm
  645. fed.DscgDate = s_tm
  646. fed.DscgMainDiseCodg = config[0].CountryCode
  647. fed.DscgMainDiseName = config[0].CountryContentName
  648. //诊断信息
  649. var fdds []*models.FsiDiagnoseDtos
  650. for index, item := range config {
  651. if index == 0 {
  652. var fdd models.FsiDiagnoseDtos
  653. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  654. fdd.InoutDiseType = "1"
  655. fdd.MaindiseFlag = "1"
  656. fdd.DiseDate = s_tm
  657. fdd.DiasSrtNo = "1"
  658. fdd.DiseName = item.CountryContentName
  659. fdd.DiseCodg = item.CountryCode
  660. fdds = append(fdds, &fdd)
  661. } else {
  662. var fdd models.FsiDiagnoseDtos
  663. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  664. fdd.InoutDiseType = "1"
  665. fdd.MaindiseFlag = "1"
  666. fdd.DiseDate = s_tm
  667. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  668. fdd.DiseName = item.CountryContentName
  669. fdd.DiseCodg = item.CountryCode
  670. fdds = append(fdds, &fdd)
  671. }
  672. }
  673. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  674. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  675. fed.AdmDeptName = department.Name
  676. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  677. fed.DscgDeptName = department.Name
  678. fed.MedMdtrtType = "1"
  679. fed.MedType = "11"
  680. //if his.Insutype == "390" {
  681. // fed.MedType = "1402"
  682. //} else {
  683. // fed.MedType = "9933"
  684. //}
  685. var orders []*models.FsiOrderDtos
  686. if trig_scen == "2" {
  687. //处方医嘱信息
  688. for _, item := range prescriptions {
  689. for _, subItem := range item.HisDoctorAdviceInfo {
  690. var order models.FsiOrderDtos
  691. order.RxID = strconv.FormatInt(item.ID, 10)
  692. order.Rxno = strconv.FormatInt(item.ID, 10)
  693. order.LongDrordFlag = "0"
  694. order.HilistType = "1"
  695. order.ChrgType = "1"
  696. order.DrordBhvr = "-"
  697. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  698. order.HosplistName = subItem.BaseDrugLib.DrugName
  699. order.HilistLv = "1"
  700. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  701. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  702. order.HosplistName = subItem.BaseDrugLib.DrugName
  703. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  704. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  705. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  706. order.OwnpayAmt = ""
  707. order.SelfpayAmt = ""
  708. order.Spec = ""
  709. order.SpecUnt = ""
  710. order.DrordBegnDate = s_tm
  711. order.DrordStopDate = ""
  712. order.DrordDrCodg = "1"
  713. order.DrordDeptName = department.Name
  714. order.DrordDrCodg = "1"
  715. order.DrordDrName = doctor_info.UserName
  716. order.DrordDrProfttl = ""
  717. order.CurrDrordFlag = "1"
  718. orders = append(orders, &order)
  719. }
  720. for _, subItem := range item.HisPrescriptionProject {
  721. if subItem.Type == 2 {
  722. var order models.FsiOrderDtos
  723. order.RxID = strconv.FormatInt(item.ID, 10)
  724. order.Rxno = strconv.FormatInt(item.ID, 10)
  725. order.LongDrordFlag = "0"
  726. order.HilistType = "1"
  727. order.ChrgType = "1"
  728. order.DrordBhvr = "-"
  729. order.HilistCode = subItem.HisProject.MedicalCode
  730. order.HosplistName = subItem.HisProject.ProjectName
  731. order.HilistLv = "1"
  732. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  733. order.HosplistCode = subItem.HisProject.MedicalCode
  734. order.HosplistName = subItem.HisProject.ProjectName
  735. order.Cnt = subItem.Count
  736. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  737. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  738. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  739. order.OwnpayAmt = ""
  740. order.SelfpayAmt = ""
  741. order.Spec = ""
  742. order.SpecUnt = ""
  743. order.DrordBegnDate = s_tm
  744. order.DrordStopDate = ""
  745. order.DrordDrCodg = "1"
  746. order.DrordDeptName = department.Name
  747. order.DrordDrCodg = "1"
  748. order.DrordDrName = doctor_info.UserName
  749. order.DrordDrProfttl = ""
  750. order.CurrDrordFlag = "1"
  751. orders = append(orders, &order)
  752. }
  753. if subItem.Type == 3 {
  754. var order models.FsiOrderDtos
  755. order.RxID = strconv.FormatInt(item.ID, 10)
  756. order.Rxno = strconv.FormatInt(item.ID, 10)
  757. order.LongDrordFlag = "0"
  758. order.HilistType = "1"
  759. order.ChrgType = "1"
  760. order.DrordBhvr = "-"
  761. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  762. order.HosplistName = subItem.GoodInfo.GoodName
  763. order.HilistLv = "1"
  764. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  765. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  766. order.HosplistName = subItem.GoodInfo.GoodName
  767. order.Cnt = subItem.Count
  768. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  769. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  770. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  771. order.OwnpayAmt = ""
  772. order.SelfpayAmt = ""
  773. order.Spec = ""
  774. order.SpecUnt = ""
  775. order.DrordBegnDate = s_tm
  776. order.DrordStopDate = ""
  777. order.DrordDrCodg = "1"
  778. order.DrordDeptName = department.Name
  779. order.DrordDrCodg = "1"
  780. order.DrordDrName = doctor_info.UserName
  781. order.DrordDrProfttl = ""
  782. order.CurrDrordFlag = "1"
  783. orders = append(orders, &order)
  784. }
  785. }
  786. }
  787. //处方医嘱信息
  788. }
  789. fed.MatnStas = "0"
  790. fed.MedfeeSumamt = "0"
  791. fed.OwnpayAmt = "0"
  792. fed.SelfpayAmt = "0"
  793. fed.AcctPayamt = "0"
  794. fed.MaAmt = "0"
  795. fed.HifpPayamt = "0"
  796. fed.SetlTotlnum = "1"
  797. fed.Insutype = his.Insutype
  798. fed.ReimFlag = "0"
  799. fed.OutSetlFlag = "0"
  800. var fopd []*models.FsiOperationDtosData
  801. data := make(map[string]interface{})
  802. data["fed"] = fed
  803. data["fdd"] = fdds
  804. data["fod"] = orders
  805. data["pd"] = pd
  806. data["pp"] = pp
  807. data["fopd"] = fopd
  808. data["trig_scen"] = trig_scen
  809. fmt.Println(data)
  810. fmt.Println(fed)
  811. fmt.Println(fdds)
  812. fmt.Println(orders)
  813. fmt.Println(pd)
  814. fmt.Println(pp)
  815. fmt.Println(fopd)
  816. client := &http.Client{}
  817. bytesData, _ := json.Marshal(data)
  818. var req *http.Request
  819. if miConfig.MdtrtareaAdmvs == "320921" {
  820. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  821. } else {
  822. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  823. }
  824. resp, _ := client.Do(req)
  825. defer resp.Body.Close()
  826. body, ioErr := ioutil.ReadAll(resp.Body)
  827. if ioErr != nil {
  828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  830. return res
  831. }
  832. var respJSON map[string]interface{}
  833. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  836. return res
  837. }
  838. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  839. fmt.Println(respJSON)
  840. result, _ := json.Marshal(respJSON)
  841. fmt.Println(result)
  842. if err := json.Unmarshal([]byte(result), &res); err != nil {
  843. utils.ErrorLog("解析失败:%v", err)
  844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  845. return res
  846. }
  847. return res
  848. }
  849. 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) {
  850. adminUser := c.GetAdminUserInfo()
  851. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  852. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  853. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  854. //record_time := c.GetString("record_time")
  855. //trig_scen := c.GetString("trig_scen")
  856. timeLayout := "2006-01-02"
  857. loc, _ := time.LoadLocation("Local")
  858. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  859. if err != nil {
  860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  861. return res
  862. }
  863. recordDateTime := theTime.Unix()
  864. var patientPrescription models.HisPrescriptionInfo
  865. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  866. if patientPrescription.ID == 0 {
  867. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  868. }
  869. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  870. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  871. //
  872. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  873. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  874. var pp models.PublicParams
  875. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  876. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  877. pp.FixmedinsName = miConfig.OrgName
  878. pp.FixmedinsCode = miConfig.Code
  879. pp.RequestUrl = miConfig.Url
  880. pp.Cainfo = miConfig.Cainfo
  881. pp.SecretKey = miConfig.SecretKey
  882. pp.AccessKey = miConfig.AccessKey
  883. pp.OpterName = roles.UserName
  884. var config []*models.HisXtDiagnoseConfig
  885. for _, item := range diagnosis_ids {
  886. id, _ := strconv.ParseInt(item, 10, 64)
  887. diagnosisConfig, _ := service.FindDiagnoseById(id)
  888. config = append(config, &diagnosisConfig)
  889. }
  890. var pd models.PatientDtos
  891. pd.PatnID = his.PsnNo
  892. pd.PatnName = his.Name
  893. pd.Gend = his.Gend
  894. pd.Brdy = his.Brdy
  895. pd.Poolarea = his.InsuplcAdmdvs
  896. pd.CurrMdtrtID = his.Number
  897. var fed models.FsiEncounterDtos
  898. fed.MdtrtID = his.Number
  899. fed.MedinsID = miConfig.Code
  900. fed.MedinsName = miConfig.OrgName
  901. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  902. fed.MedMdtrtType = "1"
  903. fed.MedinsType = "1"
  904. fed.MedinsLv = "11"
  905. tm := time.Unix(his.RecordDate, 0)
  906. s_tm := tm.Format("2006-01-02 15:04:05")
  907. fed.AdmDate = s_tm
  908. fed.DscgDate = s_tm
  909. fed.DscgMainDiseCodg = config[0].CountryCode
  910. fed.DscgMainDiseName = config[0].CountryContentName
  911. //诊断信息
  912. var fdds []*models.FsiDiagnoseDtos
  913. for index, item := range config {
  914. if index == 0 {
  915. var fdd models.FsiDiagnoseDtos
  916. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  917. fdd.InoutDiseType = "1"
  918. fdd.MaindiseFlag = "1"
  919. fdd.DiseDate = s_tm
  920. fdd.DiasSrtNo = "1"
  921. fdd.DiseName = item.CountryContentName
  922. fdd.DiseCodg = item.CountryCode
  923. fdds = append(fdds, &fdd)
  924. } else {
  925. var fdd models.FsiDiagnoseDtos
  926. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  927. fdd.InoutDiseType = "1"
  928. fdd.MaindiseFlag = "1"
  929. fdd.DiseDate = s_tm
  930. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  931. fdd.DiseName = item.CountryContentName
  932. fdd.DiseCodg = item.CountryCode
  933. fdds = append(fdds, &fdd)
  934. }
  935. }
  936. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  937. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  938. fed.AdmDeptName = department.Name
  939. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  940. fed.DscgDeptName = department.Name
  941. fed.MedMdtrtType = "1"
  942. fed.MedType = "11"
  943. //if his.Insutype == "390" {
  944. // fed.MedType = "1402"
  945. //} else {
  946. // fed.MedType = "9933"
  947. //}
  948. var orders []*models.FsiOrderDtos
  949. if trig_scen == "2" {
  950. //处方医嘱信息
  951. for _, item := range prescriptions {
  952. for _, subItem := range item.HisDoctorAdviceInfo {
  953. var order models.FsiOrderDtos
  954. order.RxID = strconv.FormatInt(item.ID, 10)
  955. order.Rxno = strconv.FormatInt(item.ID, 10)
  956. order.LongDrordFlag = "0"
  957. order.HilistType = "1"
  958. order.ChrgType = "1"
  959. order.DrordBhvr = "-"
  960. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  961. order.HosplistName = subItem.BaseDrugLib.DrugName
  962. order.HilistLv = "1"
  963. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  964. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  965. order.HosplistName = subItem.BaseDrugLib.DrugName
  966. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  967. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  968. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  969. order.OwnpayAmt = ""
  970. order.SelfpayAmt = ""
  971. order.Spec = ""
  972. order.SpecUnt = ""
  973. order.DrordBegnDate = s_tm
  974. order.DrordStopDate = ""
  975. order.DrordDrCodg = "1"
  976. order.DrordDeptName = department.Name
  977. order.DrordDrCodg = "1"
  978. order.DrordDrName = doctor_info.UserName
  979. order.DrordDrProfttl = ""
  980. order.CurrDrordFlag = "1"
  981. orders = append(orders, &order)
  982. }
  983. for _, subItem := range item.HisPrescriptionProject {
  984. if subItem.Type == 2 {
  985. var order models.FsiOrderDtos
  986. order.RxID = strconv.FormatInt(item.ID, 10)
  987. order.Rxno = strconv.FormatInt(item.ID, 10)
  988. order.LongDrordFlag = "0"
  989. order.HilistType = "1"
  990. order.ChrgType = "1"
  991. order.DrordBhvr = "-"
  992. order.HilistCode = subItem.HisProject.MedicalCode
  993. order.HosplistName = subItem.HisProject.ProjectName
  994. order.HilistLv = "1"
  995. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  996. order.HosplistCode = subItem.HisProject.MedicalCode
  997. order.HosplistName = subItem.HisProject.ProjectName
  998. order.Cnt = subItem.Count
  999. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1000. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1001. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1002. order.OwnpayAmt = ""
  1003. order.SelfpayAmt = ""
  1004. order.Spec = ""
  1005. order.SpecUnt = ""
  1006. order.DrordBegnDate = s_tm
  1007. order.DrordStopDate = ""
  1008. order.DrordDrCodg = "1"
  1009. order.DrordDeptName = department.Name
  1010. order.DrordDrCodg = "1"
  1011. order.DrordDrName = doctor_info.UserName
  1012. order.DrordDrProfttl = ""
  1013. order.CurrDrordFlag = "1"
  1014. orders = append(orders, &order)
  1015. }
  1016. if subItem.Type == 3 {
  1017. var order models.FsiOrderDtos
  1018. order.RxID = strconv.FormatInt(item.ID, 10)
  1019. order.Rxno = strconv.FormatInt(item.ID, 10)
  1020. order.LongDrordFlag = "0"
  1021. order.HilistType = "1"
  1022. order.ChrgType = "1"
  1023. order.DrordBhvr = "-"
  1024. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1025. order.HosplistName = subItem.GoodInfo.GoodName
  1026. order.HilistLv = "1"
  1027. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1028. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1029. order.HosplistName = subItem.GoodInfo.GoodName
  1030. order.Cnt = subItem.Count
  1031. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1032. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1033. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1034. order.OwnpayAmt = ""
  1035. order.SelfpayAmt = ""
  1036. order.Spec = ""
  1037. order.SpecUnt = ""
  1038. order.DrordBegnDate = s_tm
  1039. order.DrordStopDate = ""
  1040. order.DrordDrCodg = "1"
  1041. order.DrordDeptName = department.Name
  1042. order.DrordDrCodg = "1"
  1043. order.DrordDrName = doctor_info.UserName
  1044. order.DrordDrProfttl = ""
  1045. order.CurrDrordFlag = "1"
  1046. orders = append(orders, &order)
  1047. }
  1048. }
  1049. }
  1050. //处方医嘱信息
  1051. }
  1052. fed.MatnStas = "0"
  1053. fed.MedfeeSumamt = "0"
  1054. fed.OwnpayAmt = "0"
  1055. fed.SelfpayAmt = "0"
  1056. fed.AcctPayamt = "0"
  1057. fed.MaAmt = "0"
  1058. fed.HifpPayamt = "0"
  1059. fed.SetlTotlnum = "1"
  1060. fed.Insutype = his.Insutype
  1061. fed.ReimFlag = "0"
  1062. fed.OutSetlFlag = "0"
  1063. var fopd []*models.FsiOperationDtosData
  1064. data := make(map[string]interface{})
  1065. data["fed"] = fed
  1066. data["fdd"] = fdds
  1067. data["fod"] = orders
  1068. data["pd"] = pd
  1069. data["pp"] = pp
  1070. data["fopd"] = fopd
  1071. data["trig_scen"] = trig_scen
  1072. fmt.Println(data)
  1073. fmt.Println(fed)
  1074. fmt.Println(fdds)
  1075. fmt.Println(orders)
  1076. fmt.Println(pd)
  1077. fmt.Println(pp)
  1078. fmt.Println(fopd)
  1079. client := &http.Client{}
  1080. bytesData, _ := json.Marshal(data)
  1081. var req *http.Request
  1082. if miConfig.MdtrtareaAdmvs == "320921" {
  1083. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1084. } else {
  1085. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1086. }
  1087. resp, _ := client.Do(req)
  1088. defer resp.Body.Close()
  1089. body, ioErr := ioutil.ReadAll(resp.Body)
  1090. if ioErr != nil {
  1091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1093. return res
  1094. }
  1095. var respJSON map[string]interface{}
  1096. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1099. return res
  1100. }
  1101. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1102. result, _ := json.Marshal(respJSON)
  1103. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1104. utils.ErrorLog("解析失败:%v", err)
  1105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1106. return res
  1107. }
  1108. return res
  1109. }
  1110. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  1111. ////patient_id, _ := c.GetInt64("patient_id")
  1112. //order_id, _ := c.GetInt64("order_id")
  1113. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  1114. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  1115. //trig_scen := c.GetString("trig_scen")
  1116. adminUser := c.GetAdminUserInfo()
  1117. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1118. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1119. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1120. record_time := c.GetString("record_time")
  1121. order, _ := service.GetHisOrderByID(order_id)
  1122. timeLayout := "2006-01-02"
  1123. loc, _ := time.LoadLocation("Local")
  1124. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1125. if err != nil {
  1126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1127. return
  1128. }
  1129. recordDateTime := theTime.Unix()
  1130. var patientPrescription models.HisPrescriptionInfo
  1131. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1132. if patientPrescription.ID == 0 {
  1133. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1134. }
  1135. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1136. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1137. //
  1138. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1139. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1140. var pp models.PublicParams
  1141. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1142. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1143. pp.FixmedinsName = miConfig.OrgName
  1144. pp.FixmedinsCode = miConfig.Code
  1145. pp.RequestUrl = miConfig.Url
  1146. pp.Cainfo = miConfig.Cainfo
  1147. pp.SecretKey = miConfig.SecretKey
  1148. pp.AccessKey = miConfig.AccessKey
  1149. pp.OpterName = roles.UserName
  1150. var config []*models.HisXtDiagnoseConfig
  1151. for _, item := range diagnosis_ids {
  1152. id, _ := strconv.ParseInt(item, 10, 64)
  1153. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1154. config = append(config, &diagnosisConfig)
  1155. }
  1156. var pd models.PatientDtos
  1157. pd.PatnID = his.PsnNo
  1158. pd.PatnName = his.Name
  1159. pd.Gend = his.Gend
  1160. pd.Brdy = his.Brdy
  1161. pd.Poolarea = his.InsuplcAdmdvs
  1162. pd.CurrMdtrtID = his.Number
  1163. var fed models.FsiEncounterDtos
  1164. fed.MdtrtID = his.Number
  1165. fed.MedinsID = miConfig.Code
  1166. fed.MedinsName = miConfig.OrgName
  1167. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1168. fed.MedMdtrtType = "1"
  1169. fed.MedinsType = "1"
  1170. fed.MedinsLv = "11"
  1171. tm := time.Unix(his.RecordDate, 0)
  1172. s_tm := tm.Format("2006-01-02 15:04:05")
  1173. fed.AdmDate = s_tm
  1174. fed.DscgDate = s_tm
  1175. fed.DscgMainDiseCodg = config[0].CountryCode
  1176. fed.DscgMainDiseName = config[0].CountryContentName
  1177. //诊断信息
  1178. var fdds []*models.FsiDiagnoseDtos
  1179. for index, item := range config {
  1180. if index == 0 {
  1181. var fdd models.FsiDiagnoseDtos
  1182. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1183. fdd.InoutDiseType = "1"
  1184. fdd.MaindiseFlag = "1"
  1185. fdd.DiseDate = s_tm
  1186. fdd.DiasSrtNo = "1"
  1187. fdd.DiseName = item.CountryContentName
  1188. fdd.DiseCodg = item.CountryCode
  1189. fdds = append(fdds, &fdd)
  1190. } else {
  1191. var fdd models.FsiDiagnoseDtos
  1192. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1193. fdd.InoutDiseType = "1"
  1194. fdd.MaindiseFlag = "1"
  1195. fdd.DiseDate = s_tm
  1196. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1197. fdd.DiseName = item.CountryContentName
  1198. fdd.DiseCodg = item.CountryCode
  1199. fdds = append(fdds, &fdd)
  1200. }
  1201. }
  1202. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1203. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1204. fed.AdmDeptName = department.Name
  1205. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1206. fed.DscgDeptName = department.Name
  1207. fed.MedType = order.MedType
  1208. //处方医嘱信息
  1209. var orders []*models.FsiOrderDtos
  1210. //for _, item := range prescriptions {
  1211. // for _, subItem := range item.HisDoctorAdviceInfo {
  1212. // var order models.FsiOrderDtos
  1213. // order.RxID = strconv.FormatInt(item.ID, 10)
  1214. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1215. // order.LongDrordFlag = "0"
  1216. // order.HilistType = "1"
  1217. // order.ChrgType = "1"
  1218. // order.DrordBhvr = "-"
  1219. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1220. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1221. // order.HilistLv = "1"
  1222. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1223. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1224. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1225. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  1226. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1227. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  1228. // order.OwnpayAmt = ""
  1229. // order.SelfpayAmt = ""
  1230. // order.Spec = ""
  1231. // order.SpecUnt = ""
  1232. // order.DrordBegnDate = s_tm
  1233. // order.DrordStopDate = ""
  1234. // order.DrordDrCodg = "1"
  1235. // order.DrordDeptName = department.Name
  1236. // order.DrordDrCodg = "1"
  1237. // order.DrordDrName = doctor_info.UserName
  1238. // order.DrordDrProfttl = ""
  1239. // order.CurrDrordFlag = "1"
  1240. // orders = append(orders, &order)
  1241. // }
  1242. // for _, subItem := range item.HisPrescriptionProject {
  1243. // if subItem.Type == 2 {
  1244. // var order models.FsiOrderDtos
  1245. // order.RxID = strconv.FormatInt(item.ID, 10)
  1246. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1247. // order.LongDrordFlag = "0"
  1248. // order.HilistType = "1"
  1249. // order.ChrgType = "1"
  1250. // order.DrordBhvr = "-"
  1251. // order.HilistCode = subItem.HisProject.MedicalCode
  1252. // order.HosplistName = subItem.HisProject.ProjectName
  1253. // order.HilistLv = "1"
  1254. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1255. // order.HosplistCode = subItem.HisProject.MedicalCode
  1256. // order.HosplistName = subItem.HisProject.ProjectName
  1257. // order.Cnt = subItem.Count
  1258. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1259. //
  1260. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1261. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1262. // order.OwnpayAmt = ""
  1263. // order.SelfpayAmt = ""
  1264. // order.Spec = ""
  1265. // order.SpecUnt = ""
  1266. // order.DrordBegnDate = s_tm
  1267. // order.DrordStopDate = ""
  1268. // order.DrordDrCodg = "1"
  1269. // order.DrordDeptName = department.Name
  1270. // order.DrordDrCodg = "1"
  1271. // order.DrordDrName = doctor_info.UserName
  1272. // order.DrordDrProfttl = ""
  1273. // order.CurrDrordFlag = "1"
  1274. // orders = append(orders, &order)
  1275. //
  1276. // }
  1277. // if subItem.Type == 3 {
  1278. //
  1279. // var order models.FsiOrderDtos
  1280. // order.RxID = strconv.FormatInt(item.ID, 10)
  1281. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1282. // order.LongDrordFlag = "0"
  1283. // order.HilistType = "1"
  1284. // order.ChrgType = "1"
  1285. // order.DrordBhvr = "-"
  1286. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1287. // order.HosplistName = subItem.GoodInfo.GoodName
  1288. // order.HilistLv = "1"
  1289. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1290. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1291. // order.HosplistName = subItem.GoodInfo.GoodName
  1292. // order.Cnt = subItem.Count
  1293. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1294. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1295. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1296. // order.OwnpayAmt = ""
  1297. // order.SelfpayAmt = ""
  1298. // order.Spec = ""
  1299. // order.SpecUnt = ""
  1300. // order.DrordBegnDate = s_tm
  1301. // order.DrordStopDate = ""
  1302. // order.DrordDrCodg = "1"
  1303. // order.DrordDeptName = department.Name
  1304. // order.DrordDrCodg = "1"
  1305. // order.DrordDrName = doctor_info.UserName
  1306. // order.DrordDrProfttl = ""
  1307. // order.CurrDrordFlag = "1"
  1308. // orders = append(orders, &order)
  1309. //
  1310. // }
  1311. // }
  1312. //}
  1313. for _, item := range prescriptions {
  1314. for _, subItem := range item.HisDoctorAdviceInfo {
  1315. var order models.FsiOrderDtos
  1316. order.RxID = strconv.FormatInt(item.ID, 10)
  1317. order.Rxno = strconv.FormatInt(item.ID, 10)
  1318. order.LongDrordFlag = "0"
  1319. order.HilistType = "1"
  1320. order.ChrgType = "1"
  1321. order.DrordBhvr = "-"
  1322. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1323. order.HosplistName = subItem.BaseDrugLib.DrugName
  1324. order.HilistLv = "1"
  1325. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1326. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1327. order.HosplistName = subItem.BaseDrugLib.DrugName
  1328. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1329. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1330. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1331. order.OwnpayAmt = ""
  1332. order.SelfpayAmt = ""
  1333. order.Spec = ""
  1334. order.SpecUnt = ""
  1335. order.DrordBegnDate = s_tm
  1336. order.DrordStopDate = ""
  1337. order.DrordDrCodg = "1"
  1338. order.DrordDeptName = department.Name
  1339. order.DrordDrCodg = "1"
  1340. order.DrordDrName = doctor_info.UserName
  1341. order.DrordDrProfttl = ""
  1342. order.CurrDrordFlag = "1"
  1343. orders = append(orders, &order)
  1344. }
  1345. for _, subItem := range item.HisPrescriptionProject {
  1346. if subItem.Type == 2 {
  1347. var order models.FsiOrderDtos
  1348. order.RxID = strconv.FormatInt(item.ID, 10)
  1349. order.Rxno = strconv.FormatInt(item.ID, 10)
  1350. order.LongDrordFlag = "0"
  1351. order.HilistType = "1"
  1352. order.ChrgType = "1"
  1353. order.DrordBhvr = "-"
  1354. order.HilistCode = subItem.HisProject.MedicalCode
  1355. order.HosplistName = subItem.HisProject.ProjectName
  1356. order.HilistLv = "1"
  1357. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1358. order.HosplistCode = subItem.HisProject.MedicalCode
  1359. order.HosplistName = subItem.HisProject.ProjectName
  1360. order.Cnt = subItem.Count
  1361. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1362. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1363. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1364. order.OwnpayAmt = ""
  1365. order.SelfpayAmt = ""
  1366. order.Spec = ""
  1367. order.SpecUnt = ""
  1368. order.DrordBegnDate = s_tm
  1369. order.DrordStopDate = ""
  1370. order.DrordDrCodg = "1"
  1371. order.DrordDeptName = department.Name
  1372. order.DrordDrCodg = "1"
  1373. order.DrordDrName = doctor_info.UserName
  1374. order.DrordDrProfttl = ""
  1375. order.CurrDrordFlag = "1"
  1376. orders = append(orders, &order)
  1377. }
  1378. if subItem.Type == 3 {
  1379. var order models.FsiOrderDtos
  1380. order.RxID = strconv.FormatInt(item.ID, 10)
  1381. order.Rxno = strconv.FormatInt(item.ID, 10)
  1382. order.LongDrordFlag = "0"
  1383. order.HilistType = "1"
  1384. order.ChrgType = "1"
  1385. order.DrordBhvr = "-"
  1386. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1387. order.HosplistName = subItem.GoodInfo.GoodName
  1388. order.HilistLv = "1"
  1389. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1390. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1391. order.HosplistName = subItem.GoodInfo.GoodName
  1392. order.Cnt = subItem.Count
  1393. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1394. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1395. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1396. order.OwnpayAmt = ""
  1397. order.SelfpayAmt = ""
  1398. order.Spec = ""
  1399. order.SpecUnt = ""
  1400. order.DrordBegnDate = s_tm
  1401. order.DrordStopDate = ""
  1402. order.DrordDrCodg = "1"
  1403. order.DrordDeptName = department.Name
  1404. order.DrordDrCodg = "1"
  1405. order.DrordDrName = doctor_info.UserName
  1406. order.DrordDrProfttl = ""
  1407. order.CurrDrordFlag = "1"
  1408. orders = append(orders, &order)
  1409. }
  1410. }
  1411. }
  1412. //处方医嘱信息
  1413. fed.MatnStas = "0"
  1414. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1415. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  1416. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  1417. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  1418. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  1419. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  1420. fed.SetlTotlnum = "1"
  1421. fed.Insutype = his.Insutype
  1422. fed.ReimFlag = "0"
  1423. fed.OutSetlFlag = "0"
  1424. var fopd []*models.FsiOperationDtosData
  1425. data := make(map[string]interface{})
  1426. data["fed"] = fed
  1427. data["fdd"] = fdds
  1428. data["fod"] = orders
  1429. data["pd"] = pd
  1430. data["pp"] = pp
  1431. data["fopd"] = fopd
  1432. data["trig_scen"] = trig_scen
  1433. client := &http.Client{}
  1434. bytesData, _ := json.Marshal(data)
  1435. var req *http.Request
  1436. if miConfig.MdtrtareaAdmvs == "320921" {
  1437. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1438. } else {
  1439. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1440. }
  1441. resp, _ := client.Do(req)
  1442. defer resp.Body.Close()
  1443. body, ioErr := ioutil.ReadAll(resp.Body)
  1444. if ioErr != nil {
  1445. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1447. return res
  1448. }
  1449. var respJSON map[string]interface{}
  1450. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1453. return res
  1454. }
  1455. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1456. result, _ := json.Marshal(respJSON)
  1457. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1458. utils.ErrorLog("解析失败:%v", err)
  1459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1460. return res
  1461. }
  1462. return res
  1463. //手术操作集合
  1464. //手术操作集合
  1465. }
  1466. func (c *HisApiController) Check() {
  1467. psn_no := c.GetString("psn_no")
  1468. in := c.GetString("in")
  1469. mt := c.GetString("mt")
  1470. baseParams := models.BaseParams{
  1471. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1472. FixmedinsCode: "H15049901371",
  1473. InsuplcAdmdvs: "150499",
  1474. MdtrtareaAdmvs: "150499",
  1475. OrgName: "赤峰费森血液透析中心",
  1476. Doctor: "1111",
  1477. }
  1478. service.Gdyb2001(baseParams, psn_no, in, mt)
  1479. }
  1480. func (c *HisApiController) GetPsnNcdsInfo() {
  1481. admin_user_id, _ := c.GetInt64("admin_user_id")
  1482. patient_id, _ := c.GetInt64("patient_id")
  1483. id, _ := c.GetInt64("id")
  1484. adminUser := c.GetAdminUserInfo()
  1485. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1486. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1487. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1488. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1489. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1490. //
  1491. //if psn_record.ID == 0 {
  1492. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1493. // return
  1494. //}
  1495. var res Result5301
  1496. var res10265 Result5301For10265
  1497. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1498. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1499. var api string
  1500. if miConfig.MdtrtareaAdmvs == "320921" {
  1501. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  1502. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1503. } else {
  1504. 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 +
  1505. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1506. }
  1507. resp, requestErr := http.Get(api)
  1508. if requestErr != nil {
  1509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1510. return
  1511. }
  1512. body, ioErr := ioutil.ReadAll(resp.Body)
  1513. if ioErr != nil {
  1514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1516. return
  1517. }
  1518. var respJSON map[string]interface{}
  1519. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1522. return
  1523. }
  1524. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1525. result, _ := json.Marshal(respJSON)
  1526. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1527. utils.ErrorLog("解析失败:%v", err)
  1528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1529. return
  1530. }
  1531. res.ErrMsg = res10265.ErrMsg
  1532. res.Output = res10265.Output
  1533. res.InfRefmsgid = res10265.InfRefmsgid
  1534. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1535. res.Infcode = infocode
  1536. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1537. p, _ := service.GetHisPatientById(patient_id)
  1538. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1539. var dat map[string]interface{}
  1540. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1541. fmt.Println(dat)
  1542. } else {
  1543. fmt.Println(err)
  1544. }
  1545. userJSONBytes, _ := json.Marshal(dat)
  1546. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1547. utils.ErrorLog("解析失败:%v", err)
  1548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1549. return
  1550. }
  1551. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1552. p, _ := service.GetHisPatientById(patient_id)
  1553. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1554. var dat map[string]interface{}
  1555. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1556. fmt.Println(dat)
  1557. } else {
  1558. fmt.Println(err)
  1559. }
  1560. userJSONBytes, _ := json.Marshal(dat)
  1561. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1562. utils.ErrorLog("解析失败:%v", err)
  1563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1564. return
  1565. }
  1566. } else {
  1567. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1568. var dat map[string]interface{}
  1569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1570. fmt.Println(dat)
  1571. } else {
  1572. fmt.Println(err)
  1573. }
  1574. userJSONBytes, _ := json.Marshal(dat)
  1575. if miConfig.Code == "H15049901371" {
  1576. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1577. utils.ErrorLog("解析失败:%v", err)
  1578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1579. return
  1580. }
  1581. res.InfRefmsgid = res10265.InfRefmsgid
  1582. res.Output = res10265.Output
  1583. res.ErrMsg = res10265.ErrMsg
  1584. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1585. res.Infcode = infocode
  1586. } else {
  1587. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1588. utils.ErrorLog("解析失败:%v", err)
  1589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1590. return
  1591. }
  1592. }
  1593. }
  1594. if res.Infcode == 0 {
  1595. c.ServeSuccessJSON(map[string]interface{}{
  1596. "result": res.Output.Result,
  1597. })
  1598. }
  1599. }
  1600. func (c *HisApiController) CheckInsutype() {
  1601. his_patient_id, _ := c.GetInt64("his_patient_id")
  1602. admin_user_id, _ := c.GetInt64("admin_user_id")
  1603. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1604. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1605. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1606. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1607. var dat map[string]interface{}
  1608. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1609. fmt.Println(dat)
  1610. } else {
  1611. fmt.Println(err)
  1612. }
  1613. userJSONBytes, _ := json.Marshal(dat)
  1614. var res Result90100
  1615. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1616. utils.ErrorLog("解析失败:%v", err)
  1617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1618. return
  1619. }
  1620. if res.Infcode != 0 {
  1621. c.ServeSuccessJSON(map[string]interface{}{
  1622. "failed_code": -10,
  1623. "msg": res.ErrMsg,
  1624. })
  1625. return
  1626. } else {
  1627. fmt.Println(res)
  1628. }
  1629. }
  1630. func (c *HisApiController) CheckCardPWD() {
  1631. card_pwd := c.GetString("card_pwd")
  1632. his_patient_id, _ := c.GetInt64("his_patient_id")
  1633. admin_user_id, _ := c.GetInt64("admin_user_id")
  1634. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1635. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1636. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1637. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1638. bas := strings.Split(psn.CardInfo, "|")
  1639. basNumber := bas[2]
  1640. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1641. var dat map[string]interface{}
  1642. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1643. fmt.Println(dat)
  1644. } else {
  1645. fmt.Println(err)
  1646. }
  1647. userJSONBytes, _ := json.Marshal(dat)
  1648. var res Result90991
  1649. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1650. utils.ErrorLog("解析失败:%v", err)
  1651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1652. return
  1653. }
  1654. if res.Infcode != 0 {
  1655. c.ServeSuccessJSON(map[string]interface{}{
  1656. "failed_code": -10,
  1657. "msg": res.ErrMsg,
  1658. })
  1659. return
  1660. } else {
  1661. if res.Output.Result.SscnoCheckStat == "0" {
  1662. var msg string
  1663. switch res.Output.Result.CardStat {
  1664. case "00":
  1665. msg = "未激活"
  1666. break
  1667. case "10":
  1668. msg = "激活"
  1669. break
  1670. case "20":
  1671. msg = "窗口挂失"
  1672. break
  1673. case "21":
  1674. msg = "电话挂失"
  1675. break
  1676. case "22":
  1677. msg = "单位网上申报挂失"
  1678. break
  1679. case "23":
  1680. msg = "保健办挂失"
  1681. break
  1682. case "24":
  1683. msg = "个人网上挂失"
  1684. break
  1685. case "25":
  1686. msg = "网上服务大厅挂失"
  1687. break
  1688. case "30":
  1689. msg = "注销"
  1690. break
  1691. case "40":
  1692. msg = "回收"
  1693. break
  1694. case "99":
  1695. msg = "制卡中(无效卡)"
  1696. break
  1697. }
  1698. c.ServeSuccessJSON(map[string]interface{}{
  1699. "failed_code": -10,
  1700. "msg": msg,
  1701. })
  1702. return
  1703. } else {
  1704. c.ServeSuccessJSON(map[string]interface{}{
  1705. "msg": "校验成功",
  1706. })
  1707. return
  1708. }
  1709. }
  1710. }
  1711. func (c *HisApiController) CheckCardPWDTwo() {
  1712. //card_pwd := c.GetString("card_pwd")
  1713. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1714. admin_user_id, _ := c.GetInt64("admin_user_id")
  1715. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1716. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1717. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1718. var dat map[string]interface{}
  1719. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1720. fmt.Println(dat)
  1721. } else {
  1722. fmt.Println(err)
  1723. }
  1724. userJSONBytes, _ := json.Marshal(dat)
  1725. var res Result90991
  1726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1727. utils.ErrorLog("解析失败:%v", err)
  1728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1729. return
  1730. }
  1731. if res.Infcode != 0 {
  1732. c.ServeSuccessJSON(map[string]interface{}{
  1733. "failed_code": -10,
  1734. "msg": res.ErrMsg,
  1735. })
  1736. return
  1737. } else {
  1738. if res.Output.Result.SscnoCheckStat == "0" {
  1739. var msg string
  1740. switch res.Output.Result.CardStat {
  1741. case "00":
  1742. msg = "未激活"
  1743. break
  1744. case "10":
  1745. msg = "激活"
  1746. break
  1747. case "20":
  1748. msg = "窗口挂失"
  1749. break
  1750. case "21":
  1751. msg = "电话挂失"
  1752. break
  1753. case "22":
  1754. msg = "单位网上申报挂失"
  1755. break
  1756. case "23":
  1757. msg = "保健办挂失"
  1758. break
  1759. case "24":
  1760. msg = "个人网上挂失"
  1761. break
  1762. case "25":
  1763. msg = "网上服务大厅挂失"
  1764. break
  1765. case "30":
  1766. msg = "注销"
  1767. break
  1768. case "40":
  1769. msg = "回收"
  1770. break
  1771. case "99":
  1772. msg = "制卡中(无效卡)"
  1773. break
  1774. }
  1775. c.ServeSuccessJSON(map[string]interface{}{
  1776. "failed_code": -10,
  1777. "msg": msg,
  1778. })
  1779. return
  1780. } else {
  1781. c.ServeSuccessJSON(map[string]interface{}{
  1782. "msg": "校验成功",
  1783. })
  1784. return
  1785. }
  1786. }
  1787. }
  1788. type ELeCertData struct {
  1789. Data struct {
  1790. Extra string `json:"extra"`
  1791. IDNo string `json:"idNo"`
  1792. IDType string `json:"idType"`
  1793. EcToken string `json:"ecToken"`
  1794. InsuOrg string `json:"insuOrg"`
  1795. UserName string `json:"userName"`
  1796. EcIndexNo string `json:"ecIndexNo"`
  1797. Gender string `json:"gender"`
  1798. Birthday string `json:"birthday"`
  1799. Nationality string `json:"nationality"`
  1800. Email string `json:"email"`
  1801. } `json:"OutData"`
  1802. }
  1803. func (c *HisApiController) ReadCard() {
  1804. id_card_type, _ := c.GetInt64("id_card_type")
  1805. admin_user_id, _ := c.GetInt64("admin_user_id")
  1806. certificates, _ := c.GetInt64("certificates")
  1807. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1808. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1809. switch id_card_type {
  1810. case 1:
  1811. if miConfig.MdtrtareaAdmvs == "421300" {
  1812. var res ResultTwo
  1813. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1814. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1815. "&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)
  1816. resp, requestErr := http.Get(api)
  1817. if requestErr != nil {
  1818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1819. return
  1820. }
  1821. body, ioErr := ioutil.ReadAll(resp.Body)
  1822. if ioErr != nil {
  1823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1825. return
  1826. }
  1827. var respJSON map[string]interface{}
  1828. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1831. return
  1832. }
  1833. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1834. result, _ := json.Marshal(respJSON)
  1835. fmt.Println("log")
  1836. fmt.Println(string(result))
  1837. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1838. utils.ErrorLog("解析失败:%v", err)
  1839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1840. return
  1841. }
  1842. if res.Infcode == 0 {
  1843. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1844. if err == gorm.ErrRecordNotFound {
  1845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1846. return
  1847. } else if err != nil {
  1848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1849. return
  1850. } else {
  1851. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1852. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1853. infoStr := string(Iinfos)
  1854. idetinfoStr := string(Idetinfos)
  1855. psn := &models.HisPsn{
  1856. PsnNo: res.Output.Baseinfo.PsnNo,
  1857. Age: res.Output.Baseinfo.Age,
  1858. PatientId: patient.ID,
  1859. Certno: res.Output.Baseinfo.Certno,
  1860. Brdy: res.Output.Baseinfo.Brdy,
  1861. Gend: res.Output.Baseinfo.Gend,
  1862. Naty: res.Output.Baseinfo.Naty,
  1863. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1864. PsnName: res.Output.Baseinfo.PsnName,
  1865. Idetinfo: idetinfoStr,
  1866. Insuinfo: infoStr,
  1867. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1868. }
  1869. service.CreateHisPsn(psn)
  1870. c.ServeSuccessJSON(map[string]interface{}{
  1871. "patient": patient,
  1872. "number": res.Output.Baseinfo.Certno,
  1873. })
  1874. }
  1875. } else {
  1876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1877. return
  1878. }
  1879. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1880. var api string
  1881. if miConfig.MdtrtareaAdmvs == "320921" {
  1882. 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 +
  1883. "&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
  1884. fmt.Println(api)
  1885. } else {
  1886. 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 +
  1887. "&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)
  1888. }
  1889. resp, requestErr := http.Get(api)
  1890. if requestErr != nil {
  1891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1892. return
  1893. }
  1894. body, ioErr := ioutil.ReadAll(resp.Body)
  1895. if ioErr != nil {
  1896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1898. return
  1899. }
  1900. var respJSON map[string]interface{}
  1901. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1904. return
  1905. }
  1906. var status string
  1907. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1908. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1909. //console.log()
  1910. fmt.Println("type===")
  1911. fmt.Println(card_type)
  1912. var token string
  1913. var res ResultTwo //1101结果
  1914. var res10265 ResultTwo10265 //1101结果
  1915. var card_info string //卡信息
  1916. var busi_card_info string
  1917. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1918. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1919. if status == "0" { //读卡成功
  1920. if card_type == "1" {
  1921. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1922. result, _ := json.Marshal(respJSON)
  1923. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1924. utils.ErrorLog("解析失败:%v", err)
  1925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1926. return
  1927. }
  1928. res.ErrMsg = res10265.ErrMsg
  1929. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1930. res.Infcode = infocode
  1931. res.Output = res10265.Output
  1932. res.InfRefmsgid = res10265.InfRefmsgid
  1933. } else {
  1934. //var card_info string //卡信息
  1935. //var busi_card_info string
  1936. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1937. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1938. //fmt.Println(card_info)
  1939. //fmt.Println(busi_card_info)
  1940. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1941. result, _ := json.Marshal(respJSON)
  1942. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1943. utils.ErrorLog("解析失败:%v", err)
  1944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1945. return
  1946. }
  1947. res.ErrMsg = res10265.ErrMsg
  1948. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1949. res.Infcode = infocode
  1950. res.Output = res10265.Output
  1951. res.InfRefmsgid = res10265.InfRefmsgid
  1952. }
  1953. if res.Infcode == 0 {
  1954. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1955. if err == gorm.ErrRecordNotFound {
  1956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1957. return
  1958. } else if err != nil {
  1959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1960. return
  1961. } else {
  1962. if card_type == "1" {
  1963. bas := strings.Split(card_info, "|")
  1964. basNumber := bas[2]
  1965. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1966. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1967. infoStr := string(Iinfos)
  1968. idetinfoStr := string(Idetinfos)
  1969. psn := &models.HisPsn{
  1970. PsnNo: res.Output.Baseinfo.PsnNo,
  1971. Age: res.Output.Baseinfo.Age,
  1972. PatientId: patient.ID,
  1973. Certno: res.Output.Baseinfo.Certno,
  1974. Brdy: res.Output.Baseinfo.Brdy,
  1975. Gend: res.Output.Baseinfo.Gend,
  1976. Naty: res.Output.Baseinfo.Naty,
  1977. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1978. PsnName: res.Output.Baseinfo.PsnName,
  1979. Idetinfo: idetinfoStr,
  1980. Insuinfo: infoStr,
  1981. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1982. CardInfo: card_info,
  1983. VerifyNumber: busi_card_info,
  1984. }
  1985. service.CreateHisPsn(psn)
  1986. var rf []*ResultFive
  1987. json.Unmarshal([]byte(infoStr), &rf)
  1988. var insutypes []*ResultFive
  1989. var insutype string
  1990. var is390 int = 0
  1991. var is310 int = 0
  1992. for _, item := range rf {
  1993. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1994. insutypes = append(insutypes, item)
  1995. }
  1996. }
  1997. if len(insutypes) == 1 {
  1998. insutype = insutypes[0].Insutype
  1999. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2000. } else {
  2001. for _, i := range insutypes {
  2002. if i.Insutype == "390" {
  2003. is390 = 1
  2004. }
  2005. if i.Insutype == "310" {
  2006. is310 = 1
  2007. }
  2008. }
  2009. }
  2010. if is390 == 1 {
  2011. insutype = "390"
  2012. }
  2013. if is310 == 1 {
  2014. insutype = "310"
  2015. }
  2016. if len(insutypes) == 0 {
  2017. insutype = "310"
  2018. }
  2019. c.ServeSuccessJSON(map[string]interface{}{
  2020. "patient": patient,
  2021. "number": basNumber,
  2022. "insutype": insutype,
  2023. })
  2024. } else {
  2025. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2026. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2027. infoStr := string(Iinfos)
  2028. idetinfoStr := string(Idetinfos)
  2029. psn := &models.HisPsn{
  2030. PsnNo: res.Output.Baseinfo.PsnNo,
  2031. Age: res.Output.Baseinfo.Age,
  2032. PatientId: patient.ID,
  2033. Certno: res.Output.Baseinfo.Certno,
  2034. Brdy: res.Output.Baseinfo.Brdy,
  2035. Gend: res.Output.Baseinfo.Gend,
  2036. Naty: res.Output.Baseinfo.Naty,
  2037. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2038. PsnName: res.Output.Baseinfo.PsnName,
  2039. Idetinfo: idetinfoStr,
  2040. Insuinfo: infoStr,
  2041. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2042. CardInfo: card_info,
  2043. VerifyNumber: token,
  2044. }
  2045. service.CreateHisPsn(psn)
  2046. c.ServeSuccessJSON(map[string]interface{}{
  2047. "patient": patient,
  2048. "number": token,
  2049. })
  2050. }
  2051. }
  2052. } else {
  2053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2054. return
  2055. }
  2056. } else { //读卡失败
  2057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2058. return
  2059. }
  2060. } else if miConfig.MdtrtareaAdmvs == "350500" {
  2061. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  2062. cardnum = DeleteExtraSpaceTwo(cardnum)
  2063. cardCode = DeleteExtraSpaceTwo(cardCode)
  2064. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  2065. name = DeleteExtraSpaceTwo(name)
  2066. errmsg = DeleteExtraSpaceTwo(errmsg)
  2067. cardnum = Remove0000(cardnum)
  2068. cardCode = Remove0000(cardCode)
  2069. id_card_no = Remove0000(id_card_no)
  2070. name = Remove0000(name)
  2071. errmsg = Remove0000(errmsg)
  2072. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  2073. result, requestLog, errMsgLog := service.FJyb1101(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)
  2074. saveLog(result, requestLog, "1101", "获取人员信息")
  2075. fmt.Println(errMsgLog)
  2076. if len(errMsgLog) > 0 {
  2077. } else {
  2078. var dat map[string]interface{}
  2079. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2080. fmt.Println(dat)
  2081. } else {
  2082. fmt.Println(err)
  2083. }
  2084. userJSONBytes, _ := json.Marshal(dat)
  2085. var res ResultTwo
  2086. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2087. utils.ErrorLog("解析失败:%v", err)
  2088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2089. return
  2090. }
  2091. res.ErrMsg = errMsgLog
  2092. if res.Infcode == 0 {
  2093. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  2094. if err == gorm.ErrRecordNotFound {
  2095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2096. return
  2097. } else if err != nil {
  2098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2099. return
  2100. } else {
  2101. fmt.Println(res)
  2102. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2103. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2104. infoStr := string(Iinfos)
  2105. idetinfoStr := string(Idetinfos)
  2106. psn := &models.HisPsn{
  2107. PsnNo: res.Output.Baseinfo.PsnNo,
  2108. Age: res.Output.Baseinfo.Age,
  2109. PatientId: patient.ID,
  2110. Certno: res.Output.Baseinfo.Certno,
  2111. Brdy: res.Output.Baseinfo.Brdy,
  2112. Gend: res.Output.Baseinfo.Gend,
  2113. Naty: res.Output.Baseinfo.Naty,
  2114. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2115. PsnName: res.Output.Baseinfo.PsnName,
  2116. Idetinfo: idetinfoStr,
  2117. Insuinfo: infoStr,
  2118. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2119. CardInfo: basStr,
  2120. VerifyNumber: "",
  2121. }
  2122. service.CreateHisPsn(psn)
  2123. var rf []*ResultFive
  2124. json.Unmarshal([]byte(infoStr), &rf)
  2125. var insutypes []*ResultFive
  2126. var insutype string
  2127. var is390 int = 0
  2128. var is310 int = 0
  2129. for _, item := range rf {
  2130. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2131. insutypes = append(insutypes, item)
  2132. }
  2133. }
  2134. if len(insutypes) == 1 {
  2135. insutype = insutypes[0].Insutype
  2136. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2137. } else {
  2138. for _, i := range insutypes {
  2139. if i.Insutype == "390" {
  2140. is390 = 1
  2141. }
  2142. if i.Insutype == "310" {
  2143. is310 = 1
  2144. }
  2145. }
  2146. }
  2147. if is390 == 1 {
  2148. insutype = "390"
  2149. }
  2150. if is310 == 1 {
  2151. insutype = "310"
  2152. }
  2153. if len(insutypes) == 0 {
  2154. insutype = "310"
  2155. }
  2156. c.ServeSuccessJSON(map[string]interface{}{
  2157. "patient": patient,
  2158. "number": cardnum,
  2159. "insutype": insutype,
  2160. })
  2161. }
  2162. } else {
  2163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2164. return
  2165. }
  2166. }
  2167. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2168. fmt.Println(initFlag)
  2169. fmt.Println("initFlag")
  2170. if initFlag == 0 {
  2171. c.TestGetJiangXiBasBaseInit()
  2172. }
  2173. basStr := c.GetBasBaseInfo()
  2174. if len(basStr) == 0 {
  2175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2176. return
  2177. }
  2178. fmt.Println(basStr)
  2179. bas := strings.Split(basStr, "|")
  2180. basNumber := bas[1]
  2181. fmt.Println(basNumber)
  2182. card_sn := bas[3]
  2183. fmt.Println(card_sn)
  2184. 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, "")
  2185. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2186. var dat map[string]interface{}
  2187. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2188. fmt.Println(dat)
  2189. } else {
  2190. fmt.Println(err)
  2191. }
  2192. userJSONBytes, _ := json.Marshal(dat)
  2193. var res ResultTwo
  2194. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2195. utils.ErrorLog("解析失败:%v", err)
  2196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2197. return
  2198. }
  2199. if res.Infcode == 0 {
  2200. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2201. if err == gorm.ErrRecordNotFound {
  2202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2203. return
  2204. } else if err != nil {
  2205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2206. return
  2207. } else {
  2208. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2209. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2210. infoStr := string(Iinfos)
  2211. idetinfoStr := string(Idetinfos)
  2212. psn := &models.HisPsn{
  2213. PsnNo: res.Output.Baseinfo.PsnNo,
  2214. Age: res.Output.Baseinfo.Age,
  2215. PatientId: patient.ID,
  2216. Certno: res.Output.Baseinfo.Certno,
  2217. Brdy: res.Output.Baseinfo.Brdy,
  2218. Gend: res.Output.Baseinfo.Gend,
  2219. Naty: res.Output.Baseinfo.Naty,
  2220. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2221. PsnName: res.Output.Baseinfo.PsnName,
  2222. Idetinfo: idetinfoStr,
  2223. Insuinfo: infoStr,
  2224. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2225. CardInfo: basStr,
  2226. VerifyNumber: "",
  2227. }
  2228. service.CreateHisPsn(psn)
  2229. var rf []*ResultFive
  2230. json.Unmarshal([]byte(infoStr), &rf)
  2231. var insutypes []*ResultFive
  2232. var insutype string
  2233. var is390 int = 0
  2234. var is310 int = 0
  2235. for _, item := range rf {
  2236. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2237. insutypes = append(insutypes, item)
  2238. }
  2239. }
  2240. if len(insutypes) == 1 {
  2241. insutype = insutypes[0].Insutype
  2242. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2243. } else {
  2244. for _, i := range insutypes {
  2245. if i.Insutype == "390" {
  2246. is390 = 1
  2247. }
  2248. if i.Insutype == "310" {
  2249. is310 = 1
  2250. }
  2251. }
  2252. }
  2253. if is390 == 1 {
  2254. insutype = "390"
  2255. }
  2256. if is310 == 1 {
  2257. insutype = "310"
  2258. }
  2259. if len(insutypes) == 0 {
  2260. insutype = "310"
  2261. }
  2262. c.ServeSuccessJSON(map[string]interface{}{
  2263. "patient": patient,
  2264. "number": basNumber,
  2265. "insutype": insutype,
  2266. })
  2267. }
  2268. } else {
  2269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2270. return
  2271. }
  2272. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2273. fmt.Println(initFlag)
  2274. fmt.Println("initFlag")
  2275. if initFlag == 0 {
  2276. c.TestGetHnBasBaseInit()
  2277. }
  2278. basStr := c.GetBasBaseInfo()
  2279. if len(basStr) == 0 {
  2280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2281. return
  2282. }
  2283. fmt.Println(basStr)
  2284. bas := strings.Split(basStr, "|")
  2285. basNumber := bas[1]
  2286. fmt.Println(basNumber)
  2287. card_sn := bas[3]
  2288. card_no := bas[2]
  2289. fmt.Println(card_sn)
  2290. name := bas[4]
  2291. name = ConvertToString(name, "gbk", "utf-8")
  2292. 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)
  2293. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2294. var dat map[string]interface{}
  2295. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2296. fmt.Println(dat)
  2297. } else {
  2298. fmt.Println(err)
  2299. }
  2300. userJSONBytes, _ := json.Marshal(dat)
  2301. var res ResultTwo
  2302. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2303. utils.ErrorLog("解析失败:%v", err)
  2304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2305. return
  2306. }
  2307. if res.Infcode == 0 {
  2308. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2309. if err == gorm.ErrRecordNotFound {
  2310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2311. return
  2312. } else if err != nil {
  2313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2314. return
  2315. } else {
  2316. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2317. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2318. infoStr := string(Iinfos)
  2319. idetinfoStr := string(Idetinfos)
  2320. psn := &models.HisPsn{
  2321. PsnNo: res.Output.Baseinfo.PsnNo,
  2322. Age: res.Output.Baseinfo.Age,
  2323. PatientId: patient.ID,
  2324. Certno: res.Output.Baseinfo.Certno,
  2325. Brdy: res.Output.Baseinfo.Brdy,
  2326. Gend: res.Output.Baseinfo.Gend,
  2327. Naty: res.Output.Baseinfo.Naty,
  2328. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2329. PsnName: res.Output.Baseinfo.PsnName,
  2330. Idetinfo: idetinfoStr,
  2331. Insuinfo: infoStr,
  2332. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2333. CardInfo: basStr,
  2334. VerifyNumber: "",
  2335. }
  2336. service.CreateHisPsn(psn)
  2337. var rf []*ResultFive
  2338. json.Unmarshal([]byte(infoStr), &rf)
  2339. var insutypes []*ResultFive
  2340. var insutype string
  2341. var is390 int = 0
  2342. var is310 int = 0
  2343. for _, item := range rf {
  2344. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2345. insutypes = append(insutypes, item)
  2346. }
  2347. }
  2348. if len(insutypes) == 1 {
  2349. insutype = insutypes[0].Insutype
  2350. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2351. } else {
  2352. for _, i := range insutypes {
  2353. if i.Insutype == "390" {
  2354. is390 = 1
  2355. }
  2356. if i.Insutype == "310" {
  2357. is310 = 1
  2358. }
  2359. }
  2360. }
  2361. if is390 == 1 {
  2362. insutype = "390"
  2363. }
  2364. if is310 == 1 {
  2365. insutype = "310"
  2366. }
  2367. if len(insutypes) == 0 {
  2368. insutype = "310"
  2369. }
  2370. c.ServeSuccessJSON(map[string]interface{}{
  2371. "patient": patient,
  2372. "number": basNumber,
  2373. "insutype": insutype,
  2374. })
  2375. }
  2376. } else {
  2377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2378. return
  2379. }
  2380. } else {
  2381. if initFlag == 0 {
  2382. c.TestGetBasBaseInit()
  2383. }
  2384. basStr := c.GetBasBaseInfo()
  2385. if len(basStr) == 0 {
  2386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2387. return
  2388. }
  2389. fmt.Println(basStr)
  2390. bas := strings.Split(basStr, "|")
  2391. basNumber := bas[1]
  2392. fmt.Println(basNumber)
  2393. card_sn := bas[3]
  2394. fmt.Println(card_sn)
  2395. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2396. var dat map[string]interface{}
  2397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2398. fmt.Println(dat)
  2399. } else {
  2400. fmt.Println(err)
  2401. }
  2402. userJSONBytes, _ := json.Marshal(dat)
  2403. var res ResultTwo
  2404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2405. utils.ErrorLog("解析失败:%v", err)
  2406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2407. return
  2408. }
  2409. if res.Infcode == 0 {
  2410. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2411. if err == gorm.ErrRecordNotFound {
  2412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2413. return
  2414. } else if err != nil {
  2415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2416. return
  2417. } else {
  2418. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2419. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2420. infoStr := string(Iinfos)
  2421. idetinfoStr := string(Idetinfos)
  2422. psn := &models.HisPsn{
  2423. PsnNo: res.Output.Baseinfo.PsnNo,
  2424. Age: res.Output.Baseinfo.Age,
  2425. PatientId: patient.ID,
  2426. Certno: res.Output.Baseinfo.Certno,
  2427. Brdy: res.Output.Baseinfo.Brdy,
  2428. Gend: res.Output.Baseinfo.Gend,
  2429. Naty: res.Output.Baseinfo.Naty,
  2430. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2431. PsnName: res.Output.Baseinfo.PsnName,
  2432. Idetinfo: idetinfoStr,
  2433. Insuinfo: infoStr,
  2434. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2435. CardInfo: basStr,
  2436. VerifyNumber: "",
  2437. }
  2438. service.CreateHisPsn(psn)
  2439. c.ServeSuccessJSON(map[string]interface{}{
  2440. "patient": patient,
  2441. "number": basNumber,
  2442. })
  2443. }
  2444. } else {
  2445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2446. return
  2447. }
  2448. break
  2449. }
  2450. case 2:
  2451. if miConfig.MdtrtareaAdmvs == "430800" {
  2452. if initFlag == 0 {
  2453. c.TestGetHnBasBaseInit()
  2454. }
  2455. SFZStr := c.GetSFZBaseInfo()
  2456. if len(SFZStr) == 0 {
  2457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2458. return
  2459. }
  2460. fmt.Println(SFZStr)
  2461. id_card_str := strings.Split(SFZStr, "^")
  2462. card_no := id_card_str[0]
  2463. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  2464. //name := id_card_str[1]
  2465. //name = ConvertToString(name, "gbk", "utf-8")
  2466. 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)
  2467. var dat map[string]interface{}
  2468. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2469. fmt.Println(dat)
  2470. } else {
  2471. fmt.Println(err)
  2472. }
  2473. userJSONBytes, _ := json.Marshal(dat)
  2474. var res ResultTwo
  2475. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2476. utils.ErrorLog("解析失败:%v", err)
  2477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2478. return
  2479. }
  2480. if res.Infcode == 0 {
  2481. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  2482. if err == gorm.ErrRecordNotFound {
  2483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2484. return
  2485. } else if err != nil {
  2486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2487. return
  2488. } else {
  2489. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2490. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2491. infoStr := string(Iinfos)
  2492. idetinfoStr := string(Idetinfos)
  2493. psn := &models.HisPsn{
  2494. PsnNo: res.Output.Baseinfo.PsnNo,
  2495. Age: res.Output.Baseinfo.Age,
  2496. PatientId: patient.ID,
  2497. Certno: res.Output.Baseinfo.Certno,
  2498. Brdy: res.Output.Baseinfo.Brdy,
  2499. Gend: res.Output.Baseinfo.Gend,
  2500. Naty: res.Output.Baseinfo.Naty,
  2501. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2502. PsnName: res.Output.Baseinfo.PsnName,
  2503. Idetinfo: idetinfoStr,
  2504. Insuinfo: infoStr,
  2505. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2506. CardInfo: SFZStr,
  2507. VerifyNumber: "",
  2508. }
  2509. service.CreateHisPsn(psn)
  2510. var rf []*ResultFive
  2511. json.Unmarshal([]byte(infoStr), &rf)
  2512. var insutypes []*ResultFive
  2513. var insutype string
  2514. var is390 int = 0
  2515. var is310 int = 0
  2516. for _, item := range rf {
  2517. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2518. insutypes = append(insutypes, item)
  2519. }
  2520. }
  2521. if len(insutypes) == 1 {
  2522. insutype = insutypes[0].Insutype
  2523. } else {
  2524. for _, i := range insutypes {
  2525. if i.Insutype == "390" {
  2526. is390 = 1
  2527. }
  2528. if i.Insutype == "310" {
  2529. is310 = 1
  2530. }
  2531. }
  2532. }
  2533. if is390 == 1 {
  2534. insutype = "390"
  2535. }
  2536. if is310 == 1 {
  2537. insutype = "310"
  2538. }
  2539. if len(insutypes) == 0 {
  2540. insutype = "310"
  2541. }
  2542. c.ServeSuccessJSON(map[string]interface{}{
  2543. "patient": patient,
  2544. "number": card_no,
  2545. "insutype": insutype,
  2546. })
  2547. }
  2548. } else {
  2549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2550. return
  2551. }
  2552. } else {
  2553. SFZStr := c.GetSFZBaseInfo()
  2554. id_card_str := strings.Split(SFZStr, "^")
  2555. id_card_number := id_card_str[0]
  2556. card_sn := ""
  2557. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2558. var dat map[string]interface{}
  2559. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2560. fmt.Println(dat)
  2561. } else {
  2562. fmt.Println(err)
  2563. }
  2564. userJSONBytes, _ := json.Marshal(dat)
  2565. var res ResultTwo
  2566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2567. utils.ErrorLog("解析失败:%v", err)
  2568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2569. return
  2570. }
  2571. if res.Infcode == 0 {
  2572. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  2573. if err == gorm.ErrRecordNotFound {
  2574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2575. return
  2576. } else if err != nil {
  2577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2578. return
  2579. } else {
  2580. c.ServeSuccessJSON(map[string]interface{}{
  2581. "patient": patient,
  2582. "number": id_card_number,
  2583. })
  2584. }
  2585. } else {
  2586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2587. return
  2588. }
  2589. }
  2590. break
  2591. case 3:
  2592. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2593. var api string
  2594. if miConfig.MdtrtareaAdmvs == "320921" {
  2595. 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 +
  2596. "&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
  2597. fmt.Println(api)
  2598. } else {
  2599. 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 +
  2600. "&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)
  2601. }
  2602. resp, requestErr := http.Get(api)
  2603. if requestErr != nil {
  2604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2605. return
  2606. }
  2607. body, ioErr := ioutil.ReadAll(resp.Body)
  2608. if ioErr != nil {
  2609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2611. return
  2612. }
  2613. var respJSON map[string]interface{}
  2614. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2617. return
  2618. }
  2619. var status string
  2620. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2621. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2622. var token string
  2623. var res ResultTwo //1101结果
  2624. var res10265 ResultTwo10265 //1101结果
  2625. var card_info string //卡信息
  2626. var busi_card_info string
  2627. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2628. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2629. if status == "0" { //读卡成功
  2630. if card_type == "1" {
  2631. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2632. result, _ := json.Marshal(respJSON)
  2633. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2634. utils.ErrorLog("解析失败:%v", err)
  2635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2636. return
  2637. }
  2638. res.ErrMsg = res10265.ErrMsg
  2639. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2640. res.Infcode = infocode
  2641. res.Output = res10265.Output
  2642. res.InfRefmsgid = res10265.InfRefmsgid
  2643. } else {
  2644. //var card_info string //卡信息
  2645. //var busi_card_info string
  2646. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2647. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2648. //fmt.Println(card_info)
  2649. //fmt.Println(busi_card_info)
  2650. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2651. result, _ := json.Marshal(respJSON)
  2652. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2653. utils.ErrorLog("解析失败:%v", err)
  2654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2655. return
  2656. }
  2657. res.ErrMsg = res10265.ErrMsg
  2658. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2659. res.Infcode = infocode
  2660. res.Output = res10265.Output
  2661. res.InfRefmsgid = res10265.InfRefmsgid
  2662. }
  2663. if res.Infcode == 0 {
  2664. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2665. if err == gorm.ErrRecordNotFound {
  2666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2667. return
  2668. } else if err != nil {
  2669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2670. return
  2671. } else {
  2672. if card_type == "1" {
  2673. bas := strings.Split(card_info, "|")
  2674. basNumber := bas[2]
  2675. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2676. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2677. infoStr := string(Iinfos)
  2678. idetinfoStr := string(Idetinfos)
  2679. psn := &models.HisPsn{
  2680. PsnNo: res.Output.Baseinfo.PsnNo,
  2681. Age: res.Output.Baseinfo.Age,
  2682. PatientId: patient.ID,
  2683. Certno: res.Output.Baseinfo.Certno,
  2684. Brdy: res.Output.Baseinfo.Brdy,
  2685. Gend: res.Output.Baseinfo.Gend,
  2686. Naty: res.Output.Baseinfo.Naty,
  2687. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2688. PsnName: res.Output.Baseinfo.PsnName,
  2689. Idetinfo: idetinfoStr,
  2690. Insuinfo: infoStr,
  2691. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2692. CardInfo: card_info,
  2693. VerifyNumber: busi_card_info,
  2694. }
  2695. service.CreateHisPsn(psn)
  2696. c.ServeSuccessJSON(map[string]interface{}{
  2697. "patient": patient,
  2698. "number": basNumber,
  2699. })
  2700. } else {
  2701. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2702. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2703. infoStr := string(Iinfos)
  2704. idetinfoStr := string(Idetinfos)
  2705. psn := &models.HisPsn{
  2706. PsnNo: res.Output.Baseinfo.PsnNo,
  2707. Age: res.Output.Baseinfo.Age,
  2708. PatientId: patient.ID,
  2709. Certno: res.Output.Baseinfo.Certno,
  2710. Brdy: res.Output.Baseinfo.Brdy,
  2711. Gend: res.Output.Baseinfo.Gend,
  2712. Naty: res.Output.Baseinfo.Naty,
  2713. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2714. PsnName: res.Output.Baseinfo.PsnName,
  2715. Idetinfo: idetinfoStr,
  2716. Insuinfo: infoStr,
  2717. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2718. CardInfo: card_info,
  2719. VerifyNumber: token,
  2720. }
  2721. service.CreateHisPsn(psn)
  2722. var rf []*ResultFive
  2723. json.Unmarshal([]byte(infoStr), &rf)
  2724. var insutypes []*ResultFive
  2725. var insutype string
  2726. var is390 int = 0
  2727. var is310 int = 0
  2728. for _, item := range rf {
  2729. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2730. insutypes = append(insutypes, item)
  2731. }
  2732. }
  2733. if len(insutypes) == 1 {
  2734. insutype = insutypes[0].Insutype
  2735. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2736. } else {
  2737. for _, i := range insutypes {
  2738. if i.Insutype == "390" {
  2739. is390 = 1
  2740. }
  2741. if i.Insutype == "310" {
  2742. is310 = 1
  2743. }
  2744. }
  2745. }
  2746. if is390 == 1 {
  2747. insutype = "390"
  2748. }
  2749. if is310 == 1 {
  2750. insutype = "310"
  2751. }
  2752. if len(insutypes) == 0 {
  2753. insutype = "310"
  2754. }
  2755. c.ServeSuccessJSON(map[string]interface{}{
  2756. "patient": patient,
  2757. "number": token,
  2758. "insutype": insutype,
  2759. })
  2760. }
  2761. }
  2762. } else {
  2763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2764. return
  2765. }
  2766. } else { //读卡失败
  2767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2768. return
  2769. }
  2770. }
  2771. break
  2772. case 4:
  2773. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2774. var api string
  2775. if miConfig.MdtrtareaAdmvs == "320921" {
  2776. 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 +
  2777. "&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
  2778. fmt.Println(api)
  2779. } else {
  2780. 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 +
  2781. "&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)
  2782. }
  2783. resp, requestErr := http.Get(api)
  2784. if requestErr != nil {
  2785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2786. return
  2787. }
  2788. body, ioErr := ioutil.ReadAll(resp.Body)
  2789. if ioErr != nil {
  2790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2792. return
  2793. }
  2794. var respJSON map[string]interface{}
  2795. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2798. return
  2799. }
  2800. var status string
  2801. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2802. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2803. var token string
  2804. var res ResultTwo //1101结果
  2805. var res10265 ResultTwo10265 //1101结果
  2806. if status == "0" { //读卡成功
  2807. var card_info string //卡信息
  2808. var busi_card_info string
  2809. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2810. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2811. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2812. fmt.Println(card_info)
  2813. fmt.Println(busi_card_info)
  2814. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2815. result, _ := json.Marshal(respJSON)
  2816. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2817. utils.ErrorLog("解析失败:%v", err)
  2818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2819. return
  2820. }
  2821. res.ErrMsg = res10265.ErrMsg
  2822. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2823. res.Infcode = infocode
  2824. res.Output = res10265.Output
  2825. res.InfRefmsgid = res10265.InfRefmsgid
  2826. if res.Infcode == 0 {
  2827. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2828. if err == gorm.ErrRecordNotFound {
  2829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2830. return
  2831. } else if err != nil {
  2832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2833. return
  2834. } else {
  2835. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2836. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2837. infoStr := string(Iinfos)
  2838. idetinfoStr := string(Idetinfos)
  2839. psn := &models.HisPsn{
  2840. PsnNo: res.Output.Baseinfo.PsnNo,
  2841. Age: res.Output.Baseinfo.Age,
  2842. PatientId: patient.ID,
  2843. Certno: res.Output.Baseinfo.Certno,
  2844. Brdy: res.Output.Baseinfo.Brdy,
  2845. Gend: res.Output.Baseinfo.Gend,
  2846. Naty: res.Output.Baseinfo.Naty,
  2847. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2848. PsnName: res.Output.Baseinfo.PsnName,
  2849. Idetinfo: idetinfoStr,
  2850. Insuinfo: infoStr,
  2851. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2852. CardInfo: card_info,
  2853. VerifyNumber: token,
  2854. }
  2855. var rf []*ResultFive
  2856. json.Unmarshal([]byte(infoStr), &rf)
  2857. var insutypes []*ResultFive
  2858. var insutype string
  2859. var is390 int = 0
  2860. var is310 int = 0
  2861. for _, item := range rf {
  2862. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2863. insutypes = append(insutypes, item)
  2864. }
  2865. }
  2866. if len(insutypes) == 1 {
  2867. insutype = insutypes[0].Insutype
  2868. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2869. } else {
  2870. for _, i := range insutypes {
  2871. if i.Insutype == "390" {
  2872. is390 = 1
  2873. }
  2874. if i.Insutype == "310" {
  2875. is310 = 1
  2876. }
  2877. }
  2878. }
  2879. if is390 == 1 {
  2880. insutype = "390"
  2881. }
  2882. if is310 == 1 {
  2883. insutype = "310"
  2884. }
  2885. if len(insutypes) == 0 {
  2886. insutype = "310"
  2887. }
  2888. service.CreateHisPsn(psn)
  2889. c.ServeSuccessJSON(map[string]interface{}{
  2890. "patient": patient,
  2891. "number": token,
  2892. "insutype": insutype,
  2893. })
  2894. }
  2895. } else {
  2896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2897. return
  2898. }
  2899. } else { //读卡失败
  2900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2901. return
  2902. }
  2903. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  2904. if initFlag == 0 {
  2905. c.TestGetBasBaseInit()
  2906. }
  2907. token := c.GetEleBaseInfo()
  2908. token = Remove0000(token)
  2909. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  2910. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2911. //
  2912. var res ResultTwo
  2913. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2914. utils.ErrorLog("解析失败:%v", err)
  2915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2916. return
  2917. }
  2918. if res.Infcode == 0 {
  2919. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2920. if err == gorm.ErrRecordNotFound {
  2921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2922. return
  2923. } else if err != nil {
  2924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2925. return
  2926. } else {
  2927. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2928. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2929. infoStr := string(Iinfos)
  2930. idetinfoStr := string(Idetinfos)
  2931. psn := &models.HisPsn{
  2932. PsnNo: res.Output.Baseinfo.PsnNo,
  2933. Age: res.Output.Baseinfo.Age,
  2934. PatientId: patient.ID,
  2935. Certno: res.Output.Baseinfo.Certno,
  2936. Brdy: res.Output.Baseinfo.Brdy,
  2937. Gend: res.Output.Baseinfo.Gend,
  2938. Naty: res.Output.Baseinfo.Naty,
  2939. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2940. PsnName: res.Output.Baseinfo.PsnName,
  2941. Idetinfo: idetinfoStr,
  2942. Insuinfo: infoStr,
  2943. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2944. CardInfo: "",
  2945. VerifyNumber: token,
  2946. }
  2947. service.CreateHisPsn(psn)
  2948. c.ServeSuccessJSON(map[string]interface{}{
  2949. "patient": patient,
  2950. "number": token,
  2951. })
  2952. }
  2953. } else {
  2954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2955. return
  2956. }
  2957. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2958. if initFlag == 0 {
  2959. c.TestGetBasBaseInit()
  2960. }
  2961. token := c.GetEleBaseInfo()
  2962. token = Remove0000(token)
  2963. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", "", "")
  2964. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2965. //
  2966. var res ResultTwo
  2967. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2968. utils.ErrorLog("解析失败:%v", err)
  2969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2970. return
  2971. }
  2972. if res.Infcode == 0 {
  2973. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2974. if err == gorm.ErrRecordNotFound {
  2975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2976. return
  2977. } else if err != nil {
  2978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2979. return
  2980. } else {
  2981. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2982. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2983. infoStr := string(Iinfos)
  2984. idetinfoStr := string(Idetinfos)
  2985. psn := &models.HisPsn{
  2986. PsnNo: res.Output.Baseinfo.PsnNo,
  2987. Age: res.Output.Baseinfo.Age,
  2988. PatientId: patient.ID,
  2989. Certno: res.Output.Baseinfo.Certno,
  2990. Brdy: res.Output.Baseinfo.Brdy,
  2991. Gend: res.Output.Baseinfo.Gend,
  2992. Naty: res.Output.Baseinfo.Naty,
  2993. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2994. PsnName: res.Output.Baseinfo.PsnName,
  2995. Idetinfo: idetinfoStr,
  2996. Insuinfo: infoStr,
  2997. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2998. CardInfo: "",
  2999. VerifyNumber: token,
  3000. }
  3001. service.CreateHisPsn(psn)
  3002. c.ServeSuccessJSON(map[string]interface{}{
  3003. "patient": patient,
  3004. "number": token,
  3005. })
  3006. }
  3007. } else {
  3008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3009. return
  3010. }
  3011. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3012. //if initFlag == 0 {
  3013. c.TestGetJiangXiBasBaseInit()
  3014. //}
  3015. //if initEleFlag == 0 {
  3016. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3017. //}
  3018. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3019. type ELeData struct {
  3020. Data struct {
  3021. IdNo string `json:"idNo"`
  3022. IdType string `json:"idType"`
  3023. UserName string `json:"userName"`
  3024. EcToken string `json:"ecToken"`
  3025. InsuOrg string `json:"insuOrg"`
  3026. Gender string `json:"gender"`
  3027. Birthday string `json:"birthday"`
  3028. Nationality string `json:"nationality"`
  3029. Email string `json:"email"`
  3030. Extra string `json:"extra"`
  3031. } `json:"data"`
  3032. Code int `json:"code"`
  3033. Message string `json:"message"`
  3034. }
  3035. var ele ELeData
  3036. err := json.Unmarshal([]byte(json_result), &ele)
  3037. if err != nil {
  3038. utils.ErrorLog("解析失败:%v", err)
  3039. }
  3040. token := ele.Data.EcToken
  3041. token = Remove0000(token)
  3042. 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)
  3043. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3044. var res ResultTwo
  3045. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3046. utils.ErrorLog("解析失败:%v", err)
  3047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3048. return
  3049. }
  3050. if res.Infcode == 0 {
  3051. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3052. if err == gorm.ErrRecordNotFound {
  3053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3054. return
  3055. } else if err != nil {
  3056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3057. return
  3058. } else {
  3059. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3060. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3061. infoStr := string(Iinfos)
  3062. idetinfoStr := string(Idetinfos)
  3063. psn := &models.HisPsn{
  3064. PsnNo: res.Output.Baseinfo.PsnNo,
  3065. Age: res.Output.Baseinfo.Age,
  3066. PatientId: patient.ID,
  3067. Certno: res.Output.Baseinfo.Certno,
  3068. Brdy: res.Output.Baseinfo.Brdy,
  3069. Gend: res.Output.Baseinfo.Gend,
  3070. Naty: res.Output.Baseinfo.Naty,
  3071. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3072. PsnName: res.Output.Baseinfo.PsnName,
  3073. Idetinfo: idetinfoStr,
  3074. Insuinfo: infoStr,
  3075. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3076. CardInfo: "",
  3077. VerifyNumber: token,
  3078. }
  3079. service.CreateHisPsn(psn)
  3080. var rf []*ResultFive
  3081. json.Unmarshal([]byte(infoStr), &rf)
  3082. var insutypes []*ResultFive
  3083. var insutype string
  3084. var is390 int = 0
  3085. var is310 int = 0
  3086. for _, item := range rf {
  3087. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3088. insutypes = append(insutypes, item)
  3089. }
  3090. }
  3091. if len(insutypes) == 1 {
  3092. insutype = insutypes[0].Insutype
  3093. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3094. } else {
  3095. for _, i := range insutypes {
  3096. if i.Insutype == "390" {
  3097. is390 = 1
  3098. }
  3099. if i.Insutype == "310" {
  3100. is310 = 1
  3101. }
  3102. }
  3103. }
  3104. if is390 == 1 {
  3105. insutype = "390"
  3106. }
  3107. if is310 == 1 {
  3108. insutype = "310"
  3109. }
  3110. if len(insutypes) == 0 {
  3111. insutype = "310"
  3112. }
  3113. c.ServeSuccessJSON(map[string]interface{}{
  3114. "patient": patient,
  3115. "number": token,
  3116. "insutype": insutype,
  3117. })
  3118. }
  3119. } else {
  3120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3121. return
  3122. }
  3123. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3124. //if initFlag == 0 {
  3125. c.TestGetJiangXiBasBaseInit()
  3126. //}
  3127. //if initEleFlag == 0 {
  3128. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3129. //}
  3130. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3131. type ELeData struct {
  3132. Data struct {
  3133. IdNo string `json:"idNo"`
  3134. IdType string `json:"idType"`
  3135. UserName string `json:"userName"`
  3136. EcToken string `json:"ecToken"`
  3137. InsuOrg string `json:"insuOrg"`
  3138. Gender string `json:"gender"`
  3139. Birthday string `json:"birthday"`
  3140. Nationality string `json:"nationality"`
  3141. Email string `json:"email"`
  3142. Extra string `json:"extra"`
  3143. } `json:"data"`
  3144. Code int `json:"code"`
  3145. Message string `json:"message"`
  3146. }
  3147. var ele ELeData
  3148. err := json.Unmarshal([]byte(json_result), &ele)
  3149. if err != nil {
  3150. utils.ErrorLog("解析失败:%v", err)
  3151. }
  3152. token := ele.Data.EcToken
  3153. token = Remove0000(token)
  3154. 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)
  3155. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3156. var res ResultTwo
  3157. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3158. utils.ErrorLog("解析失败:%v", err)
  3159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3160. return
  3161. }
  3162. if res.Infcode == 0 {
  3163. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3164. if err == gorm.ErrRecordNotFound {
  3165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3166. return
  3167. } else if err != nil {
  3168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3169. return
  3170. } else {
  3171. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3172. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3173. infoStr := string(Iinfos)
  3174. idetinfoStr := string(Idetinfos)
  3175. psn := &models.HisPsn{
  3176. PsnNo: res.Output.Baseinfo.PsnNo,
  3177. Age: res.Output.Baseinfo.Age,
  3178. PatientId: patient.ID,
  3179. Certno: res.Output.Baseinfo.Certno,
  3180. Brdy: res.Output.Baseinfo.Brdy,
  3181. Gend: res.Output.Baseinfo.Gend,
  3182. Naty: res.Output.Baseinfo.Naty,
  3183. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3184. PsnName: res.Output.Baseinfo.PsnName,
  3185. Idetinfo: idetinfoStr,
  3186. Insuinfo: infoStr,
  3187. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3188. CardInfo: "",
  3189. VerifyNumber: token,
  3190. }
  3191. service.CreateHisPsn(psn)
  3192. var rf []*ResultFive
  3193. json.Unmarshal([]byte(infoStr), &rf)
  3194. var insutypes []*ResultFive
  3195. var insutype string
  3196. var is390 int = 0
  3197. var is310 int = 0
  3198. for _, item := range rf {
  3199. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3200. insutypes = append(insutypes, item)
  3201. }
  3202. }
  3203. if len(insutypes) == 1 {
  3204. insutype = insutypes[0].Insutype
  3205. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3206. } else {
  3207. for _, i := range insutypes {
  3208. if i.Insutype == "390" {
  3209. is390 = 1
  3210. }
  3211. if i.Insutype == "310" {
  3212. is310 = 1
  3213. }
  3214. }
  3215. }
  3216. if is390 == 1 {
  3217. insutype = "390"
  3218. }
  3219. if is310 == 1 {
  3220. insutype = "310"
  3221. }
  3222. if len(insutypes) == 0 {
  3223. insutype = "310"
  3224. }
  3225. c.ServeSuccessJSON(map[string]interface{}{
  3226. "patient": patient,
  3227. "number": token,
  3228. "insutype": insutype,
  3229. })
  3230. }
  3231. } else {
  3232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3233. return
  3234. }
  3235. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3236. type ELeData struct {
  3237. Code string `json:"code"`
  3238. Data struct {
  3239. Aac002 string `json:"aac002"`
  3240. Aaz500 string `json:"aaz500"`
  3241. ActCardNo string `json:"actCardNo"`
  3242. Bab520 string `json:"bab520"`
  3243. Bkz543 string `json:"bkz543"`
  3244. BusinessType string `json:"businessType"`
  3245. CertfCodg string `json:"certfCodg"`
  3246. EcIndexNo string `json:"ecIndexNo"`
  3247. EcToken string `json:"ecToken"`
  3248. ID0000 string `json:"id0000"`
  3249. IDNo string `json:"idNo"`
  3250. IDType string `json:"idType"`
  3251. Idcode string `json:"idcode"`
  3252. IdentityToken string `json:"identity_token"`
  3253. InsuOrg string `json:"insuOrg"`
  3254. OfficeID string `json:"officeId"`
  3255. OfficeName string `json:"officeName"`
  3256. OperatorID string `json:"operatorId"`
  3257. OperatorName string `json:"operatorName"`
  3258. OrgID string `json:"orgId"`
  3259. UserName string `json:"userName"`
  3260. } `json:"data"`
  3261. Infno interface{} `json:"infno"`
  3262. Message string `json:"message"`
  3263. OrgID string `json:"orgId"`
  3264. TransType string `json:"transType"`
  3265. }
  3266. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  3267. outPutInfo = Remove0000(outPutInfo)
  3268. if len(outPutInfo) > 0 {
  3269. var ele ELeData
  3270. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3271. if err != nil {
  3272. utils.ErrorLog("解析失败:%v", err)
  3273. }
  3274. token := ele.Data.EcToken
  3275. fmt.Println(inputInfo)
  3276. fmt.Println(outPutInfo)
  3277. result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IDNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, "", 1, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token, ele.Data.UserName)
  3278. saveLog(result, requestLog, "1101", "获取人员信息")
  3279. var dat map[string]interface{}
  3280. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3281. fmt.Println(dat)
  3282. } else {
  3283. fmt.Println(err)
  3284. }
  3285. userJSONBytes, _ := json.Marshal(dat)
  3286. var res ResultTwo
  3287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3288. utils.ErrorLog("解析失败:%v", err)
  3289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3290. return
  3291. }
  3292. res.ErrMsg = errMsgLog
  3293. if res.Infcode == 0 {
  3294. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  3295. if err == gorm.ErrRecordNotFound {
  3296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3297. return
  3298. } else if err != nil {
  3299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3300. return
  3301. } else {
  3302. fmt.Println(res)
  3303. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3304. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3305. infoStr := string(Iinfos)
  3306. idetinfoStr := string(Idetinfos)
  3307. psn := &models.HisPsn{
  3308. PsnNo: res.Output.Baseinfo.PsnNo,
  3309. Age: res.Output.Baseinfo.Age,
  3310. PatientId: patient.ID,
  3311. Certno: res.Output.Baseinfo.Certno,
  3312. Brdy: res.Output.Baseinfo.Brdy,
  3313. Gend: res.Output.Baseinfo.Gend,
  3314. Naty: res.Output.Baseinfo.Naty,
  3315. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3316. PsnName: res.Output.Baseinfo.PsnName,
  3317. Idetinfo: idetinfoStr,
  3318. Insuinfo: infoStr,
  3319. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3320. CardInfo: outPutInfo,
  3321. VerifyNumber: token,
  3322. }
  3323. service.CreateHisPsn(psn)
  3324. var rf []*ResultFive
  3325. json.Unmarshal([]byte(infoStr), &rf)
  3326. var insutypes []*ResultFive
  3327. var insutype string
  3328. var is390 int = 0
  3329. var is310 int = 0
  3330. for _, item := range rf {
  3331. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3332. insutypes = append(insutypes, item)
  3333. }
  3334. }
  3335. if len(insutypes) == 1 {
  3336. insutype = insutypes[0].Insutype
  3337. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3338. } else {
  3339. for _, i := range insutypes {
  3340. if i.Insutype == "390" {
  3341. is390 = 1
  3342. }
  3343. if i.Insutype == "310" {
  3344. is310 = 1
  3345. }
  3346. }
  3347. }
  3348. if is390 == 1 {
  3349. insutype = "390"
  3350. }
  3351. if is310 == 1 {
  3352. insutype = "310"
  3353. }
  3354. if len(insutypes) == 0 {
  3355. insutype = "310"
  3356. }
  3357. c.ServeSuccessJSON(map[string]interface{}{
  3358. "patient": patient,
  3359. "number": token,
  3360. "insutype": insutype,
  3361. })
  3362. }
  3363. } else {
  3364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3365. return
  3366. }
  3367. }
  3368. }
  3369. break
  3370. }
  3371. }
  3372. var initFlag int64 = 0
  3373. var initEleFlag int64 = 0
  3374. func (c *HisApiController) TestGetBasBaseInit() {
  3375. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3376. Iinit := DllDef.MustFindProc("Init")
  3377. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3378. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  3379. if ret != 0 {
  3380. fmt.Println("SSCard的报错原因:", err)
  3381. fmt.Println("SSCard的运算结果为:", ret)
  3382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3383. return
  3384. }
  3385. result := int(ret)
  3386. fmt.Println("SSCard的运算结果为1:", result)
  3387. initFlag = 1
  3388. return
  3389. }
  3390. func (c *HisApiController) HandleJiangXiReadCard() {
  3391. fmt.Println("~~~~~~")
  3392. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3393. admin_user_id, _ := c.GetInt64("admin_user_id")
  3394. id_card_type, _ := c.GetInt64("id_card_type")
  3395. //certificates, _ := c.GetInt64("certificates")
  3396. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3397. if initFlag == 0 {
  3398. c.TestGetJiangXiBasBaseInit()
  3399. }
  3400. basStr := c.GetBasBaseInfo()
  3401. if len(basStr) == 0 {
  3402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3403. return
  3404. }
  3405. fmt.Println(basStr)
  3406. bas := strings.Split(basStr, "|")
  3407. basNumber := bas[1]
  3408. fmt.Println(basNumber)
  3409. card_sn := bas[3]
  3410. fmt.Println(card_sn)
  3411. 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, "")
  3412. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3413. var dat map[string]interface{}
  3414. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3415. fmt.Println(dat)
  3416. } else {
  3417. fmt.Println(err)
  3418. }
  3419. userJSONBytes, _ := json.Marshal(dat)
  3420. var res ResultTwo
  3421. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3422. utils.ErrorLog("解析失败:%v", err)
  3423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3424. return
  3425. }
  3426. if res.Infcode == 0 {
  3427. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3428. if err == gorm.ErrRecordNotFound {
  3429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3430. return
  3431. } else if err != nil {
  3432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3433. return
  3434. } else {
  3435. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3436. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3437. infoStr := string(Iinfos)
  3438. idetinfoStr := string(Idetinfos)
  3439. psn := &models.HisPsn{
  3440. PsnNo: res.Output.Baseinfo.PsnNo,
  3441. Age: res.Output.Baseinfo.Age,
  3442. PatientId: patient.ID,
  3443. Certno: res.Output.Baseinfo.Certno,
  3444. Brdy: res.Output.Baseinfo.Brdy,
  3445. Gend: res.Output.Baseinfo.Gend,
  3446. Naty: res.Output.Baseinfo.Naty,
  3447. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3448. PsnName: res.Output.Baseinfo.PsnName,
  3449. Idetinfo: idetinfoStr,
  3450. Insuinfo: infoStr,
  3451. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3452. CardInfo: basStr,
  3453. VerifyNumber: "",
  3454. }
  3455. service.CreateHisPsn(psn)
  3456. c.ServeSuccessJSON(map[string]interface{}{
  3457. "patient": patient,
  3458. "number": basNumber,
  3459. })
  3460. }
  3461. } else {
  3462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3463. return
  3464. }
  3465. }
  3466. func (c *HisApiController) TestGetHnBasBaseInit() {
  3467. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3468. Iinit := DllDef.MustFindProc("Init")
  3469. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3470. //http://10.77.211.236/CSB/hsa-fsi-1303
  3471. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  3472. if ret != 0 {
  3473. fmt.Println("SSCard的报错原因:", err)
  3474. fmt.Println("SSCard的运算结果为:", ret)
  3475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3476. return
  3477. }
  3478. result := int(ret)
  3479. fmt.Println("SSCard的运算结果为1:", result)
  3480. initFlag = 1
  3481. return
  3482. }
  3483. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  3484. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3485. Iinit := DllDef.MustFindProc("Init")
  3486. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3487. //http://10.77.211.236/CSB/hsa-fsi-1303
  3488. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  3489. if ret != 0 {
  3490. fmt.Println("SSCard的报错原因:", err)
  3491. fmt.Println("SSCard的运算结果为:", ret)
  3492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3493. return
  3494. }
  3495. result := int(ret)
  3496. fmt.Println("SSCard的运算结果为1:", result)
  3497. initFlag = 1
  3498. return
  3499. }
  3500. func (c *HisApiController) GetSFZBaseInfo() string {
  3501. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3502. readCard := DllDef.MustFindProc("ReadSFZ")
  3503. if readCard == nil {
  3504. fmt.Println("readcard is nil")
  3505. readCard = DllDef.MustFindProc("ReadSFZ")
  3506. }
  3507. str := make([]byte, 8096)
  3508. str1 := make([]byte, 8096)
  3509. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  3510. fmt.Println(r)
  3511. return Remove0000(string(str))
  3512. }
  3513. func (c *HisApiController) GetEleBaseInfo() string {
  3514. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3515. readCard := DllDef.MustFindProc("GetQRBase")
  3516. fmt.Println(readCard)
  3517. if readCard == nil {
  3518. fmt.Println("readcard is nil")
  3519. readCard = DllDef.MustFindProc("GetQRBase")
  3520. }
  3521. str := make([]byte, 1024)
  3522. str1 := make([]byte, 1024)
  3523. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3524. fmt.Println(ret2)
  3525. fmt.Println(string(str1))
  3526. fmt.Println(string(str))
  3527. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3528. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3529. if ret2 != 0 {
  3530. return ""
  3531. }
  3532. return string(str)
  3533. }
  3534. func GetJxEleBaseInfo(org_id int64) string {
  3535. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3536. readCard := DllDef.MustFindProc("NationEcTrans")
  3537. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3538. if readCard == nil {
  3539. fmt.Println("readcard is nil")
  3540. readCard = DllDef.MustFindProc("NationEcTrans")
  3541. }
  3542. str1 := make([]byte, 1024)
  3543. data := make(map[string]interface{})
  3544. inputData := make(map[string]interface{})
  3545. inputData["orgId"] = miConfig.Code
  3546. inputData["businessType"] = "01101"
  3547. inputData["operatorId"] = "test001"
  3548. inputData["operatorName"] = "cn"
  3549. inputData["officeId"] = "32760"
  3550. inputData["officeName"] = "waike"
  3551. inputData["deviceType"] = ""
  3552. data["data"] = inputData
  3553. data["transType"] = "ec.query"
  3554. data["extra "] = ""
  3555. data["orgId"] = miConfig.Code
  3556. bytesData, _ := json.Marshal(data)
  3557. //bytesData, _ := json.Marshal(data)
  3558. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3559. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3560. fmt.Println(ret2)
  3561. fmt.Println(string(str1))
  3562. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3563. if ret2 != 0 {
  3564. return ""
  3565. }
  3566. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3567. }
  3568. func GetJxEleBaseInitInfo(org_id int64) string {
  3569. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3570. readCard := DllDef.MustFindProc("NationEcTrans")
  3571. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3572. if readCard == nil {
  3573. fmt.Println("readcard is nil")
  3574. readCard = DllDef.MustFindProc("NationEcTrans")
  3575. }
  3576. str1 := make([]byte, 2048)
  3577. data := make(map[string]interface{})
  3578. inputData := make(map[string]interface{})
  3579. inputData["orgId"] = miConfig.Code
  3580. inputData["businessType"] = "01101"
  3581. inputData["operatorId"] = "1"
  3582. inputData["operatorName"] = "huangchuang"
  3583. inputData["officeId"] = "101"
  3584. inputData["officeName"] = "xuetou"
  3585. inputData["deviceType"] = ""
  3586. data["data"] = inputData
  3587. data["transType"] = "ec.query"
  3588. data["orgId"] = miConfig.Code
  3589. bytesData, _ := json.Marshal(data)
  3590. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3591. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3592. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  3593. fmt.Println(ret2)
  3594. fmt.Println(string(str1))
  3595. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3596. if ret2 != 0 {
  3597. return ""
  3598. }
  3599. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  3600. initEleFlag = 1
  3601. }
  3602. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3603. }
  3604. func (c *HisApiController) GetBasBaseInfo() string {
  3605. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3606. readCard := DllDef.MustFindProc("ReadCardBas")
  3607. if readCard == nil {
  3608. fmt.Println("readcard is nil")
  3609. readCard = DllDef.MustFindProc("ReadCardBas")
  3610. }
  3611. str := make([]byte, 1024)
  3612. str1 := make([]byte, 1024)
  3613. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3614. fmt.Println(string(str1))
  3615. fmt.Println(string(str))
  3616. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3617. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3618. if ret2 != 0 {
  3619. return ""
  3620. }
  3621. return string(str)
  3622. }
  3623. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  3624. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  3625. readCard := DllDef.MustFindProc("read_cardinfo")
  3626. if readCard == nil {
  3627. fmt.Println("readcard is nil")
  3628. readCard = DllDef.MustFindProc("read_cardinfo")
  3629. }
  3630. str := make([]byte, 1024) //卡号
  3631. str1 := make([]byte, 1024) //卡识别码
  3632. str2 := make([]byte, 1024) //身份证号
  3633. str3 := make([]byte, 1024) //姓名
  3634. str4 := make([]byte, 1024) //错误信息
  3635. 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])))
  3636. fmt.Println(string(str1))
  3637. fmt.Println(string(str))
  3638. fmt.Println(string(str2))
  3639. fmt.Println(string(str3))
  3640. fmt.Println(string(str4))
  3641. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3642. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3643. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  3644. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3645. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  3646. if ret2 != 0 {
  3647. return "", "", "", "", ""
  3648. }
  3649. return string(str), string(str1), string(str2), string(str3), string(str4)
  3650. }
  3651. type CustomFundPay struct {
  3652. FundPayType string `json:"fund_pay_type"`
  3653. FundPayamt float64 `json:"fund_payamt"`
  3654. }
  3655. func (c *HisApiController) GetSettleList() {
  3656. order_id, _ := c.GetInt64("order_id")
  3657. admin_user_id, _ := c.GetInt64("admin_user_id")
  3658. order, _ := service.GetHisOrderByIDTwo(order_id)
  3659. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3660. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3661. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3662. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3663. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3664. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3665. if order.ID == 0 {
  3666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3667. return
  3668. }
  3669. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  3670. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  3671. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  3672. fmt.Println(count)
  3673. var zero string
  3674. number := count + 1
  3675. if number >= 1000 {
  3676. zero = "0000" + strconv.FormatInt(number, 10)
  3677. } else if number >= 10000 {
  3678. zero = "000" + strconv.FormatInt(number, 10)
  3679. } else if number >= 100000 {
  3680. zero = "00" + strconv.FormatInt(number, 10)
  3681. } else if number >= 1000000 {
  3682. zero = "0" + strconv.FormatInt(number, 10)
  3683. } else {
  3684. zero = strconv.FormatInt(number, 10)
  3685. }
  3686. fmt.Println(zero)
  3687. struct4101 := service.Struct4101{
  3688. PsnNo: order.PsnNo,
  3689. MdtrtId: order.MdtrtId,
  3690. SetlId: order.SetlId,
  3691. PsnName: order.PsnName,
  3692. Gend: order.Gend,
  3693. Brdy: his.Brdy,
  3694. Age: his.Age,
  3695. Naty: order.Naty,
  3696. PatnCertType: "01",
  3697. Certno: order.Certno,
  3698. Prfs: "90",
  3699. ConerName: roles[0].UserName,
  3700. PatnRlts: "99",
  3701. ConerAddr: miConfig.OrgName,
  3702. ConerTel: admin.Mobile,
  3703. HiType: order.Insutype,
  3704. Insuplc: miConfig.InsuplcAdmdvs,
  3705. MaindiagFlag: "1",
  3706. BillCode: order.SetlId,
  3707. BillNo: order.SetlId,
  3708. BizSn: order.Number,
  3709. PsnSelfPay: order.PsnPartAmt,
  3710. PsnOwnPay: order.PsnPartAmt,
  3711. AcctPay: order.AcctPay,
  3712. PsnCashpay: order.PsnCashPay,
  3713. HiPaymtd: "1",
  3714. Hsorg: miConfig.InsuplcAdmdvs,
  3715. HsorgOpter: miConfig.InsuplcAdmdvs,
  3716. MedinsFillPsn: curRoles.UserName,
  3717. MedinsFillDept: depart.Name,
  3718. IptMedType: "2",
  3719. }
  3720. struct4101.SetlBegnDate = order.SetlTime
  3721. struct4101.SetlEndDate = order.SetlTime
  3722. time_arr := strings.Split(order.SetlTime, " ")
  3723. struct4101.AdmTime = time_arr[0]
  3724. struct4101.AdmEndTime = time_arr[0]
  3725. var rf []CustomFundPay
  3726. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3727. var tempFunPays []service.CustomStruct
  3728. for _, item := range rf {
  3729. var tempFunPay service.CustomStruct
  3730. tempFunPay.FundPayamt = item.FundPayamt
  3731. tempFunPay.FundPayType = item.FundPayType
  3732. tempFunPays = append(tempFunPays, tempFunPay)
  3733. }
  3734. struct4101.CustomStruct = tempFunPays
  3735. var tempDiaginfos []service.DiaginfoStructTwo
  3736. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3737. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3738. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3739. var config []*models.HisXtDiagnoseConfig
  3740. for _, item := range diagnosis_ids {
  3741. id, _ := strconv.ParseInt(item, 10, 64)
  3742. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3743. config = append(config, &diagnosisConfig)
  3744. }
  3745. for index, item := range config {
  3746. if index == 0 {
  3747. var tempDiaginfo service.DiaginfoStructTwo
  3748. tempDiaginfo.DiagCode = item.CountryCode
  3749. tempDiaginfo.DiagName = item.CountryContentName
  3750. tempDiaginfo.DiagType = "1"
  3751. tempDiaginfo.MaindiagFlag = "1"
  3752. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3753. } else {
  3754. var tempDiaginfo service.DiaginfoStructTwo
  3755. tempDiaginfo.DiagCode = item.CountryCode
  3756. tempDiaginfo.DiagName = item.CountryContentName
  3757. tempDiaginfo.DiagType = "2"
  3758. tempDiaginfo.MaindiagFlag = "0"
  3759. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3760. }
  3761. }
  3762. struct4101.Diseinfo = tempDiaginfos
  3763. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3764. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3765. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3766. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  3767. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  3768. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3769. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3770. var iteminfo service.IteminfoStruct
  3771. var bedCostTotal float64 = 0 //床位总费
  3772. var bedCostSelfTotal float64 = 0 //床位自费
  3773. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3774. var operationCostTotal float64 = 0 //手术费
  3775. var operationCostSelfTotal float64 = 0 //手术费
  3776. var operationCostPartSelfTotal float64 = 0 //手术费
  3777. var otherCostTotal float64 = 0 //其他费用
  3778. var otherCostSelfTotal float64 = 0 //其他费用
  3779. var otherCostPartSelfTotal float64 = 0 //其他费用
  3780. var materialCostTotal float64 = 0 //材料费
  3781. var materialCostSelfTotal float64 = 0 //材料费
  3782. var materialCostPartSelfTotal float64 = 0 //材料费
  3783. var westernMedicineCostTotal float64 = 0 //西药费
  3784. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3785. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3786. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3787. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3788. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3789. var checkCostTotal float64 = 0 //检查费
  3790. var checkCostSelfTotal float64 = 0 //检查费
  3791. var checkCostPartSelfTotal float64 = 0 //检查费
  3792. var laboratoryCostTotal float64 = 0 //化验费
  3793. var laboratoryCostSelfTotal float64 = 0 //化验费
  3794. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3795. var treatCostTotal float64 = 0 //治疗费用
  3796. var treatCostSelfTotal float64 = 0 //治疗费用
  3797. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3798. decimal.DivisionPrecision = 2
  3799. var bed_fulamt_ownpay_amt float64 = 0
  3800. var operation_fulamt_ownpay_amt float64 = 0
  3801. var other_fulamt_ownpay_amt float64 = 0
  3802. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3803. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3804. var check_fulamt_ownpay_amt float64 = 0
  3805. var material_fulamt_ownpay_amt float64 = 0
  3806. var laboratory_fulamt_ownpay_amt float64 = 0
  3807. var treat_fulamt_ownpay_amt float64 = 0
  3808. var bed_claa_sunmfee float64 = 0
  3809. var bed_clab_amt float64 = 0
  3810. var bed_other_amt float64 = 0
  3811. var operation_claa_sunmfee float64 = 0
  3812. var operation_clab_amt float64 = 0
  3813. var operation_other_amt float64 = 0
  3814. var other_claa_sunmfee float64 = 0
  3815. var other_clab_amt float64 = 0
  3816. var other_other_amt float64 = 0
  3817. var westernMedicine_claa_sunmfee float64 = 0
  3818. var westernMedicine_clab_amt float64 = 0
  3819. var westernMedicine_other_amt float64 = 0
  3820. var chineseTraditional_claa_sunmfee float64 = 0
  3821. var chineseTraditional_clab_amt float64 = 0
  3822. var chineseTraditional_other_amt float64 = 0
  3823. var check_claa_sunmfee float64 = 0
  3824. var check_clab_amt float64 = 0
  3825. var check_other_amt float64 = 0
  3826. var material_claa_sunmfee float64 = 0
  3827. var material_clab_amt float64 = 0
  3828. var material_other_amt float64 = 0
  3829. var laboratory_claa_sunmfee float64 = 0
  3830. var laboratory_clab_amt float64 = 0
  3831. var laboratory_other_amt float64 = 0
  3832. var treat_claa_sunmfee float64 = 0
  3833. var treat_clab_amt float64 = 0
  3834. var treat_other_amt float64 = 0
  3835. for _, item := range order.HisOrderInfo {
  3836. if item.MedChrgitmType == "01" { //床位费
  3837. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3838. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3839. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3840. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3841. if item.ChrgitmLv == "1" {
  3842. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3843. }
  3844. if item.ChrgitmLv == "2" {
  3845. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3846. }
  3847. if item.ChrgitmLv == "3" {
  3848. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3849. }
  3850. }
  3851. if item.MedChrgitmType == "03" { //检查费
  3852. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3853. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3854. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3855. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3856. if item.ChrgitmLv == "1" {
  3857. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3858. }
  3859. if item.ChrgitmLv == "2" {
  3860. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3861. }
  3862. if item.ChrgitmLv == "3" {
  3863. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3864. }
  3865. }
  3866. if item.MedChrgitmType == "04" { //化验费
  3867. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3868. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3869. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3870. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3871. if item.ChrgitmLv == "1" {
  3872. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3873. }
  3874. if item.ChrgitmLv == "2" {
  3875. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3876. }
  3877. if item.ChrgitmLv == "3" {
  3878. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3879. }
  3880. }
  3881. if item.MedChrgitmType == "05" { //治疗费
  3882. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3883. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3884. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3885. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3886. if item.ChrgitmLv == "1" {
  3887. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3888. }
  3889. if item.ChrgitmLv == "2" {
  3890. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3891. }
  3892. if item.ChrgitmLv == "3" {
  3893. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3894. }
  3895. }
  3896. if item.MedChrgitmType == "06" { //手术费
  3897. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3898. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3899. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3900. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3901. if item.ChrgitmLv == "1" {
  3902. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3903. }
  3904. if item.ChrgitmLv == "2" {
  3905. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3906. }
  3907. if item.ChrgitmLv == "3" {
  3908. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3909. }
  3910. }
  3911. if item.MedChrgitmType == "08" { //材料费
  3912. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3913. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3914. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3915. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3916. if item.ChrgitmLv == "1" {
  3917. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3918. }
  3919. if item.ChrgitmLv == "2" {
  3920. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3921. }
  3922. if item.ChrgitmLv == "3" {
  3923. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3924. }
  3925. }
  3926. if item.MedChrgitmType == "09" { //西药费
  3927. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3928. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3929. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3930. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3931. if item.ChrgitmLv == "1" {
  3932. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3933. }
  3934. if item.ChrgitmLv == "2" {
  3935. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3936. }
  3937. if item.ChrgitmLv == "3" {
  3938. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3939. }
  3940. }
  3941. if item.MedChrgitmType == "11" { //中成费
  3942. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3943. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3944. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3945. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3946. if item.ChrgitmLv == "1" {
  3947. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3948. }
  3949. if item.ChrgitmLv == "2" {
  3950. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3951. }
  3952. if item.ChrgitmLv == "3" {
  3953. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3954. }
  3955. }
  3956. if item.MedChrgitmType == "14" { //其他费
  3957. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3958. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3959. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3960. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3961. if item.ChrgitmLv == "1" {
  3962. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3963. }
  3964. if item.ChrgitmLv == "2" {
  3965. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3966. }
  3967. if item.ChrgitmLv == "3" {
  3968. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3969. }
  3970. }
  3971. }
  3972. var iteminfoStructs []service.IteminfoStruct
  3973. if bedCostTotal != 0 {
  3974. iteminfo.MedChrgitm = "01"
  3975. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3976. iteminfo.Amt = bedCostTotal
  3977. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3978. iteminfo.ClabAmt = bed_clab_amt
  3979. iteminfo.OthAmt = bed_other_amt
  3980. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3981. }
  3982. if checkCostTotal != 0 {
  3983. iteminfo.MedChrgitm = "03"
  3984. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3985. iteminfo.Amt = checkCostTotal
  3986. iteminfo.ClaaSumfee = check_claa_sunmfee
  3987. iteminfo.ClabAmt = check_clab_amt
  3988. iteminfo.OthAmt = check_other_amt
  3989. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3990. }
  3991. if laboratoryCostTotal != 0 {
  3992. iteminfo.MedChrgitm = "04"
  3993. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3994. iteminfo.Amt = laboratoryCostTotal
  3995. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3996. iteminfo.ClabAmt = laboratory_clab_amt
  3997. iteminfo.OthAmt = laboratory_other_amt
  3998. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3999. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4000. }
  4001. if treatCostTotal != 0 {
  4002. iteminfo.MedChrgitm = "05"
  4003. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4004. iteminfo.Amt = treatCostTotal
  4005. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4006. iteminfo.ClabAmt = treat_clab_amt
  4007. iteminfo.OthAmt = treat_other_amt
  4008. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4009. //(struct4101.IteminfoStruct, iteminfo)
  4010. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4011. }
  4012. if operationCostTotal != 0 {
  4013. iteminfo.MedChrgitm = "06"
  4014. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4015. iteminfo.Amt = operationCostTotal
  4016. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4017. iteminfo.ClabAmt = operation_clab_amt
  4018. iteminfo.OthAmt = operation_other_amt
  4019. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4020. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4021. }
  4022. if materialCostTotal != 0 {
  4023. iteminfo.MedChrgitm = "08"
  4024. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4025. iteminfo.Amt = materialCostTotal
  4026. iteminfo.ClaaSumfee = material_claa_sunmfee
  4027. iteminfo.ClabAmt = material_clab_amt
  4028. iteminfo.OthAmt = material_other_amt
  4029. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4030. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4031. }
  4032. if westernMedicineCostTotal != 0 {
  4033. iteminfo.MedChrgitm = "09"
  4034. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4035. iteminfo.Amt = westernMedicineCostTotal
  4036. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4037. iteminfo.ClabAmt = westernMedicine_clab_amt
  4038. iteminfo.OthAmt = westernMedicine_other_amt
  4039. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4040. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4041. }
  4042. if chineseTraditionalMedicineCostTotal != 0 {
  4043. iteminfo.MedChrgitm = "11"
  4044. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4045. iteminfo.Amt = westernMedicineCostTotal
  4046. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4047. iteminfo.ClabAmt = westernMedicine_clab_amt
  4048. iteminfo.OthAmt = westernMedicine_other_amt
  4049. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4050. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4051. }
  4052. if otherCostTotal != 0 {
  4053. iteminfo.MedChrgitm = "14"
  4054. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4055. iteminfo.Amt = otherCostTotal
  4056. iteminfo.ClaaSumfee = other_claa_sunmfee
  4057. iteminfo.ClabAmt = other_clab_amt
  4058. iteminfo.OthAmt = other_other_amt
  4059. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4060. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4061. }
  4062. struct4101.IteminfoStruct = iteminfoStructs
  4063. struct4101.Ntly = "中国"
  4064. struct4101.AdmCaty = "A03.06"
  4065. var res ResultSeventeen
  4066. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4067. struct4101.BillCode = order.Number
  4068. struct4101.BillNo = order.SetlId
  4069. var resOther ResultSeventeenOther
  4070. var pp models.PublicParams
  4071. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4072. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4073. pp.FixmedinsName = miConfig.OrgName
  4074. pp.FixmedinsCode = miConfig.Code
  4075. pp.RequestUrl = miConfig.Url
  4076. pp.Cainfo = miConfig.Cainfo
  4077. pp.SecretKey = miConfig.SecretKey
  4078. pp.AccessKey = miConfig.AccessKey
  4079. pp.OpterName = curRoles.UserName
  4080. client := &http.Client{}
  4081. var req *http.Request
  4082. data := make(map[string]interface{})
  4083. data["struct4101"] = struct4101
  4084. data["pp"] = pp
  4085. bytesData, _ := json.Marshal(data)
  4086. if miConfig.MdtrtareaAdmvs == "320921" {
  4087. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4088. } else {
  4089. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4090. }
  4091. resp, _ := client.Do(req)
  4092. defer resp.Body.Close()
  4093. body, ioErr := ioutil.ReadAll(resp.Body)
  4094. if ioErr != nil {
  4095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4097. return
  4098. }
  4099. var respJSON map[string]interface{}
  4100. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4103. return
  4104. }
  4105. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4106. userJSONBytes, _ := json.Marshal(respJSON)
  4107. fmt.Println("log")
  4108. fmt.Println(string(userJSONBytes))
  4109. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4110. utils.ErrorLog("解析失败:%v", err)
  4111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4112. return
  4113. }
  4114. res.InfRefmsgid = resOther.InfRefmsgid
  4115. res.Output = resOther.Output
  4116. res.ErrMsg = resOther.ErrMsg
  4117. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4118. res.Infcode = infocode
  4119. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4120. var pp models.PublicParams
  4121. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4122. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4123. pp.FixmedinsName = miConfig.OrgName
  4124. pp.FixmedinsCode = miConfig.Code
  4125. pp.RequestUrl = miConfig.Url
  4126. pp.Cainfo = miConfig.Cainfo
  4127. pp.SecretKey = miConfig.SecretKey
  4128. pp.AccessKey = miConfig.AccessKey
  4129. pp.OpterName = curRoles.UserName
  4130. result, _ := service.Jxyb4101(struct4101, pp)
  4131. var dat map[string]interface{}
  4132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4133. fmt.Println(dat)
  4134. } else {
  4135. fmt.Println(err)
  4136. }
  4137. userJSONBytes, _ := json.Marshal(dat)
  4138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4139. utils.ErrorLog("解析失败:%v", err)
  4140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4141. return
  4142. }
  4143. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4144. var pp models.PublicParams
  4145. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4146. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4147. pp.FixmedinsName = miConfig.OrgName
  4148. pp.FixmedinsCode = miConfig.Code
  4149. pp.RequestUrl = miConfig.Url
  4150. pp.Cainfo = miConfig.Cainfo
  4151. pp.SecretKey = miConfig.SecretKey
  4152. pp.AccessKey = miConfig.AccessKey
  4153. pp.OpterName = curRoles.UserName
  4154. result, _ := service.Hnyb4101(struct4101, pp)
  4155. var dat map[string]interface{}
  4156. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4157. fmt.Println(dat)
  4158. } else {
  4159. fmt.Println(err)
  4160. }
  4161. userJSONBytes, _ := json.Marshal(dat)
  4162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4163. utils.ErrorLog("解析失败:%v", err)
  4164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4165. return
  4166. }
  4167. } else {
  4168. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4169. var dat map[string]interface{}
  4170. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4171. fmt.Println(dat)
  4172. } else {
  4173. fmt.Println(err)
  4174. }
  4175. userJSONBytes, _ := json.Marshal(dat)
  4176. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4177. utils.ErrorLog("解析失败:%v", err)
  4178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4179. return
  4180. }
  4181. }
  4182. if res.Infcode != 0 {
  4183. c.ServeSuccessJSON(map[string]interface{}{
  4184. "failed_code": -10,
  4185. "msg": res.ErrMsg,
  4186. })
  4187. return
  4188. } else {
  4189. order.FaPiaoNumber = zero
  4190. order.FaPiaoCode = last_order.FaPiaoCode
  4191. service.UpdateOrder(order)
  4192. hisFundSettleListResult := &models.HisFundSettleListResult{
  4193. Number: res.Output.SetlListId,
  4194. Status: 1,
  4195. Ctime: time.Now().Unix(),
  4196. Mtime: time.Now().Unix(),
  4197. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4198. IsUpload: 1,
  4199. OrderId: order_id,
  4200. }
  4201. service.CreateUploadRecord(hisFundSettleListResult)
  4202. c.ServeSuccessJSON(map[string]interface{}{
  4203. "msg": "上传成功",
  4204. "result": hisFundSettleListResult,
  4205. })
  4206. return
  4207. }
  4208. }
  4209. func (c *HisApiController) GetSettleListHospital() {
  4210. order_id, _ := c.GetInt64("order_id")
  4211. admin_user_id, _ := c.GetInt64("admin_user_id")
  4212. order, _ := service.GetHisOrderByIDTwo(order_id)
  4213. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4214. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4215. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4216. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4217. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4218. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4219. if order.ID == 0 {
  4220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4221. return
  4222. }
  4223. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  4224. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  4225. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  4226. fmt.Println(count)
  4227. var zero string
  4228. number := count + 1
  4229. if number >= 1000 {
  4230. zero = "0000" + strconv.FormatInt(number, 10)
  4231. } else if number >= 10000 {
  4232. zero = "000" + strconv.FormatInt(number, 10)
  4233. } else if number >= 100000 {
  4234. zero = "00" + strconv.FormatInt(number, 10)
  4235. } else if number >= 1000000 {
  4236. zero = "0" + strconv.FormatInt(number, 10)
  4237. } else {
  4238. zero = strconv.FormatInt(number, 10)
  4239. }
  4240. fmt.Println(zero)
  4241. struct4101 := service.Struct4101{
  4242. PsnNo: order.PsnNo,
  4243. MdtrtId: order.MdtrtId,
  4244. SetlId: order.SetlId,
  4245. PsnName: order.PsnName,
  4246. Gend: order.Gend,
  4247. Brdy: his.Brdy,
  4248. Age: int64(order.Age),
  4249. Naty: order.Naty,
  4250. PatnCertType: "01",
  4251. Certno: order.Certno,
  4252. Prfs: "90",
  4253. ConerName: roles[0].UserName,
  4254. PatnRlts: "99",
  4255. ConerAddr: miConfig.OrgName,
  4256. ConerTel: admin.Mobile,
  4257. HiType: order.Insutype,
  4258. Insuplc: miConfig.InsuplcAdmdvs,
  4259. MaindiagFlag: "1",
  4260. BillCode: order.SetlId,
  4261. BillNo: order.SetlId,
  4262. BizSn: order.Number,
  4263. PsnSelfPay: order.PsnPartAmt,
  4264. PsnOwnPay: order.PsnPartAmt,
  4265. AcctPay: order.AcctPay,
  4266. PsnCashpay: order.PsnCashPay,
  4267. HiPaymtd: "1",
  4268. Hsorg: miConfig.InsuplcAdmdvs,
  4269. HsorgOpter: miConfig.InsuplcAdmdvs,
  4270. MedinsFillPsn: curRoles.UserName,
  4271. MedinsFillDept: depart.Name,
  4272. IptMedType: "2",
  4273. AdmTime: his.InHosptialTime,
  4274. AdmEndTime: his.OutHosptialTime,
  4275. }
  4276. struct4101.SetlBegnDate = order.SetlTime
  4277. struct4101.SetlEndDate = order.SetlTime
  4278. var rf []CustomFundPay
  4279. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4280. var tempFunPays []service.CustomStruct
  4281. for _, item := range rf {
  4282. var tempFunPay service.CustomStruct
  4283. tempFunPay.FundPayamt = item.FundPayamt
  4284. tempFunPay.FundPayType = item.FundPayType
  4285. tempFunPays = append(tempFunPays, tempFunPay)
  4286. }
  4287. struct4101.CustomStruct = tempFunPays
  4288. var tempDiaginfos []service.DiaginfoStructTwo
  4289. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4290. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4291. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4292. var config []*models.HisXtDiagnoseConfig
  4293. for _, item := range diagnosis_ids {
  4294. id, _ := strconv.ParseInt(item, 10, 64)
  4295. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4296. config = append(config, &diagnosisConfig)
  4297. }
  4298. for index, item := range config {
  4299. if index == 0 {
  4300. var tempDiaginfo service.DiaginfoStructTwo
  4301. tempDiaginfo.DiagCode = item.CountryCode
  4302. tempDiaginfo.DiagName = item.CountryContentName
  4303. tempDiaginfo.DiagType = "1"
  4304. tempDiaginfo.MaindiagFlag = "1"
  4305. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4306. } else {
  4307. var tempDiaginfo service.DiaginfoStructTwo
  4308. tempDiaginfo.DiagCode = item.CountryCode
  4309. tempDiaginfo.DiagName = item.CountryContentName
  4310. tempDiaginfo.DiagType = "2"
  4311. tempDiaginfo.MaindiagFlag = "0"
  4312. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4313. }
  4314. }
  4315. struct4101.Diseinfo = tempDiaginfos
  4316. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4317. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4318. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4319. tempOpspdiseinfo2.OprnOprtCode = ""
  4320. tempOpspdiseinfo2.OprnOprtName = ""
  4321. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4322. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4323. var iteminfo service.IteminfoStruct
  4324. var bedCostTotal float64 = 0 //床位总费
  4325. var bedCostSelfTotal float64 = 0 //床位自费
  4326. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4327. var operationCostTotal float64 = 0 //手术费
  4328. var operationCostSelfTotal float64 = 0 //手术费
  4329. var operationCostPartSelfTotal float64 = 0 //手术费
  4330. var otherCostTotal float64 = 0 //其他费用
  4331. var otherCostSelfTotal float64 = 0 //其他费用
  4332. var otherCostPartSelfTotal float64 = 0 //其他费用
  4333. var materialCostTotal float64 = 0 //材料费
  4334. var materialCostSelfTotal float64 = 0 //材料费
  4335. var materialCostPartSelfTotal float64 = 0 //材料费
  4336. var westernMedicineCostTotal float64 = 0 //西药费
  4337. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4338. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4339. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4340. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4341. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4342. var checkCostTotal float64 = 0 //检查费
  4343. var checkCostSelfTotal float64 = 0 //检查费
  4344. var checkCostPartSelfTotal float64 = 0 //检查费
  4345. var laboratoryCostTotal float64 = 0 //化验费
  4346. var laboratoryCostSelfTotal float64 = 0 //化验费
  4347. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4348. var treatCostTotal float64 = 0 //治疗费用
  4349. var treatCostSelfTotal float64 = 0 //治疗费用
  4350. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4351. decimal.DivisionPrecision = 2
  4352. var bed_fulamt_ownpay_amt float64 = 0
  4353. var operation_fulamt_ownpay_amt float64 = 0
  4354. var other_fulamt_ownpay_amt float64 = 0
  4355. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4356. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4357. var check_fulamt_ownpay_amt float64 = 0
  4358. var material_fulamt_ownpay_amt float64 = 0
  4359. var laboratory_fulamt_ownpay_amt float64 = 0
  4360. var treat_fulamt_ownpay_amt float64 = 0
  4361. var bed_claa_sunmfee float64 = 0
  4362. var bed_clab_amt float64 = 0
  4363. var bed_other_amt float64 = 0
  4364. var operation_claa_sunmfee float64 = 0
  4365. var operation_clab_amt float64 = 0
  4366. var operation_other_amt float64 = 0
  4367. var other_claa_sunmfee float64 = 0
  4368. var other_clab_amt float64 = 0
  4369. var other_other_amt float64 = 0
  4370. var westernMedicine_claa_sunmfee float64 = 0
  4371. var westernMedicine_clab_amt float64 = 0
  4372. var westernMedicine_other_amt float64 = 0
  4373. var chineseTraditional_claa_sunmfee float64 = 0
  4374. var chineseTraditional_clab_amt float64 = 0
  4375. var chineseTraditional_other_amt float64 = 0
  4376. var check_claa_sunmfee float64 = 0
  4377. var check_clab_amt float64 = 0
  4378. var check_other_amt float64 = 0
  4379. var material_claa_sunmfee float64 = 0
  4380. var material_clab_amt float64 = 0
  4381. var material_other_amt float64 = 0
  4382. var laboratory_claa_sunmfee float64 = 0
  4383. var laboratory_clab_amt float64 = 0
  4384. var laboratory_other_amt float64 = 0
  4385. var treat_claa_sunmfee float64 = 0
  4386. var treat_clab_amt float64 = 0
  4387. var treat_other_amt float64 = 0
  4388. for _, item := range order.HisOrderInfo {
  4389. if item.MedChrgitmType == "01" { //床位费
  4390. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4391. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4392. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4393. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4394. if item.ChrgitmLv == "1" {
  4395. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4396. }
  4397. if item.ChrgitmLv == "2" {
  4398. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4399. }
  4400. if item.ChrgitmLv == "3" {
  4401. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4402. }
  4403. }
  4404. if item.MedChrgitmType == "03" { //检查费
  4405. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4406. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4407. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4408. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4409. if item.ChrgitmLv == "1" {
  4410. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4411. }
  4412. if item.ChrgitmLv == "2" {
  4413. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4414. }
  4415. if item.ChrgitmLv == "3" {
  4416. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4417. }
  4418. }
  4419. if item.MedChrgitmType == "04" { //化验费
  4420. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4421. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4422. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4423. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4424. if item.ChrgitmLv == "1" {
  4425. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4426. }
  4427. if item.ChrgitmLv == "2" {
  4428. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4429. }
  4430. if item.ChrgitmLv == "3" {
  4431. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4432. }
  4433. }
  4434. if item.MedChrgitmType == "05" { //治疗费
  4435. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4436. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4437. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4438. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4439. if item.ChrgitmLv == "1" {
  4440. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4441. }
  4442. if item.ChrgitmLv == "2" {
  4443. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4444. }
  4445. if item.ChrgitmLv == "3" {
  4446. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4447. }
  4448. }
  4449. if item.MedChrgitmType == "06" { //手术费
  4450. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4451. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4452. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4453. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4454. if item.ChrgitmLv == "1" {
  4455. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4456. }
  4457. if item.ChrgitmLv == "2" {
  4458. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4459. }
  4460. if item.ChrgitmLv == "3" {
  4461. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4462. }
  4463. }
  4464. if item.MedChrgitmType == "08" { //材料费
  4465. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4466. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4467. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4468. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4469. if item.ChrgitmLv == "1" {
  4470. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4471. }
  4472. if item.ChrgitmLv == "2" {
  4473. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4474. }
  4475. if item.ChrgitmLv == "3" {
  4476. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4477. }
  4478. }
  4479. if item.MedChrgitmType == "09" { //西药费
  4480. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4481. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4482. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4483. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4484. if item.ChrgitmLv == "1" {
  4485. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4486. }
  4487. if item.ChrgitmLv == "2" {
  4488. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4489. }
  4490. if item.ChrgitmLv == "3" {
  4491. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4492. }
  4493. }
  4494. if item.MedChrgitmType == "11" { //中成费
  4495. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4496. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4497. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4498. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4499. if item.ChrgitmLv == "1" {
  4500. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4501. }
  4502. if item.ChrgitmLv == "2" {
  4503. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4504. }
  4505. if item.ChrgitmLv == "3" {
  4506. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4507. }
  4508. }
  4509. if item.MedChrgitmType == "14" { //其他费
  4510. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4511. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4512. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4513. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4514. if item.ChrgitmLv == "1" {
  4515. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4516. }
  4517. if item.ChrgitmLv == "2" {
  4518. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4519. }
  4520. if item.ChrgitmLv == "3" {
  4521. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4522. }
  4523. }
  4524. }
  4525. var iteminfoStructs []service.IteminfoStruct
  4526. if bedCostTotal != 0 {
  4527. iteminfo.MedChrgitm = "01"
  4528. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4529. iteminfo.Amt = bedCostTotal
  4530. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4531. iteminfo.ClabAmt = bed_clab_amt
  4532. iteminfo.OthAmt = bed_other_amt
  4533. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4534. }
  4535. if checkCostTotal != 0 {
  4536. iteminfo.MedChrgitm = "03"
  4537. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4538. iteminfo.Amt = checkCostTotal
  4539. iteminfo.ClaaSumfee = check_claa_sunmfee
  4540. iteminfo.ClabAmt = check_clab_amt
  4541. iteminfo.OthAmt = check_other_amt
  4542. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4543. }
  4544. if laboratoryCostTotal != 0 {
  4545. iteminfo.MedChrgitm = "04"
  4546. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4547. iteminfo.Amt = laboratoryCostTotal
  4548. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4549. iteminfo.ClabAmt = laboratory_clab_amt
  4550. iteminfo.OthAmt = laboratory_other_amt
  4551. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4552. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4553. }
  4554. if treatCostTotal != 0 {
  4555. iteminfo.MedChrgitm = "05"
  4556. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4557. iteminfo.Amt = treatCostTotal
  4558. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4559. iteminfo.ClabAmt = treat_clab_amt
  4560. iteminfo.OthAmt = treat_other_amt
  4561. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4562. //(struct4101.IteminfoStruct, iteminfo)
  4563. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4564. }
  4565. if operationCostTotal != 0 {
  4566. iteminfo.MedChrgitm = "06"
  4567. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4568. iteminfo.Amt = operationCostTotal
  4569. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4570. iteminfo.ClabAmt = operation_clab_amt
  4571. iteminfo.OthAmt = operation_other_amt
  4572. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4573. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4574. }
  4575. if materialCostTotal != 0 {
  4576. iteminfo.MedChrgitm = "08"
  4577. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4578. iteminfo.Amt = materialCostTotal
  4579. iteminfo.ClaaSumfee = material_claa_sunmfee
  4580. iteminfo.ClabAmt = material_clab_amt
  4581. iteminfo.OthAmt = material_other_amt
  4582. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4583. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4584. }
  4585. if westernMedicineCostTotal != 0 {
  4586. iteminfo.MedChrgitm = "09"
  4587. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4588. iteminfo.Amt = westernMedicineCostTotal
  4589. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4590. iteminfo.ClabAmt = westernMedicine_clab_amt
  4591. iteminfo.OthAmt = westernMedicine_other_amt
  4592. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4593. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4594. }
  4595. if chineseTraditionalMedicineCostTotal != 0 {
  4596. iteminfo.MedChrgitm = "11"
  4597. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4598. iteminfo.Amt = westernMedicineCostTotal
  4599. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4600. iteminfo.ClabAmt = westernMedicine_clab_amt
  4601. iteminfo.OthAmt = westernMedicine_other_amt
  4602. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4603. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4604. }
  4605. if otherCostTotal != 0 {
  4606. iteminfo.MedChrgitm = "14"
  4607. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4608. iteminfo.Amt = otherCostTotal
  4609. iteminfo.ClaaSumfee = other_claa_sunmfee
  4610. iteminfo.ClabAmt = other_clab_amt
  4611. iteminfo.OthAmt = other_other_amt
  4612. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4613. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4614. }
  4615. struct4101.IteminfoStruct = iteminfoStructs
  4616. struct4101.Ntly = "中国"
  4617. struct4101.AdmCaty = "A03.06"
  4618. var resOther ResultSeventeenOther
  4619. var res ResultSeventeen
  4620. if miConfig.MdtrtareaAdmvs == "150499" {
  4621. var pp models.PublicParams
  4622. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4623. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4624. pp.FixmedinsName = miConfig.OrgName
  4625. pp.FixmedinsCode = miConfig.Code
  4626. pp.RequestUrl = miConfig.Url
  4627. pp.Cainfo = miConfig.Cainfo
  4628. pp.SecretKey = miConfig.SecretKey
  4629. pp.AccessKey = miConfig.AccessKey
  4630. pp.OpterName = curRoles.UserName
  4631. client := &http.Client{}
  4632. var req *http.Request
  4633. data := make(map[string]interface{})
  4634. data["struct4101"] = struct4101
  4635. data["pp"] = pp
  4636. bytesData, _ := json.Marshal(data)
  4637. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  4638. resp, _ := client.Do(req)
  4639. defer resp.Body.Close()
  4640. body, ioErr := ioutil.ReadAll(resp.Body)
  4641. if ioErr != nil {
  4642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4644. return
  4645. }
  4646. var respJSON map[string]interface{}
  4647. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4650. return
  4651. }
  4652. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4653. userJSONBytes, _ := json.Marshal(respJSON)
  4654. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4655. utils.ErrorLog("解析失败:%v", err)
  4656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4657. return
  4658. }
  4659. res.InfRefmsgid = resOther.InfRefmsgid
  4660. res.Output = resOther.Output
  4661. res.ErrMsg = resOther.ErrMsg
  4662. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4663. res.Infcode = infocode
  4664. } else {
  4665. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4666. var dat map[string]interface{}
  4667. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4668. fmt.Println(dat)
  4669. } else {
  4670. fmt.Println(err)
  4671. }
  4672. userJSONBytes, _ := json.Marshal(dat)
  4673. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4674. utils.ErrorLog("解析失败:%v", err)
  4675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4676. return
  4677. }
  4678. }
  4679. if res.Infcode != 0 {
  4680. c.ServeSuccessJSON(map[string]interface{}{
  4681. "failed_code": -10,
  4682. "msg": res.ErrMsg,
  4683. })
  4684. return
  4685. } else {
  4686. if miConfig.MdtrtareaAdmvs != "150499" {
  4687. order.FaPiaoNumber = zero
  4688. order.FaPiaoCode = last_order.FaPiaoCode
  4689. service.UpdateOrder(order)
  4690. }
  4691. hisFundSettleListResult := &models.HisFundSettleListResult{
  4692. Number: res.Output.SetlListId,
  4693. Status: 1,
  4694. Ctime: time.Now().Unix(),
  4695. Mtime: time.Now().Unix(),
  4696. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4697. IsUpload: 1,
  4698. OrderId: order_id,
  4699. }
  4700. service.CreateUploadRecord(hisFundSettleListResult)
  4701. c.ServeSuccessJSON(map[string]interface{}{
  4702. "msg": "上传成功",
  4703. "result": hisFundSettleListResult,
  4704. })
  4705. return
  4706. }
  4707. }
  4708. func (c *HisApiController) GetBatchSettleList() {
  4709. orders, _ := service.GetAllHisOrder(10106)
  4710. for _, item := range orders {
  4711. order_id := item.ID
  4712. order, _ := service.GetHisOrderByIDTwo(order_id)
  4713. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4714. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4715. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4716. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  4717. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4718. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4719. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4720. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4721. if order.ID == 0 {
  4722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4723. return
  4724. }
  4725. if his.BalanceAccountsType == 2 {
  4726. continue
  4727. }
  4728. struct4101 := service.Struct4101{
  4729. PsnNo: order.PsnNo,
  4730. MdtrtId: order.MdtrtId,
  4731. SetlId: order.SetlId,
  4732. PsnName: order.PsnName,
  4733. Gend: order.Gend,
  4734. Brdy: his.Brdy,
  4735. Age: his.Age,
  4736. Naty: order.Naty,
  4737. PatnCertType: "01",
  4738. Certno: order.Certno,
  4739. Prfs: "90",
  4740. ConerName: roles[0].UserName,
  4741. PatnRlts: "99",
  4742. ConerAddr: miConfig.OrgName,
  4743. ConerTel: admin.Mobile,
  4744. HiType: order.Insutype,
  4745. Insuplc: his.InsuplcAdmdvs,
  4746. MaindiagFlag: "1",
  4747. BillCode: order.SetlId,
  4748. BillNo: order.SetlId,
  4749. BizSn: order.Number,
  4750. PsnSelfPay: order.PsnPartAmt,
  4751. PsnOwnPay: order.PsnPartAmt,
  4752. AcctPay: order.AcctPay,
  4753. PsnCashpay: order.PsnCashPay,
  4754. HiPaymtd: "1",
  4755. Hsorg: his.InsuplcAdmdvs,
  4756. HsorgOpter: his.InsuplcAdmdvs,
  4757. MedinsFillPsn: curRoles.UserName,
  4758. MedinsFillDept: depart.Name,
  4759. IptMedType: "2",
  4760. }
  4761. struct4101.SetlBegnDate = order.SetlTime
  4762. struct4101.SetlEndDate = order.SetlTime
  4763. //if order.SettleType == 1 {
  4764. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  4765. // dateStr := t.Format("2006-01-02")
  4766. // struct4101.SetlBegnDate = dateStr
  4767. // struct4101.SetlEndDate = dateStr
  4768. //} else {
  4769. // t := time.Unix(int64(order.SettleStartTime), 0)
  4770. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  4771. // dateStartStr := t.Format("2006-01-02")
  4772. // dateEndStr := t2.Format("2006-01-02")
  4773. // struct4101.SetlBegnDate = dateStartStr
  4774. // struct4101.SetlEndDate = dateEndStr
  4775. //}
  4776. var rf []CustomFundPay
  4777. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4778. var tempFunPays []service.CustomStruct
  4779. var tempFunPay610100 service.CustomStruct
  4780. for _, item := range rf {
  4781. if item.FundPayType == "610100" {
  4782. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  4783. tempFunPay610100.FundPayType = item.FundPayType
  4784. } else {
  4785. var tempFunPay service.CustomStruct
  4786. tempFunPay.FundPayamt = item.FundPayamt
  4787. tempFunPay.FundPayType = item.FundPayType
  4788. tempFunPays = append(tempFunPays, tempFunPay)
  4789. }
  4790. }
  4791. tempFunPays = append(tempFunPays, tempFunPay610100)
  4792. struct4101.CustomStruct = tempFunPays
  4793. var tempDiaginfos []service.DiaginfoStructTwo
  4794. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4795. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4796. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4797. var config []*models.HisXtDiagnoseConfig
  4798. for _, item := range diagnosis_ids {
  4799. id, _ := strconv.ParseInt(item, 10, 64)
  4800. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4801. config = append(config, &diagnosisConfig)
  4802. }
  4803. for index, item := range config {
  4804. if index == 0 {
  4805. var tempDiaginfo service.DiaginfoStructTwo
  4806. tempDiaginfo.DiagCode = item.CountryCode
  4807. tempDiaginfo.DiagName = item.CountryContentName
  4808. tempDiaginfo.DiagType = "1"
  4809. tempDiaginfo.MaindiagFlag = "1"
  4810. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4811. } else {
  4812. var tempDiaginfo service.DiaginfoStructTwo
  4813. tempDiaginfo.DiagCode = item.CountryCode
  4814. tempDiaginfo.DiagName = item.CountryContentName
  4815. tempDiaginfo.DiagType = "2"
  4816. tempDiaginfo.MaindiagFlag = "0"
  4817. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4818. }
  4819. }
  4820. struct4101.Diseinfo = tempDiaginfos
  4821. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4822. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4823. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4824. tempOpspdiseinfo2.OprnOprtCode = ""
  4825. tempOpspdiseinfo2.OprnOprtName = ""
  4826. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4827. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4828. var iteminfo service.IteminfoStruct
  4829. var bedCostTotal float64 = 0 //床位总费
  4830. var bedCostSelfTotal float64 = 0 //床位自费
  4831. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4832. var examineCostTotal float64 = 0 //诊查总费
  4833. var examineCostSelfTotal float64 = 0 //诊查自费
  4834. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  4835. var nursingCostTotal float64 = 0 //护理总费
  4836. var nursingCostSelfTotal float64 = 0 //护理自费
  4837. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  4838. var chineseMedicineCostTotal float64 = 0 //中成药
  4839. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  4840. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  4841. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  4842. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  4843. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  4844. var registerCostTotal float64 = 0 //一般诊疗费
  4845. var registerCostSelfTotal float64 = 0 //一般诊疗费
  4846. var registerPartSelfTotal float64 = 0 //一般诊疗费
  4847. var operationCostTotal float64 = 0 //手术费
  4848. var operationCostSelfTotal float64 = 0 //手术费
  4849. var operationCostPartSelfTotal float64 = 0 //手术费
  4850. var otherCostTotal float64 = 0 //其他费用
  4851. var otherCostSelfTotal float64 = 0 //其他费用
  4852. var otherCostPartSelfTotal float64 = 0 //其他费用
  4853. var materialCostTotal float64 = 0 //材料费
  4854. var materialCostSelfTotal float64 = 0 //材料费
  4855. var materialCostPartSelfTotal float64 = 0 //材料费
  4856. var westernMedicineCostTotal float64 = 0 //西药费
  4857. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4858. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4859. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4860. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4861. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4862. var checkCostTotal float64 = 0 //检查费
  4863. var checkCostSelfTotal float64 = 0 //检查费
  4864. var checkCostPartSelfTotal float64 = 0 //检查费
  4865. var laboratoryCostTotal float64 = 0 //化验费
  4866. var laboratoryCostSelfTotal float64 = 0 //化验费
  4867. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4868. var treatCostTotal float64 = 0 //治疗费用
  4869. var treatCostSelfTotal float64 = 0 //治疗费用
  4870. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4871. decimal.DivisionPrecision = 2
  4872. var bed_fulamt_ownpay_amt float64 = 0
  4873. var examine_fulamt_ownpay_amt float64 = 0
  4874. var nursing_fulamt_ownpay_amt float64 = 0
  4875. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  4876. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  4877. var register_fulamt_ownpay_amt float64 = 0
  4878. var operation_fulamt_ownpay_amt float64 = 0
  4879. var other_fulamt_ownpay_amt float64 = 0
  4880. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4881. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4882. var check_fulamt_ownpay_amt float64 = 0
  4883. var material_fulamt_ownpay_amt float64 = 0
  4884. var laboratory_fulamt_ownpay_amt float64 = 0
  4885. var treat_fulamt_ownpay_amt float64 = 0
  4886. var bed_claa_sunmfee float64 = 0
  4887. var bed_clab_amt float64 = 0
  4888. var bed_other_amt float64 = 0
  4889. var examine_claa_sunmfee float64 = 0
  4890. var examine_clab_amt float64 = 0
  4891. var examine_other_amt float64 = 0
  4892. var nursing_claa_sunmfee float64 = 0
  4893. var nursing_clab_amt float64 = 0
  4894. var nursing_other_amt float64 = 0
  4895. var chinese_medicine_claa_sunmfee float64 = 0
  4896. var chinese_medicine_clab_amt float64 = 0
  4897. var chinese_medicine_other_amt float64 = 0
  4898. var commonly_treatment_claa_sunmfee float64 = 0
  4899. var commonly_treatment_clab_amt float64 = 0
  4900. var commonly_treatment_other_amt float64 = 0
  4901. var operation_claa_sunmfee float64 = 0
  4902. var operation_clab_amt float64 = 0
  4903. var operation_other_amt float64 = 0
  4904. var other_claa_sunmfee float64 = 0
  4905. var other_clab_amt float64 = 0
  4906. var other_other_amt float64 = 0
  4907. var westernMedicine_claa_sunmfee float64 = 0
  4908. var westernMedicine_clab_amt float64 = 0
  4909. var westernMedicine_other_amt float64 = 0
  4910. var chineseTraditional_claa_sunmfee float64 = 0
  4911. var chineseTraditional_clab_amt float64 = 0
  4912. var chineseTraditional_other_amt float64 = 0
  4913. var check_claa_sunmfee float64 = 0
  4914. var check_clab_amt float64 = 0
  4915. var check_other_amt float64 = 0
  4916. var material_claa_sunmfee float64 = 0
  4917. var material_clab_amt float64 = 0
  4918. var material_other_amt float64 = 0
  4919. var laboratory_claa_sunmfee float64 = 0
  4920. var laboratory_clab_amt float64 = 0
  4921. var laboratory_other_amt float64 = 0
  4922. var treat_claa_sunmfee float64 = 0
  4923. var treat_clab_amt float64 = 0
  4924. var treat_other_amt float64 = 0
  4925. var register_claa_sunmfee float64 = 0
  4926. var register_clab_amt float64 = 0
  4927. var register_other_amt float64 = 0
  4928. for _, item := range order.HisOrderInfo {
  4929. if item.MedChrgitmType == "01" { //床位费
  4930. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4931. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4932. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4933. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4934. if item.ChrgitmLv == "1" {
  4935. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4936. }
  4937. if item.ChrgitmLv == "2" {
  4938. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4939. }
  4940. if item.ChrgitmLv == "3" {
  4941. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4942. }
  4943. }
  4944. if item.MedChrgitmType == "02" { //诊查
  4945. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4946. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4947. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4948. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4949. if item.ChrgitmLv == "1" {
  4950. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4951. }
  4952. if item.ChrgitmLv == "2" {
  4953. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4954. }
  4955. if item.ChrgitmLv == "3" {
  4956. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4957. }
  4958. }
  4959. if item.MedChrgitmType == "03" { //检查费
  4960. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4961. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4962. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4963. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4964. if item.ChrgitmLv == "1" {
  4965. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4966. }
  4967. if item.ChrgitmLv == "2" {
  4968. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4969. }
  4970. if item.ChrgitmLv == "3" {
  4971. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4972. }
  4973. }
  4974. if item.MedChrgitmType == "04" { //化验费
  4975. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4976. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4977. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4978. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4979. if item.ChrgitmLv == "1" {
  4980. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4981. }
  4982. if item.ChrgitmLv == "2" {
  4983. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4984. }
  4985. if item.ChrgitmLv == "3" {
  4986. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4987. }
  4988. }
  4989. if item.MedChrgitmType == "05" { //治疗费
  4990. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4991. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4992. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4993. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4994. if item.ChrgitmLv == "1" {
  4995. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4996. }
  4997. if item.ChrgitmLv == "2" {
  4998. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4999. }
  5000. if item.ChrgitmLv == "3" {
  5001. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5002. }
  5003. }
  5004. if item.MedChrgitmType == "06" { //手术费
  5005. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5006. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5007. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5008. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5009. if item.ChrgitmLv == "1" {
  5010. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5011. }
  5012. if item.ChrgitmLv == "2" {
  5013. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5014. }
  5015. if item.ChrgitmLv == "3" {
  5016. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5017. }
  5018. }
  5019. if item.MedChrgitmType == "07" { //手术费
  5020. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5021. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5022. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5023. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5024. if item.ChrgitmLv == "1" {
  5025. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5026. }
  5027. if item.ChrgitmLv == "2" {
  5028. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5029. }
  5030. if item.ChrgitmLv == "3" {
  5031. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5032. }
  5033. }
  5034. if item.MedChrgitmType == "08" { //材料费
  5035. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5036. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5037. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5038. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5039. if item.ChrgitmLv == "1" {
  5040. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5041. }
  5042. if item.ChrgitmLv == "2" {
  5043. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5044. }
  5045. if item.ChrgitmLv == "3" {
  5046. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5047. }
  5048. }
  5049. if item.MedChrgitmType == "09" { //西药费
  5050. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5051. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5052. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5053. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5054. if item.ChrgitmLv == "1" {
  5055. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5056. }
  5057. if item.ChrgitmLv == "2" {
  5058. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5059. }
  5060. if item.ChrgitmLv == "3" {
  5061. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5062. }
  5063. }
  5064. if item.MedChrgitmType == "10" { //中药饮片
  5065. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5066. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5067. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5068. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5069. if item.ChrgitmLv == "1" {
  5070. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5071. }
  5072. if item.ChrgitmLv == "2" {
  5073. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5074. }
  5075. if item.ChrgitmLv == "3" {
  5076. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5077. }
  5078. }
  5079. if item.MedChrgitmType == "11" { //中成费
  5080. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5081. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5082. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5083. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5084. if item.ChrgitmLv == "1" {
  5085. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5086. }
  5087. if item.ChrgitmLv == "2" {
  5088. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5089. }
  5090. if item.ChrgitmLv == "3" {
  5091. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5092. }
  5093. }
  5094. if item.MedChrgitmType == "12" { //中成费
  5095. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5096. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5097. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5098. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5099. if item.ChrgitmLv == "1" {
  5100. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5101. }
  5102. if item.ChrgitmLv == "2" {
  5103. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5104. }
  5105. if item.ChrgitmLv == "3" {
  5106. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5107. }
  5108. }
  5109. if item.MedChrgitmType == "13" { //中成费
  5110. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5111. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5112. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5113. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5114. if item.ChrgitmLv == "1" {
  5115. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5116. }
  5117. if item.ChrgitmLv == "2" {
  5118. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5119. }
  5120. if item.ChrgitmLv == "3" {
  5121. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5122. }
  5123. }
  5124. if item.MedChrgitmType == "14" { //其他费
  5125. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5126. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5127. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5128. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5129. if item.ChrgitmLv == "1" {
  5130. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5131. }
  5132. if item.ChrgitmLv == "2" {
  5133. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5134. }
  5135. if item.ChrgitmLv == "3" {
  5136. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5137. }
  5138. }
  5139. }
  5140. var iteminfoStructs []service.IteminfoStruct
  5141. if bedCostTotal != 0 {
  5142. iteminfo.MedChrgitm = "01"
  5143. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5144. iteminfo.Amt = bedCostTotal
  5145. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5146. iteminfo.ClabAmt = bed_clab_amt
  5147. iteminfo.OthAmt = bed_other_amt
  5148. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5149. }
  5150. if examineCostTotal != 0 {
  5151. iteminfo.MedChrgitm = "02"
  5152. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  5153. iteminfo.Amt = examineCostTotal
  5154. iteminfo.ClaaSumfee = examine_claa_sunmfee
  5155. iteminfo.ClabAmt = examine_clab_amt
  5156. iteminfo.OthAmt = examine_other_amt
  5157. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5158. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5159. }
  5160. if checkCostTotal != 0 {
  5161. iteminfo.MedChrgitm = "03"
  5162. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5163. iteminfo.Amt = checkCostTotal
  5164. iteminfo.ClaaSumfee = check_claa_sunmfee
  5165. iteminfo.ClabAmt = check_clab_amt
  5166. iteminfo.OthAmt = check_other_amt
  5167. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5168. }
  5169. if laboratoryCostTotal != 0 {
  5170. iteminfo.MedChrgitm = "04"
  5171. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5172. iteminfo.Amt = laboratoryCostTotal
  5173. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5174. iteminfo.ClabAmt = laboratory_clab_amt
  5175. iteminfo.OthAmt = laboratory_other_amt
  5176. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5177. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5178. }
  5179. if treatCostTotal != 0 {
  5180. iteminfo.MedChrgitm = "05"
  5181. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5182. iteminfo.Amt = treatCostTotal
  5183. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5184. iteminfo.ClabAmt = treat_clab_amt
  5185. iteminfo.OthAmt = treat_other_amt
  5186. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5187. //(struct4101.IteminfoStruct, iteminfo)
  5188. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5189. }
  5190. if operationCostTotal != 0 {
  5191. iteminfo.MedChrgitm = "06"
  5192. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5193. iteminfo.Amt = operationCostTotal
  5194. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5195. iteminfo.ClabAmt = operation_clab_amt
  5196. iteminfo.OthAmt = operation_other_amt
  5197. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5198. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5199. }
  5200. if nursingCostTotal != 0 {
  5201. iteminfo.MedChrgitm = "07"
  5202. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  5203. iteminfo.Amt = nursingCostTotal
  5204. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  5205. iteminfo.ClabAmt = nursing_clab_amt
  5206. iteminfo.OthAmt = nursing_other_amt
  5207. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5208. }
  5209. if materialCostTotal != 0 {
  5210. iteminfo.MedChrgitm = "08"
  5211. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5212. iteminfo.Amt = materialCostTotal
  5213. iteminfo.ClaaSumfee = material_claa_sunmfee
  5214. iteminfo.ClabAmt = material_clab_amt
  5215. iteminfo.OthAmt = material_other_amt
  5216. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5217. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5218. }
  5219. if westernMedicineCostTotal != 0 {
  5220. iteminfo.MedChrgitm = "09"
  5221. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5222. iteminfo.Amt = westernMedicineCostTotal
  5223. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5224. iteminfo.ClabAmt = westernMedicine_clab_amt
  5225. iteminfo.OthAmt = westernMedicine_other_amt
  5226. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5227. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5228. }
  5229. if chineseMedicineCostTotal != 0 {
  5230. iteminfo.MedChrgitm = "10"
  5231. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  5232. iteminfo.Amt = chineseMedicineCostTotal
  5233. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  5234. iteminfo.ClabAmt = chinese_medicine_clab_amt
  5235. iteminfo.OthAmt = chinese_medicine_other_amt
  5236. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5237. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5238. }
  5239. if chineseTraditionalMedicineCostTotal != 0 {
  5240. iteminfo.MedChrgitm = "11"
  5241. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5242. iteminfo.Amt = westernMedicineCostTotal
  5243. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5244. iteminfo.ClabAmt = westernMedicine_clab_amt
  5245. iteminfo.OthAmt = westernMedicine_other_amt
  5246. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5247. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5248. }
  5249. if commonlyTreatmentCostTotal != 0 {
  5250. iteminfo.MedChrgitm = "12"
  5251. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  5252. iteminfo.Amt = commonlyTreatmentCostTotal
  5253. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  5254. iteminfo.ClabAmt = commonly_treatment_clab_amt
  5255. iteminfo.OthAmt = commonly_treatment_other_amt
  5256. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5257. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5258. }
  5259. if registerCostTotal != 0 {
  5260. iteminfo.MedChrgitm = "13"
  5261. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  5262. iteminfo.Amt = registerCostTotal
  5263. iteminfo.ClaaSumfee = register_claa_sunmfee
  5264. iteminfo.ClabAmt = register_clab_amt
  5265. iteminfo.OthAmt = register_other_amt
  5266. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5267. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5268. }
  5269. if otherCostTotal != 0 {
  5270. iteminfo.MedChrgitm = "14"
  5271. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5272. iteminfo.Amt = otherCostTotal
  5273. iteminfo.ClaaSumfee = other_claa_sunmfee
  5274. iteminfo.ClabAmt = other_clab_amt
  5275. iteminfo.OthAmt = other_other_amt
  5276. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5277. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5278. }
  5279. struct4101.IteminfoStruct = iteminfoStructs
  5280. time_arr := strings.Split(order.SetlTime, " ")
  5281. struct4101.AdmTime = time_arr[0]
  5282. struct4101.AdmEndTime = time_arr[0]
  5283. struct4101.DoctorName = doctor.UserName
  5284. struct4101.DoctorCode = doctor.DoctorNumber
  5285. struct4101.Ntly = "中国"
  5286. struct4101.AdmCaty = "A03.06"
  5287. var res ResultSeventeen
  5288. if miConfig.MdtrtareaAdmvs == "421300" {
  5289. data := make(map[string]interface{})
  5290. data["struct4101"] = struct4101
  5291. data["secret_key"] = miConfig.SecretKey
  5292. data["org_name"] = miConfig.OrgName
  5293. data["opera"] = curRoles.UserName
  5294. data["code"] = miConfig.Code
  5295. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5296. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5297. client := &http.Client{}
  5298. bytesData, _ := json.Marshal(data)
  5299. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  5300. resp, _ := client.Do(req)
  5301. defer resp.Body.Close()
  5302. body, ioErr := ioutil.ReadAll(resp.Body)
  5303. if ioErr != nil {
  5304. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5306. return
  5307. }
  5308. var respJSON map[string]interface{}
  5309. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5310. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5312. return
  5313. }
  5314. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5315. userJSONBytes, _ := json.Marshal(respJSON)
  5316. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5317. utils.ErrorLog("解析失败:%v", err)
  5318. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5319. adminUser := c.GetAdminUserInfo()
  5320. errlog := &models.HisOrderError{
  5321. UserOrgId: adminUser.CurrentOrgId,
  5322. Ctime: time.Now().Unix(),
  5323. Mtime: time.Now().Unix(),
  5324. ErrMsg: res.ErrMsg + "解析失败",
  5325. Status: 1,
  5326. PatientId: order_id,
  5327. Stage: 10088,
  5328. }
  5329. service.CreateErrMsgLog(errlog)
  5330. continue
  5331. }
  5332. } else {
  5333. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  5334. fmt.Println(result)
  5335. var dat map[string]interface{}
  5336. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5337. fmt.Println(dat)
  5338. } else {
  5339. fmt.Println(err)
  5340. }
  5341. userJSONBytes, _ := json.Marshal(dat)
  5342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5343. utils.ErrorLog("解析失败:%v", err)
  5344. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5345. adminUser := c.GetAdminUserInfo()
  5346. errlog := &models.HisOrderError{
  5347. UserOrgId: adminUser.CurrentOrgId,
  5348. Ctime: time.Now().Unix(),
  5349. Mtime: time.Now().Unix(),
  5350. ErrMsg: res.ErrMsg + "解析失败",
  5351. Status: 1,
  5352. PatientId: order_id,
  5353. Stage: 10106,
  5354. }
  5355. service.CreateErrMsgLog(errlog)
  5356. continue
  5357. }
  5358. }
  5359. if res.Infcode != 0 {
  5360. adminUser := c.GetAdminUserInfo()
  5361. errlog := &models.HisOrderError{
  5362. UserOrgId: adminUser.CurrentOrgId,
  5363. Ctime: time.Now().Unix(),
  5364. Mtime: time.Now().Unix(),
  5365. ErrMsg: res.ErrMsg,
  5366. Status: 1,
  5367. PatientId: order_id,
  5368. Stage: 10106,
  5369. }
  5370. service.CreateErrMsgLog(errlog)
  5371. continue
  5372. } else {
  5373. hisFundSettleListResult := &models.HisFundSettleListResult{
  5374. Number: res.Output.SetlListId,
  5375. Status: 1,
  5376. Ctime: time.Now().Unix(),
  5377. Mtime: time.Now().Unix(),
  5378. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5379. IsUpload: 1,
  5380. OrderId: order_id,
  5381. }
  5382. service.CreateUploadRecord(hisFundSettleListResult)
  5383. continue
  5384. }
  5385. }
  5386. }
  5387. func (c *HisApiController) GetOrgInfo() {
  5388. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  5389. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  5390. }
  5391. func (c *HisApiController) GetHisPatientInfo() {
  5392. medical_insurance_card := c.GetString("medical_insurance_card")
  5393. id_card_type, _ := c.GetInt64("id_card_type")
  5394. id_card := c.GetString("id_card")
  5395. adminInfo := c.GetAdminUserInfo()
  5396. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  5397. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5398. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  5399. IdCardNo := ""
  5400. if id_card_type == 1 {
  5401. IdCardNo = medical_insurance_card
  5402. } else if id_card_type == 2 {
  5403. IdCardNo = id_card
  5404. }
  5405. if config.IsOpen == 1 {
  5406. 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
  5407. resp, requestErr := http.Get(api)
  5408. if requestErr != nil {
  5409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5410. return
  5411. }
  5412. defer resp.Body.Close()
  5413. body, ioErr := ioutil.ReadAll(resp.Body)
  5414. if ioErr != nil {
  5415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5417. return
  5418. }
  5419. var respJSON map[string]interface{}
  5420. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5423. return
  5424. }
  5425. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5426. userJSONBytes, _ := json.Marshal(userJSON)
  5427. var res ResultTwo
  5428. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5429. utils.ErrorLog("解析失败:%v", err)
  5430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5431. return
  5432. }
  5433. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5434. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5435. infoStr := string(Iinfos)
  5436. idetinfoStr := string(Idetinfos)
  5437. if res.Infcode == 0 {
  5438. his := models.VMHisPatient{
  5439. Status: 1,
  5440. Ctime: time.Now().Unix(),
  5441. Mtime: time.Now().Unix(),
  5442. PsnNo: res.Output.Baseinfo.PsnNo,
  5443. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5444. Certno: res.Output.Baseinfo.Certno,
  5445. PsnName: res.Output.Baseinfo.PsnName,
  5446. Gend: res.Output.Baseinfo.Gend,
  5447. Naty: res.Output.Baseinfo.Naty,
  5448. Brdy: res.Output.Baseinfo.Brdy,
  5449. Age: res.Output.Baseinfo.Age,
  5450. Iinfo: infoStr,
  5451. Idetinfo: idetinfoStr,
  5452. UserOrgId: adminInfo.CurrentOrgId,
  5453. IsReturn: 1,
  5454. IdCardType: id_card_type,
  5455. }
  5456. c.ServeSuccessJSON(map[string]interface{}{
  5457. "info": his,
  5458. })
  5459. } else {
  5460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5461. return
  5462. }
  5463. }
  5464. }
  5465. //func GetBasBaseInfo() (jsonStr string, err error) {
  5466. //
  5467. // handle := syscall.NewLazyDLL("SSCard.dll")
  5468. // add := handle.NewProc("ReadCardBas")
  5469. // str := make([]byte, 1024)
  5470. // str1 := make([]byte, 1024)
  5471. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5472. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  5473. //
  5474. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  5475. //
  5476. // fmt.Println("> Add(4,5)的结果为:", ret)
  5477. // handle.Release()
  5478. //
  5479. // return "", nil
  5480. //
  5481. //}
  5482. //func GetQRBaseInfo() (jsonStr string, err error) {
  5483. // handle := syscall.LoadDLL("SSCard.dll")
  5484. // ReadCardBas := handle.FindProc("GetQRBase")
  5485. //
  5486. // str := make([]byte, 256)
  5487. // str1 := make([]byte, 256)
  5488. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5489. //
  5490. // fmt.Println(string(str))
  5491. // fmt.Println(r)
  5492. // return string(str), nil
  5493. //}
  5494. //func CardInit() int {
  5495. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  5496. // add := DllTestDef.MustFindProc("Init")
  5497. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5498. // if err != nil {
  5499. // fmt.Println("SSCard的运算结果为:", ret)
  5500. // }
  5501. // result := int(ret)
  5502. // return result
  5503. //}
  5504. //func CardInit() int {
  5505. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5506. // if err != nil {
  5507. // fmt.Println("SSCard的运算结果为:", ret)
  5508. // }
  5509. // fmt.Println(err)
  5510. // result := int(ret)
  5511. // return result
  5512. //}
  5513. func IntPtr(n int) uintptr {
  5514. return uintptr(n)
  5515. }
  5516. func StrPtr(s string) uintptr {
  5517. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  5518. }
  5519. type Result2001 struct {
  5520. Cainfo interface{} `json:"cainfo"`
  5521. ErrMsg string `json:"err_msg"`
  5522. InfRefmsgid string `json:"inf_refmsgid"`
  5523. Infcode int64 `json:"infcode"`
  5524. Output struct {
  5525. Trtinfo struct {
  5526. PsnNo string `json:"psn_no"`
  5527. TrtChkType string `json:"trt_chk_type"`
  5528. FundPayType string `json:"fund_pay_type"`
  5529. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5530. Begndate string `json:"begndate"`
  5531. Enddate string `json:"enddate"`
  5532. TrtChkRslt string `json:"trt_chk_rslt"`
  5533. } `json:"trtinfo"`
  5534. } `json:"output"`
  5535. RefmsgTime string `json:"refmsg_time"`
  5536. RespondTime string `json:"respond_time"`
  5537. Signtype interface{} `json:"signtype"`
  5538. WarnMsg interface{} `json:"warn_msg"`
  5539. }
  5540. type Result2001Org10265 struct {
  5541. Cainfo interface{} `json:"cainfo"`
  5542. ErrMsg string `json:"err_msg"`
  5543. InfRefmsgid string `json:"inf_refmsgid"`
  5544. Infcode string `json:"infcode"`
  5545. Output struct {
  5546. Trtinfo struct {
  5547. PsnNo string `json:"psn_no"`
  5548. TrtChkType string `json:"trt_chk_type"`
  5549. FundPayType string `json:"fund_pay_type"`
  5550. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5551. Begndate string `json:"begndate"`
  5552. Enddate string `json:"enddate"`
  5553. TrtChkRslt string `json:"trt_chk_rslt"`
  5554. } `json:"trtinfo"`
  5555. } `json:"output"`
  5556. RefmsgTime string `json:"refmsg_time"`
  5557. RespondTime string `json:"respond_time"`
  5558. Signtype interface{} `json:"signtype"`
  5559. WarnMsg interface{} `json:"warn_msg"`
  5560. }
  5561. type ResultTwo struct {
  5562. ErrMsg string `json:"err_msg"`
  5563. InfRefmsgid string `json:"inf_refmsgid"`
  5564. Infcode int64 `json:"infcode"`
  5565. Output struct {
  5566. Baseinfo struct {
  5567. Age float64 `json:"age"`
  5568. Brdy string `json:"brdy"`
  5569. Certno string `json:"certno"`
  5570. Gend string `json:"gend"`
  5571. Naty string `json:"naty"`
  5572. PsnCertType string `json:"psn_cert_type"`
  5573. PsnName string `json:"psn_name"`
  5574. PsnNo string `json:"psn_no"`
  5575. } `json:"baseinfo"`
  5576. Idetinfo []interface{} `json:"idetinfo"`
  5577. Iinfo []struct {
  5578. Balc float64 `json:"balc"`
  5579. CvlservFlag string `json:"cvlserv_flag"`
  5580. EmpName string `json:"emp_name"`
  5581. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5582. Insutype string `json:"insutype"`
  5583. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5584. PausInsuDate string `json:"paus_insu_date"`
  5585. PsnInsuDate string `json:"psn_insu_date"`
  5586. PsnInsuStas string `json:"psn_insu_stas"`
  5587. PsnType string `json:"psn_type"`
  5588. } `json:"insuinfo"`
  5589. } `json:"output"`
  5590. RefmsgTime string `json:"refmsg_time"`
  5591. RespondTime string `json:"respond_time"`
  5592. Signtype interface{} `json:"signtype"`
  5593. WarnInfo interface{} `json:"warn_info"`
  5594. }
  5595. type ResultTwo10265 struct {
  5596. ErrMsg string `json:"err_msg"`
  5597. InfRefmsgid string `json:"inf_refmsgid"`
  5598. Infcode string `json:"infcode"`
  5599. Output struct {
  5600. Baseinfo struct {
  5601. Age float64 `json:"age"`
  5602. Brdy string `json:"brdy"`
  5603. Certno string `json:"certno"`
  5604. Gend string `json:"gend"`
  5605. Naty string `json:"naty"`
  5606. PsnCertType string `json:"psn_cert_type"`
  5607. PsnName string `json:"psn_name"`
  5608. PsnNo string `json:"psn_no"`
  5609. } `json:"baseinfo"`
  5610. Idetinfo []interface{} `json:"idetinfo"`
  5611. Iinfo []struct {
  5612. Balc float64 `json:"balc"`
  5613. CvlservFlag string `json:"cvlserv_flag"`
  5614. EmpName string `json:"emp_name"`
  5615. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5616. Insutype string `json:"insutype"`
  5617. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5618. PausInsuDate string `json:"paus_insu_date"`
  5619. PsnInsuDate string `json:"psn_insu_date"`
  5620. PsnInsuStas string `json:"psn_insu_stas"`
  5621. PsnType string `json:"psn_type"`
  5622. } `json:"insuinfo"`
  5623. } `json:"output"`
  5624. RefmsgTime string `json:"refmsg_time"`
  5625. RespondTime string `json:"respond_time"`
  5626. Signtype interface{} `json:"signtype"`
  5627. WarnInfo interface{} `json:"warn_info"`
  5628. }
  5629. type ResultThree struct {
  5630. Cainfo interface{} `json:"cainfo"`
  5631. ErrMsg string `json:"err_msg"`
  5632. InfRefmsgid string `json:"inf_refmsgid"`
  5633. Infcode int64 `json:"infcode"`
  5634. Output struct {
  5635. Data struct {
  5636. IptOtpNo string `json:"ipt_otp_no"`
  5637. MdtrtID string `json:"mdtrt_id"`
  5638. PsnNo string `json:"psn_no"`
  5639. } `json:"data"`
  5640. } `json:"output"`
  5641. RefmsgTime string `json:"refmsg_time"`
  5642. RespondTime string `json:"respond_time"`
  5643. Signtype interface{} `json:"signtype"`
  5644. WarnMsg interface{} `json:"warn_msg"`
  5645. }
  5646. type ResultThree10265 struct {
  5647. Cainfo interface{} `json:"cainfo"`
  5648. ErrMsg string `json:"err_msg"`
  5649. InfRefmsgid string `json:"inf_refmsgid"`
  5650. Infcode string `json:"infcode"`
  5651. Output struct {
  5652. Data struct {
  5653. IptOtpNo string `json:"ipt_otp_no"`
  5654. MdtrtID string `json:"mdtrt_id"`
  5655. PsnNo string `json:"psn_no"`
  5656. } `json:"data"`
  5657. } `json:"output"`
  5658. RefmsgTime string `json:"refmsg_time"`
  5659. RespondTime string `json:"respond_time"`
  5660. Signtype interface{} `json:"signtype"`
  5661. WarnMsg interface{} `json:"warn_msg"`
  5662. }
  5663. type ResultFour struct {
  5664. Cainfo string `json:"cainfo"`
  5665. ErrMsg string `json:"err_msg"`
  5666. InfRefmsgid string `json:"inf_refmsgid"`
  5667. Infcode int64 `json:"infcode"`
  5668. Output struct {
  5669. Result []struct {
  5670. BasMednFlag string `json:"bas_medn_flag"`
  5671. ChldMedcFlag string `json:"chld_medc_flag"`
  5672. ChrgitmLv string `json:"chrgitm_lv"`
  5673. Cnt float64 `json:"cnt"`
  5674. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5675. DrtReimFlag string `json:"drt_reim_flag"`
  5676. FeedetlSn string `json:"feedetl_sn"`
  5677. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5678. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5679. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5680. ListSpItemFlag string `json:"list_sp_item_flag"`
  5681. LmtUsedFlag string `json:"lmt_used_flag"`
  5682. MedChrgitmType string `json:"med_chrgitm_type"`
  5683. Memo string `json:"memo"`
  5684. OverlmtAmt float64 `json:"overlmt_amt"`
  5685. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5686. Pric float64 `json:"pric"`
  5687. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5688. SelfpayProp float64 `json:"selfpay_prop"`
  5689. } `json:"result"`
  5690. } `json:"output"`
  5691. RefmsgTime string `json:"refmsg_time"`
  5692. RespondTime string `json:"respond_time"`
  5693. Signtype string `json:"signtype"`
  5694. WarnMsg string `json:"warn_msg"`
  5695. }
  5696. type ResultFour10265 struct {
  5697. Cainfo string `json:"cainfo"`
  5698. ErrMsg string `json:"err_msg"`
  5699. InfRefmsgid string `json:"inf_refmsgid"`
  5700. Infcode string `json:"infcode"`
  5701. Output struct {
  5702. Result []struct {
  5703. BasMednFlag string `json:"bas_medn_flag"`
  5704. ChldMedcFlag string `json:"chld_medc_flag"`
  5705. ChrgitmLv string `json:"chrgitm_lv"`
  5706. Cnt float64 `json:"cnt"`
  5707. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5708. DrtReimFlag string `json:"drt_reim_flag"`
  5709. FeedetlSn string `json:"feedetl_sn"`
  5710. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5711. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5712. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5713. ListSpItemFlag string `json:"list_sp_item_flag"`
  5714. LmtUsedFlag string `json:"lmt_used_flag"`
  5715. MedChrgitmType string `json:"med_chrgitm_type"`
  5716. Memo string `json:"memo"`
  5717. OverlmtAmt float64 `json:"overlmt_amt"`
  5718. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5719. Pric float64 `json:"pric"`
  5720. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5721. SelfpayProp float64 `json:"selfpay_prop"`
  5722. } `json:"result"`
  5723. } `json:"output"`
  5724. RefmsgTime string `json:"refmsg_time"`
  5725. RespondTime string `json:"respond_time"`
  5726. Signtype string `json:"signtype"`
  5727. WarnMsg string `json:"warn_msg"`
  5728. }
  5729. type ResultMemo struct {
  5730. InsuAdmdvs string `json:"insuAdmdvs"`
  5731. }
  5732. //[{"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}]
  5733. type ResultIDInfo struct {
  5734. Begntime string `json:"begntime"`
  5735. Endtime string `json:"endtime"`
  5736. Memo string `json:"memo"`
  5737. }
  5738. type ResultFive struct {
  5739. Balc float64 `json:"balc"`
  5740. CvlservFlag string `json:"cvlserv_flag"`
  5741. EmpName string `json:"emp_name"`
  5742. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5743. Insutype string `json:"insutype"`
  5744. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5745. PausInsuDate string `json:"paus_insu_date"`
  5746. PsnInsuDate string `json:"psn_insu_date"`
  5747. PsnInsuStas string `json:"psn_insu_stas"`
  5748. PsnType string `json:"psn_type"`
  5749. }
  5750. type ResultSix struct {
  5751. Cainfo interface{} `json:"cainfo"`
  5752. ErrMsg string `json:"err_msg"`
  5753. InfRefmsgid string `json:"inf_refmsgid"`
  5754. Infcode int64 `json:"infcode"`
  5755. Output struct {
  5756. } `json:"output"`
  5757. RefmsgTime string `json:"refmsg_time"`
  5758. RespondTime string `json:"respond_time"`
  5759. Signtype interface{} `json:"signtype"`
  5760. WarnMsg interface{} `json:"warn_msg"`
  5761. }
  5762. type ResultSix10265 struct {
  5763. Cainfo interface{} `json:"cainfo"`
  5764. ErrMsg string `json:"err_msg"`
  5765. InfRefmsgid string `json:"inf_refmsgid"`
  5766. Infcode string `json:"infcode"`
  5767. Output struct {
  5768. } `json:"output"`
  5769. RefmsgTime string `json:"refmsg_time"`
  5770. RespondTime string `json:"respond_time"`
  5771. Signtype interface{} `json:"signtype"`
  5772. WarnMsg interface{} `json:"warn_msg"`
  5773. }
  5774. type ResultSeven struct {
  5775. Cainfo string `json:"cainfo"`
  5776. ErrMsg string `json:"err_msg"`
  5777. InfRefmsgid string `json:"inf_refmsgid"`
  5778. Infcode int64 `json:"infcode"`
  5779. Output struct {
  5780. Setldetail []interface{} `json:"setldetail"`
  5781. Setlinfo struct {
  5782. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5783. AcctPay float64 `json:"acct_pay"`
  5784. ActPayDedc float64 `json:"act_pay_dedc"`
  5785. Age float64 `json:"age"`
  5786. Balc float64 `json:"balc"`
  5787. Brdy string `json:"brdy"`
  5788. Certno string `json:"certno"`
  5789. ClrOptins string `json:"clr_optins"`
  5790. ClrType string `json:"clr_type"`
  5791. ClrWay string `json:"clr_way"`
  5792. CvlservFlag string `json:"cvlserv_flag"`
  5793. CvlservPay float64 `json:"cvlserv_pay"`
  5794. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5795. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5796. Gend string `json:"gend"`
  5797. HifesPay float64 `json:"hifes_pay"`
  5798. HifmiPay float64 `json:"hifmi_pay"`
  5799. HifpPay float64 `json:"hifp_pay"`
  5800. HospPartAmt float64 `json:"hosp_part_amt"`
  5801. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5802. Insutype string `json:"insutype"`
  5803. MafPay float64 `json:"maf_pay"`
  5804. MdtrtCertType string `json:"mdtrt_cert_type"`
  5805. HifobPay float64 `json:"hifob_pay"`
  5806. MdtrtID string `json:"mdtrt_id"`
  5807. MedType string `json:"med_type"`
  5808. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5809. MedinsSetlID string `json:"medins_setl_id"`
  5810. Naty string `json:"naty"`
  5811. OthPay float64 `json:"oth_pay"`
  5812. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5813. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5814. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5815. PsnCashPay float64 `json:"psn_cash_pay"`
  5816. PsnCertType string `json:"psn_cert_type"`
  5817. PsnName string `json:"psn_name"`
  5818. PsnNo string `json:"psn_no"`
  5819. PsnPartAmt float64 `json:"psn_part_amt"`
  5820. PsnType string `json:"psn_type"`
  5821. SetlID string `json:"setl_id"`
  5822. SetlTime string `json:"setl_time"`
  5823. } `json:"setlinfo"`
  5824. } `json:"output"`
  5825. RefmsgTime string `json:"refmsg_time"`
  5826. RespondTime string `json:"respond_time"`
  5827. Signtype interface{} `json:"signtype"`
  5828. WarnMsg interface{} `json:"warn_msg"`
  5829. }
  5830. type ResultSeven10265 struct {
  5831. Cainfo string `json:"cainfo"`
  5832. ErrMsg string `json:"err_msg"`
  5833. InfRefmsgid string `json:"inf_refmsgid"`
  5834. Infcode string `json:"infcode"`
  5835. Output struct {
  5836. Setldetail []interface{} `json:"setldetail"`
  5837. Setlinfo struct {
  5838. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5839. AcctPay float64 `json:"acct_pay"`
  5840. ActPayDedc float64 `json:"act_pay_dedc"`
  5841. Age float64 `json:"age"`
  5842. Balc float64 `json:"balc"`
  5843. Brdy string `json:"brdy"`
  5844. Certno string `json:"certno"`
  5845. ClrOptins string `json:"clr_optins"`
  5846. ClrType string `json:"clr_type"`
  5847. ClrWay string `json:"clr_way"`
  5848. CvlservFlag string `json:"cvlserv_flag"`
  5849. CvlservPay float64 `json:"cvlserv_pay"`
  5850. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5851. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5852. Gend string `json:"gend"`
  5853. HifesPay float64 `json:"hifes_pay"`
  5854. HifmiPay float64 `json:"hifmi_pay"`
  5855. HifpPay float64 `json:"hifp_pay"`
  5856. HospPartAmt float64 `json:"hosp_part_amt"`
  5857. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5858. Insutype string `json:"insutype"`
  5859. MafPay float64 `json:"maf_pay"`
  5860. MdtrtCertType string `json:"mdtrt_cert_type"`
  5861. HifobPay float64 `json:"hifob_pay"`
  5862. MdtrtID string `json:"mdtrt_id"`
  5863. MedType string `json:"med_type"`
  5864. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5865. MedinsSetlID string `json:"medins_setl_id"`
  5866. Naty string `json:"naty"`
  5867. OthPay float64 `json:"oth_pay"`
  5868. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5869. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5870. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5871. PsnCashPay float64 `json:"psn_cash_pay"`
  5872. PsnCertType string `json:"psn_cert_type"`
  5873. PsnName string `json:"psn_name"`
  5874. PsnNo string `json:"psn_no"`
  5875. PsnPartAmt float64 `json:"psn_part_amt"`
  5876. PsnType string `json:"psn_type"`
  5877. SetlID string `json:"setl_id"`
  5878. SetlTime string `json:"setl_time"`
  5879. } `json:"setlinfo"`
  5880. } `json:"output"`
  5881. RefmsgTime string `json:"refmsg_time"`
  5882. RespondTime string `json:"respond_time"`
  5883. Signtype interface{} `json:"signtype"`
  5884. WarnMsg interface{} `json:"warn_msg"`
  5885. }
  5886. type ResultEight struct {
  5887. Cainfo string `json:"cainfo"`
  5888. ErrMsg string `json:"err_msg"`
  5889. InfRefmsgid string `json:"inf_refmsgid"`
  5890. Infcode int64 `json:"infcode"`
  5891. Output struct {
  5892. Stmtinfo struct {
  5893. SetlOptins string `json:"setl_optins"`
  5894. StmtRslt string `json:"stmt_rslt"`
  5895. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5896. } `json:"stmtinfo"`
  5897. } `json:"output"`
  5898. RefmsgTime string `json:"refmsg_time"`
  5899. RespondTime string `json:"respond_time"`
  5900. Signtype interface{} `json:"signtype"`
  5901. WarnMsg interface{} `json:"warn_msg"`
  5902. }
  5903. type ResultEightFor10188 struct {
  5904. Cainfo string `json:"cainfo"`
  5905. ErrMsg string `json:"err_msg"`
  5906. InfRefmsgid string `json:"inf_refmsgid"`
  5907. Infcode string `json:"infcode"`
  5908. Output struct {
  5909. Stmtinfo struct {
  5910. SetlOptins string `json:"setl_optins"`
  5911. StmtRslt string `json:"stmt_rslt"`
  5912. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5913. } `json:"stmtinfo"`
  5914. } `json:"output"`
  5915. RefmsgTime string `json:"refmsg_time"`
  5916. RespondTime string `json:"respond_time"`
  5917. Signtype interface{} `json:"signtype"`
  5918. WarnMsg interface{} `json:"warn_msg"`
  5919. }
  5920. type ResultNine struct {
  5921. Cainfo string `json:"cainfo"`
  5922. ErrMsg string `json:"err_msg"`
  5923. InfRefmsgid string `json:"inf_refmsgid"`
  5924. Infcode int64 `json:"infcode"`
  5925. Output struct {
  5926. FileQuryNo string `json:"file_qury_no"`
  5927. } `json:"output"`
  5928. RefmsgTime string `json:"refmsg_time"`
  5929. RespondTime string `json:"respond_time"`
  5930. Signtype interface{} `json:"signtype"`
  5931. WarnMsg interface{} `json:"warn_msg"`
  5932. }
  5933. type ResultTen struct {
  5934. Cainfo string `json:"cainfo"`
  5935. ErrMsg string `json:"err_msg"`
  5936. InfRefmsgid string `json:"inf_refmsgid"`
  5937. Infcode int64 `json:"infcode"`
  5938. Output struct {
  5939. DldEndtime string `json:"dld_endtime"`
  5940. FileQuryNo string `json:"file_qury_no"`
  5941. Filename string `json:"filename"`
  5942. } `json:"output"`
  5943. RefmsgTime string `json:"refmsg_time"`
  5944. RespondTime string `json:"respond_time"`
  5945. Signtype interface{} `json:"signtype"`
  5946. WarnMsg interface{} `json:"warn_msg"`
  5947. }
  5948. //type Autogenerated struct {
  5949. // Output struct {
  5950. // Setlinfo struct {
  5951. // SetlTime string `json:"setl_time"`
  5952. // CvlservPay float64 `json:"cvlserv_pay"`
  5953. // Year string `json:"year"`
  5954. // MedType string `json:"med_type"`
  5955. // PsnPay float64 `json:"psn_pay"`
  5956. // OpterID string `json:"opter_id"`
  5957. // Begndate string `json:"begndate"`
  5958. // FlxempeFlag string `json:"flxempe_flag"`
  5959. // HifmiPay float64 `json:"hifmi_pay"`
  5960. // PsnNo string `json:"psn_no"`
  5961. // ActPayDedc float64 `json:"act_pay_dedc"`
  5962. // MedinsSetlID interface{} `json:"medins_setl_id"`
  5963. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5964. // ClrWay string `json:"clr_way"`
  5965. // OthPay float64 `json:"oth_pay"`
  5966. // Gend string `json:"gend"`
  5967. // MdtrtID string `json:"mdtrt_id"`
  5968. // AcctPay float64 `json:"acct_pay"`
  5969. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  5970. // Insutype string `json:"insutype"`
  5971. // Invono interface{} `json:"invono"`
  5972. // Enddate string `json:"enddate"`
  5973. // CashPayamt float64 `json:"cash_payamt"`
  5974. // PsnType string `json:"psn_type"`
  5975. // FixmedinsName string `json:"fixmedins_name"`
  5976. // HifpPay float64 `json:"hifp_pay"`
  5977. // NewFlag interface{} `json:"new_flag"`
  5978. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5979. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  5980. // PayLoc string `json:"pay_loc"`
  5981. // ClrType string `json:"clr_type"`
  5982. // RefdSetlFlag string `json:"refd_setl_flag"`
  5983. // CvlservFlag string `json:"cvlserv_flag"`
  5984. // EmpName string `json:"emp_name"`
  5985. // Brdy string `json:"brdy"`
  5986. // Naty string `json:"naty"`
  5987. // Certno string `json:"certno"`
  5988. // DiseCode string `json:"dise_code"`
  5989. // FixmedinsCode string `json:"fixmedins_code"`
  5990. // DedcHospLv string `json:"dedc_hosp_lv"`
  5991. // OpterName string `json:"opter_name"`
  5992. // Balc float64 `json:"balc"`
  5993. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  5994. // PsnCertType string `json:"psn_cert_type"`
  5995. // HifobPay float64 `json:"hifob_pay"`
  5996. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  5997. // HifesPay float64 `json:"hifes_pay"`
  5998. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5999. // OptTime string `json:"opt_time"`
  6000. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6001. // SetlID string `json:"setl_id"`
  6002. // MafPay float64 `json:"maf_pay"`
  6003. // PsnName string `json:"psn_name"`
  6004. // InsuOptins interface{} `json:"insu_optins"`
  6005. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6006. // ClrOptins string `json:"clr_optins"`
  6007. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6008. // DiseName string `json:"dise_name"`
  6009. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6010. // Age float64 `json:"age"`
  6011. // DtrtCertType string `json:"dtrt_cert_type"`
  6012. // HospLv string `json:"hosp_lv"`
  6013. // } `json:"setlinfo"`
  6014. // Setldetail []struct {
  6015. // FundPayType string `json:"fund_pay_type"`
  6016. // FundPayamt float64 `json:"fund_payamt"`
  6017. // SetlProcInfo interface{} `json:"setl_proc_info"`
  6018. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  6019. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  6020. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  6021. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6022. // } `json:"setldetail"`
  6023. // } `json:"output"`
  6024. // Infcode int `json:"infcode"`
  6025. // WarnMsg interface{} `json:"warn_msg"`
  6026. // Cainfo interface{} `json:"cainfo"`
  6027. // ErrMsg interface{} `json:"err_msg"`
  6028. // RefmsgTime string `json:"refmsg_time"`
  6029. // Signtype interface{} `json:"signtype"`
  6030. // RespondTime string `json:"respond_time"`
  6031. // InfRefmsgid string `json:"inf_refmsgid"`
  6032. //}
  6033. type ResultEleven struct {
  6034. Cainfo string `json:"cainfo"`
  6035. ErrMsg string `json:"err_msg"`
  6036. InfRefmsgid string `json:"inf_refmsgid"`
  6037. Infcode int64 `json:"infcode"`
  6038. Output struct {
  6039. Setlinfo struct {
  6040. SetlTime string `json:"setl_time"`
  6041. CvlservPay float64 `json:"cvlserv_pay"`
  6042. Year string `json:"year"`
  6043. MedType string `json:"med_type"`
  6044. PsnPay float64 `json:"psn_pay"`
  6045. OpterID string `json:"opter_id"`
  6046. Begndate string `json:"begndate"`
  6047. FlxempeFlag string `json:"flxempe_flag"`
  6048. HifmiPay float64 `json:"hifmi_pay"`
  6049. PsnNo string `json:"psn_no"`
  6050. ActPayDedc float64 `json:"act_pay_dedc"`
  6051. MedinsSetlID interface{} `json:"medins_setl_id"`
  6052. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6053. ClrWay string `json:"clr_way"`
  6054. OthPay float64 `json:"oth_pay"`
  6055. Gend string `json:"gend"`
  6056. MdtrtID string `json:"mdtrt_id"`
  6057. AcctPay float64 `json:"acct_pay"`
  6058. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6059. Insutype string `json:"insutype"`
  6060. Invono interface{} `json:"invono"`
  6061. Enddate string `json:"enddate"`
  6062. CashPayamt float64 `json:"cash_payamt"`
  6063. PsnType string `json:"psn_type"`
  6064. FixmedinsName string `json:"fixmedins_name"`
  6065. HifpPay float64 `json:"hifp_pay"`
  6066. NewFlag interface{} `json:"new_flag"`
  6067. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6068. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6069. PayLoc string `json:"pay_loc"`
  6070. ClrType string `json:"clr_type"`
  6071. RefdSetlFlag string `json:"refd_setl_flag"`
  6072. CvlservFlag string `json:"cvlserv_flag"`
  6073. EmpName string `json:"emp_name"`
  6074. Brdy string `json:"brdy"`
  6075. Naty string `json:"naty"`
  6076. Certno string `json:"certno"`
  6077. DiseCode string `json:"dise_code"`
  6078. FixmedinsCode string `json:"fixmedins_code"`
  6079. DedcHospLv string `json:"dedc_hosp_lv"`
  6080. OpterName string `json:"opter_name"`
  6081. Balc float64 `json:"balc"`
  6082. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6083. PsnCertType string `json:"psn_cert_type"`
  6084. HifobPay float64 `json:"hifob_pay"`
  6085. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6086. HifesPay float64 `json:"hifes_pay"`
  6087. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6088. OptTime string `json:"opt_time"`
  6089. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6090. SetlID string `json:"setl_id"`
  6091. MafPay float64 `json:"maf_pay"`
  6092. PsnName string `json:"psn_name"`
  6093. InsuOptins interface{} `json:"insu_optins"`
  6094. PrefFundPay interface{} `json:"pref_fund_pay"`
  6095. ClrOptins string `json:"clr_optins"`
  6096. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6097. DiseName string `json:"dise_name"`
  6098. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6099. Age float64 `json:"age"`
  6100. DtrtCertType string `json:"dtrt_cert_type"`
  6101. HospLv string `json:"hosp_lv"`
  6102. PsnCashPay float64
  6103. } `json:"setlinfo"`
  6104. } `json:"output"`
  6105. RefmsgTime string `json:"refmsg_time"`
  6106. RespondTime string `json:"respond_time"`
  6107. Signtype interface{} `json:"signtype"`
  6108. WarnMsg interface{} `json:"warn_msg"`
  6109. }
  6110. type ResultEleven10265 struct {
  6111. Cainfo string `json:"cainfo"`
  6112. ErrMsg string `json:"err_msg"`
  6113. InfRefmsgid string `json:"inf_refmsgid"`
  6114. Infcode string `json:"infcode"`
  6115. Output struct {
  6116. Setlinfo struct {
  6117. SetlTime string `json:"setl_time"`
  6118. CvlservPay float64 `json:"cvlserv_pay"`
  6119. Year string `json:"year"`
  6120. MedType string `json:"med_type"`
  6121. PsnPay float64 `json:"psn_pay"`
  6122. OpterID string `json:"opter_id"`
  6123. Begndate string `json:"begndate"`
  6124. FlxempeFlag string `json:"flxempe_flag"`
  6125. HifmiPay float64 `json:"hifmi_pay"`
  6126. PsnNo string `json:"psn_no"`
  6127. ActPayDedc float64 `json:"act_pay_dedc"`
  6128. MedinsSetlID interface{} `json:"medins_setl_id"`
  6129. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6130. ClrWay string `json:"clr_way"`
  6131. OthPay float64 `json:"oth_pay"`
  6132. Gend string `json:"gend"`
  6133. MdtrtID string `json:"mdtrt_id"`
  6134. AcctPay float64 `json:"acct_pay"`
  6135. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6136. Insutype string `json:"insutype"`
  6137. Invono interface{} `json:"invono"`
  6138. Enddate string `json:"enddate"`
  6139. CashPayamt float64 `json:"cash_payamt"`
  6140. PsnType string `json:"psn_type"`
  6141. FixmedinsName string `json:"fixmedins_name"`
  6142. HifpPay float64 `json:"hifp_pay"`
  6143. NewFlag interface{} `json:"new_flag"`
  6144. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6145. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6146. PayLoc string `json:"pay_loc"`
  6147. ClrType string `json:"clr_type"`
  6148. RefdSetlFlag string `json:"refd_setl_flag"`
  6149. CvlservFlag string `json:"cvlserv_flag"`
  6150. EmpName string `json:"emp_name"`
  6151. Brdy string `json:"brdy"`
  6152. Naty string `json:"naty"`
  6153. Certno string `json:"certno"`
  6154. DiseCode string `json:"dise_code"`
  6155. FixmedinsCode string `json:"fixmedins_code"`
  6156. DedcHospLv string `json:"dedc_hosp_lv"`
  6157. OpterName string `json:"opter_name"`
  6158. Balc float64 `json:"balc"`
  6159. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6160. PsnCertType string `json:"psn_cert_type"`
  6161. HifobPay float64 `json:"hifob_pay"`
  6162. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6163. HifesPay float64 `json:"hifes_pay"`
  6164. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6165. OptTime string `json:"opt_time"`
  6166. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6167. SetlID string `json:"setl_id"`
  6168. MafPay float64 `json:"maf_pay"`
  6169. PsnName string `json:"psn_name"`
  6170. InsuOptins interface{} `json:"insu_optins"`
  6171. PrefFundPay interface{} `json:"pref_fund_pay"`
  6172. ClrOptins string `json:"clr_optins"`
  6173. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6174. DiseName string `json:"dise_name"`
  6175. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6176. Age float64 `json:"age"`
  6177. DtrtCertType string `json:"dtrt_cert_type"`
  6178. HospLv string `json:"hosp_lv"`
  6179. PsnCashPay float64
  6180. } `json:"setlinfo"`
  6181. } `json:"output"`
  6182. RefmsgTime string `json:"refmsg_time"`
  6183. RespondTime string `json:"respond_time"`
  6184. Signtype interface{} `json:"signtype"`
  6185. WarnMsg interface{} `json:"warn_msg"`
  6186. }
  6187. type ResultTwelve struct {
  6188. Cainfo string `json:"cainfo"`
  6189. ErrMsg string `json:"err_msg"`
  6190. InfRefmsgid string `json:"inf_refmsgid"`
  6191. Infcode int64 `json:"infcode"`
  6192. Output struct {
  6193. MdtrtId string `json:"mdtrt_id"`
  6194. ChrgBchno string `json:"chrg_bchno"`
  6195. PsnNo string `json:"psn_no"`
  6196. } `json:"output"`
  6197. RefmsgTime string `json:"refmsg_time"`
  6198. RespondTime string `json:"respond_time"`
  6199. Signtype interface{} `json:"signtype"`
  6200. WarnMsg interface{} `json:"warn_msg"`
  6201. }
  6202. type ResultThirteen struct {
  6203. ErrMsg string `json:"err_msg"`
  6204. InfRefmsgid string `json:"inf_refmsgid"`
  6205. Infcode int64 `json:"infcode"`
  6206. Output struct {
  6207. Result struct {
  6208. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6209. } `json:"result"`
  6210. } `json:"output"`
  6211. RefmsgTime string `json:"refmsg_time"`
  6212. RespondTime string `json:"respond_time"`
  6213. Signtype interface{} `json:"signtype"`
  6214. WarnInfo interface{} `json:"warn_info"`
  6215. }
  6216. type ResultThirteen10265 struct {
  6217. ErrMsg string `json:"err_msg"`
  6218. InfRefmsgid string `json:"inf_refmsgid"`
  6219. Infcode string `json:"infcode"`
  6220. Output struct {
  6221. Result struct {
  6222. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6223. } `json:"result"`
  6224. } `json:"output"`
  6225. RefmsgTime string `json:"refmsg_time"`
  6226. RespondTime string `json:"respond_time"`
  6227. Signtype interface{} `json:"signtype"`
  6228. WarnInfo interface{} `json:"warn_info"`
  6229. }
  6230. type ResultFourteen struct {
  6231. ErrMsg string `json:"err_msg"`
  6232. InfRefmsgid string `json:"inf_refmsgid"`
  6233. Infcode int64 `json:"infcode"`
  6234. Output struct {
  6235. } `json:"output"`
  6236. RefmsgTime string `json:"refmsg_time"`
  6237. RespondTime string `json:"respond_time"`
  6238. Signtype interface{} `json:"signtype"`
  6239. WarnInfo interface{} `json:"warn_info"`
  6240. }
  6241. type ResultFourteen10265 struct {
  6242. ErrMsg string `json:"err_msg"`
  6243. InfRefmsgid string `json:"inf_refmsgid"`
  6244. Infcode string `json:"infcode"`
  6245. Output struct {
  6246. } `json:"output"`
  6247. RefmsgTime string `json:"refmsg_time"`
  6248. RespondTime string `json:"respond_time"`
  6249. Signtype interface{} `json:"signtype"`
  6250. WarnInfo interface{} `json:"warn_info"`
  6251. }
  6252. type ResultSixteen struct {
  6253. Cainfo string `json:"cainfo"`
  6254. ErrMsg string `json:"err_msg"`
  6255. InfRefmsgid string `json:"inf_refmsgid"`
  6256. Infcode int64 `json:"infcode"`
  6257. Output struct {
  6258. Setldetail []interface{} `json:"setldetail"`
  6259. Setlinfo struct {
  6260. MdtrtID string `json:"mdtrt_id"`
  6261. SetlID string `json:"setl_id"`
  6262. ClrOptins string `json:"clr_optins"`
  6263. SetlTime string `json:"setl_time"`
  6264. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6265. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6266. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6267. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6268. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6269. ActPayDedc float64 `json:"act_pay_dedc"`
  6270. HifpPay float64 `json:"hifp_pay"`
  6271. PoolPropSe float64 `json:"pool_prop_selfpay"`
  6272. Lfpay float64 `json:"selfpay"`
  6273. CvlservPay float64 `json:"cvlserv_pay"`
  6274. HifesPay float64 `json:"hifes_pay"`
  6275. HifmiPay float64 `json:"hifmi_pay"`
  6276. HifobPay float64 `json:"hifob_pay"`
  6277. MafPay float64 `json:"maf_pay"`
  6278. OthPay float64 `json:"oth_pay"`
  6279. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6280. PsnPartAmt float64 `json:"psn_part_amt"`
  6281. AcctPay float64 `json:"acct_pay"`
  6282. Balc float64 `json:"balc"`
  6283. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6284. HospPartAmt float64 `json:"hosp_part_amt"`
  6285. MedinsSetlID string `json:"medins_setl_id"`
  6286. PdnCashPay string `json:"pdn_cash_pay"`
  6287. } `json:"setlinfo"`
  6288. } `json:"output"`
  6289. RefmsgTime string `json:"refmsg_time"`
  6290. RespondTime string `json:"respond_time"`
  6291. Signtype interface{} `json:"signtype"`
  6292. WarnMsg interface{} `json:"warn_msg"`
  6293. }
  6294. type ResultSixteen10265 struct {
  6295. Cainfo string `json:"cainfo"`
  6296. ErrMsg string `json:"err_msg"`
  6297. InfRefmsgid string `json:"inf_refmsgid"`
  6298. Infcode string `json:"infcode"`
  6299. Output struct {
  6300. Setldetail []interface{} `json:"setldetail"`
  6301. Setlinfo struct {
  6302. MdtrtID string `json:"mdtrt_id"`
  6303. SetlID string `json:"setl_id"`
  6304. ClrOptins string `json:"clr_optins"`
  6305. SetlTime string `json:"setl_time"`
  6306. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6307. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6308. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6309. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6310. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6311. ActPayDedc float64 `json:"act_pay_dedc"`
  6312. HifpPay float64 `json:"hifp_pay"`
  6313. PoolPropSe float64 `json:"pool_prop_selfpay"`
  6314. Lfpay float64 `json:"selfpay"`
  6315. CvlservPay float64 `json:"cvlserv_pay"`
  6316. HifesPay float64 `json:"hifes_pay"`
  6317. HifmiPay float64 `json:"hifmi_pay"`
  6318. HifobPay float64 `json:"hifob_pay"`
  6319. MafPay float64 `json:"maf_pay"`
  6320. OthPay float64 `json:"oth_pay"`
  6321. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6322. PsnPartAmt float64 `json:"psn_part_amt"`
  6323. AcctPay float64 `json:"acct_pay"`
  6324. Balc float64 `json:"balc"`
  6325. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6326. HospPartAmt float64 `json:"hosp_part_amt"`
  6327. MedinsSetlID string `json:"medins_setl_id"`
  6328. PdnCashPay string `json:"pdn_cash_pay"`
  6329. } `json:"setlinfo"`
  6330. } `json:"output"`
  6331. RefmsgTime string `json:"refmsg_time"`
  6332. RespondTime string `json:"respond_time"`
  6333. Signtype interface{} `json:"signtype"`
  6334. WarnMsg interface{} `json:"warn_msg"`
  6335. }
  6336. type ResultSeventeen struct {
  6337. ErrMsg string `json:"err_msg"`
  6338. InfRefmsgid string `json:"inf_refmsgid"`
  6339. Infcode int64 `json:"infcode"`
  6340. Output struct {
  6341. SetlListId string `json:"setl_list_id"`
  6342. } `json:"output"`
  6343. RefmsgTime string `json:"refmsg_time"`
  6344. RespondTime string `json:"respond_time"`
  6345. Signtype string `json:"signtype"`
  6346. WarnInfo string `json:"warn_info"`
  6347. }
  6348. type ResultSeventeenOther struct {
  6349. ErrMsg string `json:"err_msg"`
  6350. InfRefmsgid string `json:"inf_refmsgid"`
  6351. Infcode string `json:"infcode"`
  6352. Output struct {
  6353. SetlListId string `json:"setl_list_id"`
  6354. } `json:"output"`
  6355. RefmsgTime string `json:"refmsg_time"`
  6356. RespondTime string `json:"respond_time"`
  6357. Signtype string `json:"signtype"`
  6358. WarnInfo string `json:"warn_info"`
  6359. }
  6360. type Result90991 struct {
  6361. ErrMsg string `json:"err_msg"`
  6362. InfRefmsgid string `json:"inf_refmsgid"`
  6363. Infcode int64 `json:"infcode"`
  6364. Output struct {
  6365. Result struct {
  6366. PsnNo string `json:"psn_no"`
  6367. CardStat string `json:"card_stat"`
  6368. Certno string `json:"certno"`
  6369. PsnName string `json:"psn_name"`
  6370. CheckStat string `json:"check_stat"`
  6371. SscnoCheckStat string `json:"sscno_check_stat"`
  6372. } `json:"result"`
  6373. } `json:"output"`
  6374. RefmsgTime string `json:"refmsg_time"`
  6375. RespondTime string `json:"respond_time"`
  6376. Signtype interface{} `json:"signtype"`
  6377. WarnInfo interface{} `json:"warn_info"`
  6378. }
  6379. type Result90100 struct {
  6380. ErrMsg string `json:"err_msg"`
  6381. InfRefmsgid string `json:"inf_refmsgid"`
  6382. Infcode int64 `json:"infcode"`
  6383. Output struct {
  6384. PoolareaNo string `json:"poolarea_no"`
  6385. PoolareaNoName string `json:"poolarea_no_name"`
  6386. Insutype string `json:"insutype"`
  6387. InsutypeName string `json:"insutype_name"`
  6388. ClctType string `json:"clct_type"`
  6389. ClctTypeName string `json:"clct_type_name"`
  6390. ClctFlag string `json:"clct_flag"`
  6391. ClctFlagName string `json:"clct_flag_name"`
  6392. AccrymBegn string `json:"accrym_begn"`
  6393. AccrymEnd string `json:"accrym_end"`
  6394. ClctTime string `json:"clct_time"`
  6395. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  6396. } `json:"output"`
  6397. RefmsgTime string `json:"refmsg_time"`
  6398. RespondTime string `json:"respond_time"`
  6399. Signtype interface{} `json:"signtype"`
  6400. WarnInfo interface{} `json:"warn_info"`
  6401. }
  6402. type Custom struct {
  6403. DetItemFeeSumamt string
  6404. Cut string
  6405. FeedetlSn string
  6406. Price string
  6407. MedListCodg string
  6408. Type int64
  6409. AdviceId int64
  6410. ProjectId int64
  6411. ItemId int64
  6412. }
  6413. type Result5301 struct {
  6414. ErrMsg string `json:"err_msg"`
  6415. InfRefmsgid string `json:"inf_refmsgid"`
  6416. Infcode int64 `json:"infcode"`
  6417. Output struct {
  6418. Result []struct {
  6419. OpspDiseCode string `json:"opsp_dise_code"`
  6420. OpspDiseName string `json:"opsp_dise_name"`
  6421. Begndate string `json:"begndate"`
  6422. Enddate string `json:"enddate"`
  6423. } `json:"feedetail"`
  6424. } `json:"output"`
  6425. RefmsgTime string `json:"refmsg_time"`
  6426. RespondTime string `json:"respond_time"`
  6427. Signtype interface{} `json:"signtype"`
  6428. WarnInfo interface{} `json:"warn_info"`
  6429. }
  6430. type Result5301For10265 struct {
  6431. ErrMsg string `json:"err_msg"`
  6432. InfRefmsgid string `json:"inf_refmsgid"`
  6433. Infcode string `json:"infcode"`
  6434. Output struct {
  6435. Result []struct {
  6436. OpspDiseCode string `json:"opsp_dise_code"`
  6437. OpspDiseName string `json:"opsp_dise_name"`
  6438. Begndate string `json:"begndate"`
  6439. Enddate string `json:"enddate"`
  6440. } `json:"feedetail"`
  6441. } `json:"output"`
  6442. RefmsgTime string `json:"refmsg_time"`
  6443. RespondTime string `json:"respond_time"`
  6444. Signtype interface{} `json:"signtype"`
  6445. WarnInfo interface{} `json:"warn_info"`
  6446. }
  6447. //获取个人信息----挂号-----上传就诊信息
  6448. func (c *HisApiController) GetRegisterInfo() {
  6449. id, _ := c.GetInt64("id")
  6450. record_time := c.GetString("record_time")
  6451. settlementValue, _ := c.GetInt64("settlement_value")
  6452. medical_insurance_card := c.GetString("medical_insurance_card")
  6453. name := c.GetString("name")
  6454. id_card_type, _ := c.GetInt64("id_card_type")
  6455. certificates, _ := c.GetInt64("certificates")
  6456. medical_care, _ := c.GetInt64("medical_care")
  6457. birthday := c.GetString("birthday")
  6458. id_card := c.GetString("id_card")
  6459. register_type, _ := c.GetInt64("register")
  6460. doctor, _ := c.GetInt64("doctor")
  6461. department, _ := c.GetInt64("department")
  6462. gender, _ := c.GetInt64("sex")
  6463. registration_fee, _ := c.GetFloat("registration_fee")
  6464. medical_expenses, _ := c.GetFloat("medical_expenses")
  6465. social_type, _ := c.GetInt64("social_type")
  6466. med_type := c.GetString("social_type")
  6467. admin_user_id, _ := c.GetInt64("admin_user_id")
  6468. insuplc_admdvs := c.GetString("insuplc_admdvs")
  6469. timeLayout := "2006-01-02"
  6470. loc, _ := time.LoadLocation("Local")
  6471. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  6472. birthUnix := birthdays.Unix()
  6473. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6474. if err != nil {
  6475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6476. return
  6477. }
  6478. recordDateTime := theTime.Unix()
  6479. adminInfo := c.GetAdminUserInfo()
  6480. var patient service.Patients
  6481. if id == 0 {
  6482. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  6483. } else {
  6484. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  6485. }
  6486. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6487. if patientPrescription.ID == 0 {
  6488. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6489. }
  6490. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6491. if patient.ID == 0 {
  6492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6493. return
  6494. }
  6495. if len(patient.IdCardNo) == 0 {
  6496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  6497. return
  6498. }
  6499. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6500. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  6501. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  6502. //就诊结算未完成,不能进行二次挂号
  6503. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  6504. if len(his) >= 1 {
  6505. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  6506. if len(his) >= 1 && order.ID == 0 {
  6507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  6508. return
  6509. }
  6510. }
  6511. //var register_log string
  6512. if config.IsOpen == 1 {
  6513. var res ResultTwo
  6514. var res10265 ResultTwo10265
  6515. var PsnNo string
  6516. var PsnCertType string
  6517. var Certno string
  6518. var PsnName string
  6519. var Gend string
  6520. var Naty string
  6521. var Brdy string
  6522. var Age float64
  6523. var infoStr string
  6524. var idetinfoStr string
  6525. var infocode int64
  6526. var verify_number string
  6527. fmt.Println(verify_number)
  6528. if miConfig.MdtrtareaAdmvs == "421300" {
  6529. psn_info, _ := service.GetPsnByPatientId(id)
  6530. PsnNo = psn_info.PsnNo
  6531. PsnCertType = psn_info.PsnCertType
  6532. Certno = psn_info.Certno
  6533. PsnName = psn_info.PsnName
  6534. Gend = psn_info.Gend
  6535. Naty = psn_info.Naty
  6536. Brdy = psn_info.Brdy
  6537. Age = psn_info.Age
  6538. infoStr = psn_info.Insuinfo
  6539. idetinfoStr = psn_info.Idetinfo
  6540. infocode = 0
  6541. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6542. psn_info, _ := service.GetPsnByPatientId(id)
  6543. PsnNo = psn_info.PsnNo
  6544. PsnCertType = psn_info.PsnCertType
  6545. Certno = psn_info.Certno
  6546. PsnName = psn_info.PsnName
  6547. Gend = psn_info.Gend
  6548. Naty = psn_info.Naty
  6549. Brdy = psn_info.Brdy
  6550. Age = psn_info.Age
  6551. infoStr = psn_info.Insuinfo
  6552. idetinfoStr = psn_info.Idetinfo
  6553. infocode = 0
  6554. verify_number = psn_info.VerifyNumber
  6555. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6556. if id_card_type == 1 {
  6557. psn_info, _ := service.GetPsnByPatientId(id)
  6558. PsnNo = psn_info.PsnNo
  6559. PsnCertType = psn_info.PsnCertType
  6560. Certno = psn_info.Certno
  6561. PsnName = psn_info.PsnName
  6562. Gend = psn_info.Gend
  6563. Naty = psn_info.Naty
  6564. Brdy = psn_info.Brdy
  6565. Age = psn_info.Age
  6566. infoStr = psn_info.Insuinfo
  6567. idetinfoStr = psn_info.Idetinfo
  6568. infocode = 0
  6569. verify_number = psn_info.VerifyNumber
  6570. } else if id_card_type == 2 {
  6571. 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)
  6572. fmt.Println(errMsgLog)
  6573. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6574. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6575. utils.ErrorLog("解析失败:%v", err)
  6576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6577. return
  6578. }
  6579. PsnNo = res.Output.Baseinfo.PsnNo
  6580. PsnCertType = res.Output.Baseinfo.PsnCertType
  6581. Certno = res.Output.Baseinfo.Certno
  6582. PsnName = res.Output.Baseinfo.PsnName
  6583. Gend = res.Output.Baseinfo.Gend
  6584. Naty = res.Output.Baseinfo.Naty
  6585. Brdy = res.Output.Baseinfo.Brdy
  6586. Age = res.Output.Baseinfo.Age
  6587. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6588. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6589. infoStr = string(Iinfos)
  6590. idetinfoStr = string(Idetinfos)
  6591. infocode = res.Infcode
  6592. }
  6593. } else if miConfig.MdtrtareaAdmvs == "360399" {
  6594. if id_card_type == 1 {
  6595. psn_info, _ := service.GetPsnByPatientId(id)
  6596. PsnNo = psn_info.PsnNo
  6597. PsnCertType = psn_info.PsnCertType
  6598. Certno = psn_info.Certno
  6599. PsnName = psn_info.PsnName
  6600. Gend = psn_info.Gend
  6601. Naty = psn_info.Naty
  6602. Brdy = psn_info.Brdy
  6603. Age = psn_info.Age
  6604. infoStr = psn_info.Insuinfo
  6605. idetinfoStr = psn_info.Idetinfo
  6606. infocode = 0
  6607. verify_number = psn_info.VerifyNumber
  6608. } else if id_card_type == 2 {
  6609. 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, "")
  6610. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6611. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6612. utils.ErrorLog("解析失败:%v", err)
  6613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6614. return
  6615. }
  6616. PsnNo = res.Output.Baseinfo.PsnNo
  6617. PsnCertType = res.Output.Baseinfo.PsnCertType
  6618. Certno = res.Output.Baseinfo.Certno
  6619. PsnName = res.Output.Baseinfo.PsnName
  6620. Gend = res.Output.Baseinfo.Gend
  6621. Naty = res.Output.Baseinfo.Naty
  6622. Brdy = res.Output.Baseinfo.Brdy
  6623. Age = res.Output.Baseinfo.Age
  6624. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6625. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6626. infoStr = string(Iinfos)
  6627. idetinfoStr = string(Idetinfos)
  6628. infocode = res.Infcode
  6629. }
  6630. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6631. if id_card_type == 1 {
  6632. psn_info, _ := service.GetPsnByPatientId(id)
  6633. PsnNo = psn_info.PsnNo
  6634. PsnCertType = psn_info.PsnCertType
  6635. Certno = psn_info.Certno
  6636. PsnName = psn_info.PsnName
  6637. Gend = psn_info.Gend
  6638. Naty = psn_info.Naty
  6639. Brdy = psn_info.Brdy
  6640. Age = psn_info.Age
  6641. infoStr = psn_info.Insuinfo
  6642. idetinfoStr = psn_info.Idetinfo
  6643. infocode = 0
  6644. verify_number = psn_info.VerifyNumber
  6645. } else if id_card_type == 2 {
  6646. 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)
  6647. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6648. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6649. utils.ErrorLog("解析失败:%v", err)
  6650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6651. return
  6652. }
  6653. PsnNo = res.Output.Baseinfo.PsnNo
  6654. PsnCertType = res.Output.Baseinfo.PsnCertType
  6655. Certno = res.Output.Baseinfo.Certno
  6656. PsnName = res.Output.Baseinfo.PsnName
  6657. Gend = res.Output.Baseinfo.Gend
  6658. Naty = res.Output.Baseinfo.Naty
  6659. Brdy = res.Output.Baseinfo.Brdy
  6660. Age = res.Output.Baseinfo.Age
  6661. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6662. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6663. infoStr = string(Iinfos)
  6664. idetinfoStr = string(Idetinfos)
  6665. infocode = res.Infcode
  6666. }
  6667. } else if miConfig.MdtrtareaAdmvs == "131023" {
  6668. var result string
  6669. var requestLog string
  6670. 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), "")
  6671. if id_card_type == 4 {
  6672. psn_info, _ := service.GetPsnByPatientId(id)
  6673. PsnNo = psn_info.PsnNo
  6674. PsnCertType = psn_info.PsnCertType
  6675. Certno = psn_info.Certno
  6676. PsnName = psn_info.PsnName
  6677. Gend = psn_info.Gend
  6678. Naty = psn_info.Naty
  6679. Brdy = psn_info.Brdy
  6680. Age = psn_info.Age
  6681. infoStr = psn_info.Insuinfo
  6682. idetinfoStr = psn_info.Idetinfo
  6683. infocode = 0
  6684. verify_number = psn_info.VerifyNumber
  6685. } else {
  6686. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6687. if miConfig.Code == "H15049901371" {
  6688. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6689. utils.ErrorLog("解析失败:%v", err)
  6690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6691. return
  6692. }
  6693. res.ErrMsg = res10265.ErrMsg
  6694. res.Output = res10265.Output
  6695. res.InfRefmsgid = res10265.InfRefmsgid
  6696. } else {
  6697. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6698. utils.ErrorLog("解析失败:%v", err)
  6699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6700. return
  6701. }
  6702. }
  6703. PsnNo = res.Output.Baseinfo.PsnNo
  6704. PsnCertType = res.Output.Baseinfo.PsnCertType
  6705. Certno = res.Output.Baseinfo.Certno
  6706. PsnName = res.Output.Baseinfo.PsnName
  6707. Gend = res.Output.Baseinfo.Gend
  6708. Naty = res.Output.Baseinfo.Naty
  6709. Brdy = res.Output.Baseinfo.Brdy
  6710. Age = res.Output.Baseinfo.Age
  6711. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6712. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6713. infoStr = string(Iinfos)
  6714. idetinfoStr = string(Idetinfos)
  6715. if miConfig.Code == "H15049901371" {
  6716. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  6717. } else {
  6718. infocode = res.Infcode
  6719. }
  6720. }
  6721. } else {
  6722. var result string
  6723. var requestLog string
  6724. if miConfig.UserOrgId == 10138 {
  6725. if id_card_type != 4 {
  6726. //psn_info, _ := service.GetPsnByPatientId(id)
  6727. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  6728. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  6729. }
  6730. } else {
  6731. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  6732. }
  6733. if id_card_type == 4 {
  6734. psn_info, _ := service.GetPsnByPatientId(id)
  6735. PsnNo = psn_info.PsnNo
  6736. PsnCertType = psn_info.PsnCertType
  6737. Certno = psn_info.Certno
  6738. PsnName = psn_info.PsnName
  6739. Gend = psn_info.Gend
  6740. Naty = psn_info.Naty
  6741. Brdy = psn_info.Brdy
  6742. Age = psn_info.Age
  6743. infoStr = psn_info.Insuinfo
  6744. idetinfoStr = psn_info.Idetinfo
  6745. infocode = 0
  6746. verify_number = psn_info.VerifyNumber
  6747. } else {
  6748. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6749. if miConfig.Code == "H15049901371" {
  6750. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6751. utils.ErrorLog("解析失败:%v", err)
  6752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6753. return
  6754. }
  6755. res.ErrMsg = res10265.ErrMsg
  6756. res.Output = res10265.Output
  6757. res.InfRefmsgid = res10265.InfRefmsgid
  6758. } else {
  6759. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6760. utils.ErrorLog("解析失败:%v", err)
  6761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6762. return
  6763. }
  6764. }
  6765. PsnNo = res.Output.Baseinfo.PsnNo
  6766. PsnCertType = res.Output.Baseinfo.PsnCertType
  6767. Certno = res.Output.Baseinfo.Certno
  6768. PsnName = res.Output.Baseinfo.PsnName
  6769. Gend = res.Output.Baseinfo.Gend
  6770. Naty = res.Output.Baseinfo.Naty
  6771. Brdy = res.Output.Baseinfo.Brdy
  6772. Age = res.Output.Baseinfo.Age
  6773. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6774. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6775. infoStr = string(Iinfos)
  6776. idetinfoStr = string(Idetinfos)
  6777. if miConfig.Code == "H15049901371" {
  6778. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  6779. } else {
  6780. infocode = res.Infcode
  6781. }
  6782. }
  6783. }
  6784. if infocode == 0 {
  6785. his := models.VMHisPatient{
  6786. Name: name,
  6787. Gender: gender,
  6788. Birthday: birthUnix,
  6789. MedicalTreatmentType: medical_care,
  6790. IdType: certificates,
  6791. IdCardNo: id_card,
  6792. BalanceAccountsType: settlementValue,
  6793. SocialType: social_type,
  6794. MedicalInsuranceNumber: medical_insurance_card,
  6795. RegisterType: register_type,
  6796. RegisterCost: registration_fee,
  6797. TreatmentCost: medical_expenses,
  6798. Status: 1,
  6799. Ctime: time.Now().Unix(),
  6800. Mtime: time.Now().Unix(),
  6801. PsnNo: PsnNo,
  6802. PsnCertType: PsnCertType,
  6803. Certno: Certno,
  6804. PsnName: PsnName,
  6805. Gend: Gend,
  6806. Naty: Naty,
  6807. Brdy: Brdy,
  6808. Age: Age,
  6809. Iinfo: infoStr,
  6810. Idetinfo: idetinfoStr,
  6811. PatientId: patient.ID,
  6812. RecordDate: theTime.Unix(),
  6813. UserOrgId: adminInfo.CurrentOrgId,
  6814. AdminUserId: admin_user_id,
  6815. IsReturn: 1,
  6816. IdCardType: id_card_type,
  6817. Doctor: doctor,
  6818. Departments: department,
  6819. }
  6820. timestamp := time.Now().Unix()
  6821. tempTime := time.Unix(timestamp, 0)
  6822. timeFormat := tempTime.Format("20060102150405")
  6823. chrgBchno := rand.Intn(100000) + 10000
  6824. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6825. his.Number = ipt_otp_no
  6826. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  6827. department, _ := service.GetDepartMentDetail(department)
  6828. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  6829. IdCardNo := ""
  6830. if id_card_type == 1 {
  6831. // IdCardNo = medical_insurance_card
  6832. IdCardNo = patient.IdCardNo
  6833. } else {
  6834. IdCardNo = patient.IdCardNo
  6835. }
  6836. var rf []*ResultFive
  6837. json.Unmarshal([]byte(his.Iinfo), &rf)
  6838. var insutypes []*ResultFive
  6839. var insutype string
  6840. var insuplc_admdvs_temp string
  6841. var is390 int = 0
  6842. var is310 int = 0
  6843. for _, item := range rf {
  6844. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6845. insutypes = append(insutypes, item)
  6846. }
  6847. }
  6848. if len(insutypes) == 1 {
  6849. insutype = insutypes[0].Insutype
  6850. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6851. } else {
  6852. for _, i := range insutypes {
  6853. if i.Insutype == "390" {
  6854. is390 = 1
  6855. }
  6856. if i.Insutype == "310" {
  6857. is310 = 1
  6858. }
  6859. }
  6860. }
  6861. if is390 == 1 {
  6862. insutype = "390"
  6863. }
  6864. if is310 == 1 {
  6865. insutype = "310"
  6866. }
  6867. if len(insutypes) == 0 {
  6868. insutype = "310"
  6869. }
  6870. if len(insutypes) == 2 {
  6871. insutype = med_type
  6872. }
  6873. if len(med_type) > 0 {
  6874. insutype = med_type
  6875. }
  6876. var infocode int64
  6877. var resThree ResultThree
  6878. var resThree10265 ResultThree10265
  6879. if len(insuplc_admdvs) == 0 {
  6880. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  6881. } else {
  6882. insuplc_admdvs_temp = insuplc_admdvs
  6883. }
  6884. if miConfig.MdtrtareaAdmvs == "350500" {
  6885. var rf []*ResultIDInfo
  6886. json.Unmarshal([]byte(idetinfoStr), &rf)
  6887. if len(rf) > 0 {
  6888. if len(rf[0].Memo) > 0 {
  6889. content := rf[0].Memo[1:len(rf[0].Memo)]
  6890. content2 := content[:len(rf[0].Memo)-1]
  6891. fmt.Println(content2)
  6892. var rf2 ResultMemo
  6893. json.Unmarshal([]byte(content2), &rf2)
  6894. fmt.Println(rf2)
  6895. fmt.Println(rf2.InsuAdmdvs)
  6896. }
  6897. }
  6898. }
  6899. if miConfig.MdtrtareaAdmvs == "421300" {
  6900. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  6901. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  6902. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6903. "&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
  6904. resp, requestErr := http.Get(api)
  6905. if requestErr != nil {
  6906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6907. return
  6908. }
  6909. body, ioErr := ioutil.ReadAll(resp.Body)
  6910. if ioErr != nil {
  6911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6913. return
  6914. }
  6915. var respJSON map[string]interface{}
  6916. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6919. return
  6920. }
  6921. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6922. result, _ := json.Marshal(respJSON)
  6923. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6924. utils.ErrorLog("解析失败:%v", err)
  6925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6926. return
  6927. }
  6928. infocode = resThree.Infcode
  6929. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6930. psn_info, _ := service.GetPsnByPatientId(id)
  6931. his.PsnNo = psn_info.PsnNo
  6932. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6933. var cert_no string
  6934. if id_card_type == 3 {
  6935. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  6936. cert_no = IdCardNo
  6937. } else if id_card_type == 4 {
  6938. cert_no = IdCardNo
  6939. psn_info.VerifyNumber = psn_info.VerifyNumber
  6940. } else {
  6941. bas := strings.Split(psn_info.CardInfo, "|")
  6942. cert_no = bas[2]
  6943. }
  6944. var hisPrescription []*models.HisPrescription
  6945. for _, item := range rf {
  6946. if item.Insutype == insutype {
  6947. //insuplc_admdvs = item.InsuplcAdmdvs
  6948. his.InsuplcAdmdvs = insuplc_admdvs
  6949. }
  6950. }
  6951. his.Insutype = insutype
  6952. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  6953. fmt.Println(res3101)
  6954. fmt.Println(res3101.Infcode)
  6955. if res3101.Infcode == "0" {
  6956. fmt.Println("33333333")
  6957. if len(res3101.Output.Result) > 0 {
  6958. fmt.Println("222222")
  6959. for _, item := range res3101.Output.Result {
  6960. if len(res3101.ErrMsg) == 0 {
  6961. res3101.ErrMsg = item.VolaCont
  6962. } else {
  6963. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  6964. }
  6965. }
  6966. c.ServeSuccessJSON(map[string]interface{}{
  6967. "failed_code": -10,
  6968. "msg": res3101.ErrMsg,
  6969. })
  6970. return
  6971. } else {
  6972. fmt.Println("11111")
  6973. var api string
  6974. if miConfig.MdtrtareaAdmvs == "320921" {
  6975. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6976. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6977. "&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
  6978. } else {
  6979. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6980. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6981. "&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
  6982. }
  6983. resp, requestErr := http.Get(api)
  6984. if requestErr != nil {
  6985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6986. return
  6987. }
  6988. body, ioErr := ioutil.ReadAll(resp.Body)
  6989. if ioErr != nil {
  6990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6992. return
  6993. }
  6994. var respJSON map[string]interface{}
  6995. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6998. return
  6999. }
  7000. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7001. result, _ := json.Marshal(respJSON)
  7002. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7003. utils.ErrorLog("解析失败:%v", err)
  7004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7005. return
  7006. }
  7007. resThree.ErrMsg = resThree10265.ErrMsg
  7008. resThree.Output = resThree10265.Output
  7009. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7010. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7011. }
  7012. } else if res3101.Infcode != "0" {
  7013. c.ServeSuccessJSON(map[string]interface{}{
  7014. "failed_code": -10,
  7015. "msg": res3101.ErrMsg,
  7016. })
  7017. return
  7018. }
  7019. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7020. psn_info, _ := service.GetPsnByPatientId(id)
  7021. var cert_no string
  7022. if id_card_type == 1 {
  7023. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  7024. } else if id_card_type == 4 {
  7025. cert_no = psn_info.VerifyNumber
  7026. } else {
  7027. cert_no = psn_info.VerifyNumber
  7028. }
  7029. 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)
  7030. saveLog(result, requestLog, "2201", "挂号")
  7031. if miConfig.Code == "H15049901371" {
  7032. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7033. utils.ErrorLog("解析失败:%v", err)
  7034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7035. return
  7036. }
  7037. resThree.ErrMsg = resThree10265.ErrMsg
  7038. resThree.Output = resThree10265.Output
  7039. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7040. } else {
  7041. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7042. utils.ErrorLog("解析失败:%v", err)
  7043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7044. return
  7045. }
  7046. }
  7047. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7048. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  7049. psn_info, _ := service.GetPsnByPatientId(id)
  7050. var result string
  7051. var requestLog string
  7052. if id_card_type == 1 {
  7053. bas := strings.Split(psn_info.CardInfo, "|")
  7054. basNumber := bas[2]
  7055. card_sn := bas[3]
  7056. 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)
  7057. saveLog(result, requestLog, "2201A", "挂号")
  7058. } else if id_card_type == 2 {
  7059. 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, "", "")
  7060. saveLog(result, requestLog, "2201A", "挂号")
  7061. } else {
  7062. 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, "", "")
  7063. saveLog(result, requestLog, "2201A", "挂号")
  7064. }
  7065. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7066. utils.ErrorLog("解析失败:%v", err)
  7067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7068. return
  7069. }
  7070. infocode = resThree.Infcode
  7071. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  7072. psn_info, _ := service.GetPsnByPatientId(id)
  7073. var result string
  7074. var requestLog string
  7075. if id_card_type == 1 {
  7076. bas := strings.Split(psn_info.CardInfo, "|")
  7077. basNumber := bas[2]
  7078. card_sn := bas[3]
  7079. 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)
  7080. saveLog(result, requestLog, "2201A", "挂号")
  7081. } else if id_card_type == 2 {
  7082. 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, "", "")
  7083. saveLog(result, requestLog, "2201A", "挂号")
  7084. } else {
  7085. 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, "", "")
  7086. saveLog(result, requestLog, "2201A", "挂号")
  7087. }
  7088. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7089. utils.ErrorLog("解析失败:%v", err)
  7090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7091. return
  7092. }
  7093. infocode = resThree.Infcode
  7094. } else if miConfig.MdtrtareaAdmvs == "131023" {
  7095. psn_info, _ := service.GetPsnByPatientId(id)
  7096. 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)
  7097. saveLog(result, requestLog, "2201A", "挂号")
  7098. if miConfig.Code == "H15049901371" {
  7099. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7100. utils.ErrorLog("解析失败:%v", err)
  7101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7102. return
  7103. }
  7104. resThree.ErrMsg = resThree10265.ErrMsg
  7105. resThree.Output = resThree10265.Output
  7106. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7107. } else {
  7108. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7109. utils.ErrorLog("解析失败:%v", err)
  7110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7111. return
  7112. }
  7113. }
  7114. if miConfig.Code == "H15049901371" {
  7115. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7116. } else {
  7117. infocode = resThree.Infcode
  7118. }
  7119. } else {
  7120. psn_info, _ := service.GetPsnByPatientId(id)
  7121. 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)
  7122. saveLog(result, requestLog, "2201A", "挂号")
  7123. if miConfig.Code == "H15049901371" {
  7124. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7125. utils.ErrorLog("解析失败:%v", err)
  7126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7127. return
  7128. }
  7129. resThree.ErrMsg = resThree10265.ErrMsg
  7130. resThree.Output = resThree10265.Output
  7131. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7132. } else {
  7133. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7134. utils.ErrorLog("解析失败:%v", err)
  7135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7136. return
  7137. }
  7138. }
  7139. if miConfig.Code == "H15049901371" {
  7140. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7141. } else {
  7142. infocode = resThree.Infcode
  7143. }
  7144. }
  7145. if infocode != 0 {
  7146. adminUser := c.GetAdminUserInfo()
  7147. errlog := &models.HisOrderError{
  7148. UserOrgId: adminUser.CurrentOrgId,
  7149. Ctime: time.Now().Unix(),
  7150. Mtime: time.Now().Unix(),
  7151. ErrMsg: resThree.ErrMsg,
  7152. Status: 1,
  7153. PatientId: id,
  7154. RecordTime: recordDateTime,
  7155. Stage: 2,
  7156. }
  7157. service.CreateErrMsgLog(errlog)
  7158. c.ServeSuccessJSON(map[string]interface{}{
  7159. "failed_code": -10,
  7160. "msg": resThree.ErrMsg,
  7161. })
  7162. return
  7163. }
  7164. his.Number = resThree.Output.Data.MdtrtID
  7165. his.PsnNo = resThree.Output.Data.PsnNo
  7166. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  7167. his.IdCardNo = patient.IdCardNo
  7168. his.PhoneNumber = patient.Phone
  7169. his.UserOrgId = adminInfo.CurrentOrgId
  7170. his.Insutype = insutype
  7171. his.Ctime = time.Now().Unix()
  7172. his.Mtime = time.Now().Unix()
  7173. his.InsuplcAdmdvs = insuplc_admdvs_temp
  7174. his.Status = 1
  7175. service.UpdateHisPatientStatus(&his)
  7176. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  7177. c.ServeSuccessJSON(map[string]interface{}{
  7178. "his_info": his,
  7179. })
  7180. } else {
  7181. adminUser := c.GetAdminUserInfo()
  7182. errlog := &models.HisOrderError{
  7183. UserOrgId: adminUser.CurrentOrgId,
  7184. Ctime: time.Now().Unix(),
  7185. Mtime: time.Now().Unix(),
  7186. ErrMsg: res.ErrMsg,
  7187. Status: 1,
  7188. PatientId: id,
  7189. RecordTime: recordDateTime,
  7190. Stage: 1,
  7191. }
  7192. service.CreateErrMsgLog(errlog)
  7193. c.ServeSuccessJSON(map[string]interface{}{
  7194. "failed_code": -10,
  7195. "msg": res.ErrMsg,
  7196. })
  7197. return
  7198. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7199. }
  7200. }
  7201. }
  7202. //上传明细----预结算----确认订单
  7203. func (c *HisApiController) GetUploadInfo() {
  7204. id, _ := c.GetInt64("id")
  7205. record_time := c.GetString("record_time")
  7206. his_patient_id, _ := c.GetInt64("his_patient_id")
  7207. order_id, _ := c.GetInt64("order_id")
  7208. pay_way, _ := c.GetInt64("pay_way")
  7209. pay_price, _ := c.GetFloat("pay_price")
  7210. pay_card_no := c.GetString("pay_card_no")
  7211. discount_price, _ := c.GetFloat("discount_price")
  7212. preferential_price, _ := c.GetFloat("preferential_price")
  7213. reality_price, _ := c.GetFloat("reality_price")
  7214. found_price, _ := c.GetFloat("found_price")
  7215. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7216. private_price, _ := c.GetFloat("private_price")
  7217. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7218. admin_user_id, _ := c.GetInt64("admin_user_id")
  7219. fapiao_code := c.GetString("fapiao_code")
  7220. fapiao_number := c.GetString("fapiao_number")
  7221. diagnosis_id := c.GetString("diagnosis")
  7222. sick_type, _ := c.GetInt64("sick_type")
  7223. reg_type, _ := c.GetInt64("p_type")
  7224. begin_time := c.GetString("begin_time")
  7225. id_str := c.GetString("ids")
  7226. ids_arr := strings.Split(id_str, ",")
  7227. timeLayout := "2006-01-02"
  7228. loc, _ := time.LoadLocation("Local")
  7229. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7230. if err != nil {
  7231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7232. return
  7233. }
  7234. recordDateTime := theTime.Unix()
  7235. adminUser := c.GetAdminUserInfo()
  7236. var tempOrder models.HisOrder
  7237. tempOrder, _ = service.GetHisOrderByID(order_id)
  7238. var prescriptions []*models.HisPrescription
  7239. var start_time int64
  7240. var end_time int64
  7241. //押金模块
  7242. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  7243. tmp_decimal := c.GetString("tmp_decimal")
  7244. var decimal float64 //本次使用的押金
  7245. var errmsg error
  7246. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  7247. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  7248. return
  7249. }
  7250. if len(tmp_decimal) > 0 {
  7251. if tmp_decimal[0] == 45 {
  7252. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  7253. return
  7254. }
  7255. }
  7256. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  7257. fmt.Println(errs)
  7258. decimal = tt
  7259. //if adminUser.CurrentOrgId == 10106{
  7260. // if len(fapiao_code) == 0{
  7261. // fapiao_code = "144072080589"
  7262. // }
  7263. // if len(fapiao_number) == 0{
  7264. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  7265. // if order.ID == 0{
  7266. // fapiao_number = "00001520"
  7267. // }else{
  7268. // //fapiao_code = "00001520"
  7269. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  7270. // var zero string
  7271. // if fpNumber >= 1000{
  7272. // zero = "0000" + strconv.Itoa(fpNumber)
  7273. // }else if fpNumber >= 10000{
  7274. // zero = "000" + strconv.Itoa(fpNumber)
  7275. // } else if fpNumber >= 100000{
  7276. // zero = "00" + strconv.Itoa(fpNumber)
  7277. // } else if fpNumber >= 1000000{
  7278. // zero = "0" + strconv.Itoa(fpNumber)
  7279. // }else {
  7280. // zero = strconv.Itoa(fpNumber)
  7281. // }
  7282. // fapiao_number = zero
  7283. // }
  7284. // }
  7285. //}
  7286. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7287. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7288. var patientPrescription models.HisPrescriptionInfo
  7289. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7290. if patientPrescription.ID == 0 {
  7291. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7292. }
  7293. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7294. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7295. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7296. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7297. var config []*models.HisXtDiagnoseConfig
  7298. for _, item := range diagnosis_ids {
  7299. id, _ := strconv.ParseInt(item, 10, 64)
  7300. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7301. config = append(config, &diagnosisConfig)
  7302. }
  7303. sickConfig, _ := service.FindSickById(sick_type)
  7304. //if tempOrder.ID == 0 {
  7305. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  7306. //}
  7307. if tempOrder.ID == 0 {
  7308. var result string
  7309. var requestLog string
  7310. var res2 ResultSix
  7311. var ressix10265 ResultSix10265
  7312. if miConfig.MdtrtareaAdmvs == "421300" {
  7313. data := make(map[string]interface{})
  7314. client := &http.Client{}
  7315. data["psn_no"] = his.PsnNo
  7316. data["mdtrt_id"] = his.Number
  7317. data["opter"] = roles.UserName
  7318. data["org_name"] = miConfig.OrgName
  7319. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7320. data["doctor_id"] = doctor_info.DoctorNumber
  7321. data["doctor_name"] = doctor_info.UserName
  7322. data["department"] = department.Name
  7323. data["fixmedins_code"] = miConfig.Code
  7324. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7325. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7326. data["secret_key"] = miConfig.SecretKey
  7327. data["sick_code"] = sickConfig.CountryCode
  7328. data["sick_name"] = sickConfig.ClassName
  7329. data["dept"] = strconv.FormatInt(department.ID, 10)
  7330. data["config"] = config
  7331. data["begin_time"] = begin_time
  7332. bytesData, _ := json.Marshal(data)
  7333. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7334. resp, _ := client.Do(req)
  7335. defer resp.Body.Close()
  7336. body, ioErr := ioutil.ReadAll(resp.Body)
  7337. if ioErr != nil {
  7338. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7340. return
  7341. }
  7342. var respJSON map[string]interface{}
  7343. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7344. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7346. return
  7347. }
  7348. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7349. userJSONBytes, _ := json.Marshal(respJSON)
  7350. fmt.Println("log")
  7351. fmt.Println(string(userJSONBytes))
  7352. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7353. utils.ErrorLog("解析失败:%v", err)
  7354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7355. return
  7356. }
  7357. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7358. data := make(map[string]interface{})
  7359. client := &http.Client{}
  7360. data["psn_no"] = his.PsnNo
  7361. data["mdtrt_id"] = his.Number
  7362. data["doctor"] = roles.UserName
  7363. data["department"] = department.Name
  7364. data["org_name"] = miConfig.OrgName
  7365. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7366. data["doctor_id"] = doctor_info.DoctorNumber
  7367. data["new_doctor_name"] = doctor_info.UserName
  7368. data["fixmedins_code"] = miConfig.Code
  7369. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7370. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7371. data["secret_key"] = miConfig.SecretKey
  7372. data["sick_code"] = sickConfig.CountryCode
  7373. data["sick_name"] = sickConfig.ClassName
  7374. data["url"] = miConfig.Url
  7375. data["ak"] = miConfig.AccessKey
  7376. data["begin_time"] = begin_time
  7377. data["cainfo"] = miConfig.Cainfo
  7378. data["dept"] = strconv.FormatInt(department.ID, 10)
  7379. data["config"] = config
  7380. bytesData, _ := json.Marshal(data)
  7381. var req *http.Request
  7382. if miConfig.MdtrtareaAdmvs == "320921" {
  7383. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7384. //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 +
  7385. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7386. } else {
  7387. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7388. }
  7389. resp, _ := client.Do(req)
  7390. defer resp.Body.Close()
  7391. body, ioErr := ioutil.ReadAll(resp.Body)
  7392. if ioErr != nil {
  7393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7395. return
  7396. }
  7397. var respJSON map[string]interface{}
  7398. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7401. return
  7402. }
  7403. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7404. userJSONBytes, _ := json.Marshal(respJSON)
  7405. fmt.Println("log")
  7406. fmt.Println(string(userJSONBytes))
  7407. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  7408. utils.ErrorLog("解析失败:%v", err)
  7409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7410. return
  7411. }
  7412. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7413. res2.Output = ressix10265.Output
  7414. res2.ErrMsg = ressix10265.ErrMsg
  7415. res2.Cainfo = ressix10265.Cainfo
  7416. res2.WarnMsg = ressix10265.WarnMsg
  7417. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7418. res2.Infcode = infocode
  7419. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7420. 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)
  7421. saveLog(result, requestLog, "2203", "上传就诊信息")
  7422. var respJSON2 map[string]interface{}
  7423. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7426. return
  7427. }
  7428. userJSONBytes2, _ := json.Marshal(respJSON2)
  7429. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7430. utils.ErrorLog("解析失败:%v", err)
  7431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7432. return
  7433. }
  7434. } else {
  7435. if miConfig.MdtrtareaAdmvs == "440781" { //
  7436. 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)
  7437. } else {
  7438. if miConfig.Code == "H15049901371" {
  7439. //赤峰地区国家医保医疗类别
  7440. //职工透析:医疗类别选特殊情况门诊990502
  7441. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7442. var med_type string
  7443. if his.Insutype == "390" {
  7444. if reg_type == 14 {
  7445. med_type = "9933"
  7446. } else if reg_type == 11 {
  7447. med_type = "11"
  7448. }
  7449. } else if his.Insutype == "310" {
  7450. if reg_type == 14 {
  7451. med_type = "990502"
  7452. } else if reg_type == 11 {
  7453. med_type = "11"
  7454. }
  7455. }
  7456. 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)
  7457. } else {
  7458. 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)
  7459. }
  7460. }
  7461. saveLog(result, requestLog, "2203", "上传就诊信息")
  7462. var respJSON2 map[string]interface{}
  7463. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7466. return
  7467. }
  7468. userJSONBytes2, _ := json.Marshal(respJSON2)
  7469. if miConfig.Code == "H15049901371" {
  7470. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  7471. utils.ErrorLog("解析失败:%v", err)
  7472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7473. return
  7474. }
  7475. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7476. res2.Output = ressix10265.Output
  7477. res2.ErrMsg = ressix10265.ErrMsg
  7478. res2.Cainfo = ressix10265.Cainfo
  7479. res2.WarnMsg = ressix10265.WarnMsg
  7480. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7481. res2.Infcode = infocode
  7482. } else {
  7483. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7484. utils.ErrorLog("解析失败:%v", err)
  7485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7486. return
  7487. }
  7488. }
  7489. }
  7490. if res2.Infcode != 0 {
  7491. adminUser := c.GetAdminUserInfo()
  7492. errlog := &models.HisOrderError{
  7493. UserOrgId: adminUser.CurrentOrgId,
  7494. Ctime: time.Now().Unix(),
  7495. Mtime: time.Now().Unix(),
  7496. ErrMsg: res2.ErrMsg,
  7497. Status: 1,
  7498. PatientId: id,
  7499. RecordTime: recordDateTime,
  7500. Stage: 3,
  7501. }
  7502. service.CreateErrMsgLog(errlog)
  7503. c.ServeSuccessJSON(map[string]interface{}{
  7504. "failed_code": -10,
  7505. "msg": res2.ErrMsg,
  7506. })
  7507. return
  7508. } else {
  7509. his.Diagnosis = diagnosis_id
  7510. his.SickType = sickConfig.ID
  7511. //var p_type int64
  7512. //if reg_type == 1111 || reg_type == 1112 {
  7513. // p_type = 11
  7514. //
  7515. //}
  7516. his.PType = fmt.Sprintf("%d", reg_type)
  7517. service.UpdateHisPatientThree(&his)
  7518. data := make(map[string]interface{})
  7519. if settle_accounts_type == 1 { //日结
  7520. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7521. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7522. } else {
  7523. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7524. }
  7525. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  7526. data["pre"] = prescriptions
  7527. } else { //月结
  7528. start_time_str := c.GetString("start_time")
  7529. end_time_str := c.GetString("end_time")
  7530. timeLayout := "2006-01-02"
  7531. loc, _ := time.LoadLocation("Local")
  7532. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7533. if err != nil {
  7534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7535. return
  7536. }
  7537. recordStartTime := theStartTime.Unix()
  7538. start_time = recordStartTime
  7539. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7540. if err != nil {
  7541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7542. return
  7543. }
  7544. recordEndTime := theEndTime.Unix()
  7545. end_time = recordEndTime
  7546. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7547. data["pre"] = prescriptions
  7548. }
  7549. timestamp := time.Now().Unix()
  7550. tempTime := time.Unix(timestamp, 0)
  7551. timeFormat := tempTime.Format("20060102150405")
  7552. chrgBchno := rand.Intn(100000) + 10000
  7553. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7554. strconv.FormatInt(his.PatientId, 10)
  7555. client := &http.Client{}
  7556. data["psn_no"] = his.PsnNo
  7557. data["mdtrt_id"] = his.Number
  7558. data["chrg_bchno"] = chrg_bchno
  7559. data["org_name"] = miConfig.OrgName
  7560. data["doctor"] = doctor_info.UserName
  7561. data["doctor_id"] = doctor_info.DoctorNumber
  7562. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7563. data["fixmedins_code"] = miConfig.Code
  7564. data["opter"] = roles.UserName
  7565. data["dept_code"] = department.Number
  7566. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7567. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7568. data["secret_key"] = miConfig.SecretKey
  7569. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7570. data["url"] = miConfig.Url
  7571. data["ak"] = miConfig.AccessKey
  7572. data["new_doctor_name"] = patientPrescription.Doctor
  7573. data["diag_code"] = sickConfig.CountryCode
  7574. data["cainfo"] = miConfig.Cainfo
  7575. data["opter"] = roles.UserName
  7576. var ids []int64
  7577. for _, item := range prescriptions {
  7578. ids = append(ids, item.ID)
  7579. }
  7580. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7581. if config.IsOpen == 1 { //对接了医保,走医保流程
  7582. var res ResultFour
  7583. var resFour10265 ResultFour10265
  7584. if miConfig.MdtrtareaAdmvs == "421300" {
  7585. bytesData, _ := json.Marshal(data)
  7586. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7587. resp, _ := client.Do(req)
  7588. defer resp.Body.Close()
  7589. body, ioErr := ioutil.ReadAll(resp.Body)
  7590. if ioErr != nil {
  7591. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7593. return
  7594. }
  7595. var respJSON map[string]interface{}
  7596. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7599. return
  7600. }
  7601. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7602. userJSONBytes, _ := json.Marshal(respJSON)
  7603. fmt.Println("log")
  7604. fmt.Println(string(userJSONBytes))
  7605. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7606. utils.ErrorLog("解析失败:%v", err)
  7607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7608. return
  7609. }
  7610. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7611. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7612. if result3101.Infcode == "0" {
  7613. if len(result3101.Output.Result) > 0 {
  7614. var errMsgs []string
  7615. for _, item := range result3101.Output.Result {
  7616. errMsgs = append(errMsgs, item.VolaCont)
  7617. }
  7618. c.ServeSuccessJSON(map[string]interface{}{
  7619. "failed_code": -10,
  7620. "msg": errMsgs,
  7621. })
  7622. return
  7623. }
  7624. }
  7625. if miConfig.MdtrtareaAdmvs == "320921" {
  7626. data["doctor_id"] = "D320923012139"
  7627. } else {
  7628. data["doctor_id"] = "D371621008686"
  7629. }
  7630. bytesData, _ := json.Marshal(data)
  7631. var req *http.Request
  7632. if miConfig.MdtrtareaAdmvs == "320921" {
  7633. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7634. } else {
  7635. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7636. }
  7637. resp, _ := client.Do(req)
  7638. defer resp.Body.Close()
  7639. body, ioErr := ioutil.ReadAll(resp.Body)
  7640. if ioErr != nil {
  7641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7643. return
  7644. }
  7645. var respJSON map[string]interface{}
  7646. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7649. return
  7650. }
  7651. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7652. userJSONBytes, _ := json.Marshal(respJSON)
  7653. fmt.Println("log")
  7654. fmt.Println(string(userJSONBytes))
  7655. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7656. utils.ErrorLog("解析失败:%v", err)
  7657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7658. return
  7659. }
  7660. res.InfRefmsgid = resFour10265.InfRefmsgid
  7661. res.Output = resFour10265.Output
  7662. res.ErrMsg = resFour10265.ErrMsg
  7663. res.Cainfo = resFour10265.Cainfo
  7664. res.WarnMsg = resFour10265.WarnMsg
  7665. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7666. res.Infcode = infocode
  7667. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7668. 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)
  7669. var dat map[string]interface{}
  7670. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7671. fmt.Println(dat)
  7672. } else {
  7673. fmt.Println(err)
  7674. }
  7675. saveLog(result, request_log, "2204", "上传费用明细")
  7676. userJSONBytes, _ := json.Marshal(dat)
  7677. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7678. utils.ErrorLog("解析失败:%v", err)
  7679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7680. return
  7681. }
  7682. res.InfRefmsgid = resFour10265.InfRefmsgid
  7683. res.Output = resFour10265.Output
  7684. res.ErrMsg = resFour10265.ErrMsg
  7685. res.Cainfo = resFour10265.Cainfo
  7686. res.WarnMsg = resFour10265.WarnMsg
  7687. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7688. res.Infcode = infocode
  7689. } else {
  7690. if miConfig.Code == "H15049901371" {
  7691. 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)
  7692. var dat map[string]interface{}
  7693. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7694. fmt.Println(dat)
  7695. } else {
  7696. fmt.Println(err)
  7697. }
  7698. saveLog(result, request_log, "2204", "上传费用明细")
  7699. userJSONBytes, _ := json.Marshal(dat)
  7700. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7701. utils.ErrorLog("解析失败:%v", err)
  7702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7703. return
  7704. }
  7705. res.InfRefmsgid = resFour10265.InfRefmsgid
  7706. res.Output = resFour10265.Output
  7707. res.ErrMsg = resFour10265.ErrMsg
  7708. res.Cainfo = resFour10265.Cainfo
  7709. res.WarnMsg = resFour10265.WarnMsg
  7710. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7711. res.Infcode = infocode
  7712. } else {
  7713. 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)
  7714. var dat map[string]interface{}
  7715. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7716. fmt.Println(dat)
  7717. } else {
  7718. fmt.Println(err)
  7719. }
  7720. saveLog(result, request_log, "2204", "上传费用明细")
  7721. userJSONBytes, _ := json.Marshal(dat)
  7722. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7723. utils.ErrorLog("解析失败:%v", err)
  7724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7725. return
  7726. }
  7727. }
  7728. }
  7729. if res.Infcode == 0 {
  7730. order := &models.HisOrder{
  7731. UserOrgId: adminUser.CurrentOrgId,
  7732. HisPatientId: his.ID,
  7733. PatientId: his.PatientId,
  7734. SettleAccountsDate: recordDateTime,
  7735. MdtrtId: his.Number,
  7736. PsnNo: his.PsnNo,
  7737. MedType: strconv.FormatInt(reg_type, 10),
  7738. Ctime: time.Now().Unix(),
  7739. Mtime: time.Now().Unix(),
  7740. Status: 1,
  7741. Number: chrg_bchno,
  7742. Infcode: res.Infcode,
  7743. WarnMsg: res.WarnMsg,
  7744. Cainfo: res.Cainfo,
  7745. ErrMsg: res.ErrMsg,
  7746. RespondTime: res.RefmsgTime,
  7747. InfRefmsgid: res.InfRefmsgid,
  7748. OrderStatus: 1,
  7749. PayWay: pay_way,
  7750. PayPrice: pay_price,
  7751. PayCardNo: pay_card_no,
  7752. DiscountPrice: discount_price,
  7753. PreferentialPrice: preferential_price,
  7754. RealityPrice: reality_price,
  7755. FoundPrice: found_price,
  7756. MedicalInsurancePrice: medical_insurance_price,
  7757. PrivatePrice: private_price,
  7758. IsMedicineInsurance: 1,
  7759. SettleType: settle_accounts_type,
  7760. SettleStartTime: start_time,
  7761. SettleEndTime: end_time,
  7762. Creator: roles.AdminUserId,
  7763. Modify: roles.AdminUserId,
  7764. FaPiaoNumber: fapiao_number,
  7765. FaPiaoCode: fapiao_code,
  7766. PType: 2,
  7767. Diagnosis: diagnosis_id,
  7768. }
  7769. err = service.CreateOrder(order)
  7770. if err != nil {
  7771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7772. return
  7773. }
  7774. for _, item := range res.Output.Result {
  7775. temp := strings.Split(item.FeedetlSn, "-")
  7776. var advice_id int64 = 0
  7777. var project_id int64 = 0
  7778. var types int64 = 0
  7779. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7780. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7781. if temp[1] == "1" {
  7782. advice_id = id
  7783. project_id = 0
  7784. } else if temp[1] == "2" {
  7785. advice_id = 0
  7786. project_id = id
  7787. }
  7788. if item.MedChrgitmType == "9" {
  7789. item.MedChrgitmType = "09"
  7790. }
  7791. info := &models.HisOrderInfo{
  7792. OrderNumber: order.Number,
  7793. FeedetlSn: item.FeedetlSn,
  7794. UploadDate: time.Now().Unix(),
  7795. AdviceId: advice_id,
  7796. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7797. Cnt: item.Cnt,
  7798. Pric: float64(item.Pric),
  7799. PatientId: his.PatientId,
  7800. PricUplmtAmt: item.PricUplmtAmt,
  7801. SelfpayProp: item.SelfpayProp,
  7802. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7803. OverlmtAmt: item.OverlmtAmt,
  7804. PreselfpayAmt: item.PreselfpayAmt,
  7805. BasMednFlag: item.BasMednFlag,
  7806. MedChrgitmType: item.MedChrgitmType,
  7807. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7808. Status: 1,
  7809. Memo: item.Memo,
  7810. Mtime: time.Now().Unix(),
  7811. InscpScpAmt: item.InscpScpAmt,
  7812. DrtReimFlag: item.DrtReimFlag,
  7813. Ctime: time.Now().Unix(),
  7814. ListSpItemFlag: item.ListSpItemFlag,
  7815. ChldMedcFlag: item.ChldMedcFlag,
  7816. LmtUsedFlag: item.LmtUsedFlag,
  7817. ChrgitmLv: item.ChrgitmLv,
  7818. UserOrgId: adminUser.CurrentOrgId,
  7819. HisPatientId: his.ID,
  7820. OrderId: order.ID,
  7821. ProjectId: project_id,
  7822. Type: types,
  7823. }
  7824. service.CreateOrderInfo(info)
  7825. }
  7826. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7827. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7828. var total float64
  7829. for _, item := range prescriptions {
  7830. if item.Type == 1 { //药品
  7831. for _, subItem := range item.HisDoctorAdviceInfo {
  7832. total = total + (subItem.Price * subItem.PrescribingNumber)
  7833. }
  7834. }
  7835. if item.Type == 2 { //项目
  7836. for _, subItem := range item.HisPrescriptionProject {
  7837. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7838. total = total + (subItem.Price * cnt)
  7839. }
  7840. }
  7841. }
  7842. for _, item := range prescriptions {
  7843. for _, subItem := range item.HisAdditionalCharge {
  7844. total = total + (subItem.Price * float64(subItem.Count))
  7845. }
  7846. }
  7847. var allTotal string
  7848. if adminUser.CurrentOrgId == 9919 {
  7849. allTotal = fmt.Sprintf("%.4f", total)
  7850. } else {
  7851. allTotal = fmt.Sprintf("%.4f", total)
  7852. }
  7853. if res.Infcode == 0 {
  7854. var rf []*ResultFive
  7855. json.Unmarshal([]byte(his.Iinfo), &rf)
  7856. chrg_bchno := chrg_bchno
  7857. cert_no := his.Certno
  7858. var insutypes []string
  7859. var insutype string
  7860. var is390 int = 0
  7861. var is310 int = 0
  7862. for _, item := range rf {
  7863. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7864. insutypes = append(insutypes, item.Insutype)
  7865. }
  7866. }
  7867. if len(insutypes) == 1 {
  7868. insutype = insutypes[0]
  7869. } else {
  7870. for _, i := range insutypes {
  7871. if i == "390" {
  7872. is390 = 1
  7873. }
  7874. if i == "310" {
  7875. is310 = 1
  7876. }
  7877. }
  7878. }
  7879. if is390 == 1 {
  7880. insutype = "390"
  7881. }
  7882. if is310 == 1 {
  7883. insutype = "310"
  7884. }
  7885. if len(insutypes) == 0 {
  7886. insutype = "310"
  7887. }
  7888. if len(insutypes) == 2 {
  7889. insutype = strconv.FormatInt(his.SocialType, 10)
  7890. }
  7891. insutype = strconv.FormatInt(his.SocialType, 10)
  7892. //insutype = "390"
  7893. if his.IdCardType == 1 {
  7894. // cert_no = his.MedicalInsuranceNumber
  7895. cert_no = his.Certno
  7896. } else {
  7897. cert_no = his.Certno
  7898. }
  7899. var res ResultSeven
  7900. var resSeven10265 ResultSeven10265
  7901. var src_resquest string
  7902. var result2 string
  7903. var acct_used_flag string
  7904. fmt.Println("pay_way")
  7905. fmt.Println(pay_way)
  7906. fmt.Println("pay_way")
  7907. if pay_way == 4 {
  7908. acct_used_flag = "1"
  7909. } else {
  7910. acct_used_flag = "0"
  7911. }
  7912. if miConfig.MdtrtareaAdmvs == "421300" {
  7913. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7914. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7915. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7916. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7917. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7918. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7919. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  7920. resp, requestErr := http.Get(api)
  7921. if requestErr != nil {
  7922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7923. return
  7924. }
  7925. body, ioErr := ioutil.ReadAll(resp.Body)
  7926. if ioErr != nil {
  7927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7929. return
  7930. }
  7931. var respJSON map[string]interface{}
  7932. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7935. return
  7936. }
  7937. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7938. result, _ := json.Marshal(respJSON)
  7939. if miConfig.Code == "H15049901371" {
  7940. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7941. utils.ErrorLog("解析失败:%v", err)
  7942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7943. return
  7944. }
  7945. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7946. res.Output = resSeven10265.Output
  7947. res.ErrMsg = resSeven10265.ErrMsg
  7948. res.Cainfo = resSeven10265.Cainfo
  7949. res.WarnMsg = resSeven10265.WarnMsg
  7950. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7951. res.Infcode = infocode
  7952. } else {
  7953. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7954. utils.ErrorLog("解析失败:%v", err)
  7955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7956. return
  7957. }
  7958. }
  7959. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7960. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  7961. if result3101.Infcode == "0" {
  7962. if len(result3101.Output.Result) > 0 {
  7963. var errMsgs []string
  7964. for _, item := range result3101.Output.Result {
  7965. errMsgs = append(errMsgs, item.VolaCont)
  7966. }
  7967. c.ServeSuccessJSON(map[string]interface{}{
  7968. "failed_code": -10,
  7969. "msg": errMsgs,
  7970. })
  7971. return
  7972. } else {
  7973. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7974. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7975. bas := strings.Split(psn_info.CardInfo, "|")
  7976. if his.IdCardType == 1 {
  7977. cert_no = bas[2]
  7978. } else if his.IdCardType == 3 {
  7979. cert_no = his.Certno
  7980. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  7981. } else if his.IdCardType == 4 {
  7982. cert_no = his.Certno
  7983. psn_info.VerifyNumber = psn_info.VerifyNumber
  7984. }
  7985. var api string
  7986. if miConfig.MdtrtareaAdmvs == "320921" {
  7987. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7988. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7989. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7990. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7991. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7992. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7993. "&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
  7994. } else {
  7995. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7996. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7997. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7998. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7999. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8000. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8001. "&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
  8002. }
  8003. resp, requestErr := http.Get(api)
  8004. if requestErr != nil {
  8005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8006. return
  8007. }
  8008. body, ioErr := ioutil.ReadAll(resp.Body)
  8009. if ioErr != nil {
  8010. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8012. return
  8013. }
  8014. var respJSON map[string]interface{}
  8015. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8018. return
  8019. }
  8020. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8021. result, _ := json.Marshal(respJSON)
  8022. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8023. utils.ErrorLog("解析失败:%v", err)
  8024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8025. return
  8026. }
  8027. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8028. res.Output = resSeven10265.Output
  8029. res.ErrMsg = resSeven10265.ErrMsg
  8030. res.Cainfo = resSeven10265.Cainfo
  8031. res.WarnMsg = resSeven10265.WarnMsg
  8032. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8033. res.Infcode = infocode
  8034. }
  8035. }
  8036. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8037. var cert_no string
  8038. if his.IdCardType == 4 {
  8039. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8040. cert_no = psn_info.VerifyNumber
  8041. 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)
  8042. } else if his.IdCardType == 1 {
  8043. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8044. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8045. 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)
  8046. }
  8047. //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)
  8048. var dat map[string]interface{}
  8049. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8050. fmt.Println(dat)
  8051. } else {
  8052. fmt.Println(err)
  8053. }
  8054. saveLog(result2, src_resquest, "2207", "结算")
  8055. userJSONBytes, _ := json.Marshal(dat)
  8056. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8057. utils.ErrorLog("解析失败:%v", err)
  8058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8059. return
  8060. }
  8061. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8062. res.Output = resSeven10265.Output
  8063. res.ErrMsg = resSeven10265.ErrMsg
  8064. res.Cainfo = resSeven10265.Cainfo
  8065. res.WarnMsg = resSeven10265.WarnMsg
  8066. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8067. res.Infcode = infocode
  8068. } else {
  8069. if miConfig.Code == "H15049901371" {
  8070. //赤峰地区国家医保医疗类别
  8071. //职工透析:医疗类别选特殊情况门诊990502
  8072. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8073. var med_type string
  8074. if his.Insutype == "390" {
  8075. if reg_type == 14 {
  8076. med_type = "9933"
  8077. } else if reg_type == 11 {
  8078. med_type = "11"
  8079. }
  8080. } else if his.Insutype == "310" {
  8081. if reg_type == 14 {
  8082. med_type = "990502"
  8083. } else if reg_type == 11 {
  8084. med_type = "11"
  8085. }
  8086. }
  8087. 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, "")
  8088. } else {
  8089. if his.IdCardType == 4 {
  8090. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8091. var token string
  8092. token = psn_info.VerifyNumber
  8093. 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)
  8094. } else {
  8095. 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, "")
  8096. }
  8097. }
  8098. //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)
  8099. var dat map[string]interface{}
  8100. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8101. fmt.Println(dat)
  8102. } else {
  8103. fmt.Println(err)
  8104. }
  8105. saveLog(result2, src_resquest, "2207", "结算")
  8106. userJSONBytes, _ := json.Marshal(dat)
  8107. if miConfig.Code == "H15049901371" {
  8108. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8109. utils.ErrorLog("解析失败:%v", err)
  8110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8111. return
  8112. }
  8113. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8114. res.Output = resSeven10265.Output
  8115. res.ErrMsg = resSeven10265.ErrMsg
  8116. res.Cainfo = resSeven10265.Cainfo
  8117. res.WarnMsg = resSeven10265.WarnMsg
  8118. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8119. res.Infcode = infocode
  8120. } else {
  8121. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8122. utils.ErrorLog("解析失败:%v", err)
  8123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8124. return
  8125. }
  8126. }
  8127. }
  8128. if res.Infcode != 0 {
  8129. errlog := &models.HisOrderError{
  8130. UserOrgId: adminUser.CurrentOrgId,
  8131. Ctime: time.Now().Unix(),
  8132. Mtime: time.Now().Unix(),
  8133. Number: chrg_bchno,
  8134. ErrMsg: res.ErrMsg,
  8135. Status: 1,
  8136. PatientId: id,
  8137. RecordTime: recordDateTime,
  8138. Stage: 6,
  8139. }
  8140. service.CreateErrMsgLog(errlog)
  8141. c.ServeSuccessJSON(map[string]interface{}{
  8142. "failed_code": -10,
  8143. "msg": res.ErrMsg,
  8144. })
  8145. return
  8146. } else {
  8147. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8148. order.OrderStatus = 2
  8149. order.Status = 1
  8150. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8151. order.SetlId = res.Output.Setlinfo.SetlID
  8152. order.PsnNo = res.Output.Setlinfo.PsnNo
  8153. order.PsnName = res.Output.Setlinfo.PsnName
  8154. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8155. order.Certno = res.Output.Setlinfo.Certno
  8156. order.Gend = res.Output.Setlinfo.Gend
  8157. order.Naty = res.Output.Setlinfo.Naty
  8158. order.Age = res.Output.Setlinfo.Age
  8159. order.Insutype = res.Output.Setlinfo.Insutype
  8160. order.PsnType = res.Output.Setlinfo.PsnType
  8161. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8162. order.SetlTime = res.Output.Setlinfo.SetlTime
  8163. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8164. if res.Output.Setlinfo.MedType == "140101" {
  8165. order.MedType = "14"
  8166. } else {
  8167. order.MedType = res.Output.Setlinfo.MedType
  8168. }
  8169. if reg_type == 1112 {
  8170. order.MedType = "1112"
  8171. }
  8172. if reg_type == 1111 {
  8173. order.MedType = "1111"
  8174. }
  8175. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8176. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8177. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8178. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8179. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8180. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8181. order.HifpPay = res.Output.Setlinfo.HifpPay
  8182. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8183. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8184. order.HifesPay = res.Output.Setlinfo.HifesPay
  8185. order.HifobPay = res.Output.Setlinfo.HifobPay
  8186. order.MafPay = res.Output.Setlinfo.MafPay
  8187. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8188. order.OthPay = res.Output.Setlinfo.OthPay
  8189. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8190. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8191. order.AcctPay = res.Output.Setlinfo.AcctPay
  8192. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8193. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8194. order.Balc = res.Output.Setlinfo.Balc
  8195. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8196. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8197. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8198. order.ClrType = res.Output.Setlinfo.ClrType
  8199. order.ClrWay = res.Output.Setlinfo.ClrWay
  8200. order.Creator = order.Creator
  8201. order.Modify = roles.AdminUserId
  8202. order.RequestLog = src_resquest
  8203. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8204. detailStr := string(setlDetail)
  8205. order.SetlDetail = detailStr
  8206. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8207. err = service.UpDateOrder(order)
  8208. if err == nil {
  8209. //判断是否使用了押金
  8210. if dec_way == "true" {
  8211. tmpstring := strconv.FormatInt(order.ID, 10)
  8212. order.Decimal = decimal
  8213. service.UpDateOrder(order)
  8214. //扣押金
  8215. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8216. if errmsg != nil {
  8217. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8218. return
  8219. }
  8220. }
  8221. c.ServeSuccessJSON(map[string]interface{}{
  8222. "msg": "结算成功",
  8223. })
  8224. } else {
  8225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8226. return
  8227. }
  8228. }
  8229. } else {
  8230. adminUser := c.GetAdminUserInfo()
  8231. errlog := &models.HisOrderError{
  8232. UserOrgId: adminUser.CurrentOrgId,
  8233. Ctime: time.Now().Unix(),
  8234. Mtime: time.Now().Unix(),
  8235. ErrMsg: res.ErrMsg,
  8236. Status: 1,
  8237. PatientId: id,
  8238. RecordTime: recordDateTime,
  8239. Stage: 4,
  8240. }
  8241. service.CreateErrMsgLog(errlog)
  8242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8243. return
  8244. }
  8245. } else {
  8246. adminUser := c.GetAdminUserInfo()
  8247. errlog := &models.HisOrderError{
  8248. UserOrgId: adminUser.CurrentOrgId,
  8249. Ctime: time.Now().Unix(),
  8250. Mtime: time.Now().Unix(),
  8251. ErrMsg: res.ErrMsg,
  8252. Status: 1,
  8253. PatientId: id,
  8254. RecordTime: recordDateTime,
  8255. Stage: 4,
  8256. }
  8257. service.CreateErrMsgLog(errlog)
  8258. c.ServeSuccessJSON(map[string]interface{}{
  8259. "failed_code": -10,
  8260. "msg": res.ErrMsg,
  8261. })
  8262. return
  8263. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  8264. //return
  8265. }
  8266. }
  8267. }
  8268. } else if tempOrder.ID > 0 {
  8269. if tempOrder.IsPre == 1 {
  8270. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  8271. var rf []*ResultFive
  8272. json.Unmarshal([]byte(his.Iinfo), &rf)
  8273. chrg_bchno := tempOrder.Number
  8274. cert_no := his.Certno
  8275. var insutypes []string
  8276. var insutype string
  8277. var is390 int = 0
  8278. var is310 int = 0
  8279. for _, item := range rf {
  8280. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8281. insutypes = append(insutypes, item.Insutype)
  8282. }
  8283. }
  8284. if len(insutypes) == 1 {
  8285. insutype = insutypes[0]
  8286. } else {
  8287. for _, i := range insutypes {
  8288. if i == "390" {
  8289. is390 = 1
  8290. }
  8291. if i == "310" {
  8292. is310 = 1
  8293. }
  8294. }
  8295. }
  8296. if is390 == 1 {
  8297. insutype = "390"
  8298. }
  8299. if is310 == 1 {
  8300. insutype = "310"
  8301. }
  8302. if len(insutypes) == 0 {
  8303. insutype = "310"
  8304. }
  8305. if len(insutypes) == 2 {
  8306. insutype = strconv.FormatInt(his.SocialType, 64)
  8307. }
  8308. //insutype = "390"
  8309. if his.IdCardType == 1 {
  8310. // cert_no = his.MedicalInsuranceNumber
  8311. cert_no = his.Certno
  8312. } else {
  8313. cert_no = his.Certno
  8314. }
  8315. var res ResultSeven
  8316. var resSeven10265 ResultSeven10265
  8317. var src_resquest string
  8318. var result2 string
  8319. var acct_used_flag string
  8320. fmt.Println("pay_way")
  8321. fmt.Println(pay_way)
  8322. fmt.Println("pay_way")
  8323. if pay_way == 4 {
  8324. acct_used_flag = "1"
  8325. } else {
  8326. acct_used_flag = "0"
  8327. }
  8328. if miConfig.MdtrtareaAdmvs == "421300" {
  8329. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8330. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8331. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8332. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8333. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8334. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8335. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  8336. resp, requestErr := http.Get(api)
  8337. if requestErr != nil {
  8338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8339. return
  8340. }
  8341. body, ioErr := ioutil.ReadAll(resp.Body)
  8342. if ioErr != nil {
  8343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8345. return
  8346. }
  8347. var respJSON map[string]interface{}
  8348. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8351. return
  8352. }
  8353. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8354. result, _ := json.Marshal(respJSON)
  8355. fmt.Println("log")
  8356. fmt.Println(string(result))
  8357. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8358. utils.ErrorLog("解析失败:%v", err)
  8359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8360. return
  8361. }
  8362. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8363. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  8364. if result3101.Infcode == "0" {
  8365. if len(result3101.Output.Result) > 0 {
  8366. var errMsgs []string
  8367. for _, item := range result3101.Output.Result {
  8368. errMsgs = append(errMsgs, item.VolaCont)
  8369. }
  8370. c.ServeSuccessJSON(map[string]interface{}{
  8371. "failed_code": -10,
  8372. "msg": errMsgs,
  8373. })
  8374. return
  8375. } else {
  8376. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8377. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8378. bas := strings.Split(psn_info.CardInfo, "|")
  8379. if his.IdCardType == 1 {
  8380. cert_no = bas[2]
  8381. } else if his.IdCardType == 3 {
  8382. cert_no = his.Certno
  8383. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  8384. } else if his.IdCardType == 4 {
  8385. cert_no = his.Certno
  8386. psn_info.VerifyNumber = psn_info.VerifyNumber
  8387. }
  8388. //江苏地区国家医保医疗类别
  8389. //职工透析:医疗类别选特殊情况门诊9933
  8390. //居民血透门慢: 医疗类别选门诊慢病1402
  8391. //var med_type string
  8392. //if his.Insutype == "310" {
  8393. // if reg_type == 14 {
  8394. // med_type = "9933"
  8395. // } else if reg_type == 11 {
  8396. // med_type = "11"
  8397. //
  8398. // }
  8399. //} else if his.Insutype == "390" {
  8400. // if reg_type == 14 {
  8401. // med_type = "1402"
  8402. // } else if reg_type == 11 {
  8403. // med_type = "11"
  8404. // }
  8405. //}
  8406. var api string
  8407. if miConfig.MdtrtareaAdmvs == "320921" {
  8408. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8409. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8410. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8411. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8412. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8413. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8414. "&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
  8415. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8416. } else {
  8417. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8418. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8419. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8420. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8421. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8422. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8423. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8424. "&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
  8425. }
  8426. resp, requestErr := http.Get(api)
  8427. if requestErr != nil {
  8428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8429. return
  8430. }
  8431. body, ioErr := ioutil.ReadAll(resp.Body)
  8432. if ioErr != nil {
  8433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8435. return
  8436. }
  8437. var respJSON map[string]interface{}
  8438. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8441. return
  8442. }
  8443. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8444. result, _ := json.Marshal(respJSON)
  8445. fmt.Println("log")
  8446. fmt.Println(string(result))
  8447. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8448. utils.ErrorLog("解析失败:%v", err)
  8449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8450. return
  8451. }
  8452. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8453. res.Output = resSeven10265.Output
  8454. res.ErrMsg = resSeven10265.ErrMsg
  8455. res.Cainfo = resSeven10265.Cainfo
  8456. res.WarnMsg = resSeven10265.WarnMsg
  8457. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8458. res.Infcode = infocode
  8459. }
  8460. }
  8461. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8462. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8463. var cert_no string
  8464. if his.IdCardType == 1 {
  8465. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8466. } else {
  8467. cert_no = psn_info.VerifyNumber
  8468. }
  8469. 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)
  8470. var dat map[string]interface{}
  8471. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8472. fmt.Println(dat)
  8473. } else {
  8474. fmt.Println(err)
  8475. }
  8476. saveLog(result2, src_resquest, "2207", "结算")
  8477. userJSONBytes, _ := json.Marshal(dat)
  8478. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8479. utils.ErrorLog("解析失败:%v", err)
  8480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8481. return
  8482. }
  8483. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8484. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8485. var cert_no string
  8486. if his.IdCardType == 1 {
  8487. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8488. } else if his.IdCardType == 2 {
  8489. cert_no = his.IdCardNo
  8490. } else {
  8491. cert_no = psn_info.VerifyNumber
  8492. }
  8493. 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, "")
  8494. var dat map[string]interface{}
  8495. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8496. fmt.Println(dat)
  8497. } else {
  8498. fmt.Println(err)
  8499. }
  8500. saveLog(result2, src_resquest, "2207", "结算")
  8501. userJSONBytes, _ := json.Marshal(dat)
  8502. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8503. utils.ErrorLog("解析失败:%v", err)
  8504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8505. return
  8506. }
  8507. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8508. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8509. var cert_no string
  8510. if his.IdCardType == 1 {
  8511. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8512. } else if his.IdCardType == 2 {
  8513. cert_no = his.IdCardNo
  8514. } else {
  8515. cert_no = psn_info.VerifyNumber
  8516. }
  8517. 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, "")
  8518. var dat map[string]interface{}
  8519. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8520. fmt.Println(dat)
  8521. } else {
  8522. fmt.Println(err)
  8523. }
  8524. saveLog(result2, src_resquest, "2207", "结算")
  8525. userJSONBytes, _ := json.Marshal(dat)
  8526. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8527. utils.ErrorLog("解析失败:%v", err)
  8528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8529. return
  8530. }
  8531. } else {
  8532. var src_resquest string
  8533. if miConfig.Code == "H15049901371" {
  8534. //赤峰地区国家医保医疗类别
  8535. //职工透析:医疗类别选特殊情况门诊990502
  8536. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8537. var med_type string
  8538. if his.Insutype == "390" {
  8539. if reg_type == 14 {
  8540. med_type = "9933"
  8541. } else if reg_type == 11 {
  8542. med_type = "11"
  8543. }
  8544. } else if his.Insutype == "310" {
  8545. if reg_type == 14 {
  8546. med_type = "990502"
  8547. } else if reg_type == 11 {
  8548. med_type = "11"
  8549. }
  8550. }
  8551. 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, "")
  8552. } else {
  8553. if his.IdCardType == 4 {
  8554. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8555. token := psn_info.VerifyNumber
  8556. 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)
  8557. } else {
  8558. 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, "")
  8559. }
  8560. }
  8561. var dat map[string]interface{}
  8562. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8563. fmt.Println(dat)
  8564. } else {
  8565. fmt.Println(err)
  8566. }
  8567. saveLog(result2, src_resquest, "2207", "结算")
  8568. userJSONBytes, _ := json.Marshal(dat)
  8569. if miConfig.Code == "H15049901371" {
  8570. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8571. utils.ErrorLog("解析失败:%v", err)
  8572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8573. return
  8574. }
  8575. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8576. res.Output = resSeven10265.Output
  8577. res.ErrMsg = resSeven10265.ErrMsg
  8578. res.Cainfo = resSeven10265.Cainfo
  8579. res.WarnMsg = resSeven10265.WarnMsg
  8580. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8581. res.Infcode = infocode
  8582. } else {
  8583. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8584. utils.ErrorLog("解析失败:%v", err)
  8585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8586. return
  8587. }
  8588. }
  8589. }
  8590. if res.Infcode != 0 {
  8591. errlog := &models.HisOrderError{
  8592. UserOrgId: adminUser.CurrentOrgId,
  8593. Ctime: time.Now().Unix(),
  8594. Mtime: time.Now().Unix(),
  8595. Number: chrg_bchno,
  8596. ErrMsg: res.ErrMsg,
  8597. Status: 1,
  8598. PatientId: id,
  8599. RecordTime: recordDateTime,
  8600. Stage: 6,
  8601. }
  8602. service.CreateErrMsgLog(errlog)
  8603. c.ServeSuccessJSON(map[string]interface{}{
  8604. "failed_code": -10,
  8605. "msg": res.ErrMsg,
  8606. })
  8607. return
  8608. } else {
  8609. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8610. order.OrderStatus = 2
  8611. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8612. order.SetlId = res.Output.Setlinfo.SetlID
  8613. order.PsnNo = res.Output.Setlinfo.PsnNo
  8614. order.PsnName = res.Output.Setlinfo.PsnName
  8615. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8616. order.Certno = res.Output.Setlinfo.Certno
  8617. order.Gend = res.Output.Setlinfo.Gend
  8618. order.Naty = res.Output.Setlinfo.Naty
  8619. order.Age = res.Output.Setlinfo.Age
  8620. order.Insutype = res.Output.Setlinfo.Insutype
  8621. order.PsnType = res.Output.Setlinfo.PsnType
  8622. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8623. order.SetlTime = res.Output.Setlinfo.SetlTime
  8624. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8625. //order.MedType = res.Output.Setlinfo.MedType
  8626. if reg_type == 1112 {
  8627. order.MedType = "1112"
  8628. }
  8629. if reg_type == 1111 {
  8630. order.MedType = "1111"
  8631. }
  8632. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8633. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8634. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8635. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8636. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8637. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8638. order.HifpPay = res.Output.Setlinfo.HifpPay
  8639. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8640. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8641. order.HifesPay = res.Output.Setlinfo.HifesPay
  8642. order.HifobPay = res.Output.Setlinfo.HifobPay
  8643. order.MafPay = res.Output.Setlinfo.MafPay
  8644. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8645. order.OthPay = res.Output.Setlinfo.OthPay
  8646. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8647. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8648. order.AcctPay = res.Output.Setlinfo.AcctPay
  8649. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8650. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8651. order.Balc = res.Output.Setlinfo.Balc
  8652. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8653. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8654. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8655. order.ClrWay = res.Output.Setlinfo.ClrWay
  8656. order.Creator = order.Creator
  8657. order.Modify = roles.AdminUserId
  8658. order.RequestLog = src_resquest
  8659. order.Diagnosis = diagnosis_id
  8660. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8661. detailStr := string(setlDetail)
  8662. order.SetlDetail = detailStr
  8663. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8664. err = service.UpDateOrder(order)
  8665. if err == nil {
  8666. //判断是否使用了押金
  8667. if dec_way == "true" {
  8668. tmpstring := strconv.FormatInt(order.ID, 10)
  8669. //扣押金
  8670. order.Decimal = decimal
  8671. service.UpDateOrder(order)
  8672. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8673. if errmsg != nil {
  8674. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8675. return
  8676. }
  8677. }
  8678. c.ServeSuccessJSON(map[string]interface{}{
  8679. "msg": "结算成功",
  8680. })
  8681. } else {
  8682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8683. return
  8684. }
  8685. }
  8686. }
  8687. }
  8688. }
  8689. //func (c *HisApiController) GetPreUploadInfo() {
  8690. // id, _ := c.GetInt64("id")
  8691. // record_time := c.GetString("record_time")
  8692. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8693. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8694. //
  8695. // timeLayout := "2006-01-02"
  8696. // loc, _ := time.LoadLocation("Local")
  8697. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8698. // if err != nil {
  8699. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8700. // return
  8701. // }
  8702. // recordDateTime := theTime.Unix()
  8703. // adminUser := c.GetAdminUserInfo()
  8704. //
  8705. // var prescriptions []*models.HisPrescription
  8706. //
  8707. // var start_time int64
  8708. // var end_time int64
  8709. //
  8710. // data := make(map[string]interface{})
  8711. // if settle_accounts_type == 1 { //日结
  8712. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  8713. // data["pre"] = prescriptions
  8714. //
  8715. // } else { //月结
  8716. // start_time_str := c.GetString("start_time")
  8717. // end_time_str := c.GetString("end_time")
  8718. // timeLayout := "2006-01-02"
  8719. // loc, _ := time.LoadLocation("Local")
  8720. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  8721. // if err != nil {
  8722. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8723. // return
  8724. // }
  8725. // recordStartTime := theStartTime.Unix()
  8726. // start_time = recordStartTime
  8727. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8728. // if err != nil {
  8729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8730. // return
  8731. // }
  8732. // recordEndTime := theEndTime.Unix()
  8733. // end_time = recordEndTime
  8734. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  8735. // data["pre"] = prescriptions
  8736. //
  8737. // }
  8738. //
  8739. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8740. //
  8741. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8742. // timestamp := time.Now().Unix()
  8743. // tempTime := time.Unix(timestamp, 0)
  8744. // timeFormat := tempTime.Format("20060102150405")
  8745. // chrgBchno := rand.Intn(100000) + 10000
  8746. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8747. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8748. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8749. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8750. // strconv.FormatInt(his.PatientId, 10)
  8751. // client := &http.Client{}
  8752. // data["psn_no"] = his.PsnNo
  8753. // data["mdtrt_id"] = his.Number
  8754. // data["chrg_bchno"] = chrg_bchno
  8755. // data["org_name"] = miConfig.OrgName
  8756. // data["doctor"] = roles.UserName
  8757. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  8758. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  8759. // data["fixmedins_code"] = miConfig.Code
  8760. // data["dept_code"] = department.Number
  8761. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  8762. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8763. // data["secret_key"] = miConfig.SecretKey
  8764. // var ids []int64
  8765. //
  8766. // for _, item := range prescriptions {
  8767. // ids = append(ids, item.ID)
  8768. // }
  8769. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8770. // if config.IsOpen == 1 { //对接了医保,走医保流程
  8771. // bytesData, _ := json.Marshal(data)
  8772. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  8773. // resp, _ := client.Do(req)
  8774. // defer resp.Body.Close()
  8775. // body, ioErr := ioutil.ReadAll(resp.Body)
  8776. // if ioErr != nil {
  8777. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8778. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8779. // return
  8780. // }
  8781. // var respJSON map[string]interface{}
  8782. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8783. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8785. // return
  8786. // }
  8787. //
  8788. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8789. // userJSONBytes, _ := json.Marshal(respJSON)
  8790. // var res ResultFour
  8791. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8792. // utils.ErrorLog("解析失败:%v", err)
  8793. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8794. // return
  8795. // }
  8796. //
  8797. // if res.Infcode == 0 {
  8798. // order := &models.HisOrder{
  8799. // UserOrgId: adminUser.CurrentOrgId,
  8800. // HisPatientId: his.ID,
  8801. // PatientId: his.PatientId,
  8802. // SettleAccountsDate: recordDateTime,
  8803. // Ctime: time.Now().Unix(),
  8804. // Mtime: time.Now().Unix(),
  8805. // Status: 1,
  8806. // Number: chrg_bchno,
  8807. // Infcode: res.Infcode,
  8808. // WarnMsg: res.WarnMsg,
  8809. // Cainfo: res.Cainfo,
  8810. // ErrMsg: res.ErrMsg,
  8811. // RespondTime: res.RefmsgTime,
  8812. // InfRefmsgid: res.InfRefmsgid,
  8813. // OrderStatus: 1,
  8814. // IsMedicineInsurance: 1,
  8815. // SettleType: settle_accounts_type,
  8816. // SettleStartTime: start_time,
  8817. // SettleEndTime: end_time,
  8818. // Creator: roles.ID,
  8819. // Modify: roles.ID,
  8820. // PType: 2,
  8821. // }
  8822. // err = service.CreateOrder(order)
  8823. // if err != nil {
  8824. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8825. // return
  8826. // }
  8827. //
  8828. // for _, item := range res.Output.Result {
  8829. // temp := strings.Split(item.FeedetlSn, "-")
  8830. // var advice_id int64 = 0
  8831. // var project_id int64 = 0
  8832. // var types int64 = 0
  8833. //
  8834. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  8835. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  8836. //
  8837. // if temp[1] == "1" {
  8838. // advice_id = id
  8839. // project_id = 0
  8840. // } else if temp[1] == "2" {
  8841. // advice_id = 0
  8842. // project_id = id
  8843. // }
  8844. //
  8845. // info := &models.HisOrderInfo{
  8846. // OrderNumber: order.Number,
  8847. // FeedetlSn: item.FeedetlSn,
  8848. // UploadDate: time.Now().Unix(),
  8849. // AdviceId: advice_id,
  8850. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  8851. // Cnt: item.Cnt,
  8852. // Pric: float64(item.Pric),
  8853. // PatientId: his.PatientId,
  8854. // PricUplmtAmt: item.PricUplmtAmt,
  8855. // SelfpayProp: item.SelfpayProp,
  8856. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8857. // OverlmtAmt: item.OverlmtAmt,
  8858. // PreselfpayAmt: item.PreselfpayAmt,
  8859. // BasMednFlag: item.BasMednFlag,
  8860. // MedChrgitmType: item.MedChrgitmType,
  8861. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  8862. // Status: 1,
  8863. // Memo: item.Memo,
  8864. // Mtime: time.Now().Unix(),
  8865. // InscpScpAmt: item.InscpScpAmt,
  8866. // DrtReimFlag: item.DrtReimFlag,
  8867. // Ctime: time.Now().Unix(),
  8868. // ListSpItemFlag: item.ListSpItemFlag,
  8869. // ChldMedcFlag: item.ChldMedcFlag,
  8870. // LmtUsedFlag: item.LmtUsedFlag,
  8871. // ChrgitmLv: item.ChrgitmLv,
  8872. // UserOrgId: adminUser.CurrentOrgId,
  8873. // HisPatientId: his.ID,
  8874. // OrderId: order.ID,
  8875. // ProjectId: project_id,
  8876. // Type: types,
  8877. // }
  8878. // service.CreateOrderInfo(info)
  8879. //
  8880. // }
  8881. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8882. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  8883. //
  8884. // var total float64
  8885. // for _, item := range prescriptions {
  8886. // if item.Type == 1 { //药品
  8887. // for _, subItem := range item.HisDoctorAdviceInfo {
  8888. // total = total + (subItem.Price * subItem.PrescribingNumber)
  8889. // }
  8890. // }
  8891. // if item.Type == 2 { //项目
  8892. // for _, subItem := range item.HisPrescriptionProject {
  8893. // total = total + (subItem.Price * float64(subItem.Count))
  8894. // }
  8895. // }
  8896. // }
  8897. //
  8898. // for _, item := range prescriptions {
  8899. // for _, subItem := range item.HisAdditionalCharge {
  8900. // total = total + (subItem.Price * float64(subItem.Count))
  8901. // }
  8902. // }
  8903. //
  8904. // allTotal := fmt.Sprintf("%.2f", total)
  8905. // if res.Infcode == 0 {
  8906. // var rf []*ResultFive
  8907. // json.Unmarshal([]byte(his.Iinfo), &rf)
  8908. // psn_no := his.PsnNo
  8909. // mdtrt_id := his.Number
  8910. // chrg_bchno := chrg_bchno
  8911. // cert_no := his.Certno
  8912. // insutype := rf[0].Insutype
  8913. //
  8914. // if his.IdCardType == 1 {
  8915. // cert_no = his.MedicalInsuranceNumber
  8916. //
  8917. // } else {
  8918. //
  8919. // cert_no = his.Certno
  8920. //
  8921. // }
  8922. //
  8923. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  8924. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  8925. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  8926. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  8927. // resp, requestErr := http.Get(api)
  8928. // if requestErr != nil {
  8929. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8930. // return
  8931. // }
  8932. // defer resp.Body.Close()
  8933. // body, ioErr := ioutil.ReadAll(resp.Body)
  8934. // if ioErr != nil {
  8935. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8937. // return
  8938. // }
  8939. // var respJSON map[string]interface{}
  8940. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8941. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8943. // return
  8944. // }
  8945. // fmt.Println(respJSON)
  8946. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8947. // userJSONBytes, _ := json.Marshal(respJSON)
  8948. // var res ResultSeven
  8949. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8950. // utils.ErrorLog("解析失败:%v", err)
  8951. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8952. // return
  8953. // }
  8954. // if res.Infcode != 0 {
  8955. // errlog := &models.HisOrderError{
  8956. // UserOrgId: adminUser.CurrentOrgId,
  8957. // Ctime: time.Now().Unix(),
  8958. // Mtime: time.Now().Unix(),
  8959. // Number: chrg_bchno,
  8960. // ErrMsg: res.ErrMsg,
  8961. // Status: 1,
  8962. // PatientId: id,
  8963. // RecordTime: recordDateTime,
  8964. // Stage: 7,
  8965. // }
  8966. // service.CreateErrMsgLog(errlog)
  8967. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8968. // return
  8969. // } else {
  8970. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8971. // order.OrderStatus = 1
  8972. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8973. // order.SetlId = res.Output.Setlinfo.SetlID
  8974. // order.PsnNo = res.Output.Setlinfo.PsnNo
  8975. // order.PsnName = res.Output.Setlinfo.PsnName
  8976. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8977. // order.Certno = res.Output.Setlinfo.Certno
  8978. // order.Gend = res.Output.Setlinfo.Gend
  8979. // order.Naty = res.Output.Setlinfo.Naty
  8980. // order.Age = res.Output.Setlinfo.Age
  8981. // order.Insutype = res.Output.Setlinfo.Insutype
  8982. // order.PsnType = res.Output.Setlinfo.PsnType
  8983. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8984. // order.SetlTime = res.Output.Setlinfo.SetlTime
  8985. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8986. // order.MedType = res.Output.Setlinfo.MedType
  8987. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8988. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8989. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8990. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8991. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8992. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8993. // order.HifpPay = res.Output.Setlinfo.HifpPay
  8994. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8995. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8996. // order.HifesPay = res.Output.Setlinfo.HifesPay
  8997. // order.HifobPay = res.Output.Setlinfo.HifobPay
  8998. // order.MafPay = res.Output.Setlinfo.MafPay
  8999. // order.OthPay = res.Output.Setlinfo.OthPay
  9000. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9001. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9002. // order.AcctPay = res.Output.Setlinfo.AcctPay
  9003. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9004. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9005. // order.Balc = res.Output.Setlinfo.Balc
  9006. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9007. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9008. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9009. // order.ClrWay = res.Output.Setlinfo.ClrWay
  9010. // order.Creator = order.Creator
  9011. // order.Modify = roles.ID
  9012. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9013. // detailStr := string(setlDetail)
  9014. // order.SetlDetail = detailStr
  9015. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9016. // err = service.UpDateOrder(order)
  9017. // if err == nil {
  9018. // c.ServeSuccessJSON(map[string]interface{}{
  9019. // "msg": "预结算成功",
  9020. // })
  9021. // } else {
  9022. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9023. // return
  9024. // }
  9025. // }
  9026. // } else {
  9027. // adminUser := c.GetAdminUserInfo()
  9028. // errlog := &models.HisOrderError{
  9029. // UserOrgId: adminUser.CurrentOrgId,
  9030. // Ctime: time.Now().Unix(),
  9031. // Mtime: time.Now().Unix(),
  9032. // ErrMsg: res.ErrMsg,
  9033. // Status: 1,
  9034. // PatientId: id,
  9035. // RecordTime: recordDateTime,
  9036. // Stage: 4,
  9037. // }
  9038. // service.CreateErrMsgLog(errlog)
  9039. //
  9040. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9041. // return
  9042. // }
  9043. // } else {
  9044. // adminUser := c.GetAdminUserInfo()
  9045. // errlog := &models.HisOrderError{
  9046. // UserOrgId: adminUser.CurrentOrgId,
  9047. // Ctime: time.Now().Unix(),
  9048. // Mtime: time.Now().Unix(),
  9049. // ErrMsg: res.ErrMsg,
  9050. // Status: 1,
  9051. // PatientId: id,
  9052. // RecordTime: recordDateTime,
  9053. // Stage: 4,
  9054. // }
  9055. // service.CreateErrMsgLog(errlog)
  9056. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  9057. // return
  9058. // }
  9059. //
  9060. // } else {
  9061. // var total float64
  9062. // for _, item := range prescriptions {
  9063. // if item.Type == 1 { //药品
  9064. // for _, subItem := range item.HisDoctorAdviceInfo {
  9065. // total = total + (subItem.Price * subItem.PrescribingNumber)
  9066. // }
  9067. // }
  9068. // if item.Type == 2 { //项目
  9069. // for _, subItem := range item.HisPrescriptionProject {
  9070. // total = total + (subItem.Price * float64(subItem.Count))
  9071. // }
  9072. // }
  9073. //
  9074. // for _, subItem := range item.HisAdditionalCharge {
  9075. // total = total + (subItem.Price * float64(subItem.Count))
  9076. // }
  9077. // }
  9078. //
  9079. // allTotal := fmt.Sprintf("%.2f", total)
  9080. // totals, _ := strconv.ParseFloat(allTotal, 64)
  9081. // order := &models.HisOrder{
  9082. // UserOrgId: adminUser.CurrentOrgId,
  9083. // HisPatientId: his.ID,
  9084. // PatientId: id,
  9085. // SettleAccountsDate: recordDateTime,
  9086. // Ctime: time.Now().Unix(),
  9087. // Mtime: time.Now().Unix(),
  9088. // Status: 1,
  9089. // OrderStatus: 2,
  9090. // Number: chrg_bchno,
  9091. // MedfeeSumamt: totals,
  9092. // }
  9093. // err = service.CreateOrder(order)
  9094. // if err != nil {
  9095. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9096. // return
  9097. // }
  9098. //
  9099. // var customs []*Custom
  9100. // for _, item := range prescriptions {
  9101. //
  9102. // if item.Type == 1 { //药品
  9103. // for _, subItem := range item.HisDoctorAdviceInfo {
  9104. // cus := &Custom{
  9105. // AdviceId: subItem.ID,
  9106. // ProjectId: 0,
  9107. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  9108. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  9109. // FeedetlSn: subItem.FeedetlSn,
  9110. // Price: fmt.Sprintf("%.2f", subItem.Price),
  9111. // MedListCodg: subItem.MedListCodg,
  9112. // Type: 1,
  9113. // }
  9114. // customs = append(customs, cus)
  9115. // }
  9116. // }
  9117. //
  9118. // if item.Type == 2 { //项目
  9119. // for _, subItem := range item.HisPrescriptionProject {
  9120. //
  9121. // cus := &Custom{
  9122. // AdviceId: 0,
  9123. // ProjectId: subItem.ID,
  9124. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  9125. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  9126. // FeedetlSn: subItem.FeedetlSn,
  9127. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  9128. // MedListCodg: subItem.MedListCodg,
  9129. // Type: 2,
  9130. // }
  9131. //
  9132. // customs = append(customs, cus)
  9133. // }
  9134. // }
  9135. //
  9136. // for _, item := range item.HisAdditionalCharge {
  9137. // cus := &Custom{
  9138. // ItemId: item.ID,
  9139. // AdviceId: 0,
  9140. // ProjectId: 0,
  9141. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  9142. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  9143. // FeedetlSn: item.FeedetlSn,
  9144. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  9145. // MedListCodg: item.XtHisAddtionConfig.Code,
  9146. // Type: 3,
  9147. // }
  9148. //
  9149. // customs = append(customs, cus)
  9150. // }
  9151. //
  9152. // }
  9153. //
  9154. // for _, item := range customs {
  9155. // var advice_id int64 = 0
  9156. // var project_id int64 = 0
  9157. // var item_id int64 = 0
  9158. //
  9159. // var types int64 = 0
  9160. //
  9161. // if item.Type == 1 {
  9162. // advice_id = item.AdviceId
  9163. // project_id = 0
  9164. // item_id = 0
  9165. // } else if item.Type == 2 {
  9166. // advice_id = 0
  9167. // item_id = 0
  9168. //
  9169. // project_id = item.ProjectId
  9170. // } else if item.Type == 3 {
  9171. // advice_id = 0
  9172. // item_id = item.ItemId
  9173. // project_id = 0
  9174. // }
  9175. //
  9176. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  9177. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  9178. // pric, _ := strconv.ParseFloat(item.Price, 32)
  9179. //
  9180. // info := &models.HisOrderInfo{
  9181. // OrderNumber: order.Number,
  9182. // UploadDate: time.Now().Unix(),
  9183. // AdviceId: advice_id,
  9184. // DetItemFeeSumamt: detItemFeeSumamt,
  9185. // Cnt: cut,
  9186. // Pric: pric,
  9187. // PatientId: id,
  9188. // Status: 1,
  9189. // Mtime: time.Now().Unix(),
  9190. // Ctime: time.Now().Unix(),
  9191. // UserOrgId: adminUser.CurrentOrgId,
  9192. // HisPatientId: his.ID,
  9193. // OrderId: order.ID,
  9194. // ProjectId: project_id,
  9195. // Type: types,
  9196. // ItemId: item_id,
  9197. // }
  9198. // service.CreateOrderInfo(info)
  9199. // }
  9200. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9201. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9202. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  9203. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9204. // if err == nil {
  9205. // c.ServeSuccessJSON(map[string]interface{}{
  9206. // "msg": "结算成功",
  9207. // })
  9208. // } else {
  9209. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9210. // return
  9211. // }
  9212. // }
  9213. //}
  9214. //上传明细-预结算-
  9215. func (c *HisApiController) GetPreUploadInfo() {
  9216. id, _ := c.GetInt64("id")
  9217. record_time := c.GetString("record_time")
  9218. his_patient_id, _ := c.GetInt64("his_patient_id")
  9219. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9220. admin_user_id, _ := c.GetInt64("admin_user_id")
  9221. diagnosis_id := c.GetString("diagnosis")
  9222. sick_type, _ := c.GetInt64("sick_type")
  9223. reg_type, _ := c.GetInt64("p_type")
  9224. begin_time := c.GetString("begin_time")
  9225. id_str := c.GetString("ids")
  9226. ids_arr := strings.Split(id_str, ",")
  9227. timeLayout := "2006-01-02"
  9228. loc, _ := time.LoadLocation("Local")
  9229. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9230. if err != nil {
  9231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9232. return
  9233. }
  9234. recordDateTime := theTime.Unix()
  9235. adminUser := c.GetAdminUserInfo()
  9236. diagnosis_ids := strings.Split(diagnosis_id, ",")
  9237. var config []*models.HisXtDiagnoseConfig
  9238. for _, item := range diagnosis_ids {
  9239. id, _ := strconv.ParseInt(item, 10, 64)
  9240. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9241. config = append(config, &diagnosisConfig)
  9242. }
  9243. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9244. sickConfig, _ := service.FindSickById(sick_type)
  9245. var prescriptions []*models.HisPrescription
  9246. var start_time int64
  9247. var end_time int64
  9248. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9249. fmt.Println(his_patient_id)
  9250. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9251. timestamp := time.Now().Unix()
  9252. tempTime := time.Unix(timestamp, 0)
  9253. timeFormat := tempTime.Format("20060102150405")
  9254. chrgBchno := rand.Intn(100000) + 10000
  9255. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9256. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9257. var patientPrescription models.HisPrescriptionInfo
  9258. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9259. if patientPrescription.ID == 0 {
  9260. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9261. }
  9262. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9263. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9264. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9265. strconv.FormatInt(his.PatientId, 10)
  9266. var res2 ResultSix
  9267. var resSix10265 ResultSix10265
  9268. //var time_stamp string
  9269. if miConfig.MdtrtareaAdmvs == "421300" {
  9270. data := make(map[string]interface{})
  9271. client := &http.Client{}
  9272. data["psn_no"] = his.PsnNo
  9273. data["mdtrt_id"] = his.Number
  9274. data["department"] = department.Name
  9275. data["org_name"] = miConfig.OrgName
  9276. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9277. data["doctor_id"] = doctor_info.DoctorNumber
  9278. data["doctor_name"] = roles.UserName
  9279. data["fixmedins_code"] = miConfig.Code
  9280. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  9281. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9282. data["secret_key"] = miConfig.SecretKey
  9283. data["sick_code"] = sickConfig.CountryCode
  9284. data["sick_name"] = sickConfig.ClassName
  9285. data["begin_time"] = begin_time
  9286. data["dept"] = strconv.FormatInt(department.ID, 10)
  9287. data["config"] = config
  9288. data["opter"] = roles.UserName
  9289. fmt.Println(data)
  9290. bytesData, _ := json.Marshal(data)
  9291. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  9292. resp, _ := client.Do(req)
  9293. defer resp.Body.Close()
  9294. body, ioErr := ioutil.ReadAll(resp.Body)
  9295. if ioErr != nil {
  9296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9298. return
  9299. }
  9300. var respJSON map[string]interface{}
  9301. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9304. return
  9305. }
  9306. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9307. userJSONBytes, _ := json.Marshal(respJSON)
  9308. fmt.Println("log")
  9309. fmt.Println(string(userJSONBytes))
  9310. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9311. utils.ErrorLog("解析失败:%v", err)
  9312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9313. return
  9314. }
  9315. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9316. data := make(map[string]interface{})
  9317. client := &http.Client{}
  9318. data["psn_no"] = his.PsnNo
  9319. data["mdtrt_id"] = his.Number
  9320. data["doctor"] = roles.UserName
  9321. data["department"] = department.Name
  9322. data["org_name"] = miConfig.OrgName
  9323. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9324. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  9325. data["fixmedins_code"] = miConfig.Code
  9326. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9327. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9328. data["secret_key"] = miConfig.SecretKey
  9329. data["sick_code"] = sickConfig.CountryCode
  9330. data["sick_name"] = sickConfig.ClassName
  9331. data["begin_time"] = begin_time
  9332. data["dept"] = strconv.FormatInt(department.ID, 10)
  9333. data["config"] = config
  9334. data["url"] = miConfig.Url
  9335. data["ak"] = miConfig.AccessKey
  9336. data["cainfo"] = miConfig.Cainfo
  9337. bytesData, _ := json.Marshal(data)
  9338. var req *http.Request
  9339. if miConfig.MdtrtareaAdmvs == "320921" {
  9340. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9341. } else {
  9342. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9343. }
  9344. resp, _ := client.Do(req)
  9345. defer resp.Body.Close()
  9346. body, ioErr := ioutil.ReadAll(resp.Body)
  9347. if ioErr != nil {
  9348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9350. return
  9351. }
  9352. var respJSON map[string]interface{}
  9353. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9356. return
  9357. }
  9358. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  9359. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  9360. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  9361. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9362. userJSONBytes, _ := json.Marshal(respJSON)
  9363. fmt.Println("log")
  9364. fmt.Println(string(userJSONBytes))
  9365. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  9366. utils.ErrorLog("解析失败:%v", err)
  9367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9368. return
  9369. }
  9370. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9371. res2.Output = resSix10265.Output
  9372. res2.ErrMsg = resSix10265.ErrMsg
  9373. res2.Cainfo = resSix10265.Cainfo
  9374. res2.WarnMsg = resSix10265.WarnMsg
  9375. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9376. res2.Infcode = infocode
  9377. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9378. 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)
  9379. saveLog(result, requestLog, "2203", "上传就诊信息")
  9380. var respJSON2 map[string]interface{}
  9381. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9384. return
  9385. }
  9386. userJSONBytes2, _ := json.Marshal(respJSON2)
  9387. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9388. utils.ErrorLog("解析失败:%v", err)
  9389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9390. return
  9391. }
  9392. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9393. var result string
  9394. var requestLog string
  9395. 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, "")
  9396. saveLog(result, requestLog, "2203", "上传就诊信息")
  9397. var respJSON2 map[string]interface{}
  9398. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9401. return
  9402. }
  9403. userJSONBytes2, _ := json.Marshal(respJSON2)
  9404. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9405. utils.ErrorLog("解析失败:%v", err)
  9406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9407. return
  9408. }
  9409. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9410. var result string
  9411. var requestLog string
  9412. 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, "")
  9413. saveLog(result, requestLog, "2203", "上传就诊信息")
  9414. var respJSON2 map[string]interface{}
  9415. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9418. return
  9419. }
  9420. userJSONBytes2, _ := json.Marshal(respJSON2)
  9421. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9422. utils.ErrorLog("解析失败:%v", err)
  9423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9424. return
  9425. }
  9426. } else {
  9427. var result string
  9428. var requestLog string
  9429. if miConfig.MdtrtareaAdmvs == "440781" { //
  9430. 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)
  9431. } else {
  9432. if miConfig.Code == "H15049901371" {
  9433. //赤峰地区国家医保医疗类别
  9434. //职工透析:医疗类别选特殊情况门诊990502
  9435. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9436. var med_type string
  9437. if his.Insutype == "390" {
  9438. if reg_type == 14 {
  9439. med_type = "9933"
  9440. } else if reg_type == 11 {
  9441. med_type = "11"
  9442. }
  9443. } else if his.Insutype == "310" {
  9444. if reg_type == 14 {
  9445. med_type = "990502"
  9446. } else if reg_type == 11 {
  9447. med_type = "11"
  9448. }
  9449. }
  9450. 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)
  9451. } else {
  9452. 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)
  9453. }
  9454. saveLog(result, requestLog, "2203", "上传就诊信息")
  9455. var respJSON2 map[string]interface{}
  9456. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9459. return
  9460. }
  9461. userJSONBytes2, _ := json.Marshal(respJSON2)
  9462. if miConfig.Code == "H15049901371" {
  9463. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  9464. utils.ErrorLog("解析失败:%v", err)
  9465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9466. return
  9467. }
  9468. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9469. res2.Output = resSix10265.Output
  9470. res2.ErrMsg = resSix10265.ErrMsg
  9471. res2.Cainfo = resSix10265.Cainfo
  9472. res2.WarnMsg = resSix10265.WarnMsg
  9473. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9474. res2.Infcode = infocode
  9475. } else {
  9476. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9477. utils.ErrorLog("解析失败:%v", err)
  9478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9479. return
  9480. }
  9481. }
  9482. }
  9483. }
  9484. if res2.Infcode != 0 {
  9485. adminUser := c.GetAdminUserInfo()
  9486. errlog := &models.HisOrderError{
  9487. UserOrgId: adminUser.CurrentOrgId,
  9488. Ctime: time.Now().Unix(),
  9489. Mtime: time.Now().Unix(),
  9490. ErrMsg: res2.ErrMsg,
  9491. Status: 1,
  9492. PatientId: id,
  9493. RecordTime: recordDateTime,
  9494. Stage: 3,
  9495. }
  9496. service.CreateErrMsgLog(errlog)
  9497. c.ServeSuccessJSON(map[string]interface{}{
  9498. "failed_code": -10,
  9499. "msg": res2.ErrMsg,
  9500. })
  9501. return
  9502. } else {
  9503. his.Diagnosis = diagnosis_id
  9504. his.SickType = sickConfig.ID
  9505. his.PType = fmt.Sprintf("%d", reg_type)
  9506. service.UpdateHisPatientThree(&his)
  9507. data := make(map[string]interface{})
  9508. if settle_accounts_type == 1 { //日结
  9509. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  9510. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  9511. } else {
  9512. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  9513. }
  9514. data["pre"] = prescriptions
  9515. } else { //月结
  9516. start_time_str := c.GetString("start_time")
  9517. end_time_str := c.GetString("end_time")
  9518. timeLayout := "2006-01-02"
  9519. loc, _ := time.LoadLocation("Local")
  9520. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9521. if err != nil {
  9522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9523. return
  9524. }
  9525. recordStartTime := theStartTime.Unix()
  9526. start_time = recordStartTime
  9527. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9528. if err != nil {
  9529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9530. return
  9531. }
  9532. recordEndTime := theEndTime.Unix()
  9533. end_time = recordEndTime
  9534. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  9535. data["pre"] = prescriptions
  9536. }
  9537. client := &http.Client{}
  9538. data["psn_no"] = his.PsnNo
  9539. data["mdtrt_id"] = his.Number
  9540. data["chrg_bchno"] = chrg_bchno
  9541. data["org_name"] = miConfig.OrgName
  9542. data["doctor"] = doctor_info.UserName
  9543. data["doctor_id"] = doctor_info.DoctorNumber
  9544. data["dept"] = department.Name
  9545. data["fixmedins_code"] = miConfig.Code
  9546. data["opter"] = roles.UserName
  9547. data["dept_code"] = department.Number
  9548. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9549. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9550. data["secret_key"] = miConfig.SecretKey
  9551. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  9552. data["url"] = miConfig.Url
  9553. data["ak"] = miConfig.AccessKey
  9554. data["new_doctor_name"] = patientPrescription.Doctor
  9555. data["diag_code"] = sickConfig.CountryCode
  9556. data["cainfo"] = miConfig.Cainfo
  9557. data["opter"] = roles.UserName
  9558. var ids []int64
  9559. for _, item := range prescriptions {
  9560. ids = append(ids, item.ID)
  9561. }
  9562. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9563. if config.IsOpen == 1 { //对接了医保,走医保流程
  9564. var res ResultFour
  9565. var resFour10265 ResultFour10265
  9566. if miConfig.MdtrtareaAdmvs == "421300" {
  9567. bytesData, _ := json.Marshal(data)
  9568. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  9569. resp, _ := client.Do(req)
  9570. defer resp.Body.Close()
  9571. body, ioErr := ioutil.ReadAll(resp.Body)
  9572. if ioErr != nil {
  9573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9575. return
  9576. }
  9577. var respJSON map[string]interface{}
  9578. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9581. return
  9582. }
  9583. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9584. userJSONBytes, _ := json.Marshal(respJSON)
  9585. fmt.Println("log")
  9586. fmt.Println(string(userJSONBytes))
  9587. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9588. utils.ErrorLog("解析失败:%v", err)
  9589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9590. return
  9591. }
  9592. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9593. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  9594. if result3101.Infcode == "0" {
  9595. if len(result3101.Output.Result) > 0 {
  9596. var errMsgs []string
  9597. for _, item := range result3101.Output.Result {
  9598. errMsgs = append(errMsgs, item.VolaCont)
  9599. }
  9600. c.ServeSuccessJSON(map[string]interface{}{
  9601. "failed_code": -10,
  9602. "msg": errMsgs,
  9603. })
  9604. return
  9605. } else {
  9606. if miConfig.MdtrtareaAdmvs == "320921" {
  9607. data["doctor_id"] = "D320923012139"
  9608. } else {
  9609. data["doctor_id"] = "D371621008686"
  9610. }
  9611. bytesData, _ := json.Marshal(data)
  9612. var req *http.Request
  9613. if miConfig.MdtrtareaAdmvs == "320921" {
  9614. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9615. } else {
  9616. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9617. }
  9618. resp, _ := client.Do(req)
  9619. defer resp.Body.Close()
  9620. body, ioErr := ioutil.ReadAll(resp.Body)
  9621. if ioErr != nil {
  9622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9624. return
  9625. }
  9626. var respJSON map[string]interface{}
  9627. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9630. return
  9631. }
  9632. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9633. userJSONBytes, _ := json.Marshal(respJSON)
  9634. fmt.Println("log")
  9635. fmt.Println(string(userJSONBytes))
  9636. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9637. utils.ErrorLog("解析失败:%v", err)
  9638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9639. return
  9640. }
  9641. res.InfRefmsgid = resFour10265.InfRefmsgid
  9642. res.Output = resFour10265.Output
  9643. res.ErrMsg = resFour10265.ErrMsg
  9644. res.Cainfo = resFour10265.Cainfo
  9645. res.WarnMsg = resFour10265.WarnMsg
  9646. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9647. res.Infcode = infocode
  9648. }
  9649. }
  9650. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9651. 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)
  9652. var dat map[string]interface{}
  9653. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9654. fmt.Println(dat)
  9655. } else {
  9656. fmt.Println(err)
  9657. }
  9658. saveLog(result, request_log, "2204", "上传费用明细")
  9659. userJSONBytes, _ := json.Marshal(dat)
  9660. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9661. utils.ErrorLog("解析失败:%v", err)
  9662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9663. return
  9664. }
  9665. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9666. 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, "", "")
  9667. var dat map[string]interface{}
  9668. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9669. fmt.Println(dat)
  9670. } else {
  9671. fmt.Println(err)
  9672. }
  9673. saveLog(result, request_log, "2204", "上传费用明细")
  9674. userJSONBytes, _ := json.Marshal(dat)
  9675. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9676. utils.ErrorLog("解析失败:%v", err)
  9677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9678. return
  9679. }
  9680. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9681. 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, "", "")
  9682. var dat map[string]interface{}
  9683. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9684. fmt.Println(dat)
  9685. } else {
  9686. fmt.Println(err)
  9687. }
  9688. saveLog(result, request_log, "2204", "上传费用明细")
  9689. userJSONBytes, _ := json.Marshal(dat)
  9690. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9691. utils.ErrorLog("解析失败:%v", err)
  9692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9693. return
  9694. }
  9695. } else {
  9696. if miConfig.Code == "H15049901371" {
  9697. 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)
  9698. var dat map[string]interface{}
  9699. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9700. fmt.Println(dat)
  9701. } else {
  9702. fmt.Println(err)
  9703. }
  9704. saveLog(result, request_log, "2204", "上传费用明细")
  9705. userJSONBytes, _ := json.Marshal(dat)
  9706. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9707. utils.ErrorLog("解析失败:%v", err)
  9708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9709. return
  9710. }
  9711. res.InfRefmsgid = resFour10265.InfRefmsgid
  9712. res.Output = resFour10265.Output
  9713. res.ErrMsg = resFour10265.ErrMsg
  9714. res.Cainfo = resFour10265.Cainfo
  9715. res.WarnMsg = resFour10265.WarnMsg
  9716. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9717. res.Infcode = infocode
  9718. } else {
  9719. 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), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  9720. var dat map[string]interface{}
  9721. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9722. fmt.Println(dat)
  9723. } else {
  9724. fmt.Println(err)
  9725. }
  9726. saveLog(result, request_log, "2204", "上传费用明细")
  9727. userJSONBytes, _ := json.Marshal(dat)
  9728. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9729. utils.ErrorLog("解析失败:%v", err)
  9730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9731. return
  9732. }
  9733. }
  9734. }
  9735. if res.Infcode == 0 {
  9736. order := &models.HisOrder{
  9737. UserOrgId: adminUser.CurrentOrgId,
  9738. HisPatientId: his.ID,
  9739. PatientId: his.PatientId,
  9740. SettleAccountsDate: recordDateTime,
  9741. Ctime: time.Now().Unix(),
  9742. Mtime: time.Now().Unix(),
  9743. MdtrtId: his.Number,
  9744. PsnNo: his.PsnNo,
  9745. MedType: strconv.FormatInt(reg_type, 10),
  9746. Status: 1,
  9747. Number: chrg_bchno,
  9748. Infcode: res.Infcode,
  9749. WarnMsg: res.WarnMsg,
  9750. Cainfo: res.Cainfo,
  9751. ErrMsg: res.ErrMsg,
  9752. RespondTime: res.RefmsgTime,
  9753. InfRefmsgid: res.InfRefmsgid,
  9754. OrderStatus: 1,
  9755. IsMedicineInsurance: 1,
  9756. SettleType: settle_accounts_type,
  9757. SettleStartTime: start_time,
  9758. SettleEndTime: end_time,
  9759. Creator: roles.AdminUserId,
  9760. Modify: roles.AdminUserId,
  9761. PType: 2,
  9762. Diagnosis: diagnosis_id,
  9763. }
  9764. err = service.CreateOrder(order)
  9765. if err != nil {
  9766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9767. return
  9768. }
  9769. for _, item := range res.Output.Result {
  9770. temp := strings.Split(item.FeedetlSn, "-")
  9771. var advice_id int64 = 0
  9772. var project_id int64 = 0
  9773. var types int64 = 0
  9774. id, _ := strconv.ParseInt(temp[2], 10, 64)
  9775. types, _ = strconv.ParseInt(temp[1], 10, 64)
  9776. if temp[1] == "1" {
  9777. advice_id = id
  9778. project_id = 0
  9779. } else if temp[1] == "2" {
  9780. advice_id = 0
  9781. project_id = id
  9782. }
  9783. info := &models.HisOrderInfo{
  9784. OrderNumber: order.Number,
  9785. FeedetlSn: item.FeedetlSn,
  9786. UploadDate: time.Now().Unix(),
  9787. AdviceId: advice_id,
  9788. DetItemFeeSumamt: item.DetItemFeeSumamt,
  9789. Cnt: item.Cnt,
  9790. Pric: float64(item.Pric),
  9791. PatientId: his.PatientId,
  9792. PricUplmtAmt: item.PricUplmtAmt,
  9793. SelfpayProp: item.SelfpayProp,
  9794. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9795. OverlmtAmt: item.OverlmtAmt,
  9796. PreselfpayAmt: item.PreselfpayAmt,
  9797. BasMednFlag: item.BasMednFlag,
  9798. MedChrgitmType: item.MedChrgitmType,
  9799. HiNegoDrugFlag: item.HiNegoDrugFlag,
  9800. Status: 1,
  9801. Memo: item.Memo,
  9802. Mtime: time.Now().Unix(),
  9803. InscpScpAmt: item.InscpScpAmt,
  9804. DrtReimFlag: item.DrtReimFlag,
  9805. Ctime: time.Now().Unix(),
  9806. ListSpItemFlag: item.ListSpItemFlag,
  9807. ChldMedcFlag: item.ChldMedcFlag,
  9808. LmtUsedFlag: item.LmtUsedFlag,
  9809. ChrgitmLv: item.ChrgitmLv,
  9810. UserOrgId: adminUser.CurrentOrgId,
  9811. HisPatientId: his.ID,
  9812. OrderId: order.ID,
  9813. ProjectId: project_id,
  9814. Type: types,
  9815. }
  9816. service.CreateOrderInfo(info)
  9817. }
  9818. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9819. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  9820. var total float64
  9821. for _, item := range prescriptions {
  9822. if item.Type == 1 { //药品
  9823. for _, subItem := range item.HisDoctorAdviceInfo {
  9824. total = total + (subItem.Price * subItem.PrescribingNumber)
  9825. }
  9826. }
  9827. if item.Type == 2 { //项目
  9828. for _, subItem := range item.HisPrescriptionProject {
  9829. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9830. total = total + (subItem.Price * cnt)
  9831. }
  9832. }
  9833. }
  9834. for _, item := range prescriptions {
  9835. for _, subItem := range item.HisAdditionalCharge {
  9836. total = total + (subItem.Price * float64(subItem.Count))
  9837. }
  9838. }
  9839. allTotal := fmt.Sprintf("%.4f", total)
  9840. if res.Infcode == 0 {
  9841. var rf []*ResultFive
  9842. json.Unmarshal([]byte(his.Iinfo), &rf)
  9843. chrg_bchno := chrg_bchno
  9844. cert_no := his.Certno
  9845. var insutypes []string
  9846. var insutype string
  9847. var is390 int = 0
  9848. var is310 int = 0
  9849. for _, item := range rf {
  9850. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9851. insutypes = append(insutypes, item.Insutype)
  9852. }
  9853. }
  9854. if len(insutypes) == 1 {
  9855. insutype = insutypes[0]
  9856. } else {
  9857. for _, i := range insutypes {
  9858. if i == "390" {
  9859. is390 = 1
  9860. }
  9861. if i == "310" {
  9862. is310 = 1
  9863. }
  9864. }
  9865. }
  9866. if is390 == 1 {
  9867. insutype = "390"
  9868. }
  9869. if is310 == 1 {
  9870. insutype = "310"
  9871. }
  9872. if len(insutypes) == 0 {
  9873. insutype = "310"
  9874. }
  9875. if len(insutypes) == 2 {
  9876. insutype = strconv.FormatInt(his.SocialType, 64)
  9877. }
  9878. //insutype = "390"
  9879. if his.IdCardType == 1 {
  9880. cert_no = his.MedicalInsuranceNumber
  9881. } else {
  9882. cert_no = his.Certno
  9883. }
  9884. var res ResultSeven
  9885. var resSeven10265 ResultSeven10265
  9886. if miConfig.MdtrtareaAdmvs == "421300" {
  9887. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9888. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9889. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9890. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9891. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9892. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9893. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  9894. resp, requestErr := http.Get(api)
  9895. if requestErr != nil {
  9896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9897. return
  9898. }
  9899. body, ioErr := ioutil.ReadAll(resp.Body)
  9900. if ioErr != nil {
  9901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9903. return
  9904. }
  9905. var respJSON map[string]interface{}
  9906. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9909. return
  9910. }
  9911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9912. result, _ := json.Marshal(respJSON)
  9913. fmt.Println("log")
  9914. fmt.Println(string(result))
  9915. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9916. utils.ErrorLog("解析失败:%v", err)
  9917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9918. return
  9919. }
  9920. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9921. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  9922. if result3101.Infcode == "0" {
  9923. if len(result3101.Output.Result) > 0 {
  9924. var errMsgs []string
  9925. for _, item := range result3101.Output.Result {
  9926. errMsgs = append(errMsgs, item.VolaCont)
  9927. }
  9928. c.ServeSuccessJSON(map[string]interface{}{
  9929. "failed_code": -10,
  9930. "msg": errMsgs,
  9931. })
  9932. return
  9933. } else {
  9934. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9935. if his.IdCardType != 4 {
  9936. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9937. bas := strings.Split(psn_info.CardInfo, "|")
  9938. if his.IdCardType == 1 {
  9939. cert_no = bas[2]
  9940. } else {
  9941. cert_no = bas[1]
  9942. }
  9943. } else {
  9944. cert_no = his.Certno
  9945. }
  9946. //江苏地区国家医保医疗类别
  9947. //职工透析:医疗类别选特殊情况门诊9933
  9948. //居民血透门慢: 医疗类别选门诊慢病1402
  9949. //var med_type string
  9950. //if his.Insutype == "310" {
  9951. // if reg_type == 14 {
  9952. // med_type = "9933"
  9953. // } else if reg_type == 11 {
  9954. // med_type = "11"
  9955. //
  9956. // }
  9957. //} else if his.Insutype == "390" {
  9958. // if reg_type == 14 {
  9959. // med_type = "1402"
  9960. // } else if reg_type == 11 {
  9961. // med_type = "11"
  9962. // }
  9963. //}
  9964. var api string
  9965. if miConfig.MdtrtareaAdmvs == "320921" {
  9966. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9967. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9968. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9969. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9970. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9971. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9972. "&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
  9973. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9974. } else {
  9975. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9976. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9977. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9978. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9979. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9980. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9981. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9982. "&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
  9983. }
  9984. resp, requestErr := http.Get(api)
  9985. if requestErr != nil {
  9986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9987. return
  9988. }
  9989. body, ioErr := ioutil.ReadAll(resp.Body)
  9990. if ioErr != nil {
  9991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9993. return
  9994. }
  9995. var respJSON map[string]interface{}
  9996. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9999. return
  10000. }
  10001. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10002. result, _ := json.Marshal(respJSON)
  10003. fmt.Println("log")
  10004. fmt.Println(string(result))
  10005. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10006. utils.ErrorLog("解析失败:%v", err)
  10007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10008. return
  10009. }
  10010. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10011. res.Output = resSeven10265.Output
  10012. res.ErrMsg = resSeven10265.ErrMsg
  10013. res.Cainfo = resSeven10265.Cainfo
  10014. res.WarnMsg = resSeven10265.WarnMsg
  10015. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10016. res.Infcode = infocode
  10017. }
  10018. }
  10019. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10020. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId, recordDateTime)
  10021. var result string
  10022. var request_log string
  10023. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  10024. 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)
  10025. } else {
  10026. 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)
  10027. }
  10028. var dat map[string]interface{}
  10029. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10030. fmt.Println(dat)
  10031. } else {
  10032. fmt.Println(err)
  10033. }
  10034. saveLog(result, request_log, "2206", "预结算")
  10035. userJSONBytes, _ := json.Marshal(dat)
  10036. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10037. utils.ErrorLog("解析失败:%v", err)
  10038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10039. return
  10040. }
  10041. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10042. var result string
  10043. var request_log string
  10044. if his.IdCardType == 2 {
  10045. 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, "")
  10046. } else if his.IdCardType == 1 {
  10047. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10048. bas := strings.Split(psn_info.CardInfo, "|")
  10049. basNumber := bas[2]
  10050. card_sn := bas[3]
  10051. 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)
  10052. } else {
  10053. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10054. 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, "")
  10055. }
  10056. var dat map[string]interface{}
  10057. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10058. fmt.Println(dat)
  10059. } else {
  10060. fmt.Println(err)
  10061. }
  10062. saveLog(result, request_log, "2206", "预结算")
  10063. userJSONBytes, _ := json.Marshal(dat)
  10064. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10065. utils.ErrorLog("解析失败:%v", err)
  10066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10067. return
  10068. }
  10069. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10070. var result string
  10071. var request_log string
  10072. if his.IdCardType == 2 {
  10073. 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, "")
  10074. } else if his.IdCardType == 1 {
  10075. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10076. bas := strings.Split(psn_info.CardInfo, "|")
  10077. basNumber := bas[2]
  10078. card_sn := bas[3]
  10079. 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)
  10080. } else {
  10081. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10082. 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, "")
  10083. }
  10084. var dat map[string]interface{}
  10085. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10086. fmt.Println(dat)
  10087. } else {
  10088. fmt.Println(err)
  10089. }
  10090. saveLog(result, request_log, "2206", "预结算")
  10091. userJSONBytes, _ := json.Marshal(dat)
  10092. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10093. utils.ErrorLog("解析失败:%v", err)
  10094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10095. return
  10096. }
  10097. } else {
  10098. var result string
  10099. var request_log string
  10100. if miConfig.Code == "H15049901371" {
  10101. //赤峰地区国家医保医疗类别
  10102. //职工透析:医疗类别选特殊情况门诊990502
  10103. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10104. var med_type string
  10105. if his.Insutype == "390" {
  10106. if reg_type == 14 {
  10107. med_type = "9933"
  10108. } else if reg_type == 11 {
  10109. med_type = "11"
  10110. }
  10111. } else if his.Insutype == "310" {
  10112. if reg_type == 14 {
  10113. med_type = "990502"
  10114. } else if reg_type == 11 {
  10115. med_type = "11"
  10116. }
  10117. }
  10118. 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, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  10119. } else {
  10120. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10121. if his.IdCardType == 4 {
  10122. 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)
  10123. } else {
  10124. 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)
  10125. }
  10126. }
  10127. var dat map[string]interface{}
  10128. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10129. fmt.Println(dat)
  10130. } else {
  10131. fmt.Println(err)
  10132. }
  10133. saveLog(result, request_log, "2206", "预结算")
  10134. //userJSONBytes, _ := json.Marshal(dat)
  10135. //
  10136. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10137. // utils.ErrorLog("解析失败:%v", err)
  10138. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10139. // return
  10140. //}
  10141. userJSONBytes, _ := json.Marshal(dat)
  10142. if miConfig.Code == "H15049901371" {
  10143. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10144. utils.ErrorLog("解析失败:%v", err)
  10145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10146. return
  10147. }
  10148. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10149. res.Output = resSeven10265.Output
  10150. res.ErrMsg = resSeven10265.ErrMsg
  10151. res.Cainfo = resSeven10265.Cainfo
  10152. res.WarnMsg = resSeven10265.WarnMsg
  10153. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10154. res.Infcode = infocode
  10155. } else {
  10156. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10157. utils.ErrorLog("解析失败:%v", err)
  10158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10159. return
  10160. }
  10161. }
  10162. }
  10163. if res.Infcode != 0 {
  10164. errlog := &models.HisOrderError{
  10165. UserOrgId: adminUser.CurrentOrgId,
  10166. Ctime: time.Now().Unix(),
  10167. Mtime: time.Now().Unix(),
  10168. Number: chrg_bchno,
  10169. ErrMsg: res.ErrMsg,
  10170. Status: 1,
  10171. PatientId: id,
  10172. RecordTime: recordDateTime,
  10173. Stage: 20,
  10174. }
  10175. service.CreateErrMsgLog(errlog)
  10176. c.ServeSuccessJSON(map[string]interface{}{
  10177. "failed_code": -10,
  10178. "msg": res.ErrMsg,
  10179. })
  10180. return
  10181. } else {
  10182. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10183. order.OrderStatus = 1
  10184. order.IsPre = 1
  10185. order.Status = 1
  10186. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10187. order.SetlId = res.Output.Setlinfo.SetlID
  10188. order.PsnNo = res.Output.Setlinfo.PsnNo
  10189. order.PsnName = res.Output.Setlinfo.PsnName
  10190. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10191. order.Certno = res.Output.Setlinfo.Certno
  10192. order.Gend = res.Output.Setlinfo.Gend
  10193. order.Naty = res.Output.Setlinfo.Naty
  10194. order.Age = res.Output.Setlinfo.Age
  10195. order.Insutype = res.Output.Setlinfo.Insutype
  10196. order.PsnType = res.Output.Setlinfo.PsnType
  10197. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10198. order.SetlTime = res.Output.Setlinfo.SetlTime
  10199. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10200. if res.Output.Setlinfo.MedType == "140101" {
  10201. order.MedType = "14"
  10202. } else {
  10203. order.MedType = res.Output.Setlinfo.MedType
  10204. }
  10205. if reg_type == 1112 {
  10206. order.MedType = "1112"
  10207. }
  10208. if reg_type == 1111 {
  10209. order.MedType = "1111"
  10210. }
  10211. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10212. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10213. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10214. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10215. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10216. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10217. order.HifpPay = res.Output.Setlinfo.HifpPay
  10218. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10219. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10220. order.HifesPay = res.Output.Setlinfo.HifesPay
  10221. order.HifobPay = res.Output.Setlinfo.HifobPay
  10222. order.MafPay = res.Output.Setlinfo.MafPay
  10223. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10224. order.OthPay = res.Output.Setlinfo.OthPay
  10225. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10226. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10227. order.AcctPay = res.Output.Setlinfo.AcctPay
  10228. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10229. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10230. order.Balc = res.Output.Setlinfo.Balc
  10231. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10232. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10233. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10234. order.ClrWay = res.Output.Setlinfo.ClrWay
  10235. order.Creator = order.Creator
  10236. order.Modify = roles.AdminUserId
  10237. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10238. detailStr := string(setlDetail)
  10239. order.SetlDetail = detailStr
  10240. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10241. err = service.UpDateOrder(order)
  10242. if err == nil {
  10243. c.ServeSuccessJSON(map[string]interface{}{
  10244. "msg": "预结算成功",
  10245. })
  10246. } else {
  10247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10248. return
  10249. }
  10250. }
  10251. } else {
  10252. adminUser := c.GetAdminUserInfo()
  10253. errlog := &models.HisOrderError{
  10254. UserOrgId: adminUser.CurrentOrgId,
  10255. Ctime: time.Now().Unix(),
  10256. Mtime: time.Now().Unix(),
  10257. ErrMsg: res.ErrMsg,
  10258. Status: 1,
  10259. PatientId: id,
  10260. RecordTime: recordDateTime,
  10261. Stage: 4,
  10262. }
  10263. service.CreateErrMsgLog(errlog)
  10264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10265. return
  10266. }
  10267. } else {
  10268. adminUser := c.GetAdminUserInfo()
  10269. errlog := &models.HisOrderError{
  10270. UserOrgId: adminUser.CurrentOrgId,
  10271. Ctime: time.Now().Unix(),
  10272. Mtime: time.Now().Unix(),
  10273. ErrMsg: res.ErrMsg,
  10274. Status: 1,
  10275. PatientId: id,
  10276. RecordTime: recordDateTime,
  10277. Stage: 4,
  10278. }
  10279. service.CreateErrMsgLog(errlog)
  10280. c.ServeSuccessJSON(map[string]interface{}{
  10281. "failed_code": -10,
  10282. "msg": res.ErrMsg,
  10283. })
  10284. return
  10285. }
  10286. }
  10287. }
  10288. }
  10289. //退款
  10290. func (c *HisApiController) Refund() {
  10291. order_id, _ := c.GetInt64("order_id")
  10292. admin_user_id, _ := c.GetInt64("admin_user_id")
  10293. adminUser := c.GetAdminUserInfo()
  10294. var order models.HisOrder
  10295. order, _ = service.GetHisOrderByID(order_id)
  10296. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10297. if order.ID == 0 {
  10298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10299. return
  10300. }
  10301. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10302. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10303. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10304. if config.IsOpen == 1 { //对接了医保,走医保流程
  10305. var res ResultSixteen
  10306. var resSixteen10265 ResultSixteen10265
  10307. var src_resquest string
  10308. var result string
  10309. if miConfig.MdtrtareaAdmvs == "421300" {
  10310. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  10311. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10312. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10313. resp3, requestErr3 := http.Get(api3)
  10314. if requestErr3 != nil {
  10315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10316. return
  10317. }
  10318. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10319. if ioErr3 != nil {
  10320. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10322. return
  10323. }
  10324. var respJSON3 map[string]interface{}
  10325. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10326. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10328. return
  10329. }
  10330. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10331. userJSONBytes3, _ := json.Marshal(respJSON3)
  10332. fmt.Println("log")
  10333. fmt.Println(string(userJSONBytes3))
  10334. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  10335. utils.ErrorLog("解析失败:%v", err)
  10336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10337. return
  10338. }
  10339. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10340. var api3 string
  10341. if miConfig.MdtrtareaAdmvs == "320921" {
  10342. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10343. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10344. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10345. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10346. } else {
  10347. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10348. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10349. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10350. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10351. }
  10352. resp3, requestErr3 := http.Get(api3)
  10353. if requestErr3 != nil {
  10354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10355. return
  10356. }
  10357. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10358. if ioErr3 != nil {
  10359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10361. return
  10362. }
  10363. var respJSON3 map[string]interface{}
  10364. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10367. return
  10368. }
  10369. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10370. userJSONBytes3, _ := json.Marshal(respJSON3)
  10371. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  10372. utils.ErrorLog("解析失败:%v", err)
  10373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10374. return
  10375. }
  10376. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10377. res.Output = resSixteen10265.Output
  10378. res.ErrMsg = resSixteen10265.ErrMsg
  10379. res.Cainfo = resSixteen10265.Cainfo
  10380. res.WarnMsg = resSixteen10265.WarnMsg
  10381. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10382. res.Infcode = infocode
  10383. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10384. 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)
  10385. var dat map[string]interface{}
  10386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10387. fmt.Println(dat)
  10388. } else {
  10389. fmt.Println(err)
  10390. }
  10391. saveLog(result, src_resquest, "2208", "退费")
  10392. userJSONBytes, _ := json.Marshal(dat)
  10393. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10394. utils.ErrorLog("解析失败:%v", err)
  10395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10396. return
  10397. }
  10398. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10399. 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, "")
  10400. var dat map[string]interface{}
  10401. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10402. fmt.Println(dat)
  10403. } else {
  10404. fmt.Println(err)
  10405. }
  10406. saveLog(result, src_resquest, "2208", "退费")
  10407. userJSONBytes, _ := json.Marshal(dat)
  10408. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10409. utils.ErrorLog("解析失败:%v", err)
  10410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10411. return
  10412. }
  10413. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10414. 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, "")
  10415. var dat map[string]interface{}
  10416. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10417. fmt.Println(dat)
  10418. } else {
  10419. fmt.Println(err)
  10420. }
  10421. saveLog(result, src_resquest, "2208", "退费")
  10422. userJSONBytes, _ := json.Marshal(dat)
  10423. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10424. utils.ErrorLog("解析失败:%v", err)
  10425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10426. return
  10427. }
  10428. } else {
  10429. if miConfig.Code == "H15049901371" {
  10430. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10431. var dat map[string]interface{}
  10432. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10433. fmt.Println(dat)
  10434. } else {
  10435. fmt.Println(err)
  10436. }
  10437. saveLog(result, src_resquest, "2208", "退费")
  10438. userJSONBytes, _ := json.Marshal(dat)
  10439. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  10440. utils.ErrorLog("解析失败:%v", err)
  10441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10442. return
  10443. }
  10444. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10445. res.Output = resSixteen10265.Output
  10446. res.ErrMsg = resSixteen10265.ErrMsg
  10447. res.Cainfo = resSixteen10265.Cainfo
  10448. res.WarnMsg = resSixteen10265.WarnMsg
  10449. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10450. res.Infcode = infocode
  10451. } else {
  10452. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10453. var dat map[string]interface{}
  10454. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10455. fmt.Println(dat)
  10456. } else {
  10457. fmt.Println(err)
  10458. }
  10459. saveLog(result, src_resquest, "2208", "退费")
  10460. userJSONBytes, _ := json.Marshal(dat)
  10461. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10462. utils.ErrorLog("解析失败:%v", err)
  10463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10464. return
  10465. }
  10466. }
  10467. }
  10468. if res.Infcode == 0 {
  10469. var res2 ResultSix
  10470. var resSix10265 ResultSix10265
  10471. if miConfig.MdtrtareaAdmvs == "421300" {
  10472. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10473. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10474. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10475. resp3, requestErr3 := http.Get(api3)
  10476. if requestErr3 != nil {
  10477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10478. return
  10479. }
  10480. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10481. if ioErr3 != nil {
  10482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10484. return
  10485. }
  10486. var respJSON3 map[string]interface{}
  10487. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10490. return
  10491. }
  10492. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10493. userJSONBytes3, _ := json.Marshal(respJSON3)
  10494. fmt.Println("log")
  10495. fmt.Println(string(userJSONBytes3))
  10496. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10497. utils.ErrorLog("解析失败:%v", err)
  10498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10499. return
  10500. }
  10501. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10502. var api3 string
  10503. if miConfig.MdtrtareaAdmvs == "320921" {
  10504. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10505. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10506. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10507. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10508. } else {
  10509. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10510. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10511. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10512. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10513. }
  10514. resp3, requestErr3 := http.Get(api3)
  10515. if requestErr3 != nil {
  10516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10517. return
  10518. }
  10519. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10520. if ioErr3 != nil {
  10521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10523. return
  10524. }
  10525. var respJSON3 map[string]interface{}
  10526. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10529. return
  10530. }
  10531. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10532. userJSONBytes3, _ := json.Marshal(respJSON3)
  10533. fmt.Println("log")
  10534. fmt.Println(string(userJSONBytes3))
  10535. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10536. utils.ErrorLog("解析失败:%v", err)
  10537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10538. return
  10539. }
  10540. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10541. res2.Output = resSix10265.Output
  10542. res2.ErrMsg = resSix10265.ErrMsg
  10543. res2.Cainfo = resSix10265.Cainfo
  10544. res2.WarnMsg = resSix10265.WarnMsg
  10545. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10546. res2.Infcode = infocode
  10547. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10548. 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)
  10549. var dat map[string]interface{}
  10550. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10551. fmt.Println(dat)
  10552. } else {
  10553. fmt.Println(err)
  10554. }
  10555. saveLog(result2, src_request, "2205", "撤销明细")
  10556. userJSONBytes, _ := json.Marshal(dat)
  10557. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10558. utils.ErrorLog("解析失败:%v", err)
  10559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10560. return
  10561. }
  10562. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10563. 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, "")
  10564. var dat map[string]interface{}
  10565. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10566. fmt.Println(dat)
  10567. } else {
  10568. fmt.Println(err)
  10569. }
  10570. saveLog(result2, src_request, "2205", "撤销明细")
  10571. userJSONBytes, _ := json.Marshal(dat)
  10572. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10573. utils.ErrorLog("解析失败:%v", err)
  10574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10575. return
  10576. }
  10577. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10578. 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, "")
  10579. var dat map[string]interface{}
  10580. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10581. fmt.Println(dat)
  10582. } else {
  10583. fmt.Println(err)
  10584. }
  10585. saveLog(result2, src_request, "2205", "撤销明细")
  10586. userJSONBytes, _ := json.Marshal(dat)
  10587. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10588. utils.ErrorLog("解析失败:%v", err)
  10589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10590. return
  10591. }
  10592. } else {
  10593. if miConfig.Code == "H15049901371" {
  10594. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10595. var dat map[string]interface{}
  10596. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10597. fmt.Println(dat)
  10598. } else {
  10599. fmt.Println(err)
  10600. }
  10601. saveLog(result2, src_request, "2205", "撤销明细")
  10602. userJSONBytes, _ := json.Marshal(dat)
  10603. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  10604. utils.ErrorLog("解析失败:%v", err)
  10605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10606. return
  10607. }
  10608. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10609. res2.Output = resSix10265.Output
  10610. res2.ErrMsg = resSix10265.ErrMsg
  10611. res2.Cainfo = resSix10265.Cainfo
  10612. res2.WarnMsg = resSix10265.WarnMsg
  10613. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10614. res2.Infcode = infocode
  10615. } else {
  10616. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10617. var dat map[string]interface{}
  10618. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10619. fmt.Println(dat)
  10620. } else {
  10621. fmt.Println(err)
  10622. }
  10623. saveLog(result2, src_request, "2205", "撤销明细")
  10624. userJSONBytes, _ := json.Marshal(dat)
  10625. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10626. utils.ErrorLog("解析失败:%v", err)
  10627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10628. return
  10629. }
  10630. }
  10631. }
  10632. if res2.Infcode == 0 {
  10633. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  10634. if err == nil {
  10635. //当押金不为零时产生退费记录
  10636. if order.Decimal != 0 {
  10637. tmp := strconv.FormatInt(order.ID, 10)
  10638. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  10639. if err != nil {
  10640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10641. return
  10642. }
  10643. }
  10644. c.ServeSuccessJSON(map[string]interface{}{
  10645. "msg": "退费成功",
  10646. })
  10647. } else {
  10648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10649. return
  10650. }
  10651. } else {
  10652. c.ServeSuccessJSON(map[string]interface{}{
  10653. "code": -10,
  10654. "msg": res2.ErrMsg,
  10655. })
  10656. }
  10657. } else {
  10658. c.ServeSuccessJSON(map[string]interface{}{
  10659. "code": -10,
  10660. "msg": res.ErrMsg,
  10661. })
  10662. }
  10663. }
  10664. }
  10665. func (c *HisApiController) RefundNumber() {
  10666. record_time := c.GetString("record_time")
  10667. //patient_id, _ := c.GetInt64("patient_id")
  10668. admin_user_id, _ := c.GetInt64("admin_user_id")
  10669. his_patient_id, _ := c.GetInt64("id")
  10670. timeLayout := "2006-01-02"
  10671. loc, _ := time.LoadLocation("Local")
  10672. adminUser := c.GetAdminUserInfo()
  10673. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10674. fmt.Println(err)
  10675. if err != nil {
  10676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10677. return
  10678. }
  10679. recordDateTime := theTime.Unix()
  10680. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10681. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  10682. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10683. //order, _ := service.GetHisOrderByID(order_id)
  10684. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10685. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10686. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10687. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  10688. if count > 0 {
  10689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  10690. return
  10691. }
  10692. if config.IsOpen == 1 { //对接了医保,走医保流程
  10693. var res2 ResultSix
  10694. var resSix10265 ResultSix10265
  10695. if miConfig.MdtrtareaAdmvs == "421300" {
  10696. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  10697. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10698. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10699. resp3, requestErr3 := http.Get(api3)
  10700. if requestErr3 != nil {
  10701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10702. return
  10703. }
  10704. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10705. if ioErr3 != nil {
  10706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10708. return
  10709. }
  10710. var respJSON3 map[string]interface{}
  10711. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10714. return
  10715. }
  10716. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10717. userJSONBytes3, _ := json.Marshal(respJSON3)
  10718. fmt.Println("log")
  10719. fmt.Println(string(userJSONBytes3))
  10720. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10721. utils.ErrorLog("解析失败:%v", err)
  10722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10723. return
  10724. }
  10725. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10726. var api3 string
  10727. if miConfig.MdtrtareaAdmvs == "320921" {
  10728. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10729. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10730. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10731. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10732. } else {
  10733. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10734. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10735. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10736. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10737. }
  10738. resp3, requestErr3 := http.Get(api3)
  10739. if requestErr3 != nil {
  10740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10741. return
  10742. }
  10743. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10744. if ioErr3 != nil {
  10745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10747. return
  10748. }
  10749. var respJSON3 map[string]interface{}
  10750. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10753. return
  10754. }
  10755. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10756. userJSONBytes3, _ := json.Marshal(respJSON3)
  10757. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10758. utils.ErrorLog("解析失败:%v", err)
  10759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10760. return
  10761. }
  10762. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10763. res2.Output = resSix10265.Output
  10764. res2.ErrMsg = resSix10265.ErrMsg
  10765. res2.Cainfo = resSix10265.Cainfo
  10766. res2.WarnMsg = resSix10265.WarnMsg
  10767. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10768. res2.Infcode = infocode
  10769. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10770. 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)
  10771. var dat map[string]interface{}
  10772. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10773. fmt.Println(dat)
  10774. } else {
  10775. fmt.Println(err)
  10776. }
  10777. saveLog(result, request, "2202", "退号")
  10778. userJSONBytes, _ := json.Marshal(dat)
  10779. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10780. utils.ErrorLog("解析失败:%v", err)
  10781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10782. return
  10783. }
  10784. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10785. 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, "")
  10786. var dat map[string]interface{}
  10787. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10788. fmt.Println(dat)
  10789. } else {
  10790. fmt.Println(err)
  10791. }
  10792. saveLog(result, request, "2202", "退号")
  10793. userJSONBytes, _ := json.Marshal(dat)
  10794. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10795. utils.ErrorLog("解析失败:%v", err)
  10796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10797. return
  10798. }
  10799. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10800. 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, "")
  10801. var dat map[string]interface{}
  10802. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10803. fmt.Println(dat)
  10804. } else {
  10805. fmt.Println(err)
  10806. }
  10807. saveLog(result, request, "2202", "退号")
  10808. userJSONBytes, _ := json.Marshal(dat)
  10809. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10810. utils.ErrorLog("解析失败:%v", err)
  10811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10812. return
  10813. }
  10814. } else {
  10815. var api3 string
  10816. if miConfig.Code == "H15049901371" {
  10817. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10818. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10819. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10820. } else {
  10821. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10822. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10823. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10824. }
  10825. resp3, requestErr3 := http.Get(api3)
  10826. if requestErr3 != nil {
  10827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10828. return
  10829. }
  10830. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10831. if ioErr3 != nil {
  10832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10834. return
  10835. }
  10836. var respJSON3 map[string]interface{}
  10837. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10840. return
  10841. }
  10842. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10843. userJSONBytes3, _ := json.Marshal(respJSON3)
  10844. if miConfig.Code == "H15049901371" {
  10845. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10846. utils.ErrorLog("解析失败:%v", err)
  10847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10848. return
  10849. }
  10850. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10851. res2.Output = resSix10265.Output
  10852. res2.ErrMsg = resSix10265.ErrMsg
  10853. res2.Cainfo = resSix10265.Cainfo
  10854. res2.WarnMsg = resSix10265.WarnMsg
  10855. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10856. res2.Infcode = infocode
  10857. } else {
  10858. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10859. utils.ErrorLog("解析失败:%v", err)
  10860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10861. return
  10862. }
  10863. }
  10864. }
  10865. if res2.Infcode == 0 {
  10866. if err == nil {
  10867. c.ServeSuccessJSON(map[string]interface{}{
  10868. "msg": "退号成功",
  10869. })
  10870. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  10871. } else {
  10872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10873. return
  10874. }
  10875. } else {
  10876. c.ServeSuccessJSON(map[string]interface{}{
  10877. "code": -10,
  10878. "msg": res2.ErrMsg,
  10879. })
  10880. }
  10881. } else {
  10882. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  10883. //if err == nil {
  10884. // c.ServeSuccessJSON(map[string]interface{}{
  10885. // "msg": "退费成功",
  10886. // })
  10887. //} else {
  10888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10889. // return
  10890. //}
  10891. }
  10892. }
  10893. func (c *HisApiController) RefundDetail() {
  10894. order_id, _ := c.GetInt64("order_id")
  10895. admin_user_id, _ := c.GetInt64("admin_user_id")
  10896. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10897. number := c.GetString("number")
  10898. record_time := c.GetString("record_time")
  10899. patient_id, _ := c.GetInt64("patient_id")
  10900. //med_type, _ := c.GetInt64("med_type")
  10901. timeLayout := "2006-01-02"
  10902. loc, _ := time.LoadLocation("Local")
  10903. adminUser := c.GetAdminUserInfo()
  10904. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10905. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10906. fmt.Println(err)
  10907. if err != nil {
  10908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10909. return
  10910. }
  10911. recordDateTime := theTime.Unix()
  10912. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10913. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10914. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10915. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10916. var order models.HisOrder
  10917. order, _ = service.GetHisOrderByID(order_id)
  10918. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10919. if config.IsOpen == 1 { //对接了医保,走医保流程
  10920. var res2 ResultSix
  10921. if miConfig.MdtrtareaAdmvs == "421300" {
  10922. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10923. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10924. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10925. resp3, requestErr3 := http.Get(api3)
  10926. if requestErr3 != nil {
  10927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10928. return
  10929. }
  10930. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10931. if ioErr3 != nil {
  10932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10934. return
  10935. }
  10936. var respJSON3 map[string]interface{}
  10937. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10940. return
  10941. }
  10942. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10943. userJSONBytes3, _ := json.Marshal(respJSON3)
  10944. fmt.Println("log")
  10945. fmt.Println(string(userJSONBytes3))
  10946. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10947. utils.ErrorLog("解析失败:%v", err)
  10948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10949. return
  10950. }
  10951. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10952. if err == nil {
  10953. c.ServeSuccessJSON(map[string]interface{}{
  10954. "msg": "撤销明细成功",
  10955. })
  10956. return
  10957. } else {
  10958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10959. return
  10960. }
  10961. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10962. var resSix10265 ResultSix10265
  10963. var api3 string
  10964. if miConfig.MdtrtareaAdmvs == "320921" {
  10965. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10966. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10967. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10968. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10969. } else {
  10970. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10971. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10972. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10973. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10974. }
  10975. resp3, requestErr3 := http.Get(api3)
  10976. if requestErr3 != nil {
  10977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10978. return
  10979. }
  10980. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10981. if ioErr3 != nil {
  10982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10984. return
  10985. }
  10986. var respJSON3 map[string]interface{}
  10987. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10990. return
  10991. }
  10992. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10993. userJSONBytes3, _ := json.Marshal(respJSON3)
  10994. fmt.Println("log")
  10995. fmt.Println(string(userJSONBytes3))
  10996. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10997. utils.ErrorLog("解析失败:%v", err)
  10998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10999. return
  11000. }
  11001. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11002. res2.Output = resSix10265.Output
  11003. res2.ErrMsg = resSix10265.ErrMsg
  11004. res2.Cainfo = resSix10265.Cainfo
  11005. res2.WarnMsg = resSix10265.WarnMsg
  11006. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11007. res2.Infcode = infocode
  11008. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11009. if err == nil {
  11010. c.ServeSuccessJSON(map[string]interface{}{
  11011. "msg": "撤销明细成功",
  11012. })
  11013. return
  11014. } else {
  11015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11016. return
  11017. }
  11018. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11019. 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)
  11020. var dat map[string]interface{}
  11021. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11022. fmt.Println(dat)
  11023. } else {
  11024. fmt.Println(err)
  11025. }
  11026. saveLog(result2, src_request, "2205", "撤销明细")
  11027. userJSONBytes, _ := json.Marshal(dat)
  11028. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11029. utils.ErrorLog("解析失败:%v", err)
  11030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11031. return
  11032. }
  11033. if res2.Infcode == 0 {
  11034. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11035. if err == nil {
  11036. c.ServeSuccessJSON(map[string]interface{}{
  11037. "msg": "撤销明细成功",
  11038. })
  11039. return
  11040. } else {
  11041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11042. return
  11043. }
  11044. } else {
  11045. c.ServeSuccessJSON(map[string]interface{}{
  11046. "code": -10,
  11047. "msg": res2.ErrMsg,
  11048. })
  11049. }
  11050. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11051. 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, "")
  11052. var dat map[string]interface{}
  11053. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11054. fmt.Println(dat)
  11055. } else {
  11056. fmt.Println(err)
  11057. }
  11058. saveLog(result2, src_request, "2205", "撤销明细")
  11059. userJSONBytes, _ := json.Marshal(dat)
  11060. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11061. utils.ErrorLog("解析失败:%v", err)
  11062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11063. return
  11064. }
  11065. if res2.Infcode == 0 {
  11066. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11067. if err == nil {
  11068. c.ServeSuccessJSON(map[string]interface{}{
  11069. "msg": "撤销明细成功",
  11070. })
  11071. return
  11072. } else {
  11073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11074. return
  11075. }
  11076. } else {
  11077. c.ServeSuccessJSON(map[string]interface{}{
  11078. "code": -10,
  11079. "msg": res2.ErrMsg,
  11080. })
  11081. }
  11082. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11083. 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, "")
  11084. var dat map[string]interface{}
  11085. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11086. fmt.Println(dat)
  11087. } else {
  11088. fmt.Println(err)
  11089. }
  11090. saveLog(result2, src_request, "2205", "撤销明细")
  11091. userJSONBytes, _ := json.Marshal(dat)
  11092. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11093. utils.ErrorLog("解析失败:%v", err)
  11094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11095. return
  11096. }
  11097. if res2.Infcode == 0 {
  11098. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11099. if err == nil {
  11100. c.ServeSuccessJSON(map[string]interface{}{
  11101. "msg": "撤销明细成功",
  11102. })
  11103. return
  11104. } else {
  11105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11106. return
  11107. }
  11108. } else {
  11109. c.ServeSuccessJSON(map[string]interface{}{
  11110. "code": -10,
  11111. "msg": res2.ErrMsg,
  11112. })
  11113. }
  11114. } else {
  11115. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  11116. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11117. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11118. resp2, requestErr2 := http.Get(api2)
  11119. if requestErr2 != nil {
  11120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11121. return
  11122. }
  11123. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  11124. if ioErr2 != nil {
  11125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  11126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11127. return
  11128. }
  11129. var respJSON2 map[string]interface{}
  11130. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  11131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11133. return
  11134. }
  11135. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11136. if err == nil {
  11137. c.ServeSuccessJSON(map[string]interface{}{
  11138. "msg": "撤销明细成功",
  11139. })
  11140. return
  11141. } else {
  11142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11143. return
  11144. }
  11145. }
  11146. } else {
  11147. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11148. if err == nil {
  11149. c.ServeSuccessJSON(map[string]interface{}{
  11150. "msg": "退费成功",
  11151. })
  11152. } else {
  11153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11154. return
  11155. }
  11156. }
  11157. }
  11158. //对账
  11159. func (c *HisApiController) GetCheckAccount() {
  11160. start_time := c.GetString("start_time")
  11161. end_time := c.GetString("end_time")
  11162. insutype := c.GetString("insutype")
  11163. clr_type := c.GetString("clr_type")
  11164. clr_org := c.GetString("clr_optins")
  11165. admin_user_id, _ := c.GetInt64("admin_user_id")
  11166. adminUser := c.GetAdminUserInfo()
  11167. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11168. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11169. if len(clr_org) == 0 {
  11170. clr_org = miConfig.MdtrtareaAdmvs
  11171. }
  11172. timeLayout := "2006-01-02"
  11173. loc, _ := time.LoadLocation("Local")
  11174. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11175. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11176. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  11177. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  11178. fixmedins_setl_cnt := int64(len(orders))
  11179. var medfee_sumamt float64
  11180. var acct_pay float64
  11181. var fund_pay_sumamt float64
  11182. for _, item := range orders {
  11183. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11184. acct_pay = acct_pay + item.AcctPay
  11185. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11186. }
  11187. var user_name string
  11188. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11189. if role.ID == 0 {
  11190. user_name = "xxx"
  11191. } else {
  11192. user_name = role.UserName
  11193. }
  11194. var res ResultEight
  11195. var res10188 ResultEightFor10188
  11196. if config.IsOpen == 1 {
  11197. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11198. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  11199. "insutype=" + insutype +
  11200. "&clr_type=" + clr_type +
  11201. "&setl_optins=" + clr_org +
  11202. "&stmt_begndate=" + start_time +
  11203. "&stm_enddate=" + end_time +
  11204. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11205. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11206. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11207. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11208. "&fixmedins_code=" + miConfig.Code +
  11209. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11210. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11211. "&secret_key=" + miConfig.SecretKey +
  11212. "&org_name=" + miConfig.OrgName +
  11213. "&doctor=" + user_name +
  11214. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11215. fmt.Println(api)
  11216. resp, requestErr := http.Get(api)
  11217. if requestErr != nil {
  11218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11219. return
  11220. }
  11221. body, ioErr := ioutil.ReadAll(resp.Body)
  11222. fmt.Println(body)
  11223. if ioErr != nil {
  11224. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11226. return
  11227. }
  11228. var respJSON map[string]interface{}
  11229. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11232. return
  11233. }
  11234. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11235. userJSONBytes, _ := json.Marshal(respJSON)
  11236. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11237. utils.ErrorLog("解析失败:%v", err)
  11238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11239. return
  11240. }
  11241. res.InfRefmsgid = res10188.InfRefmsgid
  11242. res.Output = res10188.Output
  11243. res.ErrMsg = res10188.ErrMsg
  11244. res.Cainfo = res10188.Cainfo
  11245. res.WarnMsg = res10188.WarnMsg
  11246. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11247. res.Infcode = infocode
  11248. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11249. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  11250. "insutype=" + insutype +
  11251. "&clr_type=" + "21" +
  11252. "&setl_optins=" + clr_org +
  11253. "&stmt_begndate=" + start_time +
  11254. "&stm_enddate=" + end_time +
  11255. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11256. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11257. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11258. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11259. "&fixmedins_code=" + miConfig.Code +
  11260. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11261. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11262. "&secret_key=" + miConfig.SecretKey +
  11263. "&org_name=" + miConfig.OrgName +
  11264. "&doctor=" + user_name
  11265. resp, requestErr := http.Get(api)
  11266. if requestErr != nil {
  11267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11268. return
  11269. }
  11270. body, ioErr := ioutil.ReadAll(resp.Body)
  11271. if ioErr != nil {
  11272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11274. return
  11275. }
  11276. var respJSON map[string]interface{}
  11277. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11280. return
  11281. }
  11282. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11283. result, _ := json.Marshal(respJSON)
  11284. fmt.Println("log")
  11285. fmt.Println(string(result))
  11286. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  11287. utils.ErrorLog("解析失败:%v", err)
  11288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11289. return
  11290. }
  11291. res.InfRefmsgid = res10188.InfRefmsgid
  11292. res.Output = res10188.Output
  11293. res.ErrMsg = res10188.ErrMsg
  11294. res.Cainfo = res10188.Cainfo
  11295. res.WarnMsg = res10188.WarnMsg
  11296. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11297. res.Infcode = infocode
  11298. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11299. var baseParams models.BaseParams
  11300. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11301. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11302. baseParams.SecretKey = miConfig.SecretKey
  11303. baseParams.OrgName = miConfig.OrgName
  11304. baseParams.FixmedinsCode = miConfig.Code
  11305. baseParams.EncKey = miConfig.EncKey
  11306. baseParams.AppSecret = miConfig.AppSecret
  11307. baseParams.SignKey = miConfig.SignKey
  11308. baseParams.AppID = miConfig.Code
  11309. baseParams.Doctor = role.UserName
  11310. baseParams.RequestUrl = miConfig.Url
  11311. businessParams := models.BusinessParams{
  11312. Insutype: insutype,
  11313. ClrType: clr_type,
  11314. SetlOptins: clr_org,
  11315. StmtBegndate: start_time,
  11316. StmtEnddate: end_time,
  11317. MedfeeSumamt: medfee_sumamt,
  11318. FundPaySumamt: fund_pay_sumamt,
  11319. AcctPay: acct_pay,
  11320. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11321. }
  11322. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11323. fmt.Println(requestLog)
  11324. fmt.Println(result)
  11325. fmt.Println(err_msg)
  11326. var dat map[string]interface{}
  11327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11328. fmt.Println(dat)
  11329. } else {
  11330. fmt.Println(err)
  11331. }
  11332. userJSONBytes, _ := json.Marshal(dat)
  11333. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11334. utils.ErrorLog("解析失败:%v", err)
  11335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11336. return
  11337. }
  11338. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11339. var baseParams models.BaseParams
  11340. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11341. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11342. baseParams.SecretKey = miConfig.SecretKey
  11343. baseParams.OrgName = miConfig.OrgName
  11344. baseParams.FixmedinsCode = miConfig.Code
  11345. baseParams.EncKey = miConfig.EncKey
  11346. baseParams.AppSecret = miConfig.AppSecret
  11347. baseParams.SignKey = miConfig.SignKey
  11348. baseParams.AppID = miConfig.Code
  11349. baseParams.Doctor = role.UserName
  11350. baseParams.RequestUrl = miConfig.Url
  11351. baseParams.AccessKey = miConfig.AccessKey
  11352. businessParams := models.BusinessParams{
  11353. Insutype: insutype,
  11354. ClrType: clr_type,
  11355. SetlOptins: "430822",
  11356. StmtBegndate: start_time,
  11357. StmtEnddate: end_time,
  11358. MedfeeSumamt: medfee_sumamt,
  11359. FundPaySumamt: fund_pay_sumamt,
  11360. AcctPay: acct_pay,
  11361. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11362. }
  11363. 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)
  11364. fmt.Println(requestLog)
  11365. fmt.Println(result)
  11366. var dat map[string]interface{}
  11367. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11368. fmt.Println(dat)
  11369. } else {
  11370. fmt.Println(err)
  11371. }
  11372. userJSONBytes, _ := json.Marshal(dat)
  11373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11374. utils.ErrorLog("解析失败:%v", err)
  11375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11376. return
  11377. }
  11378. } else if miConfig.MdtrtareaAdmvs == "" {
  11379. var baseParams models.BaseParams
  11380. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11381. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11382. baseParams.SecretKey = miConfig.SecretKey
  11383. baseParams.OrgName = miConfig.OrgName
  11384. baseParams.FixmedinsCode = miConfig.Code
  11385. baseParams.EncKey = miConfig.EncKey
  11386. baseParams.AppSecret = miConfig.AppSecret
  11387. baseParams.SignKey = miConfig.SignKey
  11388. baseParams.AppID = miConfig.Code
  11389. baseParams.Doctor = role.UserName
  11390. baseParams.RequestUrl = miConfig.Url
  11391. businessParams := models.BusinessParams{
  11392. Insutype: insutype,
  11393. ClrType: clr_type,
  11394. SetlOptins: clr_org,
  11395. StmtBegndate: start_time,
  11396. StmtEnddate: end_time,
  11397. MedfeeSumamt: medfee_sumamt,
  11398. FundPaySumamt: fund_pay_sumamt,
  11399. AcctPay: acct_pay,
  11400. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11401. }
  11402. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11403. fmt.Println(requestLog)
  11404. fmt.Println(result)
  11405. fmt.Println(err_msg)
  11406. var dat map[string]interface{}
  11407. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11408. fmt.Println(dat)
  11409. } else {
  11410. fmt.Println(err)
  11411. }
  11412. userJSONBytes, _ := json.Marshal(dat)
  11413. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11414. utils.ErrorLog("解析失败:%v", err)
  11415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11416. return
  11417. }
  11418. } else {
  11419. if len(clr_type) == 0 {
  11420. clr_type = "11"
  11421. }
  11422. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11423. "insutype=" + insutype +
  11424. "&clr_type=" + clr_type +
  11425. "&setl_optins=" + clr_org +
  11426. "&stmt_begndate=" + start_time +
  11427. "&stm_enddate=" + end_time +
  11428. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11429. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11430. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11431. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11432. "&fixmedins_code=" + miConfig.Code +
  11433. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11434. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11435. "&secret_key=" + miConfig.SecretKey +
  11436. "&org_name=" + miConfig.OrgName +
  11437. "&doctor=" + user_name
  11438. fmt.Println(api)
  11439. resp, requestErr := http.Get(api)
  11440. if requestErr != nil {
  11441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11442. return
  11443. }
  11444. body, ioErr := ioutil.ReadAll(resp.Body)
  11445. fmt.Println(body)
  11446. if ioErr != nil {
  11447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11449. return
  11450. }
  11451. var respJSON map[string]interface{}
  11452. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11455. return
  11456. }
  11457. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11458. userJSONBytes, _ := json.Marshal(respJSON)
  11459. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11460. utils.ErrorLog("解析失败:%v", err)
  11461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11462. return
  11463. }
  11464. }
  11465. if res.Infcode == 0 {
  11466. if res.Output.Stmtinfo.StmtRslt == "0" {
  11467. micc := &models.MedicalInsuranceCostCompare{
  11468. StartTime: startime.Unix(),
  11469. EndTime: endtime.Unix(),
  11470. Insutype: insutype,
  11471. CheckType: 1,
  11472. Num: fixmedins_setl_cnt,
  11473. Mtime: time.Now().Unix(),
  11474. Status: 1,
  11475. UserOrgId: adminUser.CurrentOrgId,
  11476. CostTotal: medfee_sumamt,
  11477. FuncTotal: fund_pay_sumamt,
  11478. PsnPay: acct_pay,
  11479. Creator: admin_user_id,
  11480. Ctime: time.Now().Unix(),
  11481. ClrType: clr_type,
  11482. }
  11483. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  11484. if err == nil {
  11485. c.ServeSuccessJSON(map[string]interface{}{
  11486. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11487. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11488. })
  11489. } else {
  11490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11491. }
  11492. } else {
  11493. c.ServeSuccessJSON(map[string]interface{}{
  11494. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11495. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11496. })
  11497. }
  11498. } else {
  11499. c.ServeSuccessJSON(map[string]interface{}{
  11500. "code": -10,
  11501. "msg": res.ErrMsg,
  11502. })
  11503. }
  11504. }
  11505. }
  11506. func (c *HisApiController) Check310() {
  11507. adminUser := c.GetAdminUserInfo()
  11508. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11509. var user_name string
  11510. user_name = "高慧裕"
  11511. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11512. "insutype=" + "310" +
  11513. "&clr_type=" + "" +
  11514. "&setl_optins=" + "441202" +
  11515. "&stmt_begndate=" + "2022-03-01" +
  11516. "&stm_enddate=" + "2022-03-31" +
  11517. "&medfee_sumamt=" + "194930.12" +
  11518. "&fund_pay_sumamt=" + "188741.46" +
  11519. "&acct_pay=" + "0" +
  11520. "&fixmedins_setl_cnt=" + "452" +
  11521. "&fixmedins_code=" + miConfig.Code +
  11522. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11523. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11524. "&secret_key=" + miConfig.SecretKey +
  11525. "&org_name=" + miConfig.OrgName +
  11526. "&doctor=" + user_name
  11527. fmt.Println(api)
  11528. resp, requestErr := http.Get(api)
  11529. if requestErr != nil {
  11530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11531. return
  11532. }
  11533. body, ioErr := ioutil.ReadAll(resp.Body)
  11534. fmt.Println(body)
  11535. if ioErr != nil {
  11536. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11538. return
  11539. }
  11540. var respJSON map[string]interface{}
  11541. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11544. return
  11545. }
  11546. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11547. userJSONBytes, _ := json.Marshal(respJSON)
  11548. var res ResultEight
  11549. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11550. utils.ErrorLog("解析失败:%v", err)
  11551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11552. return
  11553. }
  11554. }
  11555. func (c *HisApiController) Check390() {
  11556. adminUser := c.GetAdminUserInfo()
  11557. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11558. var user_name string
  11559. user_name = "高慧裕"
  11560. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11561. "insutype=" + "390" +
  11562. "&clr_type=" + "" +
  11563. "&setl_optins=" + "441202" +
  11564. "&stmt_begndate=" + "2022-03-01" +
  11565. "&stm_enddate=" + "2022-03-31" +
  11566. "&medfee_sumamt=" + "1068448.89" +
  11567. "&fund_pay_sumamt=" + "1014677.62" +
  11568. "&acct_pay=" + "0" +
  11569. "&fixmedins_setl_cnt=" + "1950" +
  11570. "&fixmedins_code=" + miConfig.Code +
  11571. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11572. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11573. "&secret_key=" + miConfig.SecretKey +
  11574. "&org_name=" + miConfig.OrgName +
  11575. "&doctor=" + user_name
  11576. fmt.Println(api)
  11577. resp, requestErr := http.Get(api)
  11578. if requestErr != nil {
  11579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11580. return
  11581. }
  11582. body, ioErr := ioutil.ReadAll(resp.Body)
  11583. fmt.Println(body)
  11584. if ioErr != nil {
  11585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11587. return
  11588. }
  11589. var respJSON map[string]interface{}
  11590. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11593. return
  11594. }
  11595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11596. userJSONBytes, _ := json.Marshal(respJSON)
  11597. var res ResultEight
  11598. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11599. utils.ErrorLog("解析失败:%v", err)
  11600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11601. return
  11602. }
  11603. }
  11604. //对账明细
  11605. func (c *HisApiController) GetCheckDetailAccount() {
  11606. start_time := c.GetString("start_time")
  11607. end_time := c.GetString("end_time")
  11608. admin_user_id, _ := c.GetInt64("admin_user_id")
  11609. adminUser := c.GetAdminUserInfo()
  11610. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11611. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11612. timeLayout := "2006-01-02"
  11613. loc, _ := time.LoadLocation("Local")
  11614. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11615. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11616. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  11617. rand.Seed(time.Now().UnixNano())
  11618. num := rand.Intn(30000)
  11619. Mkdir(miConfig.OrgName)
  11620. file := strconv.FormatInt(int64(num), 10)
  11621. file_name := file + ".txt"
  11622. zip_name := file + ".zip"
  11623. zip_path := miConfig.OrgName + "/" + zip_name
  11624. file_path := miConfig.OrgName + "/" + file_name
  11625. decimal.DivisionPrecision = 2
  11626. var medfee_sumamt float64
  11627. var psn_cash_pay float64
  11628. var fund_pay_sumamt float64
  11629. fixmedins_setl_cnt := int64(len(orders))
  11630. for _, item := range orders {
  11631. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11632. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  11633. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11634. }
  11635. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  11636. defer f.Close()
  11637. if err != nil {
  11638. fmt.Println(err.Error())
  11639. } else {
  11640. for _, item := range orders {
  11641. var refd_setl_flag string
  11642. if item.OrderStatus == 2 {
  11643. refd_setl_flag = "0"
  11644. var str string
  11645. str = item.SetlId + " " +
  11646. item.MdtrtId + " " +
  11647. item.PsnNo + " " +
  11648. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11649. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11650. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  11651. _, err = f.Write([]byte(str))
  11652. }
  11653. if item.OrderStatus == 3 {
  11654. var str string
  11655. str = item.SetlId + " " +
  11656. item.MdtrtId + " " +
  11657. item.PsnNo + " " +
  11658. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11659. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11660. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  11661. _, err = f.Write([]byte(str))
  11662. var str2 string
  11663. str2 = item.SetlId + " " +
  11664. item.MdtrtId + " " +
  11665. item.PsnNo + " " +
  11666. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  11667. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  11668. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  11669. _, err = f.Write([]byte(str2))
  11670. }
  11671. }
  11672. }
  11673. Zip(file_path, zip_path)
  11674. fmt.Println(ReadFile(zip_path))
  11675. fmt.Println(string(ReadFile(zip_path)))
  11676. if config.IsOpen == 1 {
  11677. var user_name string
  11678. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11679. if role.ID == 0 {
  11680. user_name = "管理员"
  11681. } else {
  11682. user_name = role.UserName
  11683. }
  11684. baseParams := models.BaseParams{
  11685. SecretKey: miConfig.SecretKey,
  11686. FixmedinsCode: miConfig.Code,
  11687. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11688. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11689. OrgName: miConfig.OrgName,
  11690. Doctor: user_name,
  11691. }
  11692. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  11693. var dat map[string]interface{}
  11694. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11695. fmt.Println(dat)
  11696. } else {
  11697. fmt.Println(err)
  11698. }
  11699. userJSONBytes, _ := json.Marshal(dat)
  11700. var res ResultNine
  11701. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11702. utils.ErrorLog("解析失败:%v", err)
  11703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11704. return
  11705. }
  11706. if res.Infcode == 0 {
  11707. fileNo := res.Output.FileQuryNo
  11708. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  11709. "file_qury_no=" + fileNo +
  11710. "&setl_optins=" + "定点医保中心" +
  11711. "&stmt_begndate=" + start_time +
  11712. "&stm_enddate=" + end_time +
  11713. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11714. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11715. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  11716. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11717. "&fixmedins_code=" + miConfig.Code +
  11718. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11719. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11720. "&secret_key=" + miConfig.SecretKey +
  11721. "&org_name=" + miConfig.OrgName +
  11722. "&doctor=" + user_name
  11723. resp, requestErr := http.Get(api)
  11724. if requestErr != nil {
  11725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11726. return
  11727. }
  11728. body, ioErr := ioutil.ReadAll(resp.Body)
  11729. if ioErr != nil {
  11730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11732. return
  11733. }
  11734. var respJSON map[string]interface{}
  11735. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11738. return
  11739. }
  11740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11741. userJSONBytes, _ := json.Marshal(respJSON)
  11742. var res ResultTen
  11743. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11744. utils.ErrorLog("解析失败:%v", err)
  11745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11746. return
  11747. }
  11748. if res.Infcode == 0 {
  11749. service.Gdyb9102(baseParams, zip_name, fileNo)
  11750. micc := &models.MedicalInsuranceCostCompare{
  11751. StartTime: startime.Unix(),
  11752. EndTime: endtime.Unix(),
  11753. Insutype: "0",
  11754. CheckType: 2,
  11755. Num: fixmedins_setl_cnt,
  11756. Mtime: time.Now().Unix(),
  11757. Status: 1,
  11758. UserOrgId: adminUser.CurrentOrgId,
  11759. CostTotal: medfee_sumamt,
  11760. FuncTotal: fund_pay_sumamt,
  11761. PsnPay: psn_cash_pay,
  11762. Creator: admin_user_id,
  11763. Ctime: time.Now().Unix(),
  11764. }
  11765. service.CreateMedicalInsuranceCostCompareRecord(micc)
  11766. c.ServeSuccessJSON(map[string]interface{}{
  11767. "msg": "明细对账成功",
  11768. })
  11769. }
  11770. } else {
  11771. }
  11772. }
  11773. }
  11774. type CustomOrderInfo struct {
  11775. Name string
  11776. Spec string
  11777. Unit string
  11778. Count float64
  11779. Price float64
  11780. Total float64
  11781. }
  11782. func (c *HisApiController) GetSettleAccounts() {
  11783. //id, _ := c.GetInt64("id")
  11784. //record_time := c.GetString("record_time")
  11785. order_id, _ := c.GetInt64("order_id")
  11786. admin_user_id, _ := c.GetInt64("admin_user_id")
  11787. //timeLayout := "2006-01-02"
  11788. //loc, _ := time.LoadLocation("Local")
  11789. //
  11790. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11791. //if err != nil {
  11792. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11793. // return
  11794. //}
  11795. //recordDateTime := theTime.Unix()
  11796. adminUser := c.GetAdminUserInfo()
  11797. order, _ := service.GetHisOrderByID(order_id)
  11798. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11799. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  11800. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  11801. orderInfos = append(orderInfos, orderInfos_two...)
  11802. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  11803. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  11804. var diagnosis_ids []string
  11805. if his.ID > 0 {
  11806. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  11807. } else {
  11808. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  11809. }
  11810. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  11811. var dia_config []*models.HisXtDiagnoseConfig
  11812. var name string
  11813. for _, item := range diagnosis_ids {
  11814. id, _ := strconv.ParseInt(item, 10, 64)
  11815. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11816. dia_config = append(dia_config, &diagnosisConfig)
  11817. if len(name) == 0 {
  11818. name = diagnosisConfig.ClassName
  11819. } else {
  11820. name = name + "," + diagnosisConfig.ClassName
  11821. }
  11822. }
  11823. var bedCostTotal float64 = 0 //床位总费
  11824. var bedCostSelfTotal float64 = 0 //床位自费
  11825. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11826. var operationCostTotal float64 = 0 //手术费
  11827. var operationCostSelfTotal float64 = 0 //手术费
  11828. var operationCostPartSelfTotal float64 = 0 //手术费
  11829. var otherCostTotal float64 = 0 //其他费用
  11830. var otherCostSelfTotal float64 = 0 //其他费用
  11831. var otherCostPartSelfTotal float64 = 0 //其他费用
  11832. var materialCostTotal float64 = 0 //材料费
  11833. var materialCostSelfTotal float64 = 0 //材料费
  11834. var materialCostPartSelfTotal float64 = 0 //材料费
  11835. var westernMedicineCostTotal float64 = 0 //西药费
  11836. var westernMedicineCostSelfTotal float64 = 0 //西药费
  11837. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11838. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11839. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11840. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11841. var checkCostTotal float64 = 0 //检查费
  11842. var checkCostSelfTotal float64 = 0 //检查费
  11843. var checkCostPartSelfTotal float64 = 0 //检查费
  11844. var laboratoryCostTotal float64 = 0 //化验费
  11845. var laboratoryCostSelfTotal float64 = 0 //化验费
  11846. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11847. var treatCostTotal float64 = 0 //治疗费用
  11848. var treatCostSelfTotal float64 = 0 //治疗费用
  11849. var treatCostPartSelfTotal float64 = 0 //治疗费用
  11850. decimal.DivisionPrecision = 2
  11851. for _, item := range orderInfos {
  11852. if item.MedChrgitmType == "01" { //床位费
  11853. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11854. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11855. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11856. }
  11857. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  11858. if item.MedChrgitmType == "03" { //检查费
  11859. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11860. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11861. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11862. }
  11863. } else {
  11864. if item.MedChrgitmType == "03" { //检查费
  11865. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11866. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11867. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11868. }
  11869. }
  11870. if item.MedChrgitmType == "04" { //化验费
  11871. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11872. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11873. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11874. }
  11875. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  11876. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11877. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11878. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11879. }
  11880. if item.MedChrgitmType == "06" { //手术费
  11881. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11882. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11883. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11884. }
  11885. if item.MedChrgitmType == "08" { //材料费
  11886. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11887. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11888. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11889. }
  11890. if item.MedChrgitmType == "09" { //西药费
  11891. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11892. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11893. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11894. }
  11895. if item.MedChrgitmType == "11" { //中成费
  11896. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11897. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11898. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11899. }
  11900. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  11901. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11902. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11903. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11904. }
  11905. }
  11906. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11907. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11908. var user_name string
  11909. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11910. if role.ID == 0 {
  11911. user_name = "管理员"
  11912. } else {
  11913. user_name = role.UserName
  11914. }
  11915. baseParams := models.BaseParams{
  11916. SecretKey: miConfig.SecretKey,
  11917. FixmedinsCode: miConfig.Code,
  11918. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11919. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11920. OrgName: miConfig.OrgName,
  11921. Doctor: user_name,
  11922. RequestUrl: miConfig.Url,
  11923. AccessKey: miConfig.AccessKey,
  11924. }
  11925. businessParams := models.BusinessParams{
  11926. PsnNo: order.PsnNo,
  11927. MdtrtId: order.MdtrtId,
  11928. SetlId: order.SetlId,
  11929. }
  11930. var res ResultEleven
  11931. var resEleven10265 ResultEleven10265
  11932. if config.IsOpen == 1 {
  11933. if miConfig.MdtrtareaAdmvs == "421300" {
  11934. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11935. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11936. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11937. resp, requestErr := http.Get(api)
  11938. if requestErr != nil {
  11939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11940. return
  11941. }
  11942. body, ioErr := ioutil.ReadAll(resp.Body)
  11943. if ioErr != nil {
  11944. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11946. return
  11947. }
  11948. var respJSON map[string]interface{}
  11949. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11952. return
  11953. }
  11954. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11955. result, _ := json.Marshal(respJSON)
  11956. fmt.Println("log")
  11957. fmt.Println(string(result))
  11958. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11959. utils.ErrorLog("解析失败:%v", err)
  11960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11961. return
  11962. }
  11963. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11964. var api string
  11965. if miConfig.MdtrtareaAdmvs == "320921" {
  11966. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11967. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11968. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11969. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11970. } else {
  11971. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11972. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11973. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11974. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11975. }
  11976. resp, requestErr := http.Get(api)
  11977. if requestErr != nil {
  11978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11979. return
  11980. }
  11981. body, ioErr := ioutil.ReadAll(resp.Body)
  11982. if ioErr != nil {
  11983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11985. return
  11986. }
  11987. var respJSON map[string]interface{}
  11988. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11991. return
  11992. }
  11993. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11994. result, _ := json.Marshal(respJSON)
  11995. fmt.Println("log")
  11996. fmt.Println(string(result))
  11997. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  11998. utils.ErrorLog("解析失败:%v", err)
  11999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12000. return
  12001. }
  12002. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12003. res.Output = resEleven10265.Output
  12004. res.ErrMsg = resEleven10265.ErrMsg
  12005. res.Cainfo = resEleven10265.Cainfo
  12006. res.WarnMsg = resEleven10265.WarnMsg
  12007. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12008. res.Infcode = infocode
  12009. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12010. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  12011. saveLog(result, requestLog, "5203", "结算单")
  12012. var dat map[string]interface{}
  12013. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12014. fmt.Println(dat)
  12015. } else {
  12016. fmt.Println(err)
  12017. }
  12018. userJSONBytes, _ := json.Marshal(dat)
  12019. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12020. utils.ErrorLog("解析失败:%v", err)
  12021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12022. return
  12023. }
  12024. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12025. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  12026. saveLog(result, requestLog, "5203", "结算单")
  12027. var dat map[string]interface{}
  12028. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12029. fmt.Println(dat)
  12030. } else {
  12031. fmt.Println(err)
  12032. }
  12033. userJSONBytes, _ := json.Marshal(dat)
  12034. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12035. utils.ErrorLog("解析失败:%v", err)
  12036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12037. return
  12038. }
  12039. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12040. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  12041. saveLog(result, requestLog, "5203", "结算单")
  12042. var dat map[string]interface{}
  12043. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12044. fmt.Println(dat)
  12045. } else {
  12046. fmt.Println(err)
  12047. }
  12048. userJSONBytes, _ := json.Marshal(dat)
  12049. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12050. utils.ErrorLog("解析失败:%v", err)
  12051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12052. return
  12053. }
  12054. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12055. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12056. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12057. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12058. resp, requestErr := http.Get(api)
  12059. if requestErr != nil {
  12060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12061. return
  12062. }
  12063. body, ioErr := ioutil.ReadAll(resp.Body)
  12064. if ioErr != nil {
  12065. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12067. return
  12068. }
  12069. var respJSON map[string]interface{}
  12070. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12073. return
  12074. }
  12075. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12076. result, _ := json.Marshal(respJSON)
  12077. fmt.Println("log")
  12078. fmt.Println(string(result))
  12079. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12080. utils.ErrorLog("解析失败:%v", err)
  12081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12082. return
  12083. }
  12084. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12085. res.Output = resEleven10265.Output
  12086. res.ErrMsg = resEleven10265.ErrMsg
  12087. res.Cainfo = resEleven10265.Cainfo
  12088. res.WarnMsg = resEleven10265.WarnMsg
  12089. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12090. res.Infcode = infocode
  12091. } else {
  12092. result := service.Gdyb5203(baseParams, businessParams)
  12093. //service.Gdyb5204(baseParams, businessParams)
  12094. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  12095. var dat map[string]interface{}
  12096. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12097. fmt.Println(dat)
  12098. } else {
  12099. fmt.Println(err)
  12100. }
  12101. userJSONBytes, _ := json.Marshal(dat)
  12102. if miConfig.Code == "H15049901371" {
  12103. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  12104. utils.ErrorLog("解析失败:%v", err)
  12105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12106. return
  12107. }
  12108. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12109. res.Output = resEleven10265.Output
  12110. res.ErrMsg = resEleven10265.ErrMsg
  12111. res.Cainfo = resEleven10265.Cainfo
  12112. res.WarnMsg = resEleven10265.WarnMsg
  12113. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12114. res.Infcode = infocode
  12115. } else {
  12116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12117. utils.ErrorLog("解析失败:%v", err)
  12118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12119. return
  12120. }
  12121. }
  12122. }
  12123. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12124. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  12125. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  12126. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12127. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  12128. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12129. var doctor_name string
  12130. if roles.ID == 0 {
  12131. doctor_name = "管理员"
  12132. } else {
  12133. doctor_name = roles.UserName
  12134. }
  12135. yiliao_leibie := ""
  12136. switch order.MedType {
  12137. case "11":
  12138. yiliao_leibie = "普通门诊"
  12139. break
  12140. case "12":
  12141. yiliao_leibie = "门诊挂号"
  12142. break
  12143. case "13":
  12144. yiliao_leibie = "急诊"
  12145. break
  12146. case "14":
  12147. yiliao_leibie = "门诊特殊病"
  12148. break
  12149. case "15":
  12150. yiliao_leibie = "门诊统筹"
  12151. break
  12152. case "16":
  12153. yiliao_leibie = "门诊慢性病"
  12154. break
  12155. case "21":
  12156. yiliao_leibie = "普通住院"
  12157. break
  12158. }
  12159. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12160. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  12161. if res.Infcode == 0 {
  12162. c.ServeSuccessJSON(map[string]interface{}{
  12163. "diagnosis": name,
  12164. "order_infos": orderInfos,
  12165. "number": order.MdtrtId,
  12166. "date": order.SettleAccountsDate,
  12167. "charge_admin": charge_admin,
  12168. "printor_admin": printor_admin,
  12169. "info": res.Output.Setlinfo,
  12170. "order": order,
  12171. "bedCostTotal": bedCostTotal,
  12172. "bedCostSelfTotal": bedCostSelfTotal,
  12173. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  12174. "operationCostTotal": operationCostTotal,
  12175. "operationCostSelfTotal": operationCostSelfTotal,
  12176. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  12177. "otherCostTotal": otherCostTotal,
  12178. "otherCostSelfTotal": otherCostSelfTotal,
  12179. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  12180. "materialCostTotal": materialCostTotal,
  12181. "materialCostSelfTotal": materialCostSelfTotal,
  12182. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  12183. "westernMedicineCostTotal": westernMedicineCostTotal,
  12184. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  12185. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  12186. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  12187. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  12188. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  12189. "checkCostTotal": checkCostTotal,
  12190. "checkCostSelfTotal": checkCostSelfTotal,
  12191. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  12192. "laboratoryCostTotal": laboratoryCostTotal,
  12193. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  12194. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  12195. "treatCostTotal": treatCostTotal,
  12196. "treatCostSelfTotal": treatCostSelfTotal,
  12197. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  12198. "doctor_info": doctor_info,
  12199. "doctor_code": adminRole_two.DoctorCode,
  12200. "doctor_name": doctor_name,
  12201. "health_card_no": order.PsnNo,
  12202. "department": departments.Name,
  12203. "yiliao_leibie": yiliao_leibie,
  12204. "after_money": order.AccountPrice,
  12205. "patient": patient,
  12206. "org_name": miConfig.OrgName,
  12207. "org_code": miConfig.Code,
  12208. "order_number": order.Number,
  12209. "his_hospital": his_hospital,
  12210. "his": his,
  12211. "dia_config": dia_config,
  12212. //"check_order_info": cus_slice,
  12213. })
  12214. }
  12215. }
  12216. }
  12217. func (c *HisApiController) CheckTreatment() {
  12218. patient_id, _ := c.GetInt64("patient_id")
  12219. id_card_no := c.GetString("id_card_no")
  12220. insutype := c.GetString("insutype")
  12221. med_type := c.GetString("med_type")
  12222. admin_user_id, _ := c.GetInt64("admin_user_id")
  12223. adminUser := c.GetAdminUserInfo()
  12224. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12225. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12226. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12227. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12228. if miConfig.MdtrtareaAdmvs == "421300" {
  12229. var res ResultTwo
  12230. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12231. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12232. "&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)
  12233. resp, requestErr := http.Get(api)
  12234. if requestErr != nil {
  12235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12236. return
  12237. }
  12238. body, ioErr := ioutil.ReadAll(resp.Body)
  12239. if ioErr != nil {
  12240. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12242. return
  12243. }
  12244. var respJSON map[string]interface{}
  12245. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12248. return
  12249. }
  12250. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12251. result, _ := json.Marshal(respJSON)
  12252. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12253. utils.ErrorLog("解析失败:%v", err)
  12254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12255. return
  12256. }
  12257. if res.Infcode == 0 {
  12258. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  12259. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12260. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  12261. resp, requestErr := http.Get(api)
  12262. if requestErr != nil {
  12263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12264. return
  12265. }
  12266. body, ioErr := ioutil.ReadAll(resp.Body)
  12267. if ioErr != nil {
  12268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12270. return
  12271. }
  12272. var respJSON map[string]interface{}
  12273. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12276. return
  12277. }
  12278. var res Result2001
  12279. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12280. result2, _ := json.Marshal(respJSON)
  12281. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  12282. utils.ErrorLog("解析失败:%v", err)
  12283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12284. return
  12285. }
  12286. if res.Infcode == 0 {
  12287. c.ServeSuccessJSON(map[string]interface{}{
  12288. "msg": res.Output.Trtinfo,
  12289. })
  12290. }
  12291. } else {
  12292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12293. return
  12294. }
  12295. } else {
  12296. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12297. var dat map[string]interface{}
  12298. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12299. fmt.Println(dat)
  12300. } else {
  12301. fmt.Println(err)
  12302. }
  12303. userJSONBytes, _ := json.Marshal(dat)
  12304. var res ResultTwo
  12305. var res10265 ResultTwo10265
  12306. if miConfig.Code == "H15049901371" {
  12307. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12308. utils.ErrorLog("解析失败:%v", err)
  12309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12310. return
  12311. }
  12312. res.ErrMsg = res10265.ErrMsg
  12313. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12314. res.Infcode = infocode
  12315. res.Output = res10265.Output
  12316. res.InfRefmsgid = res10265.InfRefmsgid
  12317. } else {
  12318. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12319. utils.ErrorLog("解析失败:%v", err)
  12320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12321. return
  12322. }
  12323. }
  12324. var user_name string
  12325. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  12326. if role.ID == 0 {
  12327. user_name = "xxx"
  12328. } else {
  12329. user_name = role.UserName
  12330. }
  12331. baseParams := models.BaseParams{
  12332. SecretKey: miConfig.SecretKey,
  12333. FixmedinsCode: miConfig.Code,
  12334. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12335. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12336. OrgName: miConfig.OrgName,
  12337. Doctor: user_name,
  12338. }
  12339. if config.IsOpen == 1 {
  12340. if miConfig.Code == "H15049901371" {
  12341. if med_type == "14" {
  12342. if insutype == "390" {
  12343. med_type = "9933"
  12344. } else if insutype == "310" {
  12345. med_type = "990502"
  12346. }
  12347. } else if med_type == "11" {
  12348. med_type = "11"
  12349. }
  12350. }
  12351. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  12352. var dat map[string]interface{}
  12353. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12354. fmt.Println(dat)
  12355. } else {
  12356. fmt.Println(err)
  12357. }
  12358. var res Result2001
  12359. var res10265 Result2001Org10265
  12360. if miConfig.Code == "H15049901371" {
  12361. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12362. utils.ErrorLog("解析失败:%v", err)
  12363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12364. return
  12365. }
  12366. res.ErrMsg = res10265.ErrMsg
  12367. res.Output = res10265.Output
  12368. res.InfRefmsgid = res10265.InfRefmsgid
  12369. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12370. res.Infcode = infocode
  12371. } else {
  12372. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12373. utils.ErrorLog("解析失败:%v", err)
  12374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12375. return
  12376. }
  12377. }
  12378. if res.Infcode == 0 {
  12379. c.ServeSuccessJSON(map[string]interface{}{
  12380. "msg": res.Output.Trtinfo,
  12381. })
  12382. }
  12383. }
  12384. }
  12385. }
  12386. //func (c *HisApiController) PutRecord() {
  12387. // id, _ := c.GetInt64("id")
  12388. // record_time := c.GetString("record_time")
  12389. // timeLayout := "2006-01-02"
  12390. // loc, _ := time.LoadLocation("Local")
  12391. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12392. // if err != nil {
  12393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12394. // return
  12395. // }
  12396. // recordDateTime := theTime.Unix()
  12397. //
  12398. // adminInfo := c.GetAdminUserInfo()
  12399. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  12400. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12401. //
  12402. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12403. //
  12404. // fmt.Println(miConfig.SecretKey)
  12405. //
  12406. // if patient == nil {
  12407. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12408. // return
  12409. // }
  12410. // if len(patient.IdCardNo) == 0 {
  12411. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  12412. // return
  12413. // }
  12414. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  12415. // if config.IsOpen == 1 {
  12416. // 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
  12417. // resp, requestErr := http.Get(api)
  12418. // if requestErr != nil {
  12419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12420. // return
  12421. // }
  12422. // defer resp.Body.Close()
  12423. // body, ioErr := ioutil.ReadAll(resp.Body)
  12424. // if ioErr != nil {
  12425. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12426. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12427. // return
  12428. // }
  12429. // var respJSON map[string]interface{}
  12430. //
  12431. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12432. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12433. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12434. // return
  12435. // }
  12436. //
  12437. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12438. // userJSONBytes, _ := json.Marshal(userJSON)
  12439. // var res ResultTwo
  12440. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12441. // utils.ErrorLog("解析失败:%v", err)
  12442. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12443. // return
  12444. // }
  12445. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12446. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12447. // infoStr := string(Iinfos)
  12448. // idetinfoStr := string(Idetinfos)
  12449. //
  12450. // if res.Infcode == 0 {
  12451. // his := models.VMHisPatient{
  12452. // Status: 1,
  12453. // Ctime: time.Now().Unix(),
  12454. // Mtime: time.Now().Unix(),
  12455. // PsnNo: res.Output.Baseinfo.PsnNo,
  12456. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  12457. // Certno: res.Output.Baseinfo.Certno,
  12458. // PsnName: res.Output.Baseinfo.PsnName,
  12459. // Gend: res.Output.Baseinfo.Gend,
  12460. // Naty: res.Output.Baseinfo.Naty,
  12461. // Brdy: res.Output.Baseinfo.Brdy,
  12462. // Age: res.Output.Baseinfo.Age,
  12463. // Iinfo: infoStr,
  12464. // Idetinfo: idetinfoStr,
  12465. // PatientId: patient.ID,
  12466. // RecordDate: theTime.Unix(),
  12467. // UserOrgId: adminInfo.CurrentOrgId,
  12468. // AdminUserId: adminInfo.AdminUser.Id,
  12469. // IsReturn: 1,
  12470. // }
  12471. //
  12472. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  12473. // //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")
  12474. // //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")
  12475. //
  12476. // //var dat map[string]interface{}
  12477. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12478. // // fmt.Println(dat)
  12479. // //} else {
  12480. // // fmt.Println(err)
  12481. // //}
  12482. //
  12483. // var dat2 map[string]interface{}
  12484. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  12485. // fmt.Println(dat2)
  12486. // } else {
  12487. // fmt.Println(err)
  12488. // }
  12489. //
  12490. // } else {
  12491. // adminUser := c.GetAdminUserInfo()
  12492. // errlog := &models.HisOrderError{
  12493. // UserOrgId: adminUser.CurrentOrgId,
  12494. // Ctime: time.Now().Unix(),
  12495. // Mtime: time.Now().Unix(),
  12496. // ErrMsg: res.ErrMsg,
  12497. // Status: 1,
  12498. // PatientId: id,
  12499. // RecordTime: recordDateTime,
  12500. // Stage: 1,
  12501. // }
  12502. // service.CreateErrMsgLog(errlog)
  12503. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  12504. // return
  12505. // }
  12506. // }
  12507. //
  12508. //}
  12509. //func (c *HisApiController) GetUploadDiag() {
  12510. // id, _ := c.GetInt64("id")
  12511. // record_time := c.GetString("record_time")
  12512. //
  12513. // diagnosis_id, _ := c.GetInt64("diagnosis")
  12514. // sick_type, _ := c.GetInt64("sick_type")
  12515. // reg_type, _ := c.GetInt64("reg_type")
  12516. //
  12517. // timeLayout := "2006-01-02"
  12518. // loc, _ := time.LoadLocation("Local")
  12519. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12520. // if err != nil {
  12521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12522. // return
  12523. // }
  12524. //
  12525. // var patientPrescription models.HisPrescriptionInfo
  12526. // recordDateTime := theTime.Unix()
  12527. // adminInfo := c.GetAdminUserInfo()
  12528. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12529. //
  12530. // if patientPrescription.ID == 0 {
  12531. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12532. // }
  12533. //
  12534. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12535. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  12536. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12537. // sickConfig, _ := service.FindSickById(sick_type)
  12538. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12539. //
  12540. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  12541. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  12542. // "&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 +
  12543. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  12544. // resp2, requestErr2 := http.Get(api2)
  12545. // if requestErr2 != nil {
  12546. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12547. // return
  12548. // }
  12549. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  12550. // if ioErr2 != nil {
  12551. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  12552. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12553. // return
  12554. // }
  12555. // var respJSON2 map[string]interface{}
  12556. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  12557. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12559. // return
  12560. // }
  12561. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12562. // userJSONBytes2, _ := json.Marshal(respJSON2)
  12563. //
  12564. // var res2 ResultSix
  12565. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12566. // utils.ErrorLog("解析失败:%v", err)
  12567. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12568. // return
  12569. // }
  12570. // if res2.Infcode != 0 {
  12571. // adminUser := c.GetAdminUserInfo()
  12572. // errlog := &models.HisOrderError{
  12573. // UserOrgId: adminUser.CurrentOrgId,
  12574. // Ctime: time.Now().Unix(),
  12575. // Mtime: time.Now().Unix(),
  12576. // ErrMsg: res2.ErrMsg,
  12577. // Status: 1,
  12578. // PatientId: id,
  12579. // RecordTime: recordDateTime,
  12580. // Stage: 3,
  12581. // }
  12582. // service.CreateErrMsgLog(errlog)
  12583. //
  12584. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  12585. // return
  12586. // }
  12587. //
  12588. // c.ServeSuccessJSON(map[string]interface{}{
  12589. // "msg": "上传成功",
  12590. // })
  12591. //
  12592. //}
  12593. type QueryResult struct {
  12594. ID int64
  12595. Name string
  12596. Code string
  12597. List_type_code string
  12598. }
  12599. func (c *HisApiController) GetCheckCode() {
  12600. ids_str := c.GetString("ids")
  12601. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12602. ids_arr := strings.Split(ids_str, ",")
  12603. var queryResult []QueryResult
  12604. ids := make([]int64, 0)
  12605. for _, item := range ids_arr {
  12606. id, _ := strconv.ParseInt(item, 10, 64)
  12607. ids = append(ids, id)
  12608. }
  12609. if record_type == 1 {
  12610. drugs, _ := service.GetBatchDrugList(ids)
  12611. for _, item := range drugs {
  12612. result := QueryResult{
  12613. ID: item.ID,
  12614. Name: item.DrugName,
  12615. Code: item.MedicalInsuranceNumber,
  12616. List_type_code: "101",
  12617. }
  12618. queryResult = append(queryResult, result)
  12619. }
  12620. } else if record_type == 2 {
  12621. goods, _ := service.GetBatchGoodInformationList(ids)
  12622. for _, item := range goods {
  12623. result := QueryResult{
  12624. ID: item.ID,
  12625. Name: item.GoodName,
  12626. Code: item.MedicalInsuranceNumber,
  12627. List_type_code: "301",
  12628. }
  12629. queryResult = append(queryResult, result)
  12630. }
  12631. } else if record_type == 3 {
  12632. projects, _ := service.GetBathchMyPorjecgList(ids)
  12633. for _, item := range projects {
  12634. result := QueryResult{
  12635. ID: item.ID,
  12636. Name: item.ProjectName,
  12637. Code: item.MedicalCode,
  12638. List_type_code: "201",
  12639. }
  12640. queryResult = append(queryResult, result)
  12641. }
  12642. }
  12643. admin_user_id, _ := c.GetInt64("admin_user_id")
  12644. adminUser := c.GetAdminUserInfo()
  12645. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12646. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12647. var user_name string
  12648. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12649. if role.ID == 0 {
  12650. user_name = "xxx"
  12651. } else {
  12652. user_name = role.UserName
  12653. }
  12654. baseParams := &models.BaseParams{
  12655. SecretKey: miConfig.SecretKey,
  12656. FixmedinsCode: miConfig.Code,
  12657. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12658. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12659. OrgName: miConfig.OrgName,
  12660. Doctor: user_name,
  12661. }
  12662. if config.IsOpen == 1 {
  12663. for _, item := range queryResult {
  12664. var result string
  12665. if record_type == 1 {
  12666. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12667. } else if record_type == 2 {
  12668. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12669. } else if record_type == 3 {
  12670. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12671. }
  12672. var dat map[string]interface{}
  12673. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12674. fmt.Println(dat)
  12675. } else {
  12676. fmt.Println(err)
  12677. }
  12678. userJSONBytes, _ := json.Marshal(dat)
  12679. var res ResultSix
  12680. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12681. utils.ErrorLog("解析失败:%v", err)
  12682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12683. return
  12684. }
  12685. if res.Infcode == 0 {
  12686. if record_type == 1 {
  12687. service.UpdateBaseDrugById(item.ID)
  12688. } else if record_type == 2 {
  12689. service.UpdateGoodInformaitonByDetail(item.ID)
  12690. } else if record_type == 3 {
  12691. service.UpdateProjectById(item.ID)
  12692. }
  12693. c.ServeSuccessJSON(map[string]interface{}{
  12694. "failed_code": 0,
  12695. "msg": "目录对照成功",
  12696. })
  12697. } else {
  12698. c.ServeSuccessJSON(map[string]interface{}{
  12699. "failed_code": -10,
  12700. "msg": res.ErrMsg,
  12701. })
  12702. }
  12703. }
  12704. }
  12705. }
  12706. func (c *HisApiController) UnCheckCode() {
  12707. ids_str := c.GetString("ids")
  12708. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12709. admin_user_id, _ := c.GetInt64("admin_user_id")
  12710. ids_arr := strings.Split(ids_str, ",")
  12711. var queryResult []QueryResult
  12712. ids := make([]int64, 0)
  12713. for _, item := range ids_arr {
  12714. id, _ := strconv.ParseInt(item, 10, 64)
  12715. ids = append(ids, id)
  12716. }
  12717. if record_type == 1 {
  12718. drugs, _ := service.GetBatchDrugList(ids)
  12719. for _, item := range drugs {
  12720. result := QueryResult{
  12721. ID: item.ID,
  12722. Name: item.DrugName,
  12723. Code: item.MedicalInsuranceNumber,
  12724. List_type_code: "101",
  12725. }
  12726. queryResult = append(queryResult, result)
  12727. }
  12728. } else if record_type == 2 {
  12729. goods, _ := service.GetBatchGoodInformationList(ids)
  12730. for _, item := range goods {
  12731. result := QueryResult{
  12732. ID: item.ID,
  12733. Name: item.GoodName,
  12734. Code: item.MedicalInsuranceNumber,
  12735. List_type_code: "301",
  12736. }
  12737. queryResult = append(queryResult, result)
  12738. }
  12739. } else if record_type == 3 {
  12740. projects, _ := service.GetBathchMyPorjecgList(ids)
  12741. for _, item := range projects {
  12742. result := QueryResult{
  12743. ID: item.ID,
  12744. Name: item.ProjectName,
  12745. Code: item.MedicalCode,
  12746. List_type_code: "201",
  12747. }
  12748. queryResult = append(queryResult, result)
  12749. }
  12750. }
  12751. adminUser := c.GetAdminUserInfo()
  12752. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12753. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12754. var user_name string
  12755. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12756. if role.ID == 0 {
  12757. user_name = "xxx"
  12758. } else {
  12759. user_name = role.UserName
  12760. }
  12761. baseParams := &models.BaseParams{
  12762. SecretKey: miConfig.SecretKey,
  12763. FixmedinsCode: miConfig.Code,
  12764. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12765. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12766. OrgName: miConfig.OrgName,
  12767. Doctor: user_name,
  12768. }
  12769. if config.IsOpen == 1 {
  12770. for _, item := range queryResult {
  12771. var result string
  12772. if record_type == 1 {
  12773. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12774. } else if record_type == 2 {
  12775. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12776. } else if record_type == 3 {
  12777. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12778. }
  12779. var dat2 map[string]interface{}
  12780. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  12781. fmt.Println(dat2)
  12782. } else {
  12783. fmt.Println(err)
  12784. }
  12785. userJSONBytes, _ := json.Marshal(dat2)
  12786. var res ResultSix
  12787. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12788. utils.ErrorLog("解析失败:%v", err)
  12789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12790. return
  12791. }
  12792. if res.Infcode == 0 {
  12793. if record_type == 1 {
  12794. service.UpdateDrugByIdDetail(item.ID)
  12795. } else if record_type == 2 {
  12796. service.UpdateGoodInfoById(item.ID)
  12797. } else if record_type == 3 {
  12798. service.UpdateMyProjectById(item.ID)
  12799. }
  12800. c.ServeSuccessJSON(map[string]interface{}{
  12801. "failed_code": 0,
  12802. "msg": "撤销目录对照成功",
  12803. })
  12804. } else {
  12805. c.ServeSuccessJSON(map[string]interface{}{
  12806. "failed_code": -10,
  12807. "msg": res.ErrMsg,
  12808. })
  12809. }
  12810. }
  12811. }
  12812. }
  12813. func (c *HisApiController) GetPatientInfo() {
  12814. id_card_no := c.GetString("id_card_no")
  12815. admin_user_id, _ := c.GetInt64("admin_user_id")
  12816. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12817. if patient.ID == 0 {
  12818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12819. return
  12820. }
  12821. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12822. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12823. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  12824. if config.IsOpen == 1 {
  12825. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12826. var dat map[string]interface{}
  12827. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12828. fmt.Println(dat)
  12829. } else {
  12830. fmt.Println(err)
  12831. }
  12832. userJSONBytes, _ := json.Marshal(dat)
  12833. var res ResultTwo
  12834. var res10265 ResultTwo10265
  12835. if miConfig.Code == "H15049901371" {
  12836. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12837. utils.ErrorLog("解析失败:%v", err)
  12838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12839. return
  12840. }
  12841. res.ErrMsg = res10265.ErrMsg
  12842. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12843. res.Infcode = infocode
  12844. res.Output = res10265.Output
  12845. res.InfRefmsgid = res10265.InfRefmsgid
  12846. } else {
  12847. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12848. utils.ErrorLog("解析失败:%v", err)
  12849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12850. return
  12851. }
  12852. }
  12853. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12854. // utils.ErrorLog("解析失败:%v", err)
  12855. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12856. // return
  12857. //}
  12858. if res.Infcode != 0 {
  12859. c.ServeSuccessJSON(map[string]interface{}{
  12860. "failed_code": -10,
  12861. "msg": res.ErrMsg,
  12862. })
  12863. } else {
  12864. c.ServeSuccessJSON(map[string]interface{}{
  12865. "failed_code": 0,
  12866. "info": res,
  12867. })
  12868. }
  12869. }
  12870. }
  12871. func (c *HisApiController) PsnPutOnRecord() {
  12872. record_type, _ := c.GetInt64("type")
  12873. patient_id, _ := c.GetInt64("patient_id")
  12874. admin_user_id, _ := c.GetInt64("admin_user_id")
  12875. start_time := c.GetString("start_time")
  12876. end_time := c.GetString("end_time")
  12877. adminUser := c.GetAdminUserInfo()
  12878. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12879. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12880. var patients []*models.Patients
  12881. if record_type == 1 { //全部备案
  12882. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  12883. patients = append(patients, patient...)
  12884. } else { //单个备案
  12885. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12886. patients = append(patients, patient)
  12887. }
  12888. var user_name string
  12889. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12890. if role.ID == 0 {
  12891. user_name = "xxx"
  12892. } else {
  12893. user_name = role.UserName
  12894. }
  12895. if config.IsOpen == 1 {
  12896. for _, item := range patients {
  12897. 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
  12898. resp, requestErr := http.Get(api)
  12899. if requestErr != nil {
  12900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12901. return
  12902. }
  12903. defer resp.Body.Close()
  12904. body, ioErr := ioutil.ReadAll(resp.Body)
  12905. if ioErr != nil {
  12906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12908. return
  12909. }
  12910. var respJSON map[string]interface{}
  12911. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12914. return
  12915. }
  12916. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12917. userJSONBytes, _ := json.Marshal(userJSON)
  12918. var res ResultTwo
  12919. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12920. utils.ErrorLog("解析失败:%v", err)
  12921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12922. return
  12923. }
  12924. if res.Infcode == 0 {
  12925. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  12926. var dat map[string]interface{}
  12927. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12928. fmt.Println(dat)
  12929. } else {
  12930. fmt.Println(err)
  12931. }
  12932. userJSONBytes, _ := json.Marshal(dat)
  12933. var res2 ResultThirteen
  12934. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12935. utils.ErrorLog("解析失败:%v", err)
  12936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12937. return
  12938. }
  12939. if res2.Infcode == 0 {
  12940. psnResult := &models.GdybPsnRecord{
  12941. UserOrgId: adminUser.CurrentOrgId,
  12942. PatientId: item.ID,
  12943. PsnNo: res.Output.Baseinfo.PsnNo,
  12944. Ctime: time.Now().Unix(),
  12945. Mtime: time.Now().Unix(),
  12946. Status: 1,
  12947. IsCancel: 1,
  12948. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  12949. }
  12950. service.CreatePsnRecord(psnResult)
  12951. } else {
  12952. c.ServeSuccessJSON(map[string]interface{}{
  12953. "failed_code": -10,
  12954. "msg": res2.ErrMsg,
  12955. })
  12956. return
  12957. }
  12958. }
  12959. }
  12960. }
  12961. }
  12962. func (c *HisApiController) PsnUnPutOnRecord() {
  12963. id, _ := c.GetInt64("id")
  12964. //record_type, _ := c.GetInt64("type")
  12965. admin_user_id, _ := c.GetInt64("admin_user_id")
  12966. adminUser := c.GetAdminUserInfo()
  12967. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12968. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12969. var user_name string
  12970. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12971. if role.ID == 0 {
  12972. user_name = "xxx"
  12973. } else {
  12974. user_name = role.UserName
  12975. }
  12976. psn_record, _ := service.GetPsnRecordById(id)
  12977. if psn_record.ID == 0 {
  12978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12979. return
  12980. }
  12981. if config.IsOpen == 1 {
  12982. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  12983. var dat map[string]interface{}
  12984. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12985. fmt.Println(dat)
  12986. } else {
  12987. fmt.Println(err)
  12988. }
  12989. userJSONBytes, _ := json.Marshal(dat)
  12990. var res ResultFourteen
  12991. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12992. utils.ErrorLog("解析失败:%v", err)
  12993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12994. return
  12995. }
  12996. if res.Infcode == 0 {
  12997. psn_record.IsCancel = 2
  12998. service.CreatePsnRecord(&psn_record)
  12999. } else {
  13000. c.ServeSuccessJSON(map[string]interface{}{
  13001. "failed_code": -10,
  13002. "msg": res.ErrMsg,
  13003. })
  13004. return
  13005. }
  13006. }
  13007. }
  13008. func (c *HisApiController) PsnPutNCDSOnRecord() {
  13009. patient_id, _ := c.GetInt64("patient_id")
  13010. insutype_two := c.GetString("insutype")
  13011. psn_no := c.GetString("psn_no")
  13012. doctor_id, _ := c.GetInt64("doctor_id")
  13013. sick_id, _ := c.GetInt64("sick_id")
  13014. department_id, _ := c.GetInt64("department_id")
  13015. start_time := c.GetString("start_time")
  13016. end_time := c.GetString("end_time")
  13017. check_time := c.GetString("check_time")
  13018. adminUser := c.GetAdminUserInfo()
  13019. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13020. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13021. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13022. sick, _ := service.FindSickById(sick_id)
  13023. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13024. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13025. var res ResultTwo
  13026. var res10265 ResultTwo10265
  13027. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13028. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  13029. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  13030. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13031. "&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
  13032. resp, requestErr := http.Get(api)
  13033. if requestErr != nil {
  13034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13035. return
  13036. }
  13037. body, ioErr := ioutil.ReadAll(resp.Body)
  13038. if ioErr != nil {
  13039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13041. return
  13042. }
  13043. var respJSON map[string]interface{}
  13044. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13047. return
  13048. }
  13049. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13050. result, _ := json.Marshal(respJSON)
  13051. fmt.Println("log")
  13052. fmt.Println(string(result))
  13053. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13054. utils.ErrorLog("解析失败:%v", err)
  13055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13056. return
  13057. }
  13058. res.ErrMsg = res10265.ErrMsg
  13059. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13060. res.Infcode = infocode
  13061. res.Output = res10265.Output
  13062. res.InfRefmsgid = res10265.InfRefmsgid
  13063. } else {
  13064. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13065. if miConfig.Code == "H15049901371" {
  13066. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13067. utils.ErrorLog("解析失败:%v", err)
  13068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13069. return
  13070. }
  13071. res.ErrMsg = res10265.ErrMsg
  13072. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13073. res.Infcode = infocode
  13074. res.Output = res10265.Output
  13075. res.InfRefmsgid = res10265.InfRefmsgid
  13076. } else {
  13077. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13078. utils.ErrorLog("解析失败:%v", err)
  13079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13080. return
  13081. }
  13082. }
  13083. }
  13084. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13085. infoStr := string(Iinfos)
  13086. var rf []*ResultFive
  13087. json.Unmarshal([]byte(infoStr), &rf)
  13088. var insuplc_admdvs string
  13089. var insutype string
  13090. var is390 int = 0
  13091. var is310 int = 0
  13092. var insutypes []*ResultFive
  13093. for _, item := range rf {
  13094. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13095. insutypes = append(insutypes, item)
  13096. }
  13097. }
  13098. if len(insutypes) == 1 {
  13099. insutype = insutypes[0].Insutype
  13100. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13101. } else {
  13102. for _, i := range insutypes {
  13103. if i.Insutype == "390" {
  13104. is390 = 1
  13105. }
  13106. if i.Insutype == "310" {
  13107. is310 = 1
  13108. }
  13109. }
  13110. }
  13111. if is390 == 1 {
  13112. insutype = "390"
  13113. }
  13114. if is310 == 1 {
  13115. insutype = "310"
  13116. }
  13117. if len(insutypes) == 2 {
  13118. insutype = insutype_two
  13119. }
  13120. if len(insutypes) == 0 {
  13121. insutype = "310"
  13122. }
  13123. insutype = insutype_two
  13124. fmt.Println(insutype)
  13125. for _, item := range rf {
  13126. fmt.Println(item.Insutype)
  13127. fmt.Println(insutype)
  13128. if item.Insutype == insutype {
  13129. fmt.Println(item.Insutype)
  13130. fmt.Println(insutype)
  13131. insuplc_admdvs = item.InsuplcAdmdvs
  13132. }
  13133. }
  13134. fmt.Println(insuplc_admdvs)
  13135. var res2 ResultThirteen
  13136. var res10265_2 ResultThirteen10265
  13137. if config.IsOpen == 1 {
  13138. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13139. } else {
  13140. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time)
  13141. var dat map[string]interface{}
  13142. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13143. fmt.Println(dat)
  13144. } else {
  13145. fmt.Println(err)
  13146. }
  13147. userJSONBytes, _ := json.Marshal(dat)
  13148. if miConfig.Code == "H15049901371" {
  13149. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  13150. utils.ErrorLog("解析失败:%v", err)
  13151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13152. return
  13153. }
  13154. res2.ErrMsg = res10265_2.ErrMsg
  13155. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  13156. res2.Infcode = infocode
  13157. res2.Output = res10265_2.Output
  13158. res2.InfRefmsgid = res10265_2.InfRefmsgid
  13159. } else {
  13160. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13161. utils.ErrorLog("解析失败:%v", err)
  13162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13163. return
  13164. }
  13165. }
  13166. }
  13167. if res2.Infcode == 0 {
  13168. psnResult := &models.GdybPsnNcdsRecord{
  13169. UserOrgId: adminUser.CurrentOrgId,
  13170. PatientId: patient.ID,
  13171. PsnNo: psn_no,
  13172. DoctorId: doctor.AdminUserId,
  13173. DepartmentId: department_id,
  13174. SickType: sick_id,
  13175. Insutype: insutype,
  13176. Ctime: time.Now().Unix(),
  13177. Mtime: time.Now().Unix(),
  13178. Status: 1,
  13179. IsCancel: 1,
  13180. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  13181. }
  13182. service.CreatePsnNCDSRecord(psnResult)
  13183. c.ServeSuccessJSON(map[string]interface{}{
  13184. "failed_code": 0,
  13185. "msg": "备案成功",
  13186. "result": psnResult,
  13187. })
  13188. } else {
  13189. c.ServeSuccessJSON(map[string]interface{}{
  13190. "failed_code": -10,
  13191. "msg": res2.ErrMsg,
  13192. })
  13193. return
  13194. }
  13195. }
  13196. }
  13197. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  13198. id, _ := c.GetInt64("id")
  13199. admin_user_id, _ := c.GetInt64("admin_user_id")
  13200. adminUser := c.GetAdminUserInfo()
  13201. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13202. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13203. //config, _ := service.Ge(adminUser.CurrentOrgId)
  13204. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  13205. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13206. //var user_name string
  13207. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13208. //if role.ID == 0 {
  13209. // user_name = "xxx"
  13210. //} else {
  13211. // user_name = role.UserName
  13212. //}
  13213. psn_record, _ := service.GetPsnNCDSRecordById(id)
  13214. if psn_record.ID == 0 {
  13215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13216. return
  13217. }
  13218. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13219. var res ResultTwo
  13220. var res10265 ResultTwo10265
  13221. if miConfig.Code == "H15049901371" {
  13222. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13223. utils.ErrorLog("解析失败:%v", err)
  13224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13225. return
  13226. }
  13227. res.ErrMsg = res10265.ErrMsg
  13228. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13229. res.Infcode = infocode
  13230. res.Output = res10265.Output
  13231. res.InfRefmsgid = res10265.InfRefmsgid
  13232. } else {
  13233. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13234. utils.ErrorLog("解析失败:%v", err)
  13235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13236. return
  13237. }
  13238. }
  13239. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13240. infoStr := string(Iinfos)
  13241. var rf []*ResultFive
  13242. json.Unmarshal([]byte(infoStr), &rf)
  13243. var insuplc_admdvs string
  13244. var insutype string
  13245. var is390 int = 0
  13246. var is310 int = 0
  13247. var insutypes []*ResultFive
  13248. for _, item := range rf {
  13249. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13250. insutypes = append(insutypes, item)
  13251. }
  13252. }
  13253. if len(insutypes) == 1 {
  13254. insutype = insutypes[0].Insutype
  13255. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13256. } else {
  13257. for _, i := range insutypes {
  13258. if i.Insutype == "390" {
  13259. is390 = 1
  13260. }
  13261. if i.Insutype == "310" {
  13262. is310 = 1
  13263. }
  13264. }
  13265. }
  13266. if is390 == 1 {
  13267. insutype = "390"
  13268. }
  13269. if is310 == 1 {
  13270. insutype = "310"
  13271. }
  13272. if len(insutypes) == 0 {
  13273. insutype = "310"
  13274. }
  13275. insutype = psn_record.Insutype
  13276. for _, item := range rf {
  13277. if item.Insutype == insutype {
  13278. insuplc_admdvs = item.InsuplcAdmdvs
  13279. }
  13280. }
  13281. if config.IsOpen == 1 {
  13282. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  13283. var dat map[string]interface{}
  13284. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13285. fmt.Println(dat)
  13286. } else {
  13287. fmt.Println(err)
  13288. }
  13289. userJSONBytes, _ := json.Marshal(dat)
  13290. var res ResultFourteen
  13291. var res10265 ResultFourteen10265
  13292. if miConfig.Code == "H15049901371" {
  13293. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13294. utils.ErrorLog("解析失败:%v", err)
  13295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13296. return
  13297. }
  13298. res.ErrMsg = res10265.ErrMsg
  13299. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13300. res.Infcode = infocode
  13301. res.Output = res10265.Output
  13302. res.InfRefmsgid = res10265.InfRefmsgid
  13303. } else {
  13304. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13305. utils.ErrorLog("解析失败:%v", err)
  13306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13307. return
  13308. }
  13309. }
  13310. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13311. // utils.ErrorLog("解析失败:%v", err)
  13312. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13313. // return
  13314. //}
  13315. if res.Infcode == 0 {
  13316. psn_record.IsCancel = 2
  13317. service.CreatePsnNCDSRecord(&psn_record)
  13318. c.ServeSuccessJSON(map[string]interface{}{
  13319. "failed_code": 0,
  13320. "msg": "撤销备案成功",
  13321. })
  13322. } else {
  13323. c.ServeSuccessJSON(map[string]interface{}{
  13324. "failed_code": -10,
  13325. "msg": res.ErrMsg,
  13326. })
  13327. return
  13328. }
  13329. }
  13330. }
  13331. func (c *HisApiController) TestTest() {
  13332. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  13333. fmt.Println(patient.Iinfo)
  13334. }
  13335. type CustomData struct {
  13336. MsgId string
  13337. PsnNo string
  13338. Info string
  13339. }
  13340. func (c *HisApiController) ReversalData() {
  13341. var customData []*CustomData
  13342. custom := &CustomData{
  13343. MsgId: "H44022900158202103301714472004",
  13344. PsnNo: "44020000001101329945",
  13345. Info: "2207",
  13346. }
  13347. customData = append(customData, custom)
  13348. custom1 := &CustomData{
  13349. MsgId: "H4402290015820210330172057803",
  13350. PsnNo: "44020000001101161813",
  13351. Info: "2207",
  13352. }
  13353. customData = append(customData, custom1)
  13354. custom2 := &CustomData{
  13355. MsgId: "H44022900158202103301705198813",
  13356. PsnNo: "44190000133097375417",
  13357. Info: "2207",
  13358. }
  13359. customData = append(customData, custom2)
  13360. custom3 := &CustomData{
  13361. MsgId: "H44022900158202103301715524756",
  13362. PsnNo: "44020000001100187221",
  13363. Info: "2207",
  13364. }
  13365. customData = append(customData, custom3)
  13366. custom4 := &CustomData{
  13367. MsgId: "H44022900158202103301730376224",
  13368. PsnNo: "44020000001101959155",
  13369. Info: "2207",
  13370. }
  13371. customData = append(customData, custom4)
  13372. custom5 := &CustomData{
  13373. MsgId: "H44022900158202103301748008725",
  13374. PsnNo: "44020000001104246641",
  13375. Info: "2207",
  13376. }
  13377. customData = append(customData, custom5)
  13378. custom6 := &CustomData{
  13379. MsgId: "H44022900158202103301718096755",
  13380. PsnNo: "44020000001102211860",
  13381. Info: "2207",
  13382. }
  13383. customData = append(customData, custom6)
  13384. custom7 := &CustomData{
  13385. MsgId: "H44022900158202103301736551640",
  13386. PsnNo: "44020000001102687718",
  13387. Info: "2207",
  13388. }
  13389. customData = append(customData, custom7)
  13390. custom8 := &CustomData{
  13391. MsgId: "H44022900158202103301743097676",
  13392. PsnNo: "44020000001102127785",
  13393. Info: "2207",
  13394. }
  13395. customData = append(customData, custom8)
  13396. custom9 := &CustomData{
  13397. MsgId: "H44022900158202103301712304203",
  13398. PsnNo: "44020000001101518097",
  13399. Info: "2207",
  13400. }
  13401. customData = append(customData, custom9)
  13402. custom10 := &CustomData{
  13403. MsgId: "H44022900158202103301738448785",
  13404. PsnNo: "44020000001100500813",
  13405. Info: "2207",
  13406. }
  13407. customData = append(customData, custom10)
  13408. custom11 := &CustomData{
  13409. MsgId: "H44022900158202103301732455843",
  13410. PsnNo: "44020000001102690557",
  13411. Info: "2207",
  13412. }
  13413. customData = append(customData, custom11)
  13414. custom12 := &CustomData{
  13415. MsgId: "H44022900158202103301745421708",
  13416. PsnNo: "44020000001102211928",
  13417. Info: "2207",
  13418. }
  13419. customData = append(customData, custom12)
  13420. custom1212 := &CustomData{
  13421. MsgId: "H440229001582021033017351627",
  13422. PsnNo: "44020000001102481733",
  13423. Info: "2207",
  13424. }
  13425. customData = append(customData, custom1212)
  13426. custom13 := &CustomData{
  13427. MsgId: "H44022900158202103301740327951",
  13428. PsnNo: "44020000001103174866",
  13429. Info: "2207",
  13430. }
  13431. customData = append(customData, custom13)
  13432. custom14 := &CustomData{
  13433. MsgId: "H4402290015820210330174922668",
  13434. PsnNo: "44020000001102927272",
  13435. Info: "2207",
  13436. }
  13437. customData = append(customData, custom14)
  13438. custom15 := &CustomData{
  13439. MsgId: "H44022900158202103301752362273",
  13440. PsnNo: "44020000001102942890",
  13441. Info: "2207",
  13442. }
  13443. customData = append(customData, custom15)
  13444. custom16 := &CustomData{
  13445. MsgId: "H44022900158202103301751082917",
  13446. PsnNo: "44020000001101662162",
  13447. Info: "2207",
  13448. }
  13449. customData = append(customData, custom16)
  13450. custom17 := &CustomData{
  13451. MsgId: "H44022900158202103301754147728",
  13452. PsnNo: "44020000000229014511",
  13453. Info: "2207",
  13454. }
  13455. customData = append(customData, custom17)
  13456. adminUser := c.GetAdminUserInfo()
  13457. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13458. for _, item := range customData {
  13459. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13460. fmt.Println(result)
  13461. }
  13462. }
  13463. //func (c *HisApiController) GetAllopatry() {
  13464. // year := c.GetString("year")
  13465. // month := c.GetString("month")
  13466. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13467. // adminUser := c.GetAdminUserInfo()
  13468. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13469. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13470. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13471. //
  13472. // var dat map[string]interface{}
  13473. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13474. // fmt.Println(dat)
  13475. // } else {
  13476. // fmt.Println(err)
  13477. // }
  13478. // userJSONBytes, _ := json.Marshal(dat)
  13479. // var res models.Result9001
  13480. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13481. // utils.ErrorLog("解析失败:%v", err)
  13482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13483. // return
  13484. // }
  13485. //
  13486. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13487. // var dat2 map[string]interface{}
  13488. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13489. // fmt.Println(dat)
  13490. // } else {
  13491. // fmt.Println(err)
  13492. // }
  13493. // userJSONBytes2, _ := json.Marshal(dat2)
  13494. // var res2 models.Result3260
  13495. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13496. // utils.ErrorLog("解析失败:%v", err)
  13497. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13498. // return
  13499. // }
  13500. // if res2.Infcode == 0 {
  13501. // c.ServeSuccessJSON(map[string]interface{}{
  13502. // "list": res2.Output.Data,
  13503. // })
  13504. // return
  13505. // } else {
  13506. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13507. // return
  13508. // }
  13509. //
  13510. //}
  13511. //func (c *HisApiController) ComfirmAllopatry() {
  13512. // year := c.GetString("year")
  13513. // month := c.GetString("month")
  13514. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13515. // adminUser := c.GetAdminUserInfo()
  13516. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13517. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13518. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13519. // var dat map[string]interface{}
  13520. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13521. // fmt.Println(dat)
  13522. // } else {
  13523. // fmt.Println(err)
  13524. // }
  13525. // userJSONBytes, _ := json.Marshal(dat)
  13526. // var res models.Result9001
  13527. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13528. // utils.ErrorLog("解析失败:%v", err)
  13529. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13530. // return
  13531. // }
  13532. //
  13533. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13534. // var dat2 map[string]interface{}
  13535. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13536. // fmt.Println(dat)
  13537. // } else {
  13538. // fmt.Println(err)
  13539. // }
  13540. // userJSONBytes2, _ := json.Marshal(dat2)
  13541. // var res2 models.Result3260
  13542. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13543. // utils.ErrorLog("解析失败:%v", err)
  13544. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13545. // return
  13546. // }
  13547. //
  13548. // if res2.Infcode == 0 {
  13549. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  13550. // var dat map[string]interface{}
  13551. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13552. // fmt.Println(dat)
  13553. // } else {
  13554. // fmt.Println(err)
  13555. // }
  13556. // userJSONBytes, _ := json.Marshal(dat)
  13557. // var res3 models.Result3261
  13558. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  13559. // utils.ErrorLog("解析失败:%v", err)
  13560. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13561. // return
  13562. // }
  13563. //
  13564. // if res3.Infcode == 0 {
  13565. // record := &models.HisYidiClearRecord{
  13566. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13567. // Ctime: time.Now().Unix(),
  13568. // Mtime: time.Now().Unix(),
  13569. // Status: 1,
  13570. // MsgId: msgId,
  13571. // }
  13572. // service.SaveClearRecord(record)
  13573. // c.ServeSuccessJSON(map[string]interface{}{
  13574. // "msg": "提取成功",
  13575. // })
  13576. // }
  13577. // }
  13578. //}
  13579. func (c *HisApiController) RefundAllopatry() {
  13580. year := c.GetString("year")
  13581. month := c.GetString("month")
  13582. id, _ := c.GetInt64("id")
  13583. admin_user_id, _ := c.GetInt64("admin_user_id")
  13584. adminUser := c.GetAdminUserInfo()
  13585. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13586. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13587. record, _ := service.GetClearRecordById(id)
  13588. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  13589. var dat map[string]interface{}
  13590. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13591. fmt.Println(dat)
  13592. } else {
  13593. fmt.Println(err)
  13594. }
  13595. userJSONBytes, _ := json.Marshal(dat)
  13596. var empty ResultFourteen
  13597. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  13598. utils.ErrorLog("解析失败:%v", err)
  13599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13600. return
  13601. }
  13602. if empty.Infcode == 0 {
  13603. c.ServeSuccessJSON(map[string]interface{}{
  13604. "msg": "撤销成功",
  13605. })
  13606. return
  13607. }
  13608. }
  13609. func (c *HisApiController) ReversalOtherData() {
  13610. var customData []*CustomData
  13611. custom := &CustomData{
  13612. MsgId: "H44022900158202103301714472004",
  13613. PsnNo: "44020000001101329945",
  13614. Info: "2208",
  13615. }
  13616. customData = append(customData, custom)
  13617. custom1 := &CustomData{
  13618. MsgId: "H4402290015820210330172057803",
  13619. PsnNo: "44020000001101161813",
  13620. Info: "2208",
  13621. }
  13622. customData = append(customData, custom1)
  13623. custom2 := &CustomData{
  13624. MsgId: "H44022900158202103301705198813",
  13625. PsnNo: "44190000133097375417",
  13626. Info: "2208",
  13627. }
  13628. customData = append(customData, custom2)
  13629. custom3 := &CustomData{
  13630. MsgId: "H44022900158202103301715524756",
  13631. PsnNo: "44020000001100187221",
  13632. Info: "2208",
  13633. }
  13634. customData = append(customData, custom3)
  13635. custom4 := &CustomData{
  13636. MsgId: "H44022900158202103301730376224",
  13637. PsnNo: "44020000001101959155",
  13638. Info: "2208",
  13639. }
  13640. customData = append(customData, custom4)
  13641. custom5 := &CustomData{
  13642. MsgId: "H44022900158202103301748008725",
  13643. PsnNo: "44020000001104246641",
  13644. Info: "2208",
  13645. }
  13646. customData = append(customData, custom5)
  13647. custom6 := &CustomData{
  13648. MsgId: "H44022900158202103301718096755",
  13649. PsnNo: "44020000001102211860",
  13650. Info: "2208",
  13651. }
  13652. customData = append(customData, custom6)
  13653. custom7 := &CustomData{
  13654. MsgId: "H44022900158202103301736551640",
  13655. PsnNo: "44020000001102687718",
  13656. Info: "2208",
  13657. }
  13658. customData = append(customData, custom7)
  13659. custom8 := &CustomData{
  13660. MsgId: "H44022900158202103301743097676",
  13661. PsnNo: "44020000001102127785",
  13662. Info: "2208",
  13663. }
  13664. customData = append(customData, custom8)
  13665. custom9 := &CustomData{
  13666. MsgId: "H44022900158202103301712304203",
  13667. PsnNo: "44020000001101518097",
  13668. Info: "2208",
  13669. }
  13670. customData = append(customData, custom9)
  13671. custom10 := &CustomData{
  13672. MsgId: "H44022900158202103301738448785",
  13673. PsnNo: "44020000001100500813",
  13674. Info: "2208",
  13675. }
  13676. customData = append(customData, custom10)
  13677. custom11 := &CustomData{
  13678. MsgId: "H44022900158202103301732455843",
  13679. PsnNo: "44020000001102690557",
  13680. Info: "2208",
  13681. }
  13682. customData = append(customData, custom11)
  13683. custom12 := &CustomData{
  13684. MsgId: "H44022900158202103301745421708",
  13685. PsnNo: "44020000001102211928",
  13686. Info: "2208",
  13687. }
  13688. customData = append(customData, custom12)
  13689. custom1212 := &CustomData{
  13690. MsgId: "H440229001582021033017351627",
  13691. PsnNo: "44020000001102481733",
  13692. Info: "2208",
  13693. }
  13694. customData = append(customData, custom1212)
  13695. custom13 := &CustomData{
  13696. MsgId: "H44022900158202103301740327951",
  13697. PsnNo: "44020000001103174866",
  13698. Info: "2208",
  13699. }
  13700. customData = append(customData, custom13)
  13701. custom14 := &CustomData{
  13702. MsgId: "H4402290015820210330174922668",
  13703. PsnNo: "44020000001102927272",
  13704. Info: "2208",
  13705. }
  13706. customData = append(customData, custom14)
  13707. custom15 := &CustomData{
  13708. MsgId: "H44022900158202103301752362273",
  13709. PsnNo: "44020000001102942890",
  13710. Info: "2208",
  13711. }
  13712. customData = append(customData, custom15)
  13713. custom16 := &CustomData{
  13714. MsgId: "H44022900158202103301751082917",
  13715. PsnNo: "44020000001101662162",
  13716. Info: "2208",
  13717. }
  13718. customData = append(customData, custom16)
  13719. custom17 := &CustomData{
  13720. MsgId: "H44022900158202103301754147728",
  13721. PsnNo: "44020000000229014511",
  13722. Info: "2208",
  13723. }
  13724. customData = append(customData, custom17)
  13725. adminUser := c.GetAdminUserInfo()
  13726. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13727. for _, item := range customData {
  13728. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13729. fmt.Println(result)
  13730. }
  13731. }
  13732. func PathExists(path string) (bool, error) {
  13733. _, err := os.Stat(path)
  13734. if err == nil {
  13735. return true, nil
  13736. }
  13737. if os.IsNotExist(err) {
  13738. return false, nil
  13739. }
  13740. return false, err
  13741. }
  13742. //创建文件夹
  13743. func Mkdir(dir string) {
  13744. // 创建文件夹
  13745. exist, err := PathExists(dir)
  13746. if err != nil {
  13747. fmt.Println(err.Error())
  13748. } else {
  13749. if exist {
  13750. fmt.Println(dir + "文件夹已存在!")
  13751. } else {
  13752. // 文件夹名称,权限
  13753. err := os.Mkdir(dir, os.ModePerm)
  13754. if err != nil {
  13755. fmt.Println(dir+"文件夹创建失败:", err.Error())
  13756. } else {
  13757. fmt.Println(dir + "文件夹创建成功!")
  13758. }
  13759. }
  13760. }
  13761. }
  13762. //压缩文件
  13763. func Zip(srcFile string, destZip string) error {
  13764. zipfile, err := os.Create(destZip)
  13765. if err != nil {
  13766. return err
  13767. }
  13768. defer zipfile.Close()
  13769. archive := zip.NewWriter(zipfile)
  13770. defer archive.Close()
  13771. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  13772. if err != nil {
  13773. return err
  13774. }
  13775. header, err := zip.FileInfoHeader(info)
  13776. if err != nil {
  13777. return err
  13778. }
  13779. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  13780. // header.Name = path
  13781. if info.IsDir() {
  13782. header.Name += "/"
  13783. } else {
  13784. header.Method = zip.Deflate
  13785. }
  13786. writer, err := archive.CreateHeader(header)
  13787. if err != nil {
  13788. return err
  13789. }
  13790. if !info.IsDir() {
  13791. file, err := os.Open(path)
  13792. if err != nil {
  13793. return err
  13794. }
  13795. defer file.Close()
  13796. _, err = io.Copy(writer, file)
  13797. }
  13798. return err
  13799. })
  13800. return err
  13801. }
  13802. func ReadFile(filePath string) []byte {
  13803. f, err := os.Open(filePath)
  13804. if err != nil {
  13805. fmt.Println("read file fail", err)
  13806. return nil
  13807. }
  13808. defer f.Close()
  13809. fd, err := ioutil.ReadAll(f)
  13810. if err != nil {
  13811. fmt.Println("read to fd fail", err)
  13812. return nil
  13813. }
  13814. return fd
  13815. }
  13816. func saveLog(result string, request string, infno string, desc string) {
  13817. org_id, _ := beego.AppConfig.Int64("org_id")
  13818. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13819. dir := miConfig.OrgName + "日志"
  13820. utils.Mkdir(dir)
  13821. month := time.Unix(1557042972, 0).Format("1")
  13822. year := time.Now().Format("2006")
  13823. month = time.Now().Format("01")
  13824. day := time.Now().Format("02")
  13825. hour := time.Now().Format("15")
  13826. min := time.Now().Format("04")
  13827. sec := time.Now().Format("05")
  13828. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  13829. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  13830. file_name := file + ".txt"
  13831. file_path := miConfig.OrgName + "日志" + "/" + file_name
  13832. exist, _ := utils.PathExists(file_path)
  13833. if exist { //存在
  13834. fmt.Println("存在")
  13835. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  13836. if err != nil {
  13837. fmt.Println("read fail")
  13838. }
  13839. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  13840. n, _ := f.Seek(0, 2)
  13841. _, err = f.WriteAt([]byte(content), n)
  13842. } else { //不存在
  13843. fmt.Println("文件不存在,创建文件")
  13844. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  13845. defer f.Close()
  13846. if err != nil {
  13847. } else {
  13848. _, err = f.Write([]byte("记录日志"))
  13849. }
  13850. }
  13851. }
  13852. type Charset string
  13853. const (
  13854. UTF8 = Charset("UTF-8")
  13855. GB18030 = Charset("GB18030")
  13856. )
  13857. func ConvertToString(src string, srcCode string, tagCode string) string {
  13858. srcCoder := mahonia.NewDecoder(srcCode)
  13859. srcResult := srcCoder.ConvertString(src)
  13860. tagCoder := mahonia.NewDecoder(tagCode)
  13861. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  13862. result := string(cdata)
  13863. return result
  13864. }
  13865. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  13866. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  13867. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13868. var token string
  13869. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13870. var api string
  13871. if miConfig.MdtrtareaAdmvs == "320921" {
  13872. 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 +
  13873. "&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
  13874. fmt.Println(api)
  13875. } else {
  13876. 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 +
  13877. "&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
  13878. }
  13879. resp, requestErr := http.Get(api)
  13880. if requestErr != nil {
  13881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13882. return ""
  13883. }
  13884. body, ioErr := ioutil.ReadAll(resp.Body)
  13885. if ioErr != nil {
  13886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13888. return ""
  13889. }
  13890. var respJSON map[string]interface{}
  13891. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13894. return ""
  13895. }
  13896. var status string
  13897. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13898. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13899. var res ResultTwo //1101结果
  13900. var res10265 ResultTwo10265 //1101结果
  13901. if status == "0" { //读卡成功
  13902. var card_info string //卡信息
  13903. var busi_card_info string
  13904. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13905. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13906. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13907. fmt.Println(card_info)
  13908. fmt.Println(busi_card_info)
  13909. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13910. result, _ := json.Marshal(respJSON)
  13911. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13912. utils.ErrorLog("解析失败:%v", err)
  13913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13914. return ""
  13915. }
  13916. res.ErrMsg = res10265.ErrMsg
  13917. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13918. res.Infcode = infocode
  13919. res.Output = res10265.Output
  13920. res.InfRefmsgid = res10265.InfRefmsgid
  13921. if res.Infcode == 0 {
  13922. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13923. if err == gorm.ErrRecordNotFound {
  13924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13925. return ""
  13926. } else if err != nil {
  13927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13928. return ""
  13929. } else {
  13930. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13931. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13932. infoStr := string(Iinfos)
  13933. idetinfoStr := string(Idetinfos)
  13934. psn := &models.HisPsn{
  13935. PsnNo: res.Output.Baseinfo.PsnNo,
  13936. Age: res.Output.Baseinfo.Age,
  13937. PatientId: patient.ID,
  13938. Certno: res.Output.Baseinfo.Certno,
  13939. Brdy: res.Output.Baseinfo.Brdy,
  13940. Gend: res.Output.Baseinfo.Gend,
  13941. Naty: res.Output.Baseinfo.Naty,
  13942. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13943. PsnName: res.Output.Baseinfo.PsnName,
  13944. Idetinfo: idetinfoStr,
  13945. Insuinfo: infoStr,
  13946. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13947. CardInfo: card_info,
  13948. VerifyNumber: token,
  13949. }
  13950. service.CreateHisPsn(psn)
  13951. return token
  13952. }
  13953. }
  13954. } else {
  13955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13956. return ""
  13957. }
  13958. } else { //读卡失败
  13959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13960. return ""
  13961. }
  13962. return token
  13963. }
  13964. func DeleteExtraSpaceTwo(s string) string {
  13965. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  13966. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  13967. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  13968. reg, _ := regexp.Compile(regstr) //编译正则表达式
  13969. s2 := make([]byte, len(s1)) //定义字符数组切片
  13970. copy(s2, s1) //将字符串复制到切片
  13971. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  13972. for len(spc_index) > 0 { //找到适配项
  13973. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  13974. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  13975. }
  13976. return string(s2)
  13977. }
  13978. func Remove0000(s string) string {
  13979. str := make([]rune, 0, len(s))
  13980. for _, v := range []rune(s) {
  13981. if v == 0 {
  13982. continue
  13983. }
  13984. str = append(str, v)
  13985. }
  13986. return string(str)
  13987. }
  13988. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  13989. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  13990. readCard := DllDef.MustFindProc("EcQuery")
  13991. pCardInfo := make([]byte, 8192)
  13992. pBusiCardInfo := make([]byte, 8192)
  13993. data := make(map[string]interface{})
  13994. //pData := make(map[string]interface{})
  13995. inputData := make(map[string]interface{})
  13996. inputData["orgId"] = code
  13997. inputData["businessType"] = "01101"
  13998. inputData["operatorId"] = operator_id
  13999. inputData["operatorName"] = operator_name
  14000. inputData["officeId"] = "001"
  14001. inputData["officeName"] = "血透室"
  14002. //
  14003. data["data"] = inputData
  14004. data["transType"] = "ec.query"
  14005. data["orgId"] = code
  14006. bytesData, _ := json.Marshal(data)
  14007. pCardInfo = bytesData
  14008. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  14009. fmt.Println(ret2)
  14010. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  14011. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  14012. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  14013. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  14014. if ret2 != 0 {
  14015. return "", ""
  14016. }
  14017. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  14018. }
  14019. func DeleteExtraSpace(s string) string {
  14020. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  14021. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  14022. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  14023. reg, _ := regexp.Compile(regstr) //编译正则表达式
  14024. s2 := make([]byte, len(s1)) //定义字符数组切片
  14025. copy(s2, s1) //将字符串复制到切片
  14026. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  14027. for len(spc_index) > 0 { //找到适配项
  14028. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  14029. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  14030. }
  14031. return string(s2)
  14032. }
  14033. //对账
  14034. func (c *HisApiController) Post3202() {
  14035. start_time := c.GetString("start_time")
  14036. end_time := c.GetString("end_time")
  14037. //insutype := c.GetString("insutype")
  14038. clr_type := c.GetString("clr_type")
  14039. clr_org := c.GetString("clr_optins")
  14040. admin_user_id, _ := c.GetInt64("admin_user_id")
  14041. adminUser := c.GetAdminUserInfo()
  14042. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14043. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14044. if len(clr_org) == 0 {
  14045. clr_org = miConfig.MdtrtareaAdmvs
  14046. }
  14047. timeLayout := "2006-01-02"
  14048. loc, _ := time.LoadLocation("Local")
  14049. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  14050. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  14051. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  14052. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  14053. //fixmedins_setl_cnt := int64(len(orders))
  14054. var medfee_sumamt float64
  14055. var acct_pay float64
  14056. var fund_pay_sumamt float64
  14057. for _, item := range orders {
  14058. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  14059. acct_pay = acct_pay + item.AcctPay
  14060. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  14061. }
  14062. //var medfee_sumamt_two float64
  14063. //var acct_pay_two float64
  14064. //var fund_pay_sumamt_two float64
  14065. //for _, item := range orders_two {
  14066. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  14067. // acct_pay_two = acct_pay_two + item.AcctPay
  14068. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  14069. //}
  14070. //var user_name string
  14071. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14072. //if role.ID == 0 {
  14073. // user_name = "xxx"
  14074. //} else {
  14075. // user_name = role.UserName
  14076. //}
  14077. var res ResultSix
  14078. if config.IsOpen == 1 {
  14079. var bps []*models.BusinessParamsTwo
  14080. var bp models.BusinessParamsTwo
  14081. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  14082. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  14083. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  14084. bp.MedfeeSumamt = medfee_sumamt_str
  14085. bp.AcctPay = acct_pay_str
  14086. bp.FundPaySumamt = fund_pay_sumamt_str
  14087. bp.Insutype = "390"
  14088. bp.StmtBegndate = start_time
  14089. bp.ClrType = clr_type
  14090. bp.SetlOptins = clr_org
  14091. bp.StmtEnddate = end_time
  14092. bps = append(bps, &bp)
  14093. data := make(map[string]interface{})
  14094. data["bps"] = bps
  14095. data["org_name"] = miConfig.OrgName
  14096. data["doctor"] = role.UserName
  14097. data["fixmedins_code"] = miConfig.Code
  14098. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14099. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14100. if miConfig.MdtrtareaAdmvs == "421300" {
  14101. client := &http.Client{}
  14102. bytesData, _ := json.Marshal(data)
  14103. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  14104. resp, _ := client.Do(req)
  14105. defer resp.Body.Close()
  14106. body, ioErr := ioutil.ReadAll(resp.Body)
  14107. if ioErr != nil {
  14108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14110. return
  14111. }
  14112. var respJSON map[string]interface{}
  14113. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14116. return
  14117. }
  14118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14119. userJSONBytes, _ := json.Marshal(respJSON)
  14120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14121. utils.ErrorLog("解析失败:%v", err)
  14122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14123. return
  14124. }
  14125. }
  14126. if res.Infcode == 0 {
  14127. c.ServeSuccessJSON(map[string]interface{}{
  14128. "msg": "发起成功",
  14129. })
  14130. } else {
  14131. c.ServeSuccessJSON(map[string]interface{}{
  14132. "code": -10,
  14133. "msg": res.ErrMsg,
  14134. })
  14135. }
  14136. }
  14137. }
  14138. func (c *HisApiController) Post3501() {
  14139. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14140. data := make(map[string]interface{})
  14141. var struct3501s []models.Struct3501
  14142. var struct3501 models.Struct3501
  14143. struct3501.OrgName = miConfig.OrgName
  14144. struct3501.AccessKey = miConfig.AccessKey
  14145. struct3501.RequestUrl = miConfig.Url
  14146. struct3501.SecretKey = miConfig.SecretKey
  14147. struct3501.ManuDate = "2022-08-17"
  14148. struct3501.FixmedinsBchno = ""
  14149. struct3501.ManuLotnum = ""
  14150. struct3501.RxFlag = "0"
  14151. struct3501.ExpyEnd = "2022-08-17"
  14152. struct3501.Invdate = "2022-08-17"
  14153. struct3501.InvCnt = "20.25"
  14154. struct3501.Memo = ""
  14155. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14156. struct3501.FixmedinsHilistId = miConfig.Code
  14157. struct3501.FixmedinsHilistName = miConfig.OrgName
  14158. struct3501s = append(struct3501s, struct3501)
  14159. data["struct_3501s"] = struct3501s
  14160. client := &http.Client{}
  14161. bytesData, _ := json.Marshal(data)
  14162. var req *http.Request
  14163. if miConfig.MdtrtareaAdmvs == "320921" {
  14164. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14165. } else {
  14166. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14167. }
  14168. resp, _ := client.Do(req)
  14169. defer resp.Body.Close()
  14170. body, ioErr := ioutil.ReadAll(resp.Body)
  14171. if ioErr != nil {
  14172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14174. return
  14175. }
  14176. var respJSON map[string]interface{}
  14177. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14180. return
  14181. }
  14182. var res ResultSix
  14183. var resSix10265 ResultSix10265 //1101结果
  14184. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14185. result, _ := json.Marshal(respJSON)
  14186. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14187. utils.ErrorLog("解析失败:%v", err)
  14188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14189. return
  14190. }
  14191. res.InfRefmsgid = resSix10265.InfRefmsgid
  14192. res.Output = resSix10265.Output
  14193. res.ErrMsg = resSix10265.ErrMsg
  14194. res.Cainfo = resSix10265.Cainfo
  14195. res.WarnMsg = resSix10265.WarnMsg
  14196. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14197. res.Infcode = infocode
  14198. if infocode == 0 {
  14199. c.ServeSuccessJSON(map[string]interface{}{
  14200. "msg": "上传成功",
  14201. })
  14202. return
  14203. } else {
  14204. c.ServeSuccessJSON(map[string]interface{}{
  14205. "failed_code": -10,
  14206. "msg": res.ErrMsg,
  14207. })
  14208. return
  14209. }
  14210. }
  14211. func (c *HisApiController) Post3502() {
  14212. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14213. data := make(map[string]interface{})
  14214. var struct3502s []models.Struct3502
  14215. var struct3502 models.Struct3502
  14216. struct3502.OrgName = miConfig.OrgName
  14217. struct3502.AccessKey = miConfig.AccessKey
  14218. struct3502.RequestUrl = miConfig.Url
  14219. struct3502.SecretKey = miConfig.SecretKey
  14220. struct3502.ManuDate = "2022-08-15"
  14221. struct3502.FixmedinsBchno = ""
  14222. struct3502.ManuLotnum = ""
  14223. struct3502.RxFlag = "0"
  14224. struct3502.ExpyEnd = "2022-08-15"
  14225. struct3502.Invdate = "2022-08-15"
  14226. struct3502.InvCnt = "20.25"
  14227. struct3502.Memo = ""
  14228. struct3502.MedListCodg = "XB01ABD056B002020200517"
  14229. struct3502.FixmedinsHilistId = miConfig.Code
  14230. struct3502.FixmedinsHilistName = miConfig.OrgName
  14231. struct3502s = append(struct3502s, struct3502)
  14232. data["struct_3502s"] = struct3502s
  14233. client := &http.Client{}
  14234. bytesData, _ := json.Marshal(data)
  14235. var req *http.Request
  14236. if miConfig.MdtrtareaAdmvs == "320921" {
  14237. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14238. } else {
  14239. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14240. }
  14241. resp, _ := client.Do(req)
  14242. defer resp.Body.Close()
  14243. body, ioErr := ioutil.ReadAll(resp.Body)
  14244. if ioErr != nil {
  14245. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14247. return
  14248. }
  14249. var respJSON map[string]interface{}
  14250. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14253. return
  14254. }
  14255. var res ResultSix
  14256. var resSix10265 ResultSix10265 //1101结果
  14257. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14258. result, _ := json.Marshal(respJSON)
  14259. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14260. utils.ErrorLog("解析失败:%v", err)
  14261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14262. return
  14263. }
  14264. res.InfRefmsgid = resSix10265.InfRefmsgid
  14265. res.Output = resSix10265.Output
  14266. res.ErrMsg = resSix10265.ErrMsg
  14267. res.Cainfo = resSix10265.Cainfo
  14268. res.WarnMsg = resSix10265.WarnMsg
  14269. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14270. res.Infcode = infocode
  14271. if infocode == 0 {
  14272. c.ServeSuccessJSON(map[string]interface{}{
  14273. "msg": "上传成功",
  14274. })
  14275. return
  14276. } else {
  14277. c.ServeSuccessJSON(map[string]interface{}{
  14278. "failed_code": -10,
  14279. "msg": res.ErrMsg,
  14280. })
  14281. return
  14282. }
  14283. }
  14284. func (c *HisApiController) Post3503() {
  14285. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14286. data := make(map[string]interface{})
  14287. var struct3501s []models.Struct3501
  14288. var struct3501 models.Struct3501
  14289. struct3501.OrgName = miConfig.OrgName
  14290. struct3501.AccessKey = miConfig.AccessKey
  14291. struct3501.RequestUrl = miConfig.Url
  14292. struct3501.SecretKey = miConfig.SecretKey
  14293. struct3501.ManuDate = "2022-08-15"
  14294. struct3501.FixmedinsBchno = ""
  14295. struct3501.ManuLotnum = ""
  14296. struct3501.RxFlag = "0"
  14297. struct3501.ExpyEnd = "2022-08-15"
  14298. struct3501.Invdate = "2022-08-15"
  14299. struct3501.InvCnt = "20.25"
  14300. struct3501.Memo = ""
  14301. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14302. struct3501.FixmedinsHilistId = miConfig.Code
  14303. struct3501.FixmedinsHilistName = miConfig.OrgName
  14304. struct3501s = append(struct3501s, struct3501)
  14305. data["struct_3501s"] = struct3501s
  14306. client := &http.Client{}
  14307. bytesData, _ := json.Marshal(data)
  14308. var req *http.Request
  14309. if miConfig.MdtrtareaAdmvs == "320921" {
  14310. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14311. } else {
  14312. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14313. }
  14314. resp, _ := client.Do(req)
  14315. defer resp.Body.Close()
  14316. body, ioErr := ioutil.ReadAll(resp.Body)
  14317. if ioErr != nil {
  14318. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14320. return
  14321. }
  14322. var respJSON map[string]interface{}
  14323. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14324. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14326. return
  14327. }
  14328. var res ResultSix
  14329. var resSix10265 ResultSix10265 //1101结果
  14330. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14331. result, _ := json.Marshal(respJSON)
  14332. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14333. utils.ErrorLog("解析失败:%v", err)
  14334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14335. return
  14336. }
  14337. res.InfRefmsgid = resSix10265.InfRefmsgid
  14338. res.Output = resSix10265.Output
  14339. res.ErrMsg = resSix10265.ErrMsg
  14340. res.Cainfo = resSix10265.Cainfo
  14341. res.WarnMsg = resSix10265.WarnMsg
  14342. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14343. res.Infcode = infocode
  14344. if infocode == 0 {
  14345. c.ServeSuccessJSON(map[string]interface{}{
  14346. "msg": "上传成功",
  14347. })
  14348. return
  14349. } else {
  14350. c.ServeSuccessJSON(map[string]interface{}{
  14351. "failed_code": -10,
  14352. "msg": res.ErrMsg,
  14353. })
  14354. return
  14355. }
  14356. }
  14357. func (c *HisApiController) Post3504() {
  14358. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14359. data := make(map[string]interface{})
  14360. var struct3501s []models.Struct3501
  14361. var struct3501 models.Struct3501
  14362. struct3501.OrgName = miConfig.OrgName
  14363. struct3501.AccessKey = miConfig.AccessKey
  14364. struct3501.RequestUrl = miConfig.Url
  14365. struct3501.SecretKey = miConfig.SecretKey
  14366. struct3501.ManuDate = "2022-08-15"
  14367. struct3501.FixmedinsBchno = ""
  14368. struct3501.ManuLotnum = ""
  14369. struct3501.RxFlag = "0"
  14370. struct3501.ExpyEnd = "2022-08-15"
  14371. struct3501.Invdate = "2022-08-15"
  14372. struct3501.InvCnt = "20.25"
  14373. struct3501.Memo = ""
  14374. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14375. struct3501.FixmedinsHilistId = miConfig.Code
  14376. struct3501.FixmedinsHilistName = miConfig.OrgName
  14377. struct3501s = append(struct3501s, struct3501)
  14378. data["struct_3501s"] = struct3501s
  14379. client := &http.Client{}
  14380. bytesData, _ := json.Marshal(data)
  14381. var req *http.Request
  14382. if miConfig.MdtrtareaAdmvs == "320921" {
  14383. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14384. } else {
  14385. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14386. }
  14387. resp, _ := client.Do(req)
  14388. defer resp.Body.Close()
  14389. body, ioErr := ioutil.ReadAll(resp.Body)
  14390. if ioErr != nil {
  14391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14393. return
  14394. }
  14395. var respJSON map[string]interface{}
  14396. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14399. return
  14400. }
  14401. var res ResultSix
  14402. var resSix10265 ResultSix10265 //1101结果
  14403. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14404. result, _ := json.Marshal(respJSON)
  14405. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14406. utils.ErrorLog("解析失败:%v", err)
  14407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14408. return
  14409. }
  14410. res.InfRefmsgid = resSix10265.InfRefmsgid
  14411. res.Output = resSix10265.Output
  14412. res.ErrMsg = resSix10265.ErrMsg
  14413. res.Cainfo = resSix10265.Cainfo
  14414. res.WarnMsg = resSix10265.WarnMsg
  14415. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14416. res.Infcode = infocode
  14417. if infocode == 0 {
  14418. c.ServeSuccessJSON(map[string]interface{}{
  14419. "msg": "上传成功",
  14420. })
  14421. return
  14422. } else {
  14423. c.ServeSuccessJSON(map[string]interface{}{
  14424. "failed_code": -10,
  14425. "msg": res.ErrMsg,
  14426. })
  14427. return
  14428. }
  14429. }
  14430. func (c *HisApiController) Post3505() {
  14431. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14432. data := make(map[string]interface{})
  14433. var struct3501s []models.Struct3501
  14434. var struct3501 models.Struct3501
  14435. struct3501.OrgName = miConfig.OrgName
  14436. struct3501.AccessKey = miConfig.AccessKey
  14437. struct3501.RequestUrl = miConfig.Url
  14438. struct3501.SecretKey = miConfig.SecretKey
  14439. struct3501.ManuDate = "2022-08-15"
  14440. struct3501.FixmedinsBchno = ""
  14441. struct3501.ManuLotnum = ""
  14442. struct3501.RxFlag = "0"
  14443. struct3501.ExpyEnd = "2022-08-15"
  14444. struct3501.Invdate = "2022-08-15"
  14445. struct3501.InvCnt = "20.25"
  14446. struct3501.Memo = ""
  14447. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14448. struct3501.FixmedinsHilistId = miConfig.Code
  14449. struct3501.FixmedinsHilistName = miConfig.OrgName
  14450. struct3501s = append(struct3501s, struct3501)
  14451. data["struct_3501s"] = struct3501s
  14452. client := &http.Client{}
  14453. bytesData, _ := json.Marshal(data)
  14454. var req *http.Request
  14455. if miConfig.MdtrtareaAdmvs == "320921" {
  14456. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14457. } else {
  14458. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14459. }
  14460. resp, _ := client.Do(req)
  14461. defer resp.Body.Close()
  14462. body, ioErr := ioutil.ReadAll(resp.Body)
  14463. if ioErr != nil {
  14464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14466. return
  14467. }
  14468. var respJSON map[string]interface{}
  14469. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14472. return
  14473. }
  14474. var res ResultSix
  14475. var resSix10265 ResultSix10265 //1101结果
  14476. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14477. result, _ := json.Marshal(respJSON)
  14478. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14479. utils.ErrorLog("解析失败:%v", err)
  14480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14481. return
  14482. }
  14483. res.InfRefmsgid = resSix10265.InfRefmsgid
  14484. res.Output = resSix10265.Output
  14485. res.ErrMsg = resSix10265.ErrMsg
  14486. res.Cainfo = resSix10265.Cainfo
  14487. res.WarnMsg = resSix10265.WarnMsg
  14488. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14489. res.Infcode = infocode
  14490. if infocode == 0 {
  14491. c.ServeSuccessJSON(map[string]interface{}{
  14492. "msg": "上传成功",
  14493. })
  14494. return
  14495. } else {
  14496. c.ServeSuccessJSON(map[string]interface{}{
  14497. "failed_code": -10,
  14498. "msg": res.ErrMsg,
  14499. })
  14500. return
  14501. }
  14502. }
  14503. func (c *HisApiController) Post3506() {
  14504. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14505. data := make(map[string]interface{})
  14506. var struct3501s []models.Struct3501
  14507. var struct3501 models.Struct3501
  14508. struct3501.OrgName = miConfig.OrgName
  14509. struct3501.AccessKey = miConfig.AccessKey
  14510. struct3501.RequestUrl = miConfig.Url
  14511. struct3501.SecretKey = miConfig.SecretKey
  14512. struct3501.ManuDate = "2022-08-15"
  14513. struct3501.FixmedinsBchno = ""
  14514. struct3501.ManuLotnum = ""
  14515. struct3501.RxFlag = "0"
  14516. struct3501.ExpyEnd = "2022-08-15"
  14517. struct3501.Invdate = "2022-08-15"
  14518. struct3501.InvCnt = "20.25"
  14519. struct3501.Memo = ""
  14520. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14521. struct3501.FixmedinsHilistId = miConfig.Code
  14522. struct3501.FixmedinsHilistName = miConfig.OrgName
  14523. struct3501s = append(struct3501s, struct3501)
  14524. data["struct_3501s"] = struct3501s
  14525. client := &http.Client{}
  14526. bytesData, _ := json.Marshal(data)
  14527. var req *http.Request
  14528. if miConfig.MdtrtareaAdmvs == "320921" {
  14529. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14530. } else {
  14531. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14532. }
  14533. resp, _ := client.Do(req)
  14534. defer resp.Body.Close()
  14535. body, ioErr := ioutil.ReadAll(resp.Body)
  14536. if ioErr != nil {
  14537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14539. return
  14540. }
  14541. var respJSON map[string]interface{}
  14542. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14545. return
  14546. }
  14547. var res ResultSix
  14548. var resSix10265 ResultSix10265 //1101结果
  14549. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14550. result, _ := json.Marshal(respJSON)
  14551. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14552. utils.ErrorLog("解析失败:%v", err)
  14553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14554. return
  14555. }
  14556. res.InfRefmsgid = resSix10265.InfRefmsgid
  14557. res.Output = resSix10265.Output
  14558. res.ErrMsg = resSix10265.ErrMsg
  14559. res.Cainfo = resSix10265.Cainfo
  14560. res.WarnMsg = resSix10265.WarnMsg
  14561. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14562. res.Infcode = infocode
  14563. if infocode == 0 {
  14564. c.ServeSuccessJSON(map[string]interface{}{
  14565. "msg": "上传成功",
  14566. })
  14567. return
  14568. } else {
  14569. c.ServeSuccessJSON(map[string]interface{}{
  14570. "failed_code": -10,
  14571. "msg": res.ErrMsg,
  14572. })
  14573. return
  14574. }
  14575. }
  14576. func (c *HisApiController) Post3507() {
  14577. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14578. data := make(map[string]interface{})
  14579. var struct3501s []models.Struct3501
  14580. var struct3501 models.Struct3501
  14581. struct3501.OrgName = miConfig.OrgName
  14582. struct3501.AccessKey = miConfig.AccessKey
  14583. struct3501.RequestUrl = miConfig.Url
  14584. struct3501.SecretKey = miConfig.SecretKey
  14585. struct3501.ManuDate = "2022-08-15"
  14586. struct3501.FixmedinsBchno = ""
  14587. struct3501.ManuLotnum = ""
  14588. struct3501.RxFlag = "0"
  14589. struct3501.ExpyEnd = "2022-08-15"
  14590. struct3501.Invdate = "2022-08-15"
  14591. struct3501.InvCnt = "20.25"
  14592. struct3501.Memo = ""
  14593. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14594. struct3501.FixmedinsHilistId = miConfig.Code
  14595. struct3501.FixmedinsHilistName = miConfig.OrgName
  14596. struct3501s = append(struct3501s, struct3501)
  14597. data["struct_3501s"] = struct3501s
  14598. client := &http.Client{}
  14599. bytesData, _ := json.Marshal(data)
  14600. var req *http.Request
  14601. if miConfig.MdtrtareaAdmvs == "320921" {
  14602. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14603. } else {
  14604. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14605. }
  14606. resp, _ := client.Do(req)
  14607. defer resp.Body.Close()
  14608. body, ioErr := ioutil.ReadAll(resp.Body)
  14609. if ioErr != nil {
  14610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14612. return
  14613. }
  14614. var respJSON map[string]interface{}
  14615. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14618. return
  14619. }
  14620. var res ResultSix
  14621. var resSix10265 ResultSix10265 //1101结果
  14622. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14623. result, _ := json.Marshal(respJSON)
  14624. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14625. utils.ErrorLog("解析失败:%v", err)
  14626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14627. return
  14628. }
  14629. res.InfRefmsgid = resSix10265.InfRefmsgid
  14630. res.Output = resSix10265.Output
  14631. res.ErrMsg = resSix10265.ErrMsg
  14632. res.Cainfo = resSix10265.Cainfo
  14633. res.WarnMsg = resSix10265.WarnMsg
  14634. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14635. res.Infcode = infocode
  14636. if infocode == 0 {
  14637. c.ServeSuccessJSON(map[string]interface{}{
  14638. "msg": "上传成功",
  14639. })
  14640. return
  14641. } else {
  14642. c.ServeSuccessJSON(map[string]interface{}{
  14643. "failed_code": -10,
  14644. "msg": res.ErrMsg,
  14645. })
  14646. return
  14647. }
  14648. }