his_api_controller.go 590KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275
  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 ResultMemo `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.InsuAdmdvs) > 0 {
  6889. insuplc_admdvs_temp = rf[0].Memo.InsuAdmdvs
  6890. }
  6891. }
  6892. }
  6893. if miConfig.MdtrtareaAdmvs == "421300" {
  6894. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  6895. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  6896. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6897. "&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
  6898. resp, requestErr := http.Get(api)
  6899. if requestErr != nil {
  6900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6901. return
  6902. }
  6903. body, ioErr := ioutil.ReadAll(resp.Body)
  6904. if ioErr != nil {
  6905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6907. return
  6908. }
  6909. var respJSON map[string]interface{}
  6910. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6913. return
  6914. }
  6915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6916. result, _ := json.Marshal(respJSON)
  6917. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6918. utils.ErrorLog("解析失败:%v", err)
  6919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6920. return
  6921. }
  6922. infocode = resThree.Infcode
  6923. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6924. psn_info, _ := service.GetPsnByPatientId(id)
  6925. his.PsnNo = psn_info.PsnNo
  6926. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6927. var cert_no string
  6928. if id_card_type == 3 {
  6929. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  6930. cert_no = IdCardNo
  6931. } else if id_card_type == 4 {
  6932. cert_no = IdCardNo
  6933. psn_info.VerifyNumber = psn_info.VerifyNumber
  6934. } else {
  6935. bas := strings.Split(psn_info.CardInfo, "|")
  6936. cert_no = bas[2]
  6937. }
  6938. var hisPrescription []*models.HisPrescription
  6939. for _, item := range rf {
  6940. if item.Insutype == insutype {
  6941. //insuplc_admdvs = item.InsuplcAdmdvs
  6942. his.InsuplcAdmdvs = insuplc_admdvs
  6943. }
  6944. }
  6945. his.Insutype = insutype
  6946. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  6947. fmt.Println(res3101)
  6948. fmt.Println(res3101.Infcode)
  6949. if res3101.Infcode == "0" {
  6950. fmt.Println("33333333")
  6951. if len(res3101.Output.Result) > 0 {
  6952. fmt.Println("222222")
  6953. for _, item := range res3101.Output.Result {
  6954. if len(res3101.ErrMsg) == 0 {
  6955. res3101.ErrMsg = item.VolaCont
  6956. } else {
  6957. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  6958. }
  6959. }
  6960. c.ServeSuccessJSON(map[string]interface{}{
  6961. "failed_code": -10,
  6962. "msg": res3101.ErrMsg,
  6963. })
  6964. return
  6965. } else {
  6966. fmt.Println("11111")
  6967. var api string
  6968. if miConfig.MdtrtareaAdmvs == "320921" {
  6969. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6970. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6971. "&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
  6972. } else {
  6973. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6974. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6975. "&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
  6976. }
  6977. resp, requestErr := http.Get(api)
  6978. if requestErr != nil {
  6979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6980. return
  6981. }
  6982. body, ioErr := ioutil.ReadAll(resp.Body)
  6983. if ioErr != nil {
  6984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6986. return
  6987. }
  6988. var respJSON map[string]interface{}
  6989. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6992. return
  6993. }
  6994. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6995. result, _ := json.Marshal(respJSON)
  6996. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6997. utils.ErrorLog("解析失败:%v", err)
  6998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6999. return
  7000. }
  7001. resThree.ErrMsg = resThree10265.ErrMsg
  7002. resThree.Output = resThree10265.Output
  7003. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7004. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7005. }
  7006. } else if res3101.Infcode != "0" {
  7007. c.ServeSuccessJSON(map[string]interface{}{
  7008. "failed_code": -10,
  7009. "msg": res3101.ErrMsg,
  7010. })
  7011. return
  7012. }
  7013. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7014. psn_info, _ := service.GetPsnByPatientId(id)
  7015. var cert_no string
  7016. if id_card_type == 1 {
  7017. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  7018. } else if id_card_type == 4 {
  7019. cert_no = psn_info.VerifyNumber
  7020. } else {
  7021. cert_no = psn_info.VerifyNumber
  7022. }
  7023. 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)
  7024. saveLog(result, requestLog, "2201", "挂号")
  7025. if miConfig.Code == "H15049901371" {
  7026. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7027. utils.ErrorLog("解析失败:%v", err)
  7028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7029. return
  7030. }
  7031. resThree.ErrMsg = resThree10265.ErrMsg
  7032. resThree.Output = resThree10265.Output
  7033. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7034. } else {
  7035. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7036. utils.ErrorLog("解析失败:%v", err)
  7037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7038. return
  7039. }
  7040. }
  7041. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7042. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  7043. psn_info, _ := service.GetPsnByPatientId(id)
  7044. var result string
  7045. var requestLog string
  7046. if id_card_type == 1 {
  7047. bas := strings.Split(psn_info.CardInfo, "|")
  7048. basNumber := bas[2]
  7049. card_sn := bas[3]
  7050. 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)
  7051. saveLog(result, requestLog, "2201A", "挂号")
  7052. } else if id_card_type == 2 {
  7053. 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, "", "")
  7054. saveLog(result, requestLog, "2201A", "挂号")
  7055. } else {
  7056. 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, "", "")
  7057. saveLog(result, requestLog, "2201A", "挂号")
  7058. }
  7059. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7060. utils.ErrorLog("解析失败:%v", err)
  7061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7062. return
  7063. }
  7064. infocode = resThree.Infcode
  7065. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  7066. psn_info, _ := service.GetPsnByPatientId(id)
  7067. var result string
  7068. var requestLog string
  7069. if id_card_type == 1 {
  7070. bas := strings.Split(psn_info.CardInfo, "|")
  7071. basNumber := bas[2]
  7072. card_sn := bas[3]
  7073. 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)
  7074. saveLog(result, requestLog, "2201A", "挂号")
  7075. } else if id_card_type == 2 {
  7076. 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, "", "")
  7077. saveLog(result, requestLog, "2201A", "挂号")
  7078. } else {
  7079. 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, "", "")
  7080. saveLog(result, requestLog, "2201A", "挂号")
  7081. }
  7082. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7083. utils.ErrorLog("解析失败:%v", err)
  7084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7085. return
  7086. }
  7087. infocode = resThree.Infcode
  7088. } else if miConfig.MdtrtareaAdmvs == "131023" {
  7089. psn_info, _ := service.GetPsnByPatientId(id)
  7090. 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)
  7091. saveLog(result, requestLog, "2201A", "挂号")
  7092. if miConfig.Code == "H15049901371" {
  7093. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7094. utils.ErrorLog("解析失败:%v", err)
  7095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7096. return
  7097. }
  7098. resThree.ErrMsg = resThree10265.ErrMsg
  7099. resThree.Output = resThree10265.Output
  7100. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7101. } else {
  7102. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7103. utils.ErrorLog("解析失败:%v", err)
  7104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7105. return
  7106. }
  7107. }
  7108. if miConfig.Code == "H15049901371" {
  7109. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7110. } else {
  7111. infocode = resThree.Infcode
  7112. }
  7113. } else {
  7114. psn_info, _ := service.GetPsnByPatientId(id)
  7115. 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)
  7116. saveLog(result, requestLog, "2201A", "挂号")
  7117. if miConfig.Code == "H15049901371" {
  7118. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7119. utils.ErrorLog("解析失败:%v", err)
  7120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7121. return
  7122. }
  7123. resThree.ErrMsg = resThree10265.ErrMsg
  7124. resThree.Output = resThree10265.Output
  7125. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7126. } else {
  7127. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7128. utils.ErrorLog("解析失败:%v", err)
  7129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7130. return
  7131. }
  7132. }
  7133. if miConfig.Code == "H15049901371" {
  7134. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7135. } else {
  7136. infocode = resThree.Infcode
  7137. }
  7138. }
  7139. if infocode != 0 {
  7140. adminUser := c.GetAdminUserInfo()
  7141. errlog := &models.HisOrderError{
  7142. UserOrgId: adminUser.CurrentOrgId,
  7143. Ctime: time.Now().Unix(),
  7144. Mtime: time.Now().Unix(),
  7145. ErrMsg: resThree.ErrMsg,
  7146. Status: 1,
  7147. PatientId: id,
  7148. RecordTime: recordDateTime,
  7149. Stage: 2,
  7150. }
  7151. service.CreateErrMsgLog(errlog)
  7152. c.ServeSuccessJSON(map[string]interface{}{
  7153. "failed_code": -10,
  7154. "msg": resThree.ErrMsg,
  7155. })
  7156. return
  7157. }
  7158. his.Number = resThree.Output.Data.MdtrtID
  7159. his.PsnNo = resThree.Output.Data.PsnNo
  7160. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  7161. his.IdCardNo = patient.IdCardNo
  7162. his.PhoneNumber = patient.Phone
  7163. his.UserOrgId = adminInfo.CurrentOrgId
  7164. his.Insutype = insutype
  7165. his.Ctime = time.Now().Unix()
  7166. his.Mtime = time.Now().Unix()
  7167. his.InsuplcAdmdvs = insuplc_admdvs_temp
  7168. his.Status = 1
  7169. service.UpdateHisPatientStatus(&his)
  7170. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  7171. c.ServeSuccessJSON(map[string]interface{}{
  7172. "his_info": his,
  7173. })
  7174. } else {
  7175. adminUser := c.GetAdminUserInfo()
  7176. errlog := &models.HisOrderError{
  7177. UserOrgId: adminUser.CurrentOrgId,
  7178. Ctime: time.Now().Unix(),
  7179. Mtime: time.Now().Unix(),
  7180. ErrMsg: res.ErrMsg,
  7181. Status: 1,
  7182. PatientId: id,
  7183. RecordTime: recordDateTime,
  7184. Stage: 1,
  7185. }
  7186. service.CreateErrMsgLog(errlog)
  7187. c.ServeSuccessJSON(map[string]interface{}{
  7188. "failed_code": -10,
  7189. "msg": res.ErrMsg,
  7190. })
  7191. return
  7192. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7193. }
  7194. }
  7195. }
  7196. //上传明细----预结算----确认订单
  7197. func (c *HisApiController) GetUploadInfo() {
  7198. id, _ := c.GetInt64("id")
  7199. record_time := c.GetString("record_time")
  7200. his_patient_id, _ := c.GetInt64("his_patient_id")
  7201. order_id, _ := c.GetInt64("order_id")
  7202. pay_way, _ := c.GetInt64("pay_way")
  7203. pay_price, _ := c.GetFloat("pay_price")
  7204. pay_card_no := c.GetString("pay_card_no")
  7205. discount_price, _ := c.GetFloat("discount_price")
  7206. preferential_price, _ := c.GetFloat("preferential_price")
  7207. reality_price, _ := c.GetFloat("reality_price")
  7208. found_price, _ := c.GetFloat("found_price")
  7209. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7210. private_price, _ := c.GetFloat("private_price")
  7211. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7212. admin_user_id, _ := c.GetInt64("admin_user_id")
  7213. fapiao_code := c.GetString("fapiao_code")
  7214. fapiao_number := c.GetString("fapiao_number")
  7215. diagnosis_id := c.GetString("diagnosis")
  7216. sick_type, _ := c.GetInt64("sick_type")
  7217. reg_type, _ := c.GetInt64("p_type")
  7218. begin_time := c.GetString("begin_time")
  7219. id_str := c.GetString("ids")
  7220. ids_arr := strings.Split(id_str, ",")
  7221. timeLayout := "2006-01-02"
  7222. loc, _ := time.LoadLocation("Local")
  7223. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7224. if err != nil {
  7225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7226. return
  7227. }
  7228. recordDateTime := theTime.Unix()
  7229. adminUser := c.GetAdminUserInfo()
  7230. var tempOrder models.HisOrder
  7231. tempOrder, _ = service.GetHisOrderByID(order_id)
  7232. var prescriptions []*models.HisPrescription
  7233. var start_time int64
  7234. var end_time int64
  7235. //押金模块
  7236. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  7237. tmp_decimal := c.GetString("tmp_decimal")
  7238. var decimal float64 //本次使用的押金
  7239. var errmsg error
  7240. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  7241. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  7242. return
  7243. }
  7244. if len(tmp_decimal) > 0 {
  7245. if tmp_decimal[0] == 45 {
  7246. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  7247. return
  7248. }
  7249. }
  7250. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  7251. fmt.Println(errs)
  7252. decimal = tt
  7253. //if adminUser.CurrentOrgId == 10106{
  7254. // if len(fapiao_code) == 0{
  7255. // fapiao_code = "144072080589"
  7256. // }
  7257. // if len(fapiao_number) == 0{
  7258. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  7259. // if order.ID == 0{
  7260. // fapiao_number = "00001520"
  7261. // }else{
  7262. // //fapiao_code = "00001520"
  7263. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  7264. // var zero string
  7265. // if fpNumber >= 1000{
  7266. // zero = "0000" + strconv.Itoa(fpNumber)
  7267. // }else if fpNumber >= 10000{
  7268. // zero = "000" + strconv.Itoa(fpNumber)
  7269. // } else if fpNumber >= 100000{
  7270. // zero = "00" + strconv.Itoa(fpNumber)
  7271. // } else if fpNumber >= 1000000{
  7272. // zero = "0" + strconv.Itoa(fpNumber)
  7273. // }else {
  7274. // zero = strconv.Itoa(fpNumber)
  7275. // }
  7276. // fapiao_number = zero
  7277. // }
  7278. // }
  7279. //}
  7280. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7281. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7282. var patientPrescription models.HisPrescriptionInfo
  7283. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7284. if patientPrescription.ID == 0 {
  7285. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7286. }
  7287. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7288. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7289. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7290. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7291. var config []*models.HisXtDiagnoseConfig
  7292. for _, item := range diagnosis_ids {
  7293. id, _ := strconv.ParseInt(item, 10, 64)
  7294. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7295. config = append(config, &diagnosisConfig)
  7296. }
  7297. sickConfig, _ := service.FindSickById(sick_type)
  7298. //if tempOrder.ID == 0 {
  7299. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  7300. //}
  7301. if tempOrder.ID == 0 {
  7302. var result string
  7303. var requestLog string
  7304. var res2 ResultSix
  7305. var ressix10265 ResultSix10265
  7306. if miConfig.MdtrtareaAdmvs == "421300" {
  7307. data := make(map[string]interface{})
  7308. client := &http.Client{}
  7309. data["psn_no"] = his.PsnNo
  7310. data["mdtrt_id"] = his.Number
  7311. data["opter"] = roles.UserName
  7312. data["org_name"] = miConfig.OrgName
  7313. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7314. data["doctor_id"] = doctor_info.DoctorNumber
  7315. data["doctor_name"] = doctor_info.UserName
  7316. data["department"] = department.Name
  7317. data["fixmedins_code"] = miConfig.Code
  7318. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7319. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7320. data["secret_key"] = miConfig.SecretKey
  7321. data["sick_code"] = sickConfig.CountryCode
  7322. data["sick_name"] = sickConfig.ClassName
  7323. data["dept"] = strconv.FormatInt(department.ID, 10)
  7324. data["config"] = config
  7325. data["begin_time"] = begin_time
  7326. bytesData, _ := json.Marshal(data)
  7327. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7328. resp, _ := client.Do(req)
  7329. defer resp.Body.Close()
  7330. body, ioErr := ioutil.ReadAll(resp.Body)
  7331. if ioErr != nil {
  7332. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7334. return
  7335. }
  7336. var respJSON map[string]interface{}
  7337. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7340. return
  7341. }
  7342. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7343. userJSONBytes, _ := json.Marshal(respJSON)
  7344. fmt.Println("log")
  7345. fmt.Println(string(userJSONBytes))
  7346. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7347. utils.ErrorLog("解析失败:%v", err)
  7348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7349. return
  7350. }
  7351. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7352. data := make(map[string]interface{})
  7353. client := &http.Client{}
  7354. data["psn_no"] = his.PsnNo
  7355. data["mdtrt_id"] = his.Number
  7356. data["doctor"] = roles.UserName
  7357. data["department"] = department.Name
  7358. data["org_name"] = miConfig.OrgName
  7359. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7360. data["doctor_id"] = doctor_info.DoctorNumber
  7361. data["new_doctor_name"] = doctor_info.UserName
  7362. data["fixmedins_code"] = miConfig.Code
  7363. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7364. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7365. data["secret_key"] = miConfig.SecretKey
  7366. data["sick_code"] = sickConfig.CountryCode
  7367. data["sick_name"] = sickConfig.ClassName
  7368. data["url"] = miConfig.Url
  7369. data["ak"] = miConfig.AccessKey
  7370. data["begin_time"] = begin_time
  7371. data["cainfo"] = miConfig.Cainfo
  7372. data["dept"] = strconv.FormatInt(department.ID, 10)
  7373. data["config"] = config
  7374. bytesData, _ := json.Marshal(data)
  7375. var req *http.Request
  7376. if miConfig.MdtrtareaAdmvs == "320921" {
  7377. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7378. //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 +
  7379. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7380. } else {
  7381. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7382. }
  7383. resp, _ := client.Do(req)
  7384. defer resp.Body.Close()
  7385. body, ioErr := ioutil.ReadAll(resp.Body)
  7386. if ioErr != nil {
  7387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7389. return
  7390. }
  7391. var respJSON map[string]interface{}
  7392. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7395. return
  7396. }
  7397. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7398. userJSONBytes, _ := json.Marshal(respJSON)
  7399. fmt.Println("log")
  7400. fmt.Println(string(userJSONBytes))
  7401. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  7402. utils.ErrorLog("解析失败:%v", err)
  7403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7404. return
  7405. }
  7406. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7407. res2.Output = ressix10265.Output
  7408. res2.ErrMsg = ressix10265.ErrMsg
  7409. res2.Cainfo = ressix10265.Cainfo
  7410. res2.WarnMsg = ressix10265.WarnMsg
  7411. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7412. res2.Infcode = infocode
  7413. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7414. 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)
  7415. saveLog(result, requestLog, "2203", "上传就诊信息")
  7416. var respJSON2 map[string]interface{}
  7417. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7420. return
  7421. }
  7422. userJSONBytes2, _ := json.Marshal(respJSON2)
  7423. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7424. utils.ErrorLog("解析失败:%v", err)
  7425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7426. return
  7427. }
  7428. } else {
  7429. if miConfig.MdtrtareaAdmvs == "440781" { //
  7430. 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)
  7431. } else {
  7432. if miConfig.Code == "H15049901371" {
  7433. //赤峰地区国家医保医疗类别
  7434. //职工透析:医疗类别选特殊情况门诊990502
  7435. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7436. var med_type string
  7437. if his.Insutype == "390" {
  7438. if reg_type == 14 {
  7439. med_type = "9933"
  7440. } else if reg_type == 11 {
  7441. med_type = "11"
  7442. }
  7443. } else if his.Insutype == "310" {
  7444. if reg_type == 14 {
  7445. med_type = "990502"
  7446. } else if reg_type == 11 {
  7447. med_type = "11"
  7448. }
  7449. }
  7450. 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)
  7451. } else {
  7452. 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)
  7453. }
  7454. }
  7455. saveLog(result, requestLog, "2203", "上传就诊信息")
  7456. var respJSON2 map[string]interface{}
  7457. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7460. return
  7461. }
  7462. userJSONBytes2, _ := json.Marshal(respJSON2)
  7463. if miConfig.Code == "H15049901371" {
  7464. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  7465. utils.ErrorLog("解析失败:%v", err)
  7466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7467. return
  7468. }
  7469. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7470. res2.Output = ressix10265.Output
  7471. res2.ErrMsg = ressix10265.ErrMsg
  7472. res2.Cainfo = ressix10265.Cainfo
  7473. res2.WarnMsg = ressix10265.WarnMsg
  7474. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7475. res2.Infcode = infocode
  7476. } else {
  7477. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7478. utils.ErrorLog("解析失败:%v", err)
  7479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7480. return
  7481. }
  7482. }
  7483. }
  7484. if res2.Infcode != 0 {
  7485. adminUser := c.GetAdminUserInfo()
  7486. errlog := &models.HisOrderError{
  7487. UserOrgId: adminUser.CurrentOrgId,
  7488. Ctime: time.Now().Unix(),
  7489. Mtime: time.Now().Unix(),
  7490. ErrMsg: res2.ErrMsg,
  7491. Status: 1,
  7492. PatientId: id,
  7493. RecordTime: recordDateTime,
  7494. Stage: 3,
  7495. }
  7496. service.CreateErrMsgLog(errlog)
  7497. c.ServeSuccessJSON(map[string]interface{}{
  7498. "failed_code": -10,
  7499. "msg": res2.ErrMsg,
  7500. })
  7501. return
  7502. } else {
  7503. his.Diagnosis = diagnosis_id
  7504. his.SickType = sickConfig.ID
  7505. //var p_type int64
  7506. //if reg_type == 1111 || reg_type == 1112 {
  7507. // p_type = 11
  7508. //
  7509. //}
  7510. his.PType = fmt.Sprintf("%d", reg_type)
  7511. service.UpdateHisPatientThree(&his)
  7512. data := make(map[string]interface{})
  7513. if settle_accounts_type == 1 { //日结
  7514. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7515. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7516. } else {
  7517. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7518. }
  7519. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  7520. data["pre"] = prescriptions
  7521. } else { //月结
  7522. start_time_str := c.GetString("start_time")
  7523. end_time_str := c.GetString("end_time")
  7524. timeLayout := "2006-01-02"
  7525. loc, _ := time.LoadLocation("Local")
  7526. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7527. if err != nil {
  7528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7529. return
  7530. }
  7531. recordStartTime := theStartTime.Unix()
  7532. start_time = recordStartTime
  7533. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7534. if err != nil {
  7535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7536. return
  7537. }
  7538. recordEndTime := theEndTime.Unix()
  7539. end_time = recordEndTime
  7540. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7541. data["pre"] = prescriptions
  7542. }
  7543. timestamp := time.Now().Unix()
  7544. tempTime := time.Unix(timestamp, 0)
  7545. timeFormat := tempTime.Format("20060102150405")
  7546. chrgBchno := rand.Intn(100000) + 10000
  7547. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7548. strconv.FormatInt(his.PatientId, 10)
  7549. client := &http.Client{}
  7550. data["psn_no"] = his.PsnNo
  7551. data["mdtrt_id"] = his.Number
  7552. data["chrg_bchno"] = chrg_bchno
  7553. data["org_name"] = miConfig.OrgName
  7554. data["doctor"] = doctor_info.UserName
  7555. data["doctor_id"] = doctor_info.DoctorNumber
  7556. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7557. data["fixmedins_code"] = miConfig.Code
  7558. data["opter"] = roles.UserName
  7559. data["dept_code"] = department.Number
  7560. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7561. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7562. data["secret_key"] = miConfig.SecretKey
  7563. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7564. data["url"] = miConfig.Url
  7565. data["ak"] = miConfig.AccessKey
  7566. data["new_doctor_name"] = patientPrescription.Doctor
  7567. data["diag_code"] = sickConfig.CountryCode
  7568. data["cainfo"] = miConfig.Cainfo
  7569. data["opter"] = roles.UserName
  7570. var ids []int64
  7571. for _, item := range prescriptions {
  7572. ids = append(ids, item.ID)
  7573. }
  7574. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7575. if config.IsOpen == 1 { //对接了医保,走医保流程
  7576. var res ResultFour
  7577. var resFour10265 ResultFour10265
  7578. if miConfig.MdtrtareaAdmvs == "421300" {
  7579. bytesData, _ := json.Marshal(data)
  7580. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7581. resp, _ := client.Do(req)
  7582. defer resp.Body.Close()
  7583. body, ioErr := ioutil.ReadAll(resp.Body)
  7584. if ioErr != nil {
  7585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7587. return
  7588. }
  7589. var respJSON map[string]interface{}
  7590. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7593. return
  7594. }
  7595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7596. userJSONBytes, _ := json.Marshal(respJSON)
  7597. fmt.Println("log")
  7598. fmt.Println(string(userJSONBytes))
  7599. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7600. utils.ErrorLog("解析失败:%v", err)
  7601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7602. return
  7603. }
  7604. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7605. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7606. if result3101.Infcode == "0" {
  7607. if len(result3101.Output.Result) > 0 {
  7608. var errMsgs []string
  7609. for _, item := range result3101.Output.Result {
  7610. errMsgs = append(errMsgs, item.VolaCont)
  7611. }
  7612. c.ServeSuccessJSON(map[string]interface{}{
  7613. "failed_code": -10,
  7614. "msg": errMsgs,
  7615. })
  7616. return
  7617. }
  7618. }
  7619. if miConfig.MdtrtareaAdmvs == "320921" {
  7620. data["doctor_id"] = "D320923012139"
  7621. } else {
  7622. data["doctor_id"] = "D371621008686"
  7623. }
  7624. bytesData, _ := json.Marshal(data)
  7625. var req *http.Request
  7626. if miConfig.MdtrtareaAdmvs == "320921" {
  7627. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7628. } else {
  7629. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7630. }
  7631. resp, _ := client.Do(req)
  7632. defer resp.Body.Close()
  7633. body, ioErr := ioutil.ReadAll(resp.Body)
  7634. if ioErr != nil {
  7635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7637. return
  7638. }
  7639. var respJSON map[string]interface{}
  7640. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7643. return
  7644. }
  7645. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7646. userJSONBytes, _ := json.Marshal(respJSON)
  7647. fmt.Println("log")
  7648. fmt.Println(string(userJSONBytes))
  7649. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7650. utils.ErrorLog("解析失败:%v", err)
  7651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7652. return
  7653. }
  7654. res.InfRefmsgid = resFour10265.InfRefmsgid
  7655. res.Output = resFour10265.Output
  7656. res.ErrMsg = resFour10265.ErrMsg
  7657. res.Cainfo = resFour10265.Cainfo
  7658. res.WarnMsg = resFour10265.WarnMsg
  7659. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7660. res.Infcode = infocode
  7661. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7662. 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)
  7663. var dat map[string]interface{}
  7664. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7665. fmt.Println(dat)
  7666. } else {
  7667. fmt.Println(err)
  7668. }
  7669. saveLog(result, request_log, "2204", "上传费用明细")
  7670. userJSONBytes, _ := json.Marshal(dat)
  7671. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7672. utils.ErrorLog("解析失败:%v", err)
  7673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7674. return
  7675. }
  7676. res.InfRefmsgid = resFour10265.InfRefmsgid
  7677. res.Output = resFour10265.Output
  7678. res.ErrMsg = resFour10265.ErrMsg
  7679. res.Cainfo = resFour10265.Cainfo
  7680. res.WarnMsg = resFour10265.WarnMsg
  7681. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7682. res.Infcode = infocode
  7683. } else {
  7684. if miConfig.Code == "H15049901371" {
  7685. 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)
  7686. var dat map[string]interface{}
  7687. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7688. fmt.Println(dat)
  7689. } else {
  7690. fmt.Println(err)
  7691. }
  7692. saveLog(result, request_log, "2204", "上传费用明细")
  7693. userJSONBytes, _ := json.Marshal(dat)
  7694. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7695. utils.ErrorLog("解析失败:%v", err)
  7696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7697. return
  7698. }
  7699. res.InfRefmsgid = resFour10265.InfRefmsgid
  7700. res.Output = resFour10265.Output
  7701. res.ErrMsg = resFour10265.ErrMsg
  7702. res.Cainfo = resFour10265.Cainfo
  7703. res.WarnMsg = resFour10265.WarnMsg
  7704. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7705. res.Infcode = infocode
  7706. } else {
  7707. 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)
  7708. var dat map[string]interface{}
  7709. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7710. fmt.Println(dat)
  7711. } else {
  7712. fmt.Println(err)
  7713. }
  7714. saveLog(result, request_log, "2204", "上传费用明细")
  7715. userJSONBytes, _ := json.Marshal(dat)
  7716. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7717. utils.ErrorLog("解析失败:%v", err)
  7718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7719. return
  7720. }
  7721. }
  7722. }
  7723. if res.Infcode == 0 {
  7724. order := &models.HisOrder{
  7725. UserOrgId: adminUser.CurrentOrgId,
  7726. HisPatientId: his.ID,
  7727. PatientId: his.PatientId,
  7728. SettleAccountsDate: recordDateTime,
  7729. MdtrtId: his.Number,
  7730. PsnNo: his.PsnNo,
  7731. MedType: strconv.FormatInt(reg_type, 10),
  7732. Ctime: time.Now().Unix(),
  7733. Mtime: time.Now().Unix(),
  7734. Status: 1,
  7735. Number: chrg_bchno,
  7736. Infcode: res.Infcode,
  7737. WarnMsg: res.WarnMsg,
  7738. Cainfo: res.Cainfo,
  7739. ErrMsg: res.ErrMsg,
  7740. RespondTime: res.RefmsgTime,
  7741. InfRefmsgid: res.InfRefmsgid,
  7742. OrderStatus: 1,
  7743. PayWay: pay_way,
  7744. PayPrice: pay_price,
  7745. PayCardNo: pay_card_no,
  7746. DiscountPrice: discount_price,
  7747. PreferentialPrice: preferential_price,
  7748. RealityPrice: reality_price,
  7749. FoundPrice: found_price,
  7750. MedicalInsurancePrice: medical_insurance_price,
  7751. PrivatePrice: private_price,
  7752. IsMedicineInsurance: 1,
  7753. SettleType: settle_accounts_type,
  7754. SettleStartTime: start_time,
  7755. SettleEndTime: end_time,
  7756. Creator: roles.AdminUserId,
  7757. Modify: roles.AdminUserId,
  7758. FaPiaoNumber: fapiao_number,
  7759. FaPiaoCode: fapiao_code,
  7760. PType: 2,
  7761. Diagnosis: diagnosis_id,
  7762. }
  7763. err = service.CreateOrder(order)
  7764. if err != nil {
  7765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7766. return
  7767. }
  7768. for _, item := range res.Output.Result {
  7769. temp := strings.Split(item.FeedetlSn, "-")
  7770. var advice_id int64 = 0
  7771. var project_id int64 = 0
  7772. var types int64 = 0
  7773. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7774. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7775. if temp[1] == "1" {
  7776. advice_id = id
  7777. project_id = 0
  7778. } else if temp[1] == "2" {
  7779. advice_id = 0
  7780. project_id = id
  7781. }
  7782. if item.MedChrgitmType == "9" {
  7783. item.MedChrgitmType = "09"
  7784. }
  7785. info := &models.HisOrderInfo{
  7786. OrderNumber: order.Number,
  7787. FeedetlSn: item.FeedetlSn,
  7788. UploadDate: time.Now().Unix(),
  7789. AdviceId: advice_id,
  7790. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7791. Cnt: item.Cnt,
  7792. Pric: float64(item.Pric),
  7793. PatientId: his.PatientId,
  7794. PricUplmtAmt: item.PricUplmtAmt,
  7795. SelfpayProp: item.SelfpayProp,
  7796. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7797. OverlmtAmt: item.OverlmtAmt,
  7798. PreselfpayAmt: item.PreselfpayAmt,
  7799. BasMednFlag: item.BasMednFlag,
  7800. MedChrgitmType: item.MedChrgitmType,
  7801. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7802. Status: 1,
  7803. Memo: item.Memo,
  7804. Mtime: time.Now().Unix(),
  7805. InscpScpAmt: item.InscpScpAmt,
  7806. DrtReimFlag: item.DrtReimFlag,
  7807. Ctime: time.Now().Unix(),
  7808. ListSpItemFlag: item.ListSpItemFlag,
  7809. ChldMedcFlag: item.ChldMedcFlag,
  7810. LmtUsedFlag: item.LmtUsedFlag,
  7811. ChrgitmLv: item.ChrgitmLv,
  7812. UserOrgId: adminUser.CurrentOrgId,
  7813. HisPatientId: his.ID,
  7814. OrderId: order.ID,
  7815. ProjectId: project_id,
  7816. Type: types,
  7817. }
  7818. service.CreateOrderInfo(info)
  7819. }
  7820. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7821. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7822. var total float64
  7823. for _, item := range prescriptions {
  7824. if item.Type == 1 { //药品
  7825. for _, subItem := range item.HisDoctorAdviceInfo {
  7826. total = total + (subItem.Price * subItem.PrescribingNumber)
  7827. }
  7828. }
  7829. if item.Type == 2 { //项目
  7830. for _, subItem := range item.HisPrescriptionProject {
  7831. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7832. total = total + (subItem.Price * cnt)
  7833. }
  7834. }
  7835. }
  7836. for _, item := range prescriptions {
  7837. for _, subItem := range item.HisAdditionalCharge {
  7838. total = total + (subItem.Price * float64(subItem.Count))
  7839. }
  7840. }
  7841. var allTotal string
  7842. if adminUser.CurrentOrgId == 9919 {
  7843. allTotal = fmt.Sprintf("%.4f", total)
  7844. } else {
  7845. allTotal = fmt.Sprintf("%.4f", total)
  7846. }
  7847. if res.Infcode == 0 {
  7848. var rf []*ResultFive
  7849. json.Unmarshal([]byte(his.Iinfo), &rf)
  7850. chrg_bchno := chrg_bchno
  7851. cert_no := his.Certno
  7852. var insutypes []string
  7853. var insutype string
  7854. var is390 int = 0
  7855. var is310 int = 0
  7856. for _, item := range rf {
  7857. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7858. insutypes = append(insutypes, item.Insutype)
  7859. }
  7860. }
  7861. if len(insutypes) == 1 {
  7862. insutype = insutypes[0]
  7863. } else {
  7864. for _, i := range insutypes {
  7865. if i == "390" {
  7866. is390 = 1
  7867. }
  7868. if i == "310" {
  7869. is310 = 1
  7870. }
  7871. }
  7872. }
  7873. if is390 == 1 {
  7874. insutype = "390"
  7875. }
  7876. if is310 == 1 {
  7877. insutype = "310"
  7878. }
  7879. if len(insutypes) == 0 {
  7880. insutype = "310"
  7881. }
  7882. if len(insutypes) == 2 {
  7883. insutype = strconv.FormatInt(his.SocialType, 10)
  7884. }
  7885. insutype = strconv.FormatInt(his.SocialType, 10)
  7886. //insutype = "390"
  7887. if his.IdCardType == 1 {
  7888. // cert_no = his.MedicalInsuranceNumber
  7889. cert_no = his.Certno
  7890. } else {
  7891. cert_no = his.Certno
  7892. }
  7893. var res ResultSeven
  7894. var resSeven10265 ResultSeven10265
  7895. var src_resquest string
  7896. var result2 string
  7897. var acct_used_flag string
  7898. fmt.Println("pay_way")
  7899. fmt.Println(pay_way)
  7900. fmt.Println("pay_way")
  7901. if pay_way == 4 {
  7902. acct_used_flag = "1"
  7903. } else {
  7904. acct_used_flag = "0"
  7905. }
  7906. if miConfig.MdtrtareaAdmvs == "421300" {
  7907. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7908. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7909. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7910. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7911. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7912. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7913. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  7914. resp, requestErr := http.Get(api)
  7915. if requestErr != nil {
  7916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7917. return
  7918. }
  7919. body, ioErr := ioutil.ReadAll(resp.Body)
  7920. if ioErr != nil {
  7921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7923. return
  7924. }
  7925. var respJSON map[string]interface{}
  7926. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7929. return
  7930. }
  7931. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7932. result, _ := json.Marshal(respJSON)
  7933. if miConfig.Code == "H15049901371" {
  7934. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7935. utils.ErrorLog("解析失败:%v", err)
  7936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7937. return
  7938. }
  7939. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7940. res.Output = resSeven10265.Output
  7941. res.ErrMsg = resSeven10265.ErrMsg
  7942. res.Cainfo = resSeven10265.Cainfo
  7943. res.WarnMsg = resSeven10265.WarnMsg
  7944. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7945. res.Infcode = infocode
  7946. } else {
  7947. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7948. utils.ErrorLog("解析失败:%v", err)
  7949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7950. return
  7951. }
  7952. }
  7953. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7954. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  7955. if result3101.Infcode == "0" {
  7956. if len(result3101.Output.Result) > 0 {
  7957. var errMsgs []string
  7958. for _, item := range result3101.Output.Result {
  7959. errMsgs = append(errMsgs, item.VolaCont)
  7960. }
  7961. c.ServeSuccessJSON(map[string]interface{}{
  7962. "failed_code": -10,
  7963. "msg": errMsgs,
  7964. })
  7965. return
  7966. } else {
  7967. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7968. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7969. bas := strings.Split(psn_info.CardInfo, "|")
  7970. if his.IdCardType == 1 {
  7971. cert_no = bas[2]
  7972. } else if his.IdCardType == 3 {
  7973. cert_no = his.Certno
  7974. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  7975. } else if his.IdCardType == 4 {
  7976. cert_no = his.Certno
  7977. psn_info.VerifyNumber = psn_info.VerifyNumber
  7978. }
  7979. var api string
  7980. if miConfig.MdtrtareaAdmvs == "320921" {
  7981. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7982. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7983. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7984. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7985. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7986. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7987. "&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
  7988. } else {
  7989. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7990. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7991. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7992. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7993. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7994. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7995. "&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
  7996. }
  7997. resp, requestErr := http.Get(api)
  7998. if requestErr != nil {
  7999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8000. return
  8001. }
  8002. body, ioErr := ioutil.ReadAll(resp.Body)
  8003. if ioErr != nil {
  8004. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8006. return
  8007. }
  8008. var respJSON map[string]interface{}
  8009. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8010. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8012. return
  8013. }
  8014. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8015. result, _ := json.Marshal(respJSON)
  8016. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8017. utils.ErrorLog("解析失败:%v", err)
  8018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8019. return
  8020. }
  8021. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8022. res.Output = resSeven10265.Output
  8023. res.ErrMsg = resSeven10265.ErrMsg
  8024. res.Cainfo = resSeven10265.Cainfo
  8025. res.WarnMsg = resSeven10265.WarnMsg
  8026. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8027. res.Infcode = infocode
  8028. }
  8029. }
  8030. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8031. var cert_no string
  8032. if his.IdCardType == 4 {
  8033. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8034. cert_no = psn_info.VerifyNumber
  8035. 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)
  8036. } else if his.IdCardType == 1 {
  8037. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8038. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8039. 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)
  8040. }
  8041. //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)
  8042. var dat map[string]interface{}
  8043. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8044. fmt.Println(dat)
  8045. } else {
  8046. fmt.Println(err)
  8047. }
  8048. saveLog(result2, src_resquest, "2207", "结算")
  8049. userJSONBytes, _ := json.Marshal(dat)
  8050. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8051. utils.ErrorLog("解析失败:%v", err)
  8052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8053. return
  8054. }
  8055. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8056. res.Output = resSeven10265.Output
  8057. res.ErrMsg = resSeven10265.ErrMsg
  8058. res.Cainfo = resSeven10265.Cainfo
  8059. res.WarnMsg = resSeven10265.WarnMsg
  8060. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8061. res.Infcode = infocode
  8062. } else {
  8063. if miConfig.Code == "H15049901371" {
  8064. //赤峰地区国家医保医疗类别
  8065. //职工透析:医疗类别选特殊情况门诊990502
  8066. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8067. var med_type string
  8068. if his.Insutype == "390" {
  8069. if reg_type == 14 {
  8070. med_type = "9933"
  8071. } else if reg_type == 11 {
  8072. med_type = "11"
  8073. }
  8074. } else if his.Insutype == "310" {
  8075. if reg_type == 14 {
  8076. med_type = "990502"
  8077. } else if reg_type == 11 {
  8078. med_type = "11"
  8079. }
  8080. }
  8081. 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, "")
  8082. } else {
  8083. if his.IdCardType == 4 {
  8084. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8085. var token string
  8086. token = psn_info.VerifyNumber
  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, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, token)
  8088. } else {
  8089. 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, "")
  8090. }
  8091. }
  8092. //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)
  8093. var dat map[string]interface{}
  8094. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8095. fmt.Println(dat)
  8096. } else {
  8097. fmt.Println(err)
  8098. }
  8099. saveLog(result2, src_resquest, "2207", "结算")
  8100. userJSONBytes, _ := json.Marshal(dat)
  8101. if miConfig.Code == "H15049901371" {
  8102. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8103. utils.ErrorLog("解析失败:%v", err)
  8104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8105. return
  8106. }
  8107. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8108. res.Output = resSeven10265.Output
  8109. res.ErrMsg = resSeven10265.ErrMsg
  8110. res.Cainfo = resSeven10265.Cainfo
  8111. res.WarnMsg = resSeven10265.WarnMsg
  8112. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8113. res.Infcode = infocode
  8114. } else {
  8115. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8116. utils.ErrorLog("解析失败:%v", err)
  8117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8118. return
  8119. }
  8120. }
  8121. }
  8122. if res.Infcode != 0 {
  8123. errlog := &models.HisOrderError{
  8124. UserOrgId: adminUser.CurrentOrgId,
  8125. Ctime: time.Now().Unix(),
  8126. Mtime: time.Now().Unix(),
  8127. Number: chrg_bchno,
  8128. ErrMsg: res.ErrMsg,
  8129. Status: 1,
  8130. PatientId: id,
  8131. RecordTime: recordDateTime,
  8132. Stage: 6,
  8133. }
  8134. service.CreateErrMsgLog(errlog)
  8135. c.ServeSuccessJSON(map[string]interface{}{
  8136. "failed_code": -10,
  8137. "msg": res.ErrMsg,
  8138. })
  8139. return
  8140. } else {
  8141. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8142. order.OrderStatus = 2
  8143. order.Status = 1
  8144. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8145. order.SetlId = res.Output.Setlinfo.SetlID
  8146. order.PsnNo = res.Output.Setlinfo.PsnNo
  8147. order.PsnName = res.Output.Setlinfo.PsnName
  8148. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8149. order.Certno = res.Output.Setlinfo.Certno
  8150. order.Gend = res.Output.Setlinfo.Gend
  8151. order.Naty = res.Output.Setlinfo.Naty
  8152. order.Age = res.Output.Setlinfo.Age
  8153. order.Insutype = res.Output.Setlinfo.Insutype
  8154. order.PsnType = res.Output.Setlinfo.PsnType
  8155. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8156. order.SetlTime = res.Output.Setlinfo.SetlTime
  8157. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8158. if res.Output.Setlinfo.MedType == "140101" {
  8159. order.MedType = "14"
  8160. } else {
  8161. order.MedType = res.Output.Setlinfo.MedType
  8162. }
  8163. if reg_type == 1112 {
  8164. order.MedType = "1112"
  8165. }
  8166. if reg_type == 1111 {
  8167. order.MedType = "1111"
  8168. }
  8169. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8170. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8171. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8172. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8173. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8174. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8175. order.HifpPay = res.Output.Setlinfo.HifpPay
  8176. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8177. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8178. order.HifesPay = res.Output.Setlinfo.HifesPay
  8179. order.HifobPay = res.Output.Setlinfo.HifobPay
  8180. order.MafPay = res.Output.Setlinfo.MafPay
  8181. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8182. order.OthPay = res.Output.Setlinfo.OthPay
  8183. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8184. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8185. order.AcctPay = res.Output.Setlinfo.AcctPay
  8186. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8187. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8188. order.Balc = res.Output.Setlinfo.Balc
  8189. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8190. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8191. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8192. order.ClrType = res.Output.Setlinfo.ClrType
  8193. order.ClrWay = res.Output.Setlinfo.ClrWay
  8194. order.Creator = order.Creator
  8195. order.Modify = roles.AdminUserId
  8196. order.RequestLog = src_resquest
  8197. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8198. detailStr := string(setlDetail)
  8199. order.SetlDetail = detailStr
  8200. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8201. err = service.UpDateOrder(order)
  8202. if err == nil {
  8203. //判断是否使用了押金
  8204. if dec_way == "true" {
  8205. tmpstring := strconv.FormatInt(order.ID, 10)
  8206. order.Decimal = decimal
  8207. service.UpDateOrder(order)
  8208. //扣押金
  8209. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8210. if errmsg != nil {
  8211. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8212. return
  8213. }
  8214. }
  8215. c.ServeSuccessJSON(map[string]interface{}{
  8216. "msg": "结算成功",
  8217. })
  8218. } else {
  8219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8220. return
  8221. }
  8222. }
  8223. } else {
  8224. adminUser := c.GetAdminUserInfo()
  8225. errlog := &models.HisOrderError{
  8226. UserOrgId: adminUser.CurrentOrgId,
  8227. Ctime: time.Now().Unix(),
  8228. Mtime: time.Now().Unix(),
  8229. ErrMsg: res.ErrMsg,
  8230. Status: 1,
  8231. PatientId: id,
  8232. RecordTime: recordDateTime,
  8233. Stage: 4,
  8234. }
  8235. service.CreateErrMsgLog(errlog)
  8236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8237. return
  8238. }
  8239. } else {
  8240. adminUser := c.GetAdminUserInfo()
  8241. errlog := &models.HisOrderError{
  8242. UserOrgId: adminUser.CurrentOrgId,
  8243. Ctime: time.Now().Unix(),
  8244. Mtime: time.Now().Unix(),
  8245. ErrMsg: res.ErrMsg,
  8246. Status: 1,
  8247. PatientId: id,
  8248. RecordTime: recordDateTime,
  8249. Stage: 4,
  8250. }
  8251. service.CreateErrMsgLog(errlog)
  8252. c.ServeSuccessJSON(map[string]interface{}{
  8253. "failed_code": -10,
  8254. "msg": res.ErrMsg,
  8255. })
  8256. return
  8257. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  8258. //return
  8259. }
  8260. }
  8261. }
  8262. } else if tempOrder.ID > 0 {
  8263. if tempOrder.IsPre == 1 {
  8264. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  8265. var rf []*ResultFive
  8266. json.Unmarshal([]byte(his.Iinfo), &rf)
  8267. chrg_bchno := tempOrder.Number
  8268. cert_no := his.Certno
  8269. var insutypes []string
  8270. var insutype string
  8271. var is390 int = 0
  8272. var is310 int = 0
  8273. for _, item := range rf {
  8274. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8275. insutypes = append(insutypes, item.Insutype)
  8276. }
  8277. }
  8278. if len(insutypes) == 1 {
  8279. insutype = insutypes[0]
  8280. } else {
  8281. for _, i := range insutypes {
  8282. if i == "390" {
  8283. is390 = 1
  8284. }
  8285. if i == "310" {
  8286. is310 = 1
  8287. }
  8288. }
  8289. }
  8290. if is390 == 1 {
  8291. insutype = "390"
  8292. }
  8293. if is310 == 1 {
  8294. insutype = "310"
  8295. }
  8296. if len(insutypes) == 0 {
  8297. insutype = "310"
  8298. }
  8299. if len(insutypes) == 2 {
  8300. insutype = strconv.FormatInt(his.SocialType, 64)
  8301. }
  8302. //insutype = "390"
  8303. if his.IdCardType == 1 {
  8304. // cert_no = his.MedicalInsuranceNumber
  8305. cert_no = his.Certno
  8306. } else {
  8307. cert_no = his.Certno
  8308. }
  8309. var res ResultSeven
  8310. var resSeven10265 ResultSeven10265
  8311. var src_resquest string
  8312. var result2 string
  8313. var acct_used_flag string
  8314. fmt.Println("pay_way")
  8315. fmt.Println(pay_way)
  8316. fmt.Println("pay_way")
  8317. if pay_way == 4 {
  8318. acct_used_flag = "1"
  8319. } else {
  8320. acct_used_flag = "0"
  8321. }
  8322. if miConfig.MdtrtareaAdmvs == "421300" {
  8323. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8324. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8325. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8326. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8327. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8328. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8329. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  8330. resp, requestErr := http.Get(api)
  8331. if requestErr != nil {
  8332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8333. return
  8334. }
  8335. body, ioErr := ioutil.ReadAll(resp.Body)
  8336. if ioErr != nil {
  8337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8339. return
  8340. }
  8341. var respJSON map[string]interface{}
  8342. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8345. return
  8346. }
  8347. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8348. result, _ := json.Marshal(respJSON)
  8349. fmt.Println("log")
  8350. fmt.Println(string(result))
  8351. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8352. utils.ErrorLog("解析失败:%v", err)
  8353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8354. return
  8355. }
  8356. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8357. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  8358. if result3101.Infcode == "0" {
  8359. if len(result3101.Output.Result) > 0 {
  8360. var errMsgs []string
  8361. for _, item := range result3101.Output.Result {
  8362. errMsgs = append(errMsgs, item.VolaCont)
  8363. }
  8364. c.ServeSuccessJSON(map[string]interface{}{
  8365. "failed_code": -10,
  8366. "msg": errMsgs,
  8367. })
  8368. return
  8369. } else {
  8370. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8371. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8372. bas := strings.Split(psn_info.CardInfo, "|")
  8373. if his.IdCardType == 1 {
  8374. cert_no = bas[2]
  8375. } else if his.IdCardType == 3 {
  8376. cert_no = his.Certno
  8377. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  8378. } else if his.IdCardType == 4 {
  8379. cert_no = his.Certno
  8380. psn_info.VerifyNumber = psn_info.VerifyNumber
  8381. }
  8382. //江苏地区国家医保医疗类别
  8383. //职工透析:医疗类别选特殊情况门诊9933
  8384. //居民血透门慢: 医疗类别选门诊慢病1402
  8385. //var med_type string
  8386. //if his.Insutype == "310" {
  8387. // if reg_type == 14 {
  8388. // med_type = "9933"
  8389. // } else if reg_type == 11 {
  8390. // med_type = "11"
  8391. //
  8392. // }
  8393. //} else if his.Insutype == "390" {
  8394. // if reg_type == 14 {
  8395. // med_type = "1402"
  8396. // } else if reg_type == 11 {
  8397. // med_type = "11"
  8398. // }
  8399. //}
  8400. var api string
  8401. if miConfig.MdtrtareaAdmvs == "320921" {
  8402. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8403. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8404. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8405. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8406. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8407. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8408. "&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
  8409. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8410. } else {
  8411. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8412. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8413. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8414. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8415. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8416. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8417. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8418. "&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
  8419. }
  8420. resp, requestErr := http.Get(api)
  8421. if requestErr != nil {
  8422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8423. return
  8424. }
  8425. body, ioErr := ioutil.ReadAll(resp.Body)
  8426. if ioErr != nil {
  8427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8429. return
  8430. }
  8431. var respJSON map[string]interface{}
  8432. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8435. return
  8436. }
  8437. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8438. result, _ := json.Marshal(respJSON)
  8439. fmt.Println("log")
  8440. fmt.Println(string(result))
  8441. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8442. utils.ErrorLog("解析失败:%v", err)
  8443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8444. return
  8445. }
  8446. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8447. res.Output = resSeven10265.Output
  8448. res.ErrMsg = resSeven10265.ErrMsg
  8449. res.Cainfo = resSeven10265.Cainfo
  8450. res.WarnMsg = resSeven10265.WarnMsg
  8451. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8452. res.Infcode = infocode
  8453. }
  8454. }
  8455. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8456. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8457. var cert_no string
  8458. if his.IdCardType == 1 {
  8459. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8460. } else {
  8461. cert_no = psn_info.VerifyNumber
  8462. }
  8463. 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)
  8464. var dat map[string]interface{}
  8465. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8466. fmt.Println(dat)
  8467. } else {
  8468. fmt.Println(err)
  8469. }
  8470. saveLog(result2, src_resquest, "2207", "结算")
  8471. userJSONBytes, _ := json.Marshal(dat)
  8472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8473. utils.ErrorLog("解析失败:%v", err)
  8474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8475. return
  8476. }
  8477. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8478. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8479. var cert_no string
  8480. if his.IdCardType == 1 {
  8481. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8482. } else if his.IdCardType == 2 {
  8483. cert_no = his.IdCardNo
  8484. } else {
  8485. cert_no = psn_info.VerifyNumber
  8486. }
  8487. 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, "")
  8488. var dat map[string]interface{}
  8489. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8490. fmt.Println(dat)
  8491. } else {
  8492. fmt.Println(err)
  8493. }
  8494. saveLog(result2, src_resquest, "2207", "结算")
  8495. userJSONBytes, _ := json.Marshal(dat)
  8496. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8497. utils.ErrorLog("解析失败:%v", err)
  8498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8499. return
  8500. }
  8501. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8502. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8503. var cert_no string
  8504. if his.IdCardType == 1 {
  8505. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8506. } else if his.IdCardType == 2 {
  8507. cert_no = his.IdCardNo
  8508. } else {
  8509. cert_no = psn_info.VerifyNumber
  8510. }
  8511. 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, "")
  8512. var dat map[string]interface{}
  8513. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8514. fmt.Println(dat)
  8515. } else {
  8516. fmt.Println(err)
  8517. }
  8518. saveLog(result2, src_resquest, "2207", "结算")
  8519. userJSONBytes, _ := json.Marshal(dat)
  8520. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8521. utils.ErrorLog("解析失败:%v", err)
  8522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8523. return
  8524. }
  8525. } else {
  8526. var src_resquest string
  8527. if miConfig.Code == "H15049901371" {
  8528. //赤峰地区国家医保医疗类别
  8529. //职工透析:医疗类别选特殊情况门诊990502
  8530. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8531. var med_type string
  8532. if his.Insutype == "390" {
  8533. if reg_type == 14 {
  8534. med_type = "9933"
  8535. } else if reg_type == 11 {
  8536. med_type = "11"
  8537. }
  8538. } else if his.Insutype == "310" {
  8539. if reg_type == 14 {
  8540. med_type = "990502"
  8541. } else if reg_type == 11 {
  8542. med_type = "11"
  8543. }
  8544. }
  8545. 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, "")
  8546. } else {
  8547. if his.IdCardType == 4 {
  8548. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8549. token := psn_info.VerifyNumber
  8550. 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)
  8551. } else {
  8552. 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, "")
  8553. }
  8554. }
  8555. var dat map[string]interface{}
  8556. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8557. fmt.Println(dat)
  8558. } else {
  8559. fmt.Println(err)
  8560. }
  8561. saveLog(result2, src_resquest, "2207", "结算")
  8562. userJSONBytes, _ := json.Marshal(dat)
  8563. if miConfig.Code == "H15049901371" {
  8564. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8565. utils.ErrorLog("解析失败:%v", err)
  8566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8567. return
  8568. }
  8569. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8570. res.Output = resSeven10265.Output
  8571. res.ErrMsg = resSeven10265.ErrMsg
  8572. res.Cainfo = resSeven10265.Cainfo
  8573. res.WarnMsg = resSeven10265.WarnMsg
  8574. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8575. res.Infcode = infocode
  8576. } else {
  8577. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8578. utils.ErrorLog("解析失败:%v", err)
  8579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8580. return
  8581. }
  8582. }
  8583. }
  8584. if res.Infcode != 0 {
  8585. errlog := &models.HisOrderError{
  8586. UserOrgId: adminUser.CurrentOrgId,
  8587. Ctime: time.Now().Unix(),
  8588. Mtime: time.Now().Unix(),
  8589. Number: chrg_bchno,
  8590. ErrMsg: res.ErrMsg,
  8591. Status: 1,
  8592. PatientId: id,
  8593. RecordTime: recordDateTime,
  8594. Stage: 6,
  8595. }
  8596. service.CreateErrMsgLog(errlog)
  8597. c.ServeSuccessJSON(map[string]interface{}{
  8598. "failed_code": -10,
  8599. "msg": res.ErrMsg,
  8600. })
  8601. return
  8602. } else {
  8603. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8604. order.OrderStatus = 2
  8605. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8606. order.SetlId = res.Output.Setlinfo.SetlID
  8607. order.PsnNo = res.Output.Setlinfo.PsnNo
  8608. order.PsnName = res.Output.Setlinfo.PsnName
  8609. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8610. order.Certno = res.Output.Setlinfo.Certno
  8611. order.Gend = res.Output.Setlinfo.Gend
  8612. order.Naty = res.Output.Setlinfo.Naty
  8613. order.Age = res.Output.Setlinfo.Age
  8614. order.Insutype = res.Output.Setlinfo.Insutype
  8615. order.PsnType = res.Output.Setlinfo.PsnType
  8616. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8617. order.SetlTime = res.Output.Setlinfo.SetlTime
  8618. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8619. //order.MedType = res.Output.Setlinfo.MedType
  8620. if reg_type == 1112 {
  8621. order.MedType = "1112"
  8622. }
  8623. if reg_type == 1111 {
  8624. order.MedType = "1111"
  8625. }
  8626. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8627. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8628. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8629. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8630. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8631. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8632. order.HifpPay = res.Output.Setlinfo.HifpPay
  8633. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8634. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8635. order.HifesPay = res.Output.Setlinfo.HifesPay
  8636. order.HifobPay = res.Output.Setlinfo.HifobPay
  8637. order.MafPay = res.Output.Setlinfo.MafPay
  8638. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8639. order.OthPay = res.Output.Setlinfo.OthPay
  8640. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8641. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8642. order.AcctPay = res.Output.Setlinfo.AcctPay
  8643. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8644. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8645. order.Balc = res.Output.Setlinfo.Balc
  8646. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8647. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8648. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8649. order.ClrWay = res.Output.Setlinfo.ClrWay
  8650. order.Creator = order.Creator
  8651. order.Modify = roles.AdminUserId
  8652. order.RequestLog = src_resquest
  8653. order.Diagnosis = diagnosis_id
  8654. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8655. detailStr := string(setlDetail)
  8656. order.SetlDetail = detailStr
  8657. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8658. err = service.UpDateOrder(order)
  8659. if err == nil {
  8660. //判断是否使用了押金
  8661. if dec_way == "true" {
  8662. tmpstring := strconv.FormatInt(order.ID, 10)
  8663. //扣押金
  8664. order.Decimal = decimal
  8665. service.UpDateOrder(order)
  8666. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8667. if errmsg != nil {
  8668. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8669. return
  8670. }
  8671. }
  8672. c.ServeSuccessJSON(map[string]interface{}{
  8673. "msg": "结算成功",
  8674. })
  8675. } else {
  8676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8677. return
  8678. }
  8679. }
  8680. }
  8681. }
  8682. }
  8683. //func (c *HisApiController) GetPreUploadInfo() {
  8684. // id, _ := c.GetInt64("id")
  8685. // record_time := c.GetString("record_time")
  8686. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8687. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8688. //
  8689. // timeLayout := "2006-01-02"
  8690. // loc, _ := time.LoadLocation("Local")
  8691. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8692. // if err != nil {
  8693. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8694. // return
  8695. // }
  8696. // recordDateTime := theTime.Unix()
  8697. // adminUser := c.GetAdminUserInfo()
  8698. //
  8699. // var prescriptions []*models.HisPrescription
  8700. //
  8701. // var start_time int64
  8702. // var end_time int64
  8703. //
  8704. // data := make(map[string]interface{})
  8705. // if settle_accounts_type == 1 { //日结
  8706. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  8707. // data["pre"] = prescriptions
  8708. //
  8709. // } else { //月结
  8710. // start_time_str := c.GetString("start_time")
  8711. // end_time_str := c.GetString("end_time")
  8712. // timeLayout := "2006-01-02"
  8713. // loc, _ := time.LoadLocation("Local")
  8714. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  8715. // if err != nil {
  8716. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8717. // return
  8718. // }
  8719. // recordStartTime := theStartTime.Unix()
  8720. // start_time = recordStartTime
  8721. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8722. // if err != nil {
  8723. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8724. // return
  8725. // }
  8726. // recordEndTime := theEndTime.Unix()
  8727. // end_time = recordEndTime
  8728. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  8729. // data["pre"] = prescriptions
  8730. //
  8731. // }
  8732. //
  8733. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8734. //
  8735. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8736. // timestamp := time.Now().Unix()
  8737. // tempTime := time.Unix(timestamp, 0)
  8738. // timeFormat := tempTime.Format("20060102150405")
  8739. // chrgBchno := rand.Intn(100000) + 10000
  8740. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8741. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8742. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8743. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8744. // strconv.FormatInt(his.PatientId, 10)
  8745. // client := &http.Client{}
  8746. // data["psn_no"] = his.PsnNo
  8747. // data["mdtrt_id"] = his.Number
  8748. // data["chrg_bchno"] = chrg_bchno
  8749. // data["org_name"] = miConfig.OrgName
  8750. // data["doctor"] = roles.UserName
  8751. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  8752. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  8753. // data["fixmedins_code"] = miConfig.Code
  8754. // data["dept_code"] = department.Number
  8755. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  8756. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8757. // data["secret_key"] = miConfig.SecretKey
  8758. // var ids []int64
  8759. //
  8760. // for _, item := range prescriptions {
  8761. // ids = append(ids, item.ID)
  8762. // }
  8763. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8764. // if config.IsOpen == 1 { //对接了医保,走医保流程
  8765. // bytesData, _ := json.Marshal(data)
  8766. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  8767. // resp, _ := client.Do(req)
  8768. // defer resp.Body.Close()
  8769. // body, ioErr := ioutil.ReadAll(resp.Body)
  8770. // if ioErr != nil {
  8771. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8772. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8773. // return
  8774. // }
  8775. // var respJSON map[string]interface{}
  8776. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8777. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8778. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8779. // return
  8780. // }
  8781. //
  8782. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8783. // userJSONBytes, _ := json.Marshal(respJSON)
  8784. // var res ResultFour
  8785. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8786. // utils.ErrorLog("解析失败:%v", err)
  8787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8788. // return
  8789. // }
  8790. //
  8791. // if res.Infcode == 0 {
  8792. // order := &models.HisOrder{
  8793. // UserOrgId: adminUser.CurrentOrgId,
  8794. // HisPatientId: his.ID,
  8795. // PatientId: his.PatientId,
  8796. // SettleAccountsDate: recordDateTime,
  8797. // Ctime: time.Now().Unix(),
  8798. // Mtime: time.Now().Unix(),
  8799. // Status: 1,
  8800. // Number: chrg_bchno,
  8801. // Infcode: res.Infcode,
  8802. // WarnMsg: res.WarnMsg,
  8803. // Cainfo: res.Cainfo,
  8804. // ErrMsg: res.ErrMsg,
  8805. // RespondTime: res.RefmsgTime,
  8806. // InfRefmsgid: res.InfRefmsgid,
  8807. // OrderStatus: 1,
  8808. // IsMedicineInsurance: 1,
  8809. // SettleType: settle_accounts_type,
  8810. // SettleStartTime: start_time,
  8811. // SettleEndTime: end_time,
  8812. // Creator: roles.ID,
  8813. // Modify: roles.ID,
  8814. // PType: 2,
  8815. // }
  8816. // err = service.CreateOrder(order)
  8817. // if err != nil {
  8818. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8819. // return
  8820. // }
  8821. //
  8822. // for _, item := range res.Output.Result {
  8823. // temp := strings.Split(item.FeedetlSn, "-")
  8824. // var advice_id int64 = 0
  8825. // var project_id int64 = 0
  8826. // var types int64 = 0
  8827. //
  8828. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  8829. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  8830. //
  8831. // if temp[1] == "1" {
  8832. // advice_id = id
  8833. // project_id = 0
  8834. // } else if temp[1] == "2" {
  8835. // advice_id = 0
  8836. // project_id = id
  8837. // }
  8838. //
  8839. // info := &models.HisOrderInfo{
  8840. // OrderNumber: order.Number,
  8841. // FeedetlSn: item.FeedetlSn,
  8842. // UploadDate: time.Now().Unix(),
  8843. // AdviceId: advice_id,
  8844. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  8845. // Cnt: item.Cnt,
  8846. // Pric: float64(item.Pric),
  8847. // PatientId: his.PatientId,
  8848. // PricUplmtAmt: item.PricUplmtAmt,
  8849. // SelfpayProp: item.SelfpayProp,
  8850. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8851. // OverlmtAmt: item.OverlmtAmt,
  8852. // PreselfpayAmt: item.PreselfpayAmt,
  8853. // BasMednFlag: item.BasMednFlag,
  8854. // MedChrgitmType: item.MedChrgitmType,
  8855. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  8856. // Status: 1,
  8857. // Memo: item.Memo,
  8858. // Mtime: time.Now().Unix(),
  8859. // InscpScpAmt: item.InscpScpAmt,
  8860. // DrtReimFlag: item.DrtReimFlag,
  8861. // Ctime: time.Now().Unix(),
  8862. // ListSpItemFlag: item.ListSpItemFlag,
  8863. // ChldMedcFlag: item.ChldMedcFlag,
  8864. // LmtUsedFlag: item.LmtUsedFlag,
  8865. // ChrgitmLv: item.ChrgitmLv,
  8866. // UserOrgId: adminUser.CurrentOrgId,
  8867. // HisPatientId: his.ID,
  8868. // OrderId: order.ID,
  8869. // ProjectId: project_id,
  8870. // Type: types,
  8871. // }
  8872. // service.CreateOrderInfo(info)
  8873. //
  8874. // }
  8875. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8876. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  8877. //
  8878. // var total float64
  8879. // for _, item := range prescriptions {
  8880. // if item.Type == 1 { //药品
  8881. // for _, subItem := range item.HisDoctorAdviceInfo {
  8882. // total = total + (subItem.Price * subItem.PrescribingNumber)
  8883. // }
  8884. // }
  8885. // if item.Type == 2 { //项目
  8886. // for _, subItem := range item.HisPrescriptionProject {
  8887. // total = total + (subItem.Price * float64(subItem.Count))
  8888. // }
  8889. // }
  8890. // }
  8891. //
  8892. // for _, item := range prescriptions {
  8893. // for _, subItem := range item.HisAdditionalCharge {
  8894. // total = total + (subItem.Price * float64(subItem.Count))
  8895. // }
  8896. // }
  8897. //
  8898. // allTotal := fmt.Sprintf("%.2f", total)
  8899. // if res.Infcode == 0 {
  8900. // var rf []*ResultFive
  8901. // json.Unmarshal([]byte(his.Iinfo), &rf)
  8902. // psn_no := his.PsnNo
  8903. // mdtrt_id := his.Number
  8904. // chrg_bchno := chrg_bchno
  8905. // cert_no := his.Certno
  8906. // insutype := rf[0].Insutype
  8907. //
  8908. // if his.IdCardType == 1 {
  8909. // cert_no = his.MedicalInsuranceNumber
  8910. //
  8911. // } else {
  8912. //
  8913. // cert_no = his.Certno
  8914. //
  8915. // }
  8916. //
  8917. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  8918. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  8919. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  8920. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  8921. // resp, requestErr := http.Get(api)
  8922. // if requestErr != nil {
  8923. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8924. // return
  8925. // }
  8926. // defer resp.Body.Close()
  8927. // body, ioErr := ioutil.ReadAll(resp.Body)
  8928. // if ioErr != nil {
  8929. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8930. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8931. // return
  8932. // }
  8933. // var respJSON map[string]interface{}
  8934. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8935. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8937. // return
  8938. // }
  8939. // fmt.Println(respJSON)
  8940. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8941. // userJSONBytes, _ := json.Marshal(respJSON)
  8942. // var res ResultSeven
  8943. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8944. // utils.ErrorLog("解析失败:%v", err)
  8945. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8946. // return
  8947. // }
  8948. // if res.Infcode != 0 {
  8949. // errlog := &models.HisOrderError{
  8950. // UserOrgId: adminUser.CurrentOrgId,
  8951. // Ctime: time.Now().Unix(),
  8952. // Mtime: time.Now().Unix(),
  8953. // Number: chrg_bchno,
  8954. // ErrMsg: res.ErrMsg,
  8955. // Status: 1,
  8956. // PatientId: id,
  8957. // RecordTime: recordDateTime,
  8958. // Stage: 7,
  8959. // }
  8960. // service.CreateErrMsgLog(errlog)
  8961. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8962. // return
  8963. // } else {
  8964. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8965. // order.OrderStatus = 1
  8966. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8967. // order.SetlId = res.Output.Setlinfo.SetlID
  8968. // order.PsnNo = res.Output.Setlinfo.PsnNo
  8969. // order.PsnName = res.Output.Setlinfo.PsnName
  8970. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8971. // order.Certno = res.Output.Setlinfo.Certno
  8972. // order.Gend = res.Output.Setlinfo.Gend
  8973. // order.Naty = res.Output.Setlinfo.Naty
  8974. // order.Age = res.Output.Setlinfo.Age
  8975. // order.Insutype = res.Output.Setlinfo.Insutype
  8976. // order.PsnType = res.Output.Setlinfo.PsnType
  8977. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8978. // order.SetlTime = res.Output.Setlinfo.SetlTime
  8979. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8980. // order.MedType = res.Output.Setlinfo.MedType
  8981. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8982. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8983. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8984. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8985. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8986. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8987. // order.HifpPay = res.Output.Setlinfo.HifpPay
  8988. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8989. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8990. // order.HifesPay = res.Output.Setlinfo.HifesPay
  8991. // order.HifobPay = res.Output.Setlinfo.HifobPay
  8992. // order.MafPay = res.Output.Setlinfo.MafPay
  8993. // order.OthPay = res.Output.Setlinfo.OthPay
  8994. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8995. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8996. // order.AcctPay = res.Output.Setlinfo.AcctPay
  8997. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8998. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8999. // order.Balc = res.Output.Setlinfo.Balc
  9000. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9001. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9002. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9003. // order.ClrWay = res.Output.Setlinfo.ClrWay
  9004. // order.Creator = order.Creator
  9005. // order.Modify = roles.ID
  9006. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9007. // detailStr := string(setlDetail)
  9008. // order.SetlDetail = detailStr
  9009. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9010. // err = service.UpDateOrder(order)
  9011. // if err == nil {
  9012. // c.ServeSuccessJSON(map[string]interface{}{
  9013. // "msg": "预结算成功",
  9014. // })
  9015. // } else {
  9016. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9017. // return
  9018. // }
  9019. // }
  9020. // } else {
  9021. // adminUser := c.GetAdminUserInfo()
  9022. // errlog := &models.HisOrderError{
  9023. // UserOrgId: adminUser.CurrentOrgId,
  9024. // Ctime: time.Now().Unix(),
  9025. // Mtime: time.Now().Unix(),
  9026. // ErrMsg: res.ErrMsg,
  9027. // Status: 1,
  9028. // PatientId: id,
  9029. // RecordTime: recordDateTime,
  9030. // Stage: 4,
  9031. // }
  9032. // service.CreateErrMsgLog(errlog)
  9033. //
  9034. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9035. // return
  9036. // }
  9037. // } else {
  9038. // adminUser := c.GetAdminUserInfo()
  9039. // errlog := &models.HisOrderError{
  9040. // UserOrgId: adminUser.CurrentOrgId,
  9041. // Ctime: time.Now().Unix(),
  9042. // Mtime: time.Now().Unix(),
  9043. // ErrMsg: res.ErrMsg,
  9044. // Status: 1,
  9045. // PatientId: id,
  9046. // RecordTime: recordDateTime,
  9047. // Stage: 4,
  9048. // }
  9049. // service.CreateErrMsgLog(errlog)
  9050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  9051. // return
  9052. // }
  9053. //
  9054. // } else {
  9055. // var total float64
  9056. // for _, item := range prescriptions {
  9057. // if item.Type == 1 { //药品
  9058. // for _, subItem := range item.HisDoctorAdviceInfo {
  9059. // total = total + (subItem.Price * subItem.PrescribingNumber)
  9060. // }
  9061. // }
  9062. // if item.Type == 2 { //项目
  9063. // for _, subItem := range item.HisPrescriptionProject {
  9064. // total = total + (subItem.Price * float64(subItem.Count))
  9065. // }
  9066. // }
  9067. //
  9068. // for _, subItem := range item.HisAdditionalCharge {
  9069. // total = total + (subItem.Price * float64(subItem.Count))
  9070. // }
  9071. // }
  9072. //
  9073. // allTotal := fmt.Sprintf("%.2f", total)
  9074. // totals, _ := strconv.ParseFloat(allTotal, 64)
  9075. // order := &models.HisOrder{
  9076. // UserOrgId: adminUser.CurrentOrgId,
  9077. // HisPatientId: his.ID,
  9078. // PatientId: id,
  9079. // SettleAccountsDate: recordDateTime,
  9080. // Ctime: time.Now().Unix(),
  9081. // Mtime: time.Now().Unix(),
  9082. // Status: 1,
  9083. // OrderStatus: 2,
  9084. // Number: chrg_bchno,
  9085. // MedfeeSumamt: totals,
  9086. // }
  9087. // err = service.CreateOrder(order)
  9088. // if err != nil {
  9089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9090. // return
  9091. // }
  9092. //
  9093. // var customs []*Custom
  9094. // for _, item := range prescriptions {
  9095. //
  9096. // if item.Type == 1 { //药品
  9097. // for _, subItem := range item.HisDoctorAdviceInfo {
  9098. // cus := &Custom{
  9099. // AdviceId: subItem.ID,
  9100. // ProjectId: 0,
  9101. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  9102. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  9103. // FeedetlSn: subItem.FeedetlSn,
  9104. // Price: fmt.Sprintf("%.2f", subItem.Price),
  9105. // MedListCodg: subItem.MedListCodg,
  9106. // Type: 1,
  9107. // }
  9108. // customs = append(customs, cus)
  9109. // }
  9110. // }
  9111. //
  9112. // if item.Type == 2 { //项目
  9113. // for _, subItem := range item.HisPrescriptionProject {
  9114. //
  9115. // cus := &Custom{
  9116. // AdviceId: 0,
  9117. // ProjectId: subItem.ID,
  9118. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  9119. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  9120. // FeedetlSn: subItem.FeedetlSn,
  9121. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  9122. // MedListCodg: subItem.MedListCodg,
  9123. // Type: 2,
  9124. // }
  9125. //
  9126. // customs = append(customs, cus)
  9127. // }
  9128. // }
  9129. //
  9130. // for _, item := range item.HisAdditionalCharge {
  9131. // cus := &Custom{
  9132. // ItemId: item.ID,
  9133. // AdviceId: 0,
  9134. // ProjectId: 0,
  9135. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  9136. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  9137. // FeedetlSn: item.FeedetlSn,
  9138. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  9139. // MedListCodg: item.XtHisAddtionConfig.Code,
  9140. // Type: 3,
  9141. // }
  9142. //
  9143. // customs = append(customs, cus)
  9144. // }
  9145. //
  9146. // }
  9147. //
  9148. // for _, item := range customs {
  9149. // var advice_id int64 = 0
  9150. // var project_id int64 = 0
  9151. // var item_id int64 = 0
  9152. //
  9153. // var types int64 = 0
  9154. //
  9155. // if item.Type == 1 {
  9156. // advice_id = item.AdviceId
  9157. // project_id = 0
  9158. // item_id = 0
  9159. // } else if item.Type == 2 {
  9160. // advice_id = 0
  9161. // item_id = 0
  9162. //
  9163. // project_id = item.ProjectId
  9164. // } else if item.Type == 3 {
  9165. // advice_id = 0
  9166. // item_id = item.ItemId
  9167. // project_id = 0
  9168. // }
  9169. //
  9170. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  9171. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  9172. // pric, _ := strconv.ParseFloat(item.Price, 32)
  9173. //
  9174. // info := &models.HisOrderInfo{
  9175. // OrderNumber: order.Number,
  9176. // UploadDate: time.Now().Unix(),
  9177. // AdviceId: advice_id,
  9178. // DetItemFeeSumamt: detItemFeeSumamt,
  9179. // Cnt: cut,
  9180. // Pric: pric,
  9181. // PatientId: id,
  9182. // Status: 1,
  9183. // Mtime: time.Now().Unix(),
  9184. // Ctime: time.Now().Unix(),
  9185. // UserOrgId: adminUser.CurrentOrgId,
  9186. // HisPatientId: his.ID,
  9187. // OrderId: order.ID,
  9188. // ProjectId: project_id,
  9189. // Type: types,
  9190. // ItemId: item_id,
  9191. // }
  9192. // service.CreateOrderInfo(info)
  9193. // }
  9194. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9195. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9196. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  9197. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9198. // if err == nil {
  9199. // c.ServeSuccessJSON(map[string]interface{}{
  9200. // "msg": "结算成功",
  9201. // })
  9202. // } else {
  9203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9204. // return
  9205. // }
  9206. // }
  9207. //}
  9208. //上传明细-预结算-
  9209. func (c *HisApiController) GetPreUploadInfo() {
  9210. id, _ := c.GetInt64("id")
  9211. record_time := c.GetString("record_time")
  9212. his_patient_id, _ := c.GetInt64("his_patient_id")
  9213. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9214. admin_user_id, _ := c.GetInt64("admin_user_id")
  9215. diagnosis_id := c.GetString("diagnosis")
  9216. sick_type, _ := c.GetInt64("sick_type")
  9217. reg_type, _ := c.GetInt64("p_type")
  9218. begin_time := c.GetString("begin_time")
  9219. id_str := c.GetString("ids")
  9220. ids_arr := strings.Split(id_str, ",")
  9221. timeLayout := "2006-01-02"
  9222. loc, _ := time.LoadLocation("Local")
  9223. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9224. if err != nil {
  9225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9226. return
  9227. }
  9228. recordDateTime := theTime.Unix()
  9229. adminUser := c.GetAdminUserInfo()
  9230. diagnosis_ids := strings.Split(diagnosis_id, ",")
  9231. var config []*models.HisXtDiagnoseConfig
  9232. for _, item := range diagnosis_ids {
  9233. id, _ := strconv.ParseInt(item, 10, 64)
  9234. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9235. config = append(config, &diagnosisConfig)
  9236. }
  9237. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9238. sickConfig, _ := service.FindSickById(sick_type)
  9239. var prescriptions []*models.HisPrescription
  9240. var start_time int64
  9241. var end_time int64
  9242. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9243. fmt.Println(his_patient_id)
  9244. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9245. timestamp := time.Now().Unix()
  9246. tempTime := time.Unix(timestamp, 0)
  9247. timeFormat := tempTime.Format("20060102150405")
  9248. chrgBchno := rand.Intn(100000) + 10000
  9249. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9250. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9251. var patientPrescription models.HisPrescriptionInfo
  9252. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9253. if patientPrescription.ID == 0 {
  9254. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9255. }
  9256. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9257. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9258. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9259. strconv.FormatInt(his.PatientId, 10)
  9260. var res2 ResultSix
  9261. var resSix10265 ResultSix10265
  9262. //var time_stamp string
  9263. if miConfig.MdtrtareaAdmvs == "421300" {
  9264. data := make(map[string]interface{})
  9265. client := &http.Client{}
  9266. data["psn_no"] = his.PsnNo
  9267. data["mdtrt_id"] = his.Number
  9268. data["department"] = department.Name
  9269. data["org_name"] = miConfig.OrgName
  9270. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9271. data["doctor_id"] = doctor_info.DoctorNumber
  9272. data["doctor_name"] = roles.UserName
  9273. data["fixmedins_code"] = miConfig.Code
  9274. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  9275. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9276. data["secret_key"] = miConfig.SecretKey
  9277. data["sick_code"] = sickConfig.CountryCode
  9278. data["sick_name"] = sickConfig.ClassName
  9279. data["begin_time"] = begin_time
  9280. data["dept"] = strconv.FormatInt(department.ID, 10)
  9281. data["config"] = config
  9282. data["opter"] = roles.UserName
  9283. fmt.Println(data)
  9284. bytesData, _ := json.Marshal(data)
  9285. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  9286. resp, _ := client.Do(req)
  9287. defer resp.Body.Close()
  9288. body, ioErr := ioutil.ReadAll(resp.Body)
  9289. if ioErr != nil {
  9290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9292. return
  9293. }
  9294. var respJSON map[string]interface{}
  9295. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9298. return
  9299. }
  9300. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9301. userJSONBytes, _ := json.Marshal(respJSON)
  9302. fmt.Println("log")
  9303. fmt.Println(string(userJSONBytes))
  9304. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9305. utils.ErrorLog("解析失败:%v", err)
  9306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9307. return
  9308. }
  9309. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9310. data := make(map[string]interface{})
  9311. client := &http.Client{}
  9312. data["psn_no"] = his.PsnNo
  9313. data["mdtrt_id"] = his.Number
  9314. data["doctor"] = roles.UserName
  9315. data["department"] = department.Name
  9316. data["org_name"] = miConfig.OrgName
  9317. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9318. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  9319. data["fixmedins_code"] = miConfig.Code
  9320. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9321. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9322. data["secret_key"] = miConfig.SecretKey
  9323. data["sick_code"] = sickConfig.CountryCode
  9324. data["sick_name"] = sickConfig.ClassName
  9325. data["begin_time"] = begin_time
  9326. data["dept"] = strconv.FormatInt(department.ID, 10)
  9327. data["config"] = config
  9328. data["url"] = miConfig.Url
  9329. data["ak"] = miConfig.AccessKey
  9330. data["cainfo"] = miConfig.Cainfo
  9331. bytesData, _ := json.Marshal(data)
  9332. var req *http.Request
  9333. if miConfig.MdtrtareaAdmvs == "320921" {
  9334. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9335. } else {
  9336. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9337. }
  9338. resp, _ := client.Do(req)
  9339. defer resp.Body.Close()
  9340. body, ioErr := ioutil.ReadAll(resp.Body)
  9341. if ioErr != nil {
  9342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9344. return
  9345. }
  9346. var respJSON map[string]interface{}
  9347. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9350. return
  9351. }
  9352. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  9353. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  9354. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  9355. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9356. userJSONBytes, _ := json.Marshal(respJSON)
  9357. fmt.Println("log")
  9358. fmt.Println(string(userJSONBytes))
  9359. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  9360. utils.ErrorLog("解析失败:%v", err)
  9361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9362. return
  9363. }
  9364. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9365. res2.Output = resSix10265.Output
  9366. res2.ErrMsg = resSix10265.ErrMsg
  9367. res2.Cainfo = resSix10265.Cainfo
  9368. res2.WarnMsg = resSix10265.WarnMsg
  9369. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9370. res2.Infcode = infocode
  9371. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9372. 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)
  9373. saveLog(result, requestLog, "2203", "上传就诊信息")
  9374. var respJSON2 map[string]interface{}
  9375. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9378. return
  9379. }
  9380. userJSONBytes2, _ := json.Marshal(respJSON2)
  9381. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9382. utils.ErrorLog("解析失败:%v", err)
  9383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9384. return
  9385. }
  9386. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9387. var result string
  9388. var requestLog string
  9389. 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, "")
  9390. saveLog(result, requestLog, "2203", "上传就诊信息")
  9391. var respJSON2 map[string]interface{}
  9392. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9395. return
  9396. }
  9397. userJSONBytes2, _ := json.Marshal(respJSON2)
  9398. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9399. utils.ErrorLog("解析失败:%v", err)
  9400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9401. return
  9402. }
  9403. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9404. var result string
  9405. var requestLog string
  9406. 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, "")
  9407. saveLog(result, requestLog, "2203", "上传就诊信息")
  9408. var respJSON2 map[string]interface{}
  9409. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9412. return
  9413. }
  9414. userJSONBytes2, _ := json.Marshal(respJSON2)
  9415. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9416. utils.ErrorLog("解析失败:%v", err)
  9417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9418. return
  9419. }
  9420. } else {
  9421. var result string
  9422. var requestLog string
  9423. if miConfig.MdtrtareaAdmvs == "440781" { //
  9424. 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)
  9425. } else {
  9426. if miConfig.Code == "H15049901371" {
  9427. //赤峰地区国家医保医疗类别
  9428. //职工透析:医疗类别选特殊情况门诊990502
  9429. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9430. var med_type string
  9431. if his.Insutype == "390" {
  9432. if reg_type == 14 {
  9433. med_type = "9933"
  9434. } else if reg_type == 11 {
  9435. med_type = "11"
  9436. }
  9437. } else if his.Insutype == "310" {
  9438. if reg_type == 14 {
  9439. med_type = "990502"
  9440. } else if reg_type == 11 {
  9441. med_type = "11"
  9442. }
  9443. }
  9444. 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)
  9445. } else {
  9446. 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)
  9447. }
  9448. saveLog(result, requestLog, "2203", "上传就诊信息")
  9449. var respJSON2 map[string]interface{}
  9450. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9453. return
  9454. }
  9455. userJSONBytes2, _ := json.Marshal(respJSON2)
  9456. if miConfig.Code == "H15049901371" {
  9457. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  9458. utils.ErrorLog("解析失败:%v", err)
  9459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9460. return
  9461. }
  9462. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9463. res2.Output = resSix10265.Output
  9464. res2.ErrMsg = resSix10265.ErrMsg
  9465. res2.Cainfo = resSix10265.Cainfo
  9466. res2.WarnMsg = resSix10265.WarnMsg
  9467. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9468. res2.Infcode = infocode
  9469. } else {
  9470. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9471. utils.ErrorLog("解析失败:%v", err)
  9472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9473. return
  9474. }
  9475. }
  9476. }
  9477. }
  9478. if res2.Infcode != 0 {
  9479. adminUser := c.GetAdminUserInfo()
  9480. errlog := &models.HisOrderError{
  9481. UserOrgId: adminUser.CurrentOrgId,
  9482. Ctime: time.Now().Unix(),
  9483. Mtime: time.Now().Unix(),
  9484. ErrMsg: res2.ErrMsg,
  9485. Status: 1,
  9486. PatientId: id,
  9487. RecordTime: recordDateTime,
  9488. Stage: 3,
  9489. }
  9490. service.CreateErrMsgLog(errlog)
  9491. c.ServeSuccessJSON(map[string]interface{}{
  9492. "failed_code": -10,
  9493. "msg": res2.ErrMsg,
  9494. })
  9495. return
  9496. } else {
  9497. his.Diagnosis = diagnosis_id
  9498. his.SickType = sickConfig.ID
  9499. his.PType = fmt.Sprintf("%d", reg_type)
  9500. service.UpdateHisPatientThree(&his)
  9501. data := make(map[string]interface{})
  9502. if settle_accounts_type == 1 { //日结
  9503. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  9504. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  9505. } else {
  9506. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  9507. }
  9508. data["pre"] = prescriptions
  9509. } else { //月结
  9510. start_time_str := c.GetString("start_time")
  9511. end_time_str := c.GetString("end_time")
  9512. timeLayout := "2006-01-02"
  9513. loc, _ := time.LoadLocation("Local")
  9514. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9515. if err != nil {
  9516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9517. return
  9518. }
  9519. recordStartTime := theStartTime.Unix()
  9520. start_time = recordStartTime
  9521. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9522. if err != nil {
  9523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9524. return
  9525. }
  9526. recordEndTime := theEndTime.Unix()
  9527. end_time = recordEndTime
  9528. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  9529. data["pre"] = prescriptions
  9530. }
  9531. client := &http.Client{}
  9532. data["psn_no"] = his.PsnNo
  9533. data["mdtrt_id"] = his.Number
  9534. data["chrg_bchno"] = chrg_bchno
  9535. data["org_name"] = miConfig.OrgName
  9536. data["doctor"] = doctor_info.UserName
  9537. data["doctor_id"] = doctor_info.DoctorNumber
  9538. data["dept"] = department.Name
  9539. data["fixmedins_code"] = miConfig.Code
  9540. data["opter"] = roles.UserName
  9541. data["dept_code"] = department.Number
  9542. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9543. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9544. data["secret_key"] = miConfig.SecretKey
  9545. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  9546. data["url"] = miConfig.Url
  9547. data["ak"] = miConfig.AccessKey
  9548. data["new_doctor_name"] = patientPrescription.Doctor
  9549. data["diag_code"] = sickConfig.CountryCode
  9550. data["cainfo"] = miConfig.Cainfo
  9551. data["opter"] = roles.UserName
  9552. var ids []int64
  9553. for _, item := range prescriptions {
  9554. ids = append(ids, item.ID)
  9555. }
  9556. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9557. if config.IsOpen == 1 { //对接了医保,走医保流程
  9558. var res ResultFour
  9559. var resFour10265 ResultFour10265
  9560. if miConfig.MdtrtareaAdmvs == "421300" {
  9561. bytesData, _ := json.Marshal(data)
  9562. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  9563. resp, _ := client.Do(req)
  9564. defer resp.Body.Close()
  9565. body, ioErr := ioutil.ReadAll(resp.Body)
  9566. if ioErr != nil {
  9567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9569. return
  9570. }
  9571. var respJSON map[string]interface{}
  9572. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9575. return
  9576. }
  9577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9578. userJSONBytes, _ := json.Marshal(respJSON)
  9579. fmt.Println("log")
  9580. fmt.Println(string(userJSONBytes))
  9581. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9582. utils.ErrorLog("解析失败:%v", err)
  9583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9584. return
  9585. }
  9586. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9587. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  9588. if result3101.Infcode == "0" {
  9589. if len(result3101.Output.Result) > 0 {
  9590. var errMsgs []string
  9591. for _, item := range result3101.Output.Result {
  9592. errMsgs = append(errMsgs, item.VolaCont)
  9593. }
  9594. c.ServeSuccessJSON(map[string]interface{}{
  9595. "failed_code": -10,
  9596. "msg": errMsgs,
  9597. })
  9598. return
  9599. } else {
  9600. if miConfig.MdtrtareaAdmvs == "320921" {
  9601. data["doctor_id"] = "D320923012139"
  9602. } else {
  9603. data["doctor_id"] = "D371621008686"
  9604. }
  9605. bytesData, _ := json.Marshal(data)
  9606. var req *http.Request
  9607. if miConfig.MdtrtareaAdmvs == "320921" {
  9608. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9609. } else {
  9610. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9611. }
  9612. resp, _ := client.Do(req)
  9613. defer resp.Body.Close()
  9614. body, ioErr := ioutil.ReadAll(resp.Body)
  9615. if ioErr != nil {
  9616. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9618. return
  9619. }
  9620. var respJSON map[string]interface{}
  9621. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9622. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9624. return
  9625. }
  9626. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9627. userJSONBytes, _ := json.Marshal(respJSON)
  9628. fmt.Println("log")
  9629. fmt.Println(string(userJSONBytes))
  9630. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9631. utils.ErrorLog("解析失败:%v", err)
  9632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9633. return
  9634. }
  9635. res.InfRefmsgid = resFour10265.InfRefmsgid
  9636. res.Output = resFour10265.Output
  9637. res.ErrMsg = resFour10265.ErrMsg
  9638. res.Cainfo = resFour10265.Cainfo
  9639. res.WarnMsg = resFour10265.WarnMsg
  9640. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9641. res.Infcode = infocode
  9642. }
  9643. }
  9644. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9645. 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)
  9646. var dat map[string]interface{}
  9647. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9648. fmt.Println(dat)
  9649. } else {
  9650. fmt.Println(err)
  9651. }
  9652. saveLog(result, request_log, "2204", "上传费用明细")
  9653. userJSONBytes, _ := json.Marshal(dat)
  9654. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9655. utils.ErrorLog("解析失败:%v", err)
  9656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9657. return
  9658. }
  9659. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9660. 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, "", "")
  9661. var dat map[string]interface{}
  9662. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9663. fmt.Println(dat)
  9664. } else {
  9665. fmt.Println(err)
  9666. }
  9667. saveLog(result, request_log, "2204", "上传费用明细")
  9668. userJSONBytes, _ := json.Marshal(dat)
  9669. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9670. utils.ErrorLog("解析失败:%v", err)
  9671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9672. return
  9673. }
  9674. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9675. 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, "", "")
  9676. var dat map[string]interface{}
  9677. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9678. fmt.Println(dat)
  9679. } else {
  9680. fmt.Println(err)
  9681. }
  9682. saveLog(result, request_log, "2204", "上传费用明细")
  9683. userJSONBytes, _ := json.Marshal(dat)
  9684. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9685. utils.ErrorLog("解析失败:%v", err)
  9686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9687. return
  9688. }
  9689. } else {
  9690. if miConfig.Code == "H15049901371" {
  9691. 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)
  9692. var dat map[string]interface{}
  9693. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9694. fmt.Println(dat)
  9695. } else {
  9696. fmt.Println(err)
  9697. }
  9698. saveLog(result, request_log, "2204", "上传费用明细")
  9699. userJSONBytes, _ := json.Marshal(dat)
  9700. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9701. utils.ErrorLog("解析失败:%v", err)
  9702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9703. return
  9704. }
  9705. res.InfRefmsgid = resFour10265.InfRefmsgid
  9706. res.Output = resFour10265.Output
  9707. res.ErrMsg = resFour10265.ErrMsg
  9708. res.Cainfo = resFour10265.Cainfo
  9709. res.WarnMsg = resFour10265.WarnMsg
  9710. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9711. res.Infcode = infocode
  9712. } else {
  9713. 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)
  9714. var dat map[string]interface{}
  9715. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9716. fmt.Println(dat)
  9717. } else {
  9718. fmt.Println(err)
  9719. }
  9720. saveLog(result, request_log, "2204", "上传费用明细")
  9721. userJSONBytes, _ := json.Marshal(dat)
  9722. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9723. utils.ErrorLog("解析失败:%v", err)
  9724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9725. return
  9726. }
  9727. }
  9728. }
  9729. if res.Infcode == 0 {
  9730. order := &models.HisOrder{
  9731. UserOrgId: adminUser.CurrentOrgId,
  9732. HisPatientId: his.ID,
  9733. PatientId: his.PatientId,
  9734. SettleAccountsDate: recordDateTime,
  9735. Ctime: time.Now().Unix(),
  9736. Mtime: time.Now().Unix(),
  9737. MdtrtId: his.Number,
  9738. PsnNo: his.PsnNo,
  9739. MedType: strconv.FormatInt(reg_type, 10),
  9740. Status: 1,
  9741. Number: chrg_bchno,
  9742. Infcode: res.Infcode,
  9743. WarnMsg: res.WarnMsg,
  9744. Cainfo: res.Cainfo,
  9745. ErrMsg: res.ErrMsg,
  9746. RespondTime: res.RefmsgTime,
  9747. InfRefmsgid: res.InfRefmsgid,
  9748. OrderStatus: 1,
  9749. IsMedicineInsurance: 1,
  9750. SettleType: settle_accounts_type,
  9751. SettleStartTime: start_time,
  9752. SettleEndTime: end_time,
  9753. Creator: roles.AdminUserId,
  9754. Modify: roles.AdminUserId,
  9755. PType: 2,
  9756. Diagnosis: diagnosis_id,
  9757. }
  9758. err = service.CreateOrder(order)
  9759. if err != nil {
  9760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9761. return
  9762. }
  9763. for _, item := range res.Output.Result {
  9764. temp := strings.Split(item.FeedetlSn, "-")
  9765. var advice_id int64 = 0
  9766. var project_id int64 = 0
  9767. var types int64 = 0
  9768. id, _ := strconv.ParseInt(temp[2], 10, 64)
  9769. types, _ = strconv.ParseInt(temp[1], 10, 64)
  9770. if temp[1] == "1" {
  9771. advice_id = id
  9772. project_id = 0
  9773. } else if temp[1] == "2" {
  9774. advice_id = 0
  9775. project_id = id
  9776. }
  9777. info := &models.HisOrderInfo{
  9778. OrderNumber: order.Number,
  9779. FeedetlSn: item.FeedetlSn,
  9780. UploadDate: time.Now().Unix(),
  9781. AdviceId: advice_id,
  9782. DetItemFeeSumamt: item.DetItemFeeSumamt,
  9783. Cnt: item.Cnt,
  9784. Pric: float64(item.Pric),
  9785. PatientId: his.PatientId,
  9786. PricUplmtAmt: item.PricUplmtAmt,
  9787. SelfpayProp: item.SelfpayProp,
  9788. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9789. OverlmtAmt: item.OverlmtAmt,
  9790. PreselfpayAmt: item.PreselfpayAmt,
  9791. BasMednFlag: item.BasMednFlag,
  9792. MedChrgitmType: item.MedChrgitmType,
  9793. HiNegoDrugFlag: item.HiNegoDrugFlag,
  9794. Status: 1,
  9795. Memo: item.Memo,
  9796. Mtime: time.Now().Unix(),
  9797. InscpScpAmt: item.InscpScpAmt,
  9798. DrtReimFlag: item.DrtReimFlag,
  9799. Ctime: time.Now().Unix(),
  9800. ListSpItemFlag: item.ListSpItemFlag,
  9801. ChldMedcFlag: item.ChldMedcFlag,
  9802. LmtUsedFlag: item.LmtUsedFlag,
  9803. ChrgitmLv: item.ChrgitmLv,
  9804. UserOrgId: adminUser.CurrentOrgId,
  9805. HisPatientId: his.ID,
  9806. OrderId: order.ID,
  9807. ProjectId: project_id,
  9808. Type: types,
  9809. }
  9810. service.CreateOrderInfo(info)
  9811. }
  9812. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9813. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  9814. var total float64
  9815. for _, item := range prescriptions {
  9816. if item.Type == 1 { //药品
  9817. for _, subItem := range item.HisDoctorAdviceInfo {
  9818. total = total + (subItem.Price * subItem.PrescribingNumber)
  9819. }
  9820. }
  9821. if item.Type == 2 { //项目
  9822. for _, subItem := range item.HisPrescriptionProject {
  9823. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9824. total = total + (subItem.Price * cnt)
  9825. }
  9826. }
  9827. }
  9828. for _, item := range prescriptions {
  9829. for _, subItem := range item.HisAdditionalCharge {
  9830. total = total + (subItem.Price * float64(subItem.Count))
  9831. }
  9832. }
  9833. allTotal := fmt.Sprintf("%.4f", total)
  9834. if res.Infcode == 0 {
  9835. var rf []*ResultFive
  9836. json.Unmarshal([]byte(his.Iinfo), &rf)
  9837. chrg_bchno := chrg_bchno
  9838. cert_no := his.Certno
  9839. var insutypes []string
  9840. var insutype string
  9841. var is390 int = 0
  9842. var is310 int = 0
  9843. for _, item := range rf {
  9844. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9845. insutypes = append(insutypes, item.Insutype)
  9846. }
  9847. }
  9848. if len(insutypes) == 1 {
  9849. insutype = insutypes[0]
  9850. } else {
  9851. for _, i := range insutypes {
  9852. if i == "390" {
  9853. is390 = 1
  9854. }
  9855. if i == "310" {
  9856. is310 = 1
  9857. }
  9858. }
  9859. }
  9860. if is390 == 1 {
  9861. insutype = "390"
  9862. }
  9863. if is310 == 1 {
  9864. insutype = "310"
  9865. }
  9866. if len(insutypes) == 0 {
  9867. insutype = "310"
  9868. }
  9869. if len(insutypes) == 2 {
  9870. insutype = strconv.FormatInt(his.SocialType, 64)
  9871. }
  9872. //insutype = "390"
  9873. if his.IdCardType == 1 {
  9874. cert_no = his.MedicalInsuranceNumber
  9875. } else {
  9876. cert_no = his.Certno
  9877. }
  9878. var res ResultSeven
  9879. var resSeven10265 ResultSeven10265
  9880. if miConfig.MdtrtareaAdmvs == "421300" {
  9881. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9882. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9883. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9884. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9885. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9886. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9887. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  9888. resp, requestErr := http.Get(api)
  9889. if requestErr != nil {
  9890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9891. return
  9892. }
  9893. body, ioErr := ioutil.ReadAll(resp.Body)
  9894. if ioErr != nil {
  9895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9897. return
  9898. }
  9899. var respJSON map[string]interface{}
  9900. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9903. return
  9904. }
  9905. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9906. result, _ := json.Marshal(respJSON)
  9907. fmt.Println("log")
  9908. fmt.Println(string(result))
  9909. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9910. utils.ErrorLog("解析失败:%v", err)
  9911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9912. return
  9913. }
  9914. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9915. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  9916. if result3101.Infcode == "0" {
  9917. if len(result3101.Output.Result) > 0 {
  9918. var errMsgs []string
  9919. for _, item := range result3101.Output.Result {
  9920. errMsgs = append(errMsgs, item.VolaCont)
  9921. }
  9922. c.ServeSuccessJSON(map[string]interface{}{
  9923. "failed_code": -10,
  9924. "msg": errMsgs,
  9925. })
  9926. return
  9927. } else {
  9928. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9929. if his.IdCardType != 4 {
  9930. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9931. bas := strings.Split(psn_info.CardInfo, "|")
  9932. if his.IdCardType == 1 {
  9933. cert_no = bas[2]
  9934. } else {
  9935. cert_no = bas[1]
  9936. }
  9937. } else {
  9938. cert_no = his.Certno
  9939. }
  9940. //江苏地区国家医保医疗类别
  9941. //职工透析:医疗类别选特殊情况门诊9933
  9942. //居民血透门慢: 医疗类别选门诊慢病1402
  9943. //var med_type string
  9944. //if his.Insutype == "310" {
  9945. // if reg_type == 14 {
  9946. // med_type = "9933"
  9947. // } else if reg_type == 11 {
  9948. // med_type = "11"
  9949. //
  9950. // }
  9951. //} else if his.Insutype == "390" {
  9952. // if reg_type == 14 {
  9953. // med_type = "1402"
  9954. // } else if reg_type == 11 {
  9955. // med_type = "11"
  9956. // }
  9957. //}
  9958. var api string
  9959. if miConfig.MdtrtareaAdmvs == "320921" {
  9960. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9961. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9962. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9963. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9964. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9965. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9966. "&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
  9967. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9968. } else {
  9969. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9970. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9971. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9972. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9973. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9974. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9975. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9976. "&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
  9977. }
  9978. resp, requestErr := http.Get(api)
  9979. if requestErr != nil {
  9980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9981. return
  9982. }
  9983. body, ioErr := ioutil.ReadAll(resp.Body)
  9984. if ioErr != nil {
  9985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9987. return
  9988. }
  9989. var respJSON map[string]interface{}
  9990. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9993. return
  9994. }
  9995. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9996. result, _ := json.Marshal(respJSON)
  9997. fmt.Println("log")
  9998. fmt.Println(string(result))
  9999. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10000. utils.ErrorLog("解析失败:%v", err)
  10001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10002. return
  10003. }
  10004. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10005. res.Output = resSeven10265.Output
  10006. res.ErrMsg = resSeven10265.ErrMsg
  10007. res.Cainfo = resSeven10265.Cainfo
  10008. res.WarnMsg = resSeven10265.WarnMsg
  10009. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10010. res.Infcode = infocode
  10011. }
  10012. }
  10013. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10014. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId, recordDateTime)
  10015. var result string
  10016. var request_log string
  10017. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  10018. 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)
  10019. } else {
  10020. 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)
  10021. }
  10022. var dat map[string]interface{}
  10023. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10024. fmt.Println(dat)
  10025. } else {
  10026. fmt.Println(err)
  10027. }
  10028. saveLog(result, request_log, "2206", "预结算")
  10029. userJSONBytes, _ := json.Marshal(dat)
  10030. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10031. utils.ErrorLog("解析失败:%v", err)
  10032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10033. return
  10034. }
  10035. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10036. var result string
  10037. var request_log string
  10038. if his.IdCardType == 2 {
  10039. 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, "")
  10040. } else if his.IdCardType == 1 {
  10041. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10042. bas := strings.Split(psn_info.CardInfo, "|")
  10043. basNumber := bas[2]
  10044. card_sn := bas[3]
  10045. 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)
  10046. } else {
  10047. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10048. 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, "")
  10049. }
  10050. var dat map[string]interface{}
  10051. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10052. fmt.Println(dat)
  10053. } else {
  10054. fmt.Println(err)
  10055. }
  10056. saveLog(result, request_log, "2206", "预结算")
  10057. userJSONBytes, _ := json.Marshal(dat)
  10058. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10059. utils.ErrorLog("解析失败:%v", err)
  10060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10061. return
  10062. }
  10063. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10064. var result string
  10065. var request_log string
  10066. if his.IdCardType == 2 {
  10067. 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, "")
  10068. } else if his.IdCardType == 1 {
  10069. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10070. bas := strings.Split(psn_info.CardInfo, "|")
  10071. basNumber := bas[2]
  10072. card_sn := bas[3]
  10073. 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)
  10074. } else {
  10075. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10076. 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, "")
  10077. }
  10078. var dat map[string]interface{}
  10079. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10080. fmt.Println(dat)
  10081. } else {
  10082. fmt.Println(err)
  10083. }
  10084. saveLog(result, request_log, "2206", "预结算")
  10085. userJSONBytes, _ := json.Marshal(dat)
  10086. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10087. utils.ErrorLog("解析失败:%v", err)
  10088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10089. return
  10090. }
  10091. } else {
  10092. var result string
  10093. var request_log string
  10094. if miConfig.Code == "H15049901371" {
  10095. //赤峰地区国家医保医疗类别
  10096. //职工透析:医疗类别选特殊情况门诊990502
  10097. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10098. var med_type string
  10099. if his.Insutype == "390" {
  10100. if reg_type == 14 {
  10101. med_type = "9933"
  10102. } else if reg_type == 11 {
  10103. med_type = "11"
  10104. }
  10105. } else if his.Insutype == "310" {
  10106. if reg_type == 14 {
  10107. med_type = "990502"
  10108. } else if reg_type == 11 {
  10109. med_type = "11"
  10110. }
  10111. }
  10112. 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)
  10113. } else {
  10114. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10115. if his.IdCardType == 4 {
  10116. 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)
  10117. } else {
  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, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  10119. }
  10120. }
  10121. var dat map[string]interface{}
  10122. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10123. fmt.Println(dat)
  10124. } else {
  10125. fmt.Println(err)
  10126. }
  10127. saveLog(result, request_log, "2206", "预结算")
  10128. //userJSONBytes, _ := json.Marshal(dat)
  10129. //
  10130. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10131. // utils.ErrorLog("解析失败:%v", err)
  10132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10133. // return
  10134. //}
  10135. userJSONBytes, _ := json.Marshal(dat)
  10136. if miConfig.Code == "H15049901371" {
  10137. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10138. utils.ErrorLog("解析失败:%v", err)
  10139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10140. return
  10141. }
  10142. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10143. res.Output = resSeven10265.Output
  10144. res.ErrMsg = resSeven10265.ErrMsg
  10145. res.Cainfo = resSeven10265.Cainfo
  10146. res.WarnMsg = resSeven10265.WarnMsg
  10147. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10148. res.Infcode = infocode
  10149. } else {
  10150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10151. utils.ErrorLog("解析失败:%v", err)
  10152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10153. return
  10154. }
  10155. }
  10156. }
  10157. if res.Infcode != 0 {
  10158. errlog := &models.HisOrderError{
  10159. UserOrgId: adminUser.CurrentOrgId,
  10160. Ctime: time.Now().Unix(),
  10161. Mtime: time.Now().Unix(),
  10162. Number: chrg_bchno,
  10163. ErrMsg: res.ErrMsg,
  10164. Status: 1,
  10165. PatientId: id,
  10166. RecordTime: recordDateTime,
  10167. Stage: 20,
  10168. }
  10169. service.CreateErrMsgLog(errlog)
  10170. c.ServeSuccessJSON(map[string]interface{}{
  10171. "failed_code": -10,
  10172. "msg": res.ErrMsg,
  10173. })
  10174. return
  10175. } else {
  10176. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10177. order.OrderStatus = 1
  10178. order.IsPre = 1
  10179. order.Status = 1
  10180. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10181. order.SetlId = res.Output.Setlinfo.SetlID
  10182. order.PsnNo = res.Output.Setlinfo.PsnNo
  10183. order.PsnName = res.Output.Setlinfo.PsnName
  10184. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10185. order.Certno = res.Output.Setlinfo.Certno
  10186. order.Gend = res.Output.Setlinfo.Gend
  10187. order.Naty = res.Output.Setlinfo.Naty
  10188. order.Age = res.Output.Setlinfo.Age
  10189. order.Insutype = res.Output.Setlinfo.Insutype
  10190. order.PsnType = res.Output.Setlinfo.PsnType
  10191. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10192. order.SetlTime = res.Output.Setlinfo.SetlTime
  10193. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10194. if res.Output.Setlinfo.MedType == "140101" {
  10195. order.MedType = "14"
  10196. } else {
  10197. order.MedType = res.Output.Setlinfo.MedType
  10198. }
  10199. if reg_type == 1112 {
  10200. order.MedType = "1112"
  10201. }
  10202. if reg_type == 1111 {
  10203. order.MedType = "1111"
  10204. }
  10205. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10206. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10207. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10208. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10209. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10210. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10211. order.HifpPay = res.Output.Setlinfo.HifpPay
  10212. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10213. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10214. order.HifesPay = res.Output.Setlinfo.HifesPay
  10215. order.HifobPay = res.Output.Setlinfo.HifobPay
  10216. order.MafPay = res.Output.Setlinfo.MafPay
  10217. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10218. order.OthPay = res.Output.Setlinfo.OthPay
  10219. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10220. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10221. order.AcctPay = res.Output.Setlinfo.AcctPay
  10222. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10223. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10224. order.Balc = res.Output.Setlinfo.Balc
  10225. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10226. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10227. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10228. order.ClrWay = res.Output.Setlinfo.ClrWay
  10229. order.Creator = order.Creator
  10230. order.Modify = roles.AdminUserId
  10231. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10232. detailStr := string(setlDetail)
  10233. order.SetlDetail = detailStr
  10234. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10235. err = service.UpDateOrder(order)
  10236. if err == nil {
  10237. c.ServeSuccessJSON(map[string]interface{}{
  10238. "msg": "预结算成功",
  10239. })
  10240. } else {
  10241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10242. return
  10243. }
  10244. }
  10245. } else {
  10246. adminUser := c.GetAdminUserInfo()
  10247. errlog := &models.HisOrderError{
  10248. UserOrgId: adminUser.CurrentOrgId,
  10249. Ctime: time.Now().Unix(),
  10250. Mtime: time.Now().Unix(),
  10251. ErrMsg: res.ErrMsg,
  10252. Status: 1,
  10253. PatientId: id,
  10254. RecordTime: recordDateTime,
  10255. Stage: 4,
  10256. }
  10257. service.CreateErrMsgLog(errlog)
  10258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10259. return
  10260. }
  10261. } else {
  10262. adminUser := c.GetAdminUserInfo()
  10263. errlog := &models.HisOrderError{
  10264. UserOrgId: adminUser.CurrentOrgId,
  10265. Ctime: time.Now().Unix(),
  10266. Mtime: time.Now().Unix(),
  10267. ErrMsg: res.ErrMsg,
  10268. Status: 1,
  10269. PatientId: id,
  10270. RecordTime: recordDateTime,
  10271. Stage: 4,
  10272. }
  10273. service.CreateErrMsgLog(errlog)
  10274. c.ServeSuccessJSON(map[string]interface{}{
  10275. "failed_code": -10,
  10276. "msg": res.ErrMsg,
  10277. })
  10278. return
  10279. }
  10280. }
  10281. }
  10282. }
  10283. //退款
  10284. func (c *HisApiController) Refund() {
  10285. order_id, _ := c.GetInt64("order_id")
  10286. admin_user_id, _ := c.GetInt64("admin_user_id")
  10287. adminUser := c.GetAdminUserInfo()
  10288. var order models.HisOrder
  10289. order, _ = service.GetHisOrderByID(order_id)
  10290. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10291. if order.ID == 0 {
  10292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10293. return
  10294. }
  10295. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10296. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10297. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10298. if config.IsOpen == 1 { //对接了医保,走医保流程
  10299. var res ResultSixteen
  10300. var resSixteen10265 ResultSixteen10265
  10301. var src_resquest string
  10302. var result string
  10303. if miConfig.MdtrtareaAdmvs == "421300" {
  10304. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  10305. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10306. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10307. resp3, requestErr3 := http.Get(api3)
  10308. if requestErr3 != nil {
  10309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10310. return
  10311. }
  10312. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10313. if ioErr3 != nil {
  10314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10316. return
  10317. }
  10318. var respJSON3 map[string]interface{}
  10319. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10322. return
  10323. }
  10324. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10325. userJSONBytes3, _ := json.Marshal(respJSON3)
  10326. fmt.Println("log")
  10327. fmt.Println(string(userJSONBytes3))
  10328. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  10329. utils.ErrorLog("解析失败:%v", err)
  10330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10331. return
  10332. }
  10333. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10334. var api3 string
  10335. if miConfig.MdtrtareaAdmvs == "320921" {
  10336. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10337. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10338. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10339. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10340. } else {
  10341. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10342. api3 = "http://192.168.5.251: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. }
  10346. resp3, requestErr3 := http.Get(api3)
  10347. if requestErr3 != nil {
  10348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10349. return
  10350. }
  10351. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10352. if ioErr3 != nil {
  10353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10355. return
  10356. }
  10357. var respJSON3 map[string]interface{}
  10358. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10361. return
  10362. }
  10363. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10364. userJSONBytes3, _ := json.Marshal(respJSON3)
  10365. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  10366. utils.ErrorLog("解析失败:%v", err)
  10367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10368. return
  10369. }
  10370. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10371. res.Output = resSixteen10265.Output
  10372. res.ErrMsg = resSixteen10265.ErrMsg
  10373. res.Cainfo = resSixteen10265.Cainfo
  10374. res.WarnMsg = resSixteen10265.WarnMsg
  10375. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10376. res.Infcode = infocode
  10377. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10378. 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)
  10379. var dat map[string]interface{}
  10380. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10381. fmt.Println(dat)
  10382. } else {
  10383. fmt.Println(err)
  10384. }
  10385. saveLog(result, src_resquest, "2208", "退费")
  10386. userJSONBytes, _ := json.Marshal(dat)
  10387. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10388. utils.ErrorLog("解析失败:%v", err)
  10389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10390. return
  10391. }
  10392. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10393. 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, "")
  10394. var dat map[string]interface{}
  10395. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10396. fmt.Println(dat)
  10397. } else {
  10398. fmt.Println(err)
  10399. }
  10400. saveLog(result, src_resquest, "2208", "退费")
  10401. userJSONBytes, _ := json.Marshal(dat)
  10402. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10403. utils.ErrorLog("解析失败:%v", err)
  10404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10405. return
  10406. }
  10407. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10408. 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, "")
  10409. var dat map[string]interface{}
  10410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10411. fmt.Println(dat)
  10412. } else {
  10413. fmt.Println(err)
  10414. }
  10415. saveLog(result, src_resquest, "2208", "退费")
  10416. userJSONBytes, _ := json.Marshal(dat)
  10417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10418. utils.ErrorLog("解析失败:%v", err)
  10419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10420. return
  10421. }
  10422. } else {
  10423. if miConfig.Code == "H15049901371" {
  10424. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10425. var dat map[string]interface{}
  10426. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10427. fmt.Println(dat)
  10428. } else {
  10429. fmt.Println(err)
  10430. }
  10431. saveLog(result, src_resquest, "2208", "退费")
  10432. userJSONBytes, _ := json.Marshal(dat)
  10433. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  10434. utils.ErrorLog("解析失败:%v", err)
  10435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10436. return
  10437. }
  10438. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10439. res.Output = resSixteen10265.Output
  10440. res.ErrMsg = resSixteen10265.ErrMsg
  10441. res.Cainfo = resSixteen10265.Cainfo
  10442. res.WarnMsg = resSixteen10265.WarnMsg
  10443. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10444. res.Infcode = infocode
  10445. } else {
  10446. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10447. var dat map[string]interface{}
  10448. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10449. fmt.Println(dat)
  10450. } else {
  10451. fmt.Println(err)
  10452. }
  10453. saveLog(result, src_resquest, "2208", "退费")
  10454. userJSONBytes, _ := json.Marshal(dat)
  10455. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10456. utils.ErrorLog("解析失败:%v", err)
  10457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10458. return
  10459. }
  10460. }
  10461. }
  10462. if res.Infcode == 0 {
  10463. var res2 ResultSix
  10464. var resSix10265 ResultSix10265
  10465. if miConfig.MdtrtareaAdmvs == "421300" {
  10466. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10467. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10468. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10469. resp3, requestErr3 := http.Get(api3)
  10470. if requestErr3 != nil {
  10471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10472. return
  10473. }
  10474. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10475. if ioErr3 != nil {
  10476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10478. return
  10479. }
  10480. var respJSON3 map[string]interface{}
  10481. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10484. return
  10485. }
  10486. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10487. userJSONBytes3, _ := json.Marshal(respJSON3)
  10488. fmt.Println("log")
  10489. fmt.Println(string(userJSONBytes3))
  10490. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10491. utils.ErrorLog("解析失败:%v", err)
  10492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10493. return
  10494. }
  10495. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10496. var api3 string
  10497. if miConfig.MdtrtareaAdmvs == "320921" {
  10498. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10499. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10500. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10501. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10502. } else {
  10503. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10504. api3 = "http://192.168.5.251: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. }
  10508. resp3, requestErr3 := http.Get(api3)
  10509. if requestErr3 != nil {
  10510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10511. return
  10512. }
  10513. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10514. if ioErr3 != nil {
  10515. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10517. return
  10518. }
  10519. var respJSON3 map[string]interface{}
  10520. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10523. return
  10524. }
  10525. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10526. userJSONBytes3, _ := json.Marshal(respJSON3)
  10527. fmt.Println("log")
  10528. fmt.Println(string(userJSONBytes3))
  10529. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10530. utils.ErrorLog("解析失败:%v", err)
  10531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10532. return
  10533. }
  10534. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10535. res2.Output = resSix10265.Output
  10536. res2.ErrMsg = resSix10265.ErrMsg
  10537. res2.Cainfo = resSix10265.Cainfo
  10538. res2.WarnMsg = resSix10265.WarnMsg
  10539. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10540. res2.Infcode = infocode
  10541. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10542. 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)
  10543. var dat map[string]interface{}
  10544. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10545. fmt.Println(dat)
  10546. } else {
  10547. fmt.Println(err)
  10548. }
  10549. saveLog(result2, src_request, "2205", "撤销明细")
  10550. userJSONBytes, _ := json.Marshal(dat)
  10551. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10552. utils.ErrorLog("解析失败:%v", err)
  10553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10554. return
  10555. }
  10556. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10557. 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, "")
  10558. var dat map[string]interface{}
  10559. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10560. fmt.Println(dat)
  10561. } else {
  10562. fmt.Println(err)
  10563. }
  10564. saveLog(result2, src_request, "2205", "撤销明细")
  10565. userJSONBytes, _ := json.Marshal(dat)
  10566. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10567. utils.ErrorLog("解析失败:%v", err)
  10568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10569. return
  10570. }
  10571. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10572. 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, "")
  10573. var dat map[string]interface{}
  10574. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10575. fmt.Println(dat)
  10576. } else {
  10577. fmt.Println(err)
  10578. }
  10579. saveLog(result2, src_request, "2205", "撤销明细")
  10580. userJSONBytes, _ := json.Marshal(dat)
  10581. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10582. utils.ErrorLog("解析失败:%v", err)
  10583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10584. return
  10585. }
  10586. } else {
  10587. if miConfig.Code == "H15049901371" {
  10588. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10589. var dat map[string]interface{}
  10590. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10591. fmt.Println(dat)
  10592. } else {
  10593. fmt.Println(err)
  10594. }
  10595. saveLog(result2, src_request, "2205", "撤销明细")
  10596. userJSONBytes, _ := json.Marshal(dat)
  10597. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  10598. utils.ErrorLog("解析失败:%v", err)
  10599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10600. return
  10601. }
  10602. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10603. res2.Output = resSix10265.Output
  10604. res2.ErrMsg = resSix10265.ErrMsg
  10605. res2.Cainfo = resSix10265.Cainfo
  10606. res2.WarnMsg = resSix10265.WarnMsg
  10607. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10608. res2.Infcode = infocode
  10609. } else {
  10610. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10611. var dat map[string]interface{}
  10612. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10613. fmt.Println(dat)
  10614. } else {
  10615. fmt.Println(err)
  10616. }
  10617. saveLog(result2, src_request, "2205", "撤销明细")
  10618. userJSONBytes, _ := json.Marshal(dat)
  10619. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10620. utils.ErrorLog("解析失败:%v", err)
  10621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10622. return
  10623. }
  10624. }
  10625. }
  10626. if res2.Infcode == 0 {
  10627. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  10628. if err == nil {
  10629. //当押金不为零时产生退费记录
  10630. if order.Decimal != 0 {
  10631. tmp := strconv.FormatInt(order.ID, 10)
  10632. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  10633. if err != nil {
  10634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10635. return
  10636. }
  10637. }
  10638. c.ServeSuccessJSON(map[string]interface{}{
  10639. "msg": "退费成功",
  10640. })
  10641. } else {
  10642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10643. return
  10644. }
  10645. } else {
  10646. c.ServeSuccessJSON(map[string]interface{}{
  10647. "code": -10,
  10648. "msg": res2.ErrMsg,
  10649. })
  10650. }
  10651. } else {
  10652. c.ServeSuccessJSON(map[string]interface{}{
  10653. "code": -10,
  10654. "msg": res.ErrMsg,
  10655. })
  10656. }
  10657. }
  10658. }
  10659. func (c *HisApiController) RefundNumber() {
  10660. record_time := c.GetString("record_time")
  10661. //patient_id, _ := c.GetInt64("patient_id")
  10662. admin_user_id, _ := c.GetInt64("admin_user_id")
  10663. his_patient_id, _ := c.GetInt64("id")
  10664. timeLayout := "2006-01-02"
  10665. loc, _ := time.LoadLocation("Local")
  10666. adminUser := c.GetAdminUserInfo()
  10667. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10668. fmt.Println(err)
  10669. if err != nil {
  10670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10671. return
  10672. }
  10673. recordDateTime := theTime.Unix()
  10674. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10675. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  10676. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10677. //order, _ := service.GetHisOrderByID(order_id)
  10678. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10679. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10680. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10681. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  10682. if count > 0 {
  10683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  10684. return
  10685. }
  10686. if config.IsOpen == 1 { //对接了医保,走医保流程
  10687. var res2 ResultSix
  10688. var resSix10265 ResultSix10265
  10689. if miConfig.MdtrtareaAdmvs == "421300" {
  10690. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  10691. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10692. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10693. resp3, requestErr3 := http.Get(api3)
  10694. if requestErr3 != nil {
  10695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10696. return
  10697. }
  10698. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10699. if ioErr3 != nil {
  10700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10702. return
  10703. }
  10704. var respJSON3 map[string]interface{}
  10705. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10708. return
  10709. }
  10710. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10711. userJSONBytes3, _ := json.Marshal(respJSON3)
  10712. fmt.Println("log")
  10713. fmt.Println(string(userJSONBytes3))
  10714. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10715. utils.ErrorLog("解析失败:%v", err)
  10716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10717. return
  10718. }
  10719. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10720. var api3 string
  10721. if miConfig.MdtrtareaAdmvs == "320921" {
  10722. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10723. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10724. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10725. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10726. } else {
  10727. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10728. api3 = "http://192.168.5.251: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. }
  10732. resp3, requestErr3 := http.Get(api3)
  10733. if requestErr3 != nil {
  10734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10735. return
  10736. }
  10737. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10738. if ioErr3 != nil {
  10739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10741. return
  10742. }
  10743. var respJSON3 map[string]interface{}
  10744. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10747. return
  10748. }
  10749. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10750. userJSONBytes3, _ := json.Marshal(respJSON3)
  10751. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10752. utils.ErrorLog("解析失败:%v", err)
  10753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10754. return
  10755. }
  10756. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10757. res2.Output = resSix10265.Output
  10758. res2.ErrMsg = resSix10265.ErrMsg
  10759. res2.Cainfo = resSix10265.Cainfo
  10760. res2.WarnMsg = resSix10265.WarnMsg
  10761. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10762. res2.Infcode = infocode
  10763. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10764. 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)
  10765. var dat map[string]interface{}
  10766. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10767. fmt.Println(dat)
  10768. } else {
  10769. fmt.Println(err)
  10770. }
  10771. saveLog(result, request, "2202", "退号")
  10772. userJSONBytes, _ := json.Marshal(dat)
  10773. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10774. utils.ErrorLog("解析失败:%v", err)
  10775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10776. return
  10777. }
  10778. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10779. 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, "")
  10780. var dat map[string]interface{}
  10781. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10782. fmt.Println(dat)
  10783. } else {
  10784. fmt.Println(err)
  10785. }
  10786. saveLog(result, request, "2202", "退号")
  10787. userJSONBytes, _ := json.Marshal(dat)
  10788. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10789. utils.ErrorLog("解析失败:%v", err)
  10790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10791. return
  10792. }
  10793. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10794. 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, "")
  10795. var dat map[string]interface{}
  10796. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10797. fmt.Println(dat)
  10798. } else {
  10799. fmt.Println(err)
  10800. }
  10801. saveLog(result, request, "2202", "退号")
  10802. userJSONBytes, _ := json.Marshal(dat)
  10803. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10804. utils.ErrorLog("解析失败:%v", err)
  10805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10806. return
  10807. }
  10808. } else {
  10809. var api3 string
  10810. if miConfig.Code == "H15049901371" {
  10811. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10812. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10813. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10814. } else {
  10815. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10816. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10817. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10818. }
  10819. resp3, requestErr3 := http.Get(api3)
  10820. if requestErr3 != nil {
  10821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10822. return
  10823. }
  10824. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10825. if ioErr3 != nil {
  10826. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10828. return
  10829. }
  10830. var respJSON3 map[string]interface{}
  10831. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10834. return
  10835. }
  10836. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10837. userJSONBytes3, _ := json.Marshal(respJSON3)
  10838. if miConfig.Code == "H15049901371" {
  10839. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10840. utils.ErrorLog("解析失败:%v", err)
  10841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10842. return
  10843. }
  10844. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10845. res2.Output = resSix10265.Output
  10846. res2.ErrMsg = resSix10265.ErrMsg
  10847. res2.Cainfo = resSix10265.Cainfo
  10848. res2.WarnMsg = resSix10265.WarnMsg
  10849. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10850. res2.Infcode = infocode
  10851. } else {
  10852. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10853. utils.ErrorLog("解析失败:%v", err)
  10854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10855. return
  10856. }
  10857. }
  10858. }
  10859. if res2.Infcode == 0 {
  10860. if err == nil {
  10861. c.ServeSuccessJSON(map[string]interface{}{
  10862. "msg": "退号成功",
  10863. })
  10864. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  10865. } else {
  10866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10867. return
  10868. }
  10869. } else {
  10870. c.ServeSuccessJSON(map[string]interface{}{
  10871. "code": -10,
  10872. "msg": res2.ErrMsg,
  10873. })
  10874. }
  10875. } else {
  10876. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  10877. //if err == nil {
  10878. // c.ServeSuccessJSON(map[string]interface{}{
  10879. // "msg": "退费成功",
  10880. // })
  10881. //} else {
  10882. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10883. // return
  10884. //}
  10885. }
  10886. }
  10887. func (c *HisApiController) RefundDetail() {
  10888. order_id, _ := c.GetInt64("order_id")
  10889. admin_user_id, _ := c.GetInt64("admin_user_id")
  10890. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10891. number := c.GetString("number")
  10892. record_time := c.GetString("record_time")
  10893. patient_id, _ := c.GetInt64("patient_id")
  10894. //med_type, _ := c.GetInt64("med_type")
  10895. timeLayout := "2006-01-02"
  10896. loc, _ := time.LoadLocation("Local")
  10897. adminUser := c.GetAdminUserInfo()
  10898. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10899. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10900. fmt.Println(err)
  10901. if err != nil {
  10902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10903. return
  10904. }
  10905. recordDateTime := theTime.Unix()
  10906. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10907. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10908. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10909. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10910. var order models.HisOrder
  10911. order, _ = service.GetHisOrderByID(order_id)
  10912. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10913. if config.IsOpen == 1 { //对接了医保,走医保流程
  10914. var res2 ResultSix
  10915. if miConfig.MdtrtareaAdmvs == "421300" {
  10916. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10917. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10918. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10919. resp3, requestErr3 := http.Get(api3)
  10920. if requestErr3 != nil {
  10921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10922. return
  10923. }
  10924. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10925. if ioErr3 != nil {
  10926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10928. return
  10929. }
  10930. var respJSON3 map[string]interface{}
  10931. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10934. return
  10935. }
  10936. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10937. userJSONBytes3, _ := json.Marshal(respJSON3)
  10938. fmt.Println("log")
  10939. fmt.Println(string(userJSONBytes3))
  10940. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10941. utils.ErrorLog("解析失败:%v", err)
  10942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10943. return
  10944. }
  10945. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10946. if err == nil {
  10947. c.ServeSuccessJSON(map[string]interface{}{
  10948. "msg": "撤销明细成功",
  10949. })
  10950. return
  10951. } else {
  10952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10953. return
  10954. }
  10955. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10956. var resSix10265 ResultSix10265
  10957. var api3 string
  10958. if miConfig.MdtrtareaAdmvs == "320921" {
  10959. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10960. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10961. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10962. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10963. } else {
  10964. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10965. api3 = "http://192.168.5.251: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. }
  10969. resp3, requestErr3 := http.Get(api3)
  10970. if requestErr3 != nil {
  10971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10972. return
  10973. }
  10974. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10975. if ioErr3 != nil {
  10976. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10978. return
  10979. }
  10980. var respJSON3 map[string]interface{}
  10981. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10982. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10984. return
  10985. }
  10986. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10987. userJSONBytes3, _ := json.Marshal(respJSON3)
  10988. fmt.Println("log")
  10989. fmt.Println(string(userJSONBytes3))
  10990. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10991. utils.ErrorLog("解析失败:%v", err)
  10992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10993. return
  10994. }
  10995. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10996. res2.Output = resSix10265.Output
  10997. res2.ErrMsg = resSix10265.ErrMsg
  10998. res2.Cainfo = resSix10265.Cainfo
  10999. res2.WarnMsg = resSix10265.WarnMsg
  11000. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11001. res2.Infcode = infocode
  11002. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11003. if err == nil {
  11004. c.ServeSuccessJSON(map[string]interface{}{
  11005. "msg": "撤销明细成功",
  11006. })
  11007. return
  11008. } else {
  11009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11010. return
  11011. }
  11012. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11013. 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)
  11014. var dat map[string]interface{}
  11015. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11016. fmt.Println(dat)
  11017. } else {
  11018. fmt.Println(err)
  11019. }
  11020. saveLog(result2, src_request, "2205", "撤销明细")
  11021. userJSONBytes, _ := json.Marshal(dat)
  11022. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11023. utils.ErrorLog("解析失败:%v", err)
  11024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11025. return
  11026. }
  11027. if res2.Infcode == 0 {
  11028. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11029. if err == nil {
  11030. c.ServeSuccessJSON(map[string]interface{}{
  11031. "msg": "撤销明细成功",
  11032. })
  11033. return
  11034. } else {
  11035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11036. return
  11037. }
  11038. } else {
  11039. c.ServeSuccessJSON(map[string]interface{}{
  11040. "code": -10,
  11041. "msg": res2.ErrMsg,
  11042. })
  11043. }
  11044. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11045. 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, "")
  11046. var dat map[string]interface{}
  11047. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11048. fmt.Println(dat)
  11049. } else {
  11050. fmt.Println(err)
  11051. }
  11052. saveLog(result2, src_request, "2205", "撤销明细")
  11053. userJSONBytes, _ := json.Marshal(dat)
  11054. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11055. utils.ErrorLog("解析失败:%v", err)
  11056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11057. return
  11058. }
  11059. if res2.Infcode == 0 {
  11060. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11061. if err == nil {
  11062. c.ServeSuccessJSON(map[string]interface{}{
  11063. "msg": "撤销明细成功",
  11064. })
  11065. return
  11066. } else {
  11067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11068. return
  11069. }
  11070. } else {
  11071. c.ServeSuccessJSON(map[string]interface{}{
  11072. "code": -10,
  11073. "msg": res2.ErrMsg,
  11074. })
  11075. }
  11076. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11077. 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, "")
  11078. var dat map[string]interface{}
  11079. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11080. fmt.Println(dat)
  11081. } else {
  11082. fmt.Println(err)
  11083. }
  11084. saveLog(result2, src_request, "2205", "撤销明细")
  11085. userJSONBytes, _ := json.Marshal(dat)
  11086. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11087. utils.ErrorLog("解析失败:%v", err)
  11088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11089. return
  11090. }
  11091. if res2.Infcode == 0 {
  11092. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11093. if err == nil {
  11094. c.ServeSuccessJSON(map[string]interface{}{
  11095. "msg": "撤销明细成功",
  11096. })
  11097. return
  11098. } else {
  11099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11100. return
  11101. }
  11102. } else {
  11103. c.ServeSuccessJSON(map[string]interface{}{
  11104. "code": -10,
  11105. "msg": res2.ErrMsg,
  11106. })
  11107. }
  11108. } else {
  11109. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  11110. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11111. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11112. resp2, requestErr2 := http.Get(api2)
  11113. if requestErr2 != nil {
  11114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11115. return
  11116. }
  11117. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  11118. if ioErr2 != nil {
  11119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  11120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11121. return
  11122. }
  11123. var respJSON2 map[string]interface{}
  11124. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  11125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11127. return
  11128. }
  11129. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11130. if err == nil {
  11131. c.ServeSuccessJSON(map[string]interface{}{
  11132. "msg": "撤销明细成功",
  11133. })
  11134. return
  11135. } else {
  11136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11137. return
  11138. }
  11139. }
  11140. } else {
  11141. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11142. if err == nil {
  11143. c.ServeSuccessJSON(map[string]interface{}{
  11144. "msg": "退费成功",
  11145. })
  11146. } else {
  11147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11148. return
  11149. }
  11150. }
  11151. }
  11152. //对账
  11153. func (c *HisApiController) GetCheckAccount() {
  11154. start_time := c.GetString("start_time")
  11155. end_time := c.GetString("end_time")
  11156. insutype := c.GetString("insutype")
  11157. clr_type := c.GetString("clr_type")
  11158. clr_org := c.GetString("clr_optins")
  11159. admin_user_id, _ := c.GetInt64("admin_user_id")
  11160. adminUser := c.GetAdminUserInfo()
  11161. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11162. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11163. if len(clr_org) == 0 {
  11164. clr_org = miConfig.MdtrtareaAdmvs
  11165. }
  11166. timeLayout := "2006-01-02"
  11167. loc, _ := time.LoadLocation("Local")
  11168. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11169. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11170. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  11171. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  11172. fixmedins_setl_cnt := int64(len(orders))
  11173. var medfee_sumamt float64
  11174. var acct_pay float64
  11175. var fund_pay_sumamt float64
  11176. for _, item := range orders {
  11177. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11178. acct_pay = acct_pay + item.AcctPay
  11179. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11180. }
  11181. var user_name string
  11182. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11183. if role.ID == 0 {
  11184. user_name = "xxx"
  11185. } else {
  11186. user_name = role.UserName
  11187. }
  11188. var res ResultEight
  11189. var res10188 ResultEightFor10188
  11190. if config.IsOpen == 1 {
  11191. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11192. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  11193. "insutype=" + insutype +
  11194. "&clr_type=" + clr_type +
  11195. "&setl_optins=" + clr_org +
  11196. "&stmt_begndate=" + start_time +
  11197. "&stm_enddate=" + end_time +
  11198. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11199. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11200. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11201. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11202. "&fixmedins_code=" + miConfig.Code +
  11203. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11204. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11205. "&secret_key=" + miConfig.SecretKey +
  11206. "&org_name=" + miConfig.OrgName +
  11207. "&doctor=" + user_name +
  11208. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11209. fmt.Println(api)
  11210. resp, requestErr := http.Get(api)
  11211. if requestErr != nil {
  11212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11213. return
  11214. }
  11215. body, ioErr := ioutil.ReadAll(resp.Body)
  11216. fmt.Println(body)
  11217. if ioErr != nil {
  11218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11220. return
  11221. }
  11222. var respJSON map[string]interface{}
  11223. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11226. return
  11227. }
  11228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11229. userJSONBytes, _ := json.Marshal(respJSON)
  11230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11231. utils.ErrorLog("解析失败:%v", err)
  11232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11233. return
  11234. }
  11235. res.InfRefmsgid = res10188.InfRefmsgid
  11236. res.Output = res10188.Output
  11237. res.ErrMsg = res10188.ErrMsg
  11238. res.Cainfo = res10188.Cainfo
  11239. res.WarnMsg = res10188.WarnMsg
  11240. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11241. res.Infcode = infocode
  11242. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11243. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  11244. "insutype=" + insutype +
  11245. "&clr_type=" + "21" +
  11246. "&setl_optins=" + clr_org +
  11247. "&stmt_begndate=" + start_time +
  11248. "&stm_enddate=" + end_time +
  11249. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11250. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11251. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11252. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11253. "&fixmedins_code=" + miConfig.Code +
  11254. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11255. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11256. "&secret_key=" + miConfig.SecretKey +
  11257. "&org_name=" + miConfig.OrgName +
  11258. "&doctor=" + user_name
  11259. resp, requestErr := http.Get(api)
  11260. if requestErr != nil {
  11261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11262. return
  11263. }
  11264. body, ioErr := ioutil.ReadAll(resp.Body)
  11265. if ioErr != nil {
  11266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11268. return
  11269. }
  11270. var respJSON map[string]interface{}
  11271. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11274. return
  11275. }
  11276. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11277. result, _ := json.Marshal(respJSON)
  11278. fmt.Println("log")
  11279. fmt.Println(string(result))
  11280. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  11281. utils.ErrorLog("解析失败:%v", err)
  11282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11283. return
  11284. }
  11285. res.InfRefmsgid = res10188.InfRefmsgid
  11286. res.Output = res10188.Output
  11287. res.ErrMsg = res10188.ErrMsg
  11288. res.Cainfo = res10188.Cainfo
  11289. res.WarnMsg = res10188.WarnMsg
  11290. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11291. res.Infcode = infocode
  11292. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11293. var baseParams models.BaseParams
  11294. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11295. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11296. baseParams.SecretKey = miConfig.SecretKey
  11297. baseParams.OrgName = miConfig.OrgName
  11298. baseParams.FixmedinsCode = miConfig.Code
  11299. baseParams.EncKey = miConfig.EncKey
  11300. baseParams.AppSecret = miConfig.AppSecret
  11301. baseParams.SignKey = miConfig.SignKey
  11302. baseParams.AppID = miConfig.Code
  11303. baseParams.Doctor = role.UserName
  11304. baseParams.RequestUrl = miConfig.Url
  11305. businessParams := models.BusinessParams{
  11306. Insutype: insutype,
  11307. ClrType: clr_type,
  11308. SetlOptins: clr_org,
  11309. StmtBegndate: start_time,
  11310. StmtEnddate: end_time,
  11311. MedfeeSumamt: medfee_sumamt,
  11312. FundPaySumamt: fund_pay_sumamt,
  11313. AcctPay: acct_pay,
  11314. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11315. }
  11316. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11317. fmt.Println(requestLog)
  11318. fmt.Println(result)
  11319. fmt.Println(err_msg)
  11320. var dat map[string]interface{}
  11321. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11322. fmt.Println(dat)
  11323. } else {
  11324. fmt.Println(err)
  11325. }
  11326. userJSONBytes, _ := json.Marshal(dat)
  11327. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11328. utils.ErrorLog("解析失败:%v", err)
  11329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11330. return
  11331. }
  11332. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11333. var baseParams models.BaseParams
  11334. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11335. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11336. baseParams.SecretKey = miConfig.SecretKey
  11337. baseParams.OrgName = miConfig.OrgName
  11338. baseParams.FixmedinsCode = miConfig.Code
  11339. baseParams.EncKey = miConfig.EncKey
  11340. baseParams.AppSecret = miConfig.AppSecret
  11341. baseParams.SignKey = miConfig.SignKey
  11342. baseParams.AppID = miConfig.Code
  11343. baseParams.Doctor = role.UserName
  11344. baseParams.RequestUrl = miConfig.Url
  11345. baseParams.AccessKey = miConfig.AccessKey
  11346. businessParams := models.BusinessParams{
  11347. Insutype: insutype,
  11348. ClrType: clr_type,
  11349. SetlOptins: "430822",
  11350. StmtBegndate: start_time,
  11351. StmtEnddate: end_time,
  11352. MedfeeSumamt: medfee_sumamt,
  11353. FundPaySumamt: fund_pay_sumamt,
  11354. AcctPay: acct_pay,
  11355. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11356. }
  11357. 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)
  11358. fmt.Println(requestLog)
  11359. fmt.Println(result)
  11360. var dat map[string]interface{}
  11361. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11362. fmt.Println(dat)
  11363. } else {
  11364. fmt.Println(err)
  11365. }
  11366. userJSONBytes, _ := json.Marshal(dat)
  11367. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11368. utils.ErrorLog("解析失败:%v", err)
  11369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11370. return
  11371. }
  11372. } else if miConfig.MdtrtareaAdmvs == "" {
  11373. var baseParams models.BaseParams
  11374. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11375. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11376. baseParams.SecretKey = miConfig.SecretKey
  11377. baseParams.OrgName = miConfig.OrgName
  11378. baseParams.FixmedinsCode = miConfig.Code
  11379. baseParams.EncKey = miConfig.EncKey
  11380. baseParams.AppSecret = miConfig.AppSecret
  11381. baseParams.SignKey = miConfig.SignKey
  11382. baseParams.AppID = miConfig.Code
  11383. baseParams.Doctor = role.UserName
  11384. baseParams.RequestUrl = miConfig.Url
  11385. businessParams := models.BusinessParams{
  11386. Insutype: insutype,
  11387. ClrType: clr_type,
  11388. SetlOptins: clr_org,
  11389. StmtBegndate: start_time,
  11390. StmtEnddate: end_time,
  11391. MedfeeSumamt: medfee_sumamt,
  11392. FundPaySumamt: fund_pay_sumamt,
  11393. AcctPay: acct_pay,
  11394. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11395. }
  11396. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11397. fmt.Println(requestLog)
  11398. fmt.Println(result)
  11399. fmt.Println(err_msg)
  11400. var dat map[string]interface{}
  11401. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11402. fmt.Println(dat)
  11403. } else {
  11404. fmt.Println(err)
  11405. }
  11406. userJSONBytes, _ := json.Marshal(dat)
  11407. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11408. utils.ErrorLog("解析失败:%v", err)
  11409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11410. return
  11411. }
  11412. } else {
  11413. if len(clr_type) == 0 {
  11414. clr_type = "11"
  11415. }
  11416. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11417. "insutype=" + insutype +
  11418. "&clr_type=" + clr_type +
  11419. "&setl_optins=" + clr_org +
  11420. "&stmt_begndate=" + start_time +
  11421. "&stm_enddate=" + end_time +
  11422. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11423. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11424. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11425. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11426. "&fixmedins_code=" + miConfig.Code +
  11427. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11428. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11429. "&secret_key=" + miConfig.SecretKey +
  11430. "&org_name=" + miConfig.OrgName +
  11431. "&doctor=" + user_name
  11432. fmt.Println(api)
  11433. resp, requestErr := http.Get(api)
  11434. if requestErr != nil {
  11435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11436. return
  11437. }
  11438. body, ioErr := ioutil.ReadAll(resp.Body)
  11439. fmt.Println(body)
  11440. if ioErr != nil {
  11441. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11443. return
  11444. }
  11445. var respJSON map[string]interface{}
  11446. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11449. return
  11450. }
  11451. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11452. userJSONBytes, _ := json.Marshal(respJSON)
  11453. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11454. utils.ErrorLog("解析失败:%v", err)
  11455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11456. return
  11457. }
  11458. }
  11459. if res.Infcode == 0 {
  11460. if res.Output.Stmtinfo.StmtRslt == "0" {
  11461. micc := &models.MedicalInsuranceCostCompare{
  11462. StartTime: startime.Unix(),
  11463. EndTime: endtime.Unix(),
  11464. Insutype: insutype,
  11465. CheckType: 1,
  11466. Num: fixmedins_setl_cnt,
  11467. Mtime: time.Now().Unix(),
  11468. Status: 1,
  11469. UserOrgId: adminUser.CurrentOrgId,
  11470. CostTotal: medfee_sumamt,
  11471. FuncTotal: fund_pay_sumamt,
  11472. PsnPay: acct_pay,
  11473. Creator: admin_user_id,
  11474. Ctime: time.Now().Unix(),
  11475. ClrType: clr_type,
  11476. }
  11477. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  11478. if err == nil {
  11479. c.ServeSuccessJSON(map[string]interface{}{
  11480. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11481. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11482. })
  11483. } else {
  11484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11485. }
  11486. } else {
  11487. c.ServeSuccessJSON(map[string]interface{}{
  11488. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11489. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11490. })
  11491. }
  11492. } else {
  11493. c.ServeSuccessJSON(map[string]interface{}{
  11494. "code": -10,
  11495. "msg": res.ErrMsg,
  11496. })
  11497. }
  11498. }
  11499. }
  11500. func (c *HisApiController) Check310() {
  11501. adminUser := c.GetAdminUserInfo()
  11502. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11503. var user_name string
  11504. user_name = "高慧裕"
  11505. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11506. "insutype=" + "310" +
  11507. "&clr_type=" + "" +
  11508. "&setl_optins=" + "441202" +
  11509. "&stmt_begndate=" + "2022-03-01" +
  11510. "&stm_enddate=" + "2022-03-31" +
  11511. "&medfee_sumamt=" + "194930.12" +
  11512. "&fund_pay_sumamt=" + "188741.46" +
  11513. "&acct_pay=" + "0" +
  11514. "&fixmedins_setl_cnt=" + "452" +
  11515. "&fixmedins_code=" + miConfig.Code +
  11516. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11517. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11518. "&secret_key=" + miConfig.SecretKey +
  11519. "&org_name=" + miConfig.OrgName +
  11520. "&doctor=" + user_name
  11521. fmt.Println(api)
  11522. resp, requestErr := http.Get(api)
  11523. if requestErr != nil {
  11524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11525. return
  11526. }
  11527. body, ioErr := ioutil.ReadAll(resp.Body)
  11528. fmt.Println(body)
  11529. if ioErr != nil {
  11530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11532. return
  11533. }
  11534. var respJSON map[string]interface{}
  11535. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11538. return
  11539. }
  11540. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11541. userJSONBytes, _ := json.Marshal(respJSON)
  11542. var res ResultEight
  11543. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11544. utils.ErrorLog("解析失败:%v", err)
  11545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11546. return
  11547. }
  11548. }
  11549. func (c *HisApiController) Check390() {
  11550. adminUser := c.GetAdminUserInfo()
  11551. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11552. var user_name string
  11553. user_name = "高慧裕"
  11554. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11555. "insutype=" + "390" +
  11556. "&clr_type=" + "" +
  11557. "&setl_optins=" + "441202" +
  11558. "&stmt_begndate=" + "2022-03-01" +
  11559. "&stm_enddate=" + "2022-03-31" +
  11560. "&medfee_sumamt=" + "1068448.89" +
  11561. "&fund_pay_sumamt=" + "1014677.62" +
  11562. "&acct_pay=" + "0" +
  11563. "&fixmedins_setl_cnt=" + "1950" +
  11564. "&fixmedins_code=" + miConfig.Code +
  11565. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11566. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11567. "&secret_key=" + miConfig.SecretKey +
  11568. "&org_name=" + miConfig.OrgName +
  11569. "&doctor=" + user_name
  11570. fmt.Println(api)
  11571. resp, requestErr := http.Get(api)
  11572. if requestErr != nil {
  11573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11574. return
  11575. }
  11576. body, ioErr := ioutil.ReadAll(resp.Body)
  11577. fmt.Println(body)
  11578. if ioErr != nil {
  11579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11581. return
  11582. }
  11583. var respJSON map[string]interface{}
  11584. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11587. return
  11588. }
  11589. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11590. userJSONBytes, _ := json.Marshal(respJSON)
  11591. var res ResultEight
  11592. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11593. utils.ErrorLog("解析失败:%v", err)
  11594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11595. return
  11596. }
  11597. }
  11598. //对账明细
  11599. func (c *HisApiController) GetCheckDetailAccount() {
  11600. start_time := c.GetString("start_time")
  11601. end_time := c.GetString("end_time")
  11602. admin_user_id, _ := c.GetInt64("admin_user_id")
  11603. adminUser := c.GetAdminUserInfo()
  11604. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11605. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11606. timeLayout := "2006-01-02"
  11607. loc, _ := time.LoadLocation("Local")
  11608. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11609. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11610. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  11611. rand.Seed(time.Now().UnixNano())
  11612. num := rand.Intn(30000)
  11613. Mkdir(miConfig.OrgName)
  11614. file := strconv.FormatInt(int64(num), 10)
  11615. file_name := file + ".txt"
  11616. zip_name := file + ".zip"
  11617. zip_path := miConfig.OrgName + "/" + zip_name
  11618. file_path := miConfig.OrgName + "/" + file_name
  11619. decimal.DivisionPrecision = 2
  11620. var medfee_sumamt float64
  11621. var psn_cash_pay float64
  11622. var fund_pay_sumamt float64
  11623. fixmedins_setl_cnt := int64(len(orders))
  11624. for _, item := range orders {
  11625. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11626. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  11627. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11628. }
  11629. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  11630. defer f.Close()
  11631. if err != nil {
  11632. fmt.Println(err.Error())
  11633. } else {
  11634. for _, item := range orders {
  11635. var refd_setl_flag string
  11636. if item.OrderStatus == 2 {
  11637. refd_setl_flag = "0"
  11638. var str string
  11639. str = item.SetlId + " " +
  11640. item.MdtrtId + " " +
  11641. item.PsnNo + " " +
  11642. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11643. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11644. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  11645. _, err = f.Write([]byte(str))
  11646. }
  11647. if item.OrderStatus == 3 {
  11648. var str string
  11649. str = item.SetlId + " " +
  11650. item.MdtrtId + " " +
  11651. item.PsnNo + " " +
  11652. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11653. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11654. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  11655. _, err = f.Write([]byte(str))
  11656. var str2 string
  11657. str2 = item.SetlId + " " +
  11658. item.MdtrtId + " " +
  11659. item.PsnNo + " " +
  11660. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  11661. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  11662. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  11663. _, err = f.Write([]byte(str2))
  11664. }
  11665. }
  11666. }
  11667. Zip(file_path, zip_path)
  11668. fmt.Println(ReadFile(zip_path))
  11669. fmt.Println(string(ReadFile(zip_path)))
  11670. if config.IsOpen == 1 {
  11671. var user_name string
  11672. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11673. if role.ID == 0 {
  11674. user_name = "管理员"
  11675. } else {
  11676. user_name = role.UserName
  11677. }
  11678. baseParams := models.BaseParams{
  11679. SecretKey: miConfig.SecretKey,
  11680. FixmedinsCode: miConfig.Code,
  11681. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11682. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11683. OrgName: miConfig.OrgName,
  11684. Doctor: user_name,
  11685. }
  11686. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  11687. var dat map[string]interface{}
  11688. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11689. fmt.Println(dat)
  11690. } else {
  11691. fmt.Println(err)
  11692. }
  11693. userJSONBytes, _ := json.Marshal(dat)
  11694. var res ResultNine
  11695. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11696. utils.ErrorLog("解析失败:%v", err)
  11697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11698. return
  11699. }
  11700. if res.Infcode == 0 {
  11701. fileNo := res.Output.FileQuryNo
  11702. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  11703. "file_qury_no=" + fileNo +
  11704. "&setl_optins=" + "定点医保中心" +
  11705. "&stmt_begndate=" + start_time +
  11706. "&stm_enddate=" + end_time +
  11707. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11708. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11709. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  11710. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11711. "&fixmedins_code=" + miConfig.Code +
  11712. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11713. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11714. "&secret_key=" + miConfig.SecretKey +
  11715. "&org_name=" + miConfig.OrgName +
  11716. "&doctor=" + user_name
  11717. resp, requestErr := http.Get(api)
  11718. if requestErr != nil {
  11719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11720. return
  11721. }
  11722. body, ioErr := ioutil.ReadAll(resp.Body)
  11723. if ioErr != nil {
  11724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11726. return
  11727. }
  11728. var respJSON map[string]interface{}
  11729. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11732. return
  11733. }
  11734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11735. userJSONBytes, _ := json.Marshal(respJSON)
  11736. var res ResultTen
  11737. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11738. utils.ErrorLog("解析失败:%v", err)
  11739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11740. return
  11741. }
  11742. if res.Infcode == 0 {
  11743. service.Gdyb9102(baseParams, zip_name, fileNo)
  11744. micc := &models.MedicalInsuranceCostCompare{
  11745. StartTime: startime.Unix(),
  11746. EndTime: endtime.Unix(),
  11747. Insutype: "0",
  11748. CheckType: 2,
  11749. Num: fixmedins_setl_cnt,
  11750. Mtime: time.Now().Unix(),
  11751. Status: 1,
  11752. UserOrgId: adminUser.CurrentOrgId,
  11753. CostTotal: medfee_sumamt,
  11754. FuncTotal: fund_pay_sumamt,
  11755. PsnPay: psn_cash_pay,
  11756. Creator: admin_user_id,
  11757. Ctime: time.Now().Unix(),
  11758. }
  11759. service.CreateMedicalInsuranceCostCompareRecord(micc)
  11760. c.ServeSuccessJSON(map[string]interface{}{
  11761. "msg": "明细对账成功",
  11762. })
  11763. }
  11764. } else {
  11765. }
  11766. }
  11767. }
  11768. type CustomOrderInfo struct {
  11769. Name string
  11770. Spec string
  11771. Unit string
  11772. Count float64
  11773. Price float64
  11774. Total float64
  11775. }
  11776. func (c *HisApiController) GetSettleAccounts() {
  11777. //id, _ := c.GetInt64("id")
  11778. //record_time := c.GetString("record_time")
  11779. order_id, _ := c.GetInt64("order_id")
  11780. admin_user_id, _ := c.GetInt64("admin_user_id")
  11781. //timeLayout := "2006-01-02"
  11782. //loc, _ := time.LoadLocation("Local")
  11783. //
  11784. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11785. //if err != nil {
  11786. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11787. // return
  11788. //}
  11789. //recordDateTime := theTime.Unix()
  11790. adminUser := c.GetAdminUserInfo()
  11791. order, _ := service.GetHisOrderByID(order_id)
  11792. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11793. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  11794. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  11795. orderInfos = append(orderInfos, orderInfos_two...)
  11796. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  11797. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  11798. var diagnosis_ids []string
  11799. if his.ID > 0 {
  11800. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  11801. } else {
  11802. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  11803. }
  11804. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  11805. var dia_config []*models.HisXtDiagnoseConfig
  11806. var name string
  11807. for _, item := range diagnosis_ids {
  11808. id, _ := strconv.ParseInt(item, 10, 64)
  11809. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11810. dia_config = append(dia_config, &diagnosisConfig)
  11811. if len(name) == 0 {
  11812. name = diagnosisConfig.ClassName
  11813. } else {
  11814. name = name + "," + diagnosisConfig.ClassName
  11815. }
  11816. }
  11817. var bedCostTotal float64 = 0 //床位总费
  11818. var bedCostSelfTotal float64 = 0 //床位自费
  11819. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11820. var operationCostTotal float64 = 0 //手术费
  11821. var operationCostSelfTotal float64 = 0 //手术费
  11822. var operationCostPartSelfTotal float64 = 0 //手术费
  11823. var otherCostTotal float64 = 0 //其他费用
  11824. var otherCostSelfTotal float64 = 0 //其他费用
  11825. var otherCostPartSelfTotal float64 = 0 //其他费用
  11826. var materialCostTotal float64 = 0 //材料费
  11827. var materialCostSelfTotal float64 = 0 //材料费
  11828. var materialCostPartSelfTotal float64 = 0 //材料费
  11829. var westernMedicineCostTotal float64 = 0 //西药费
  11830. var westernMedicineCostSelfTotal float64 = 0 //西药费
  11831. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11832. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11833. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11834. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11835. var checkCostTotal float64 = 0 //检查费
  11836. var checkCostSelfTotal float64 = 0 //检查费
  11837. var checkCostPartSelfTotal float64 = 0 //检查费
  11838. var laboratoryCostTotal float64 = 0 //化验费
  11839. var laboratoryCostSelfTotal float64 = 0 //化验费
  11840. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11841. var treatCostTotal float64 = 0 //治疗费用
  11842. var treatCostSelfTotal float64 = 0 //治疗费用
  11843. var treatCostPartSelfTotal float64 = 0 //治疗费用
  11844. decimal.DivisionPrecision = 2
  11845. for _, item := range orderInfos {
  11846. if item.MedChrgitmType == "01" { //床位费
  11847. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11848. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11849. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11850. }
  11851. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  11852. if item.MedChrgitmType == "03" { //检查费
  11853. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11854. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11855. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11856. }
  11857. } else {
  11858. if item.MedChrgitmType == "03" { //检查费
  11859. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11860. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11861. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11862. }
  11863. }
  11864. if item.MedChrgitmType == "04" { //化验费
  11865. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11866. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11867. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11868. }
  11869. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  11870. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11871. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11872. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11873. }
  11874. if item.MedChrgitmType == "06" { //手术费
  11875. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11876. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11877. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11878. }
  11879. if item.MedChrgitmType == "08" { //材料费
  11880. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11881. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11882. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11883. }
  11884. if item.MedChrgitmType == "09" { //西药费
  11885. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11886. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11887. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11888. }
  11889. if item.MedChrgitmType == "11" { //中成费
  11890. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11891. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11892. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11893. }
  11894. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  11895. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11896. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11897. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11898. }
  11899. }
  11900. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11901. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11902. var user_name string
  11903. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11904. if role.ID == 0 {
  11905. user_name = "管理员"
  11906. } else {
  11907. user_name = role.UserName
  11908. }
  11909. baseParams := models.BaseParams{
  11910. SecretKey: miConfig.SecretKey,
  11911. FixmedinsCode: miConfig.Code,
  11912. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11913. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11914. OrgName: miConfig.OrgName,
  11915. Doctor: user_name,
  11916. RequestUrl: miConfig.Url,
  11917. AccessKey: miConfig.AccessKey,
  11918. }
  11919. businessParams := models.BusinessParams{
  11920. PsnNo: order.PsnNo,
  11921. MdtrtId: order.MdtrtId,
  11922. SetlId: order.SetlId,
  11923. }
  11924. var res ResultEleven
  11925. var resEleven10265 ResultEleven10265
  11926. if config.IsOpen == 1 {
  11927. if miConfig.MdtrtareaAdmvs == "421300" {
  11928. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11929. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11930. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11931. resp, requestErr := http.Get(api)
  11932. if requestErr != nil {
  11933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11934. return
  11935. }
  11936. body, ioErr := ioutil.ReadAll(resp.Body)
  11937. if ioErr != nil {
  11938. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11940. return
  11941. }
  11942. var respJSON map[string]interface{}
  11943. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11944. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11946. return
  11947. }
  11948. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11949. result, _ := json.Marshal(respJSON)
  11950. fmt.Println("log")
  11951. fmt.Println(string(result))
  11952. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11953. utils.ErrorLog("解析失败:%v", err)
  11954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11955. return
  11956. }
  11957. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11958. var api string
  11959. if miConfig.MdtrtareaAdmvs == "320921" {
  11960. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11961. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11962. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11963. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11964. } else {
  11965. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11966. api = "http://192.168.5.251: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. }
  11970. resp, requestErr := http.Get(api)
  11971. if requestErr != nil {
  11972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11973. return
  11974. }
  11975. body, ioErr := ioutil.ReadAll(resp.Body)
  11976. if ioErr != nil {
  11977. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11979. return
  11980. }
  11981. var respJSON map[string]interface{}
  11982. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11985. return
  11986. }
  11987. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11988. result, _ := json.Marshal(respJSON)
  11989. fmt.Println("log")
  11990. fmt.Println(string(result))
  11991. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  11992. utils.ErrorLog("解析失败:%v", err)
  11993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11994. return
  11995. }
  11996. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11997. res.Output = resEleven10265.Output
  11998. res.ErrMsg = resEleven10265.ErrMsg
  11999. res.Cainfo = resEleven10265.Cainfo
  12000. res.WarnMsg = resEleven10265.WarnMsg
  12001. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12002. res.Infcode = infocode
  12003. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12004. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  12005. saveLog(result, requestLog, "5203", "结算单")
  12006. var dat map[string]interface{}
  12007. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12008. fmt.Println(dat)
  12009. } else {
  12010. fmt.Println(err)
  12011. }
  12012. userJSONBytes, _ := json.Marshal(dat)
  12013. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12014. utils.ErrorLog("解析失败:%v", err)
  12015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12016. return
  12017. }
  12018. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12019. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  12020. saveLog(result, requestLog, "5203", "结算单")
  12021. var dat map[string]interface{}
  12022. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12023. fmt.Println(dat)
  12024. } else {
  12025. fmt.Println(err)
  12026. }
  12027. userJSONBytes, _ := json.Marshal(dat)
  12028. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12029. utils.ErrorLog("解析失败:%v", err)
  12030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12031. return
  12032. }
  12033. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12034. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  12035. saveLog(result, requestLog, "5203", "结算单")
  12036. var dat map[string]interface{}
  12037. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12038. fmt.Println(dat)
  12039. } else {
  12040. fmt.Println(err)
  12041. }
  12042. userJSONBytes, _ := json.Marshal(dat)
  12043. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12044. utils.ErrorLog("解析失败:%v", err)
  12045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12046. return
  12047. }
  12048. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12049. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12050. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12051. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12052. resp, requestErr := http.Get(api)
  12053. if requestErr != nil {
  12054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12055. return
  12056. }
  12057. body, ioErr := ioutil.ReadAll(resp.Body)
  12058. if ioErr != nil {
  12059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12061. return
  12062. }
  12063. var respJSON map[string]interface{}
  12064. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12067. return
  12068. }
  12069. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12070. result, _ := json.Marshal(respJSON)
  12071. fmt.Println("log")
  12072. fmt.Println(string(result))
  12073. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12074. utils.ErrorLog("解析失败:%v", err)
  12075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12076. return
  12077. }
  12078. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12079. res.Output = resEleven10265.Output
  12080. res.ErrMsg = resEleven10265.ErrMsg
  12081. res.Cainfo = resEleven10265.Cainfo
  12082. res.WarnMsg = resEleven10265.WarnMsg
  12083. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12084. res.Infcode = infocode
  12085. } else {
  12086. result := service.Gdyb5203(baseParams, businessParams)
  12087. //service.Gdyb5204(baseParams, businessParams)
  12088. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  12089. var dat map[string]interface{}
  12090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12091. fmt.Println(dat)
  12092. } else {
  12093. fmt.Println(err)
  12094. }
  12095. userJSONBytes, _ := json.Marshal(dat)
  12096. if miConfig.Code == "H15049901371" {
  12097. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  12098. utils.ErrorLog("解析失败:%v", err)
  12099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12100. return
  12101. }
  12102. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12103. res.Output = resEleven10265.Output
  12104. res.ErrMsg = resEleven10265.ErrMsg
  12105. res.Cainfo = resEleven10265.Cainfo
  12106. res.WarnMsg = resEleven10265.WarnMsg
  12107. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12108. res.Infcode = infocode
  12109. } else {
  12110. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12111. utils.ErrorLog("解析失败:%v", err)
  12112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12113. return
  12114. }
  12115. }
  12116. }
  12117. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12118. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  12119. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  12120. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12121. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  12122. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12123. var doctor_name string
  12124. if roles.ID == 0 {
  12125. doctor_name = "管理员"
  12126. } else {
  12127. doctor_name = roles.UserName
  12128. }
  12129. yiliao_leibie := ""
  12130. switch order.MedType {
  12131. case "11":
  12132. yiliao_leibie = "普通门诊"
  12133. break
  12134. case "12":
  12135. yiliao_leibie = "门诊挂号"
  12136. break
  12137. case "13":
  12138. yiliao_leibie = "急诊"
  12139. break
  12140. case "14":
  12141. yiliao_leibie = "门诊特殊病"
  12142. break
  12143. case "15":
  12144. yiliao_leibie = "门诊统筹"
  12145. break
  12146. case "16":
  12147. yiliao_leibie = "门诊慢性病"
  12148. break
  12149. case "21":
  12150. yiliao_leibie = "普通住院"
  12151. break
  12152. }
  12153. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12154. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  12155. if res.Infcode == 0 {
  12156. c.ServeSuccessJSON(map[string]interface{}{
  12157. "diagnosis": name,
  12158. "order_infos": orderInfos,
  12159. "number": order.MdtrtId,
  12160. "date": order.SettleAccountsDate,
  12161. "charge_admin": charge_admin,
  12162. "printor_admin": printor_admin,
  12163. "info": res.Output.Setlinfo,
  12164. "order": order,
  12165. "bedCostTotal": bedCostTotal,
  12166. "bedCostSelfTotal": bedCostSelfTotal,
  12167. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  12168. "operationCostTotal": operationCostTotal,
  12169. "operationCostSelfTotal": operationCostSelfTotal,
  12170. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  12171. "otherCostTotal": otherCostTotal,
  12172. "otherCostSelfTotal": otherCostSelfTotal,
  12173. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  12174. "materialCostTotal": materialCostTotal,
  12175. "materialCostSelfTotal": materialCostSelfTotal,
  12176. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  12177. "westernMedicineCostTotal": westernMedicineCostTotal,
  12178. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  12179. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  12180. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  12181. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  12182. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  12183. "checkCostTotal": checkCostTotal,
  12184. "checkCostSelfTotal": checkCostSelfTotal,
  12185. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  12186. "laboratoryCostTotal": laboratoryCostTotal,
  12187. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  12188. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  12189. "treatCostTotal": treatCostTotal,
  12190. "treatCostSelfTotal": treatCostSelfTotal,
  12191. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  12192. "doctor_info": doctor_info,
  12193. "doctor_code": adminRole_two.DoctorCode,
  12194. "doctor_name": doctor_name,
  12195. "health_card_no": order.PsnNo,
  12196. "department": departments.Name,
  12197. "yiliao_leibie": yiliao_leibie,
  12198. "after_money": order.AccountPrice,
  12199. "patient": patient,
  12200. "org_name": miConfig.OrgName,
  12201. "org_code": miConfig.Code,
  12202. "order_number": order.Number,
  12203. "his_hospital": his_hospital,
  12204. "his": his,
  12205. "dia_config": dia_config,
  12206. //"check_order_info": cus_slice,
  12207. })
  12208. }
  12209. }
  12210. }
  12211. func (c *HisApiController) CheckTreatment() {
  12212. patient_id, _ := c.GetInt64("patient_id")
  12213. id_card_no := c.GetString("id_card_no")
  12214. insutype := c.GetString("insutype")
  12215. med_type := c.GetString("med_type")
  12216. admin_user_id, _ := c.GetInt64("admin_user_id")
  12217. adminUser := c.GetAdminUserInfo()
  12218. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12219. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12220. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12221. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12222. if miConfig.MdtrtareaAdmvs == "421300" {
  12223. var res ResultTwo
  12224. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12225. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12226. "&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)
  12227. resp, requestErr := http.Get(api)
  12228. if requestErr != nil {
  12229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12230. return
  12231. }
  12232. body, ioErr := ioutil.ReadAll(resp.Body)
  12233. if ioErr != nil {
  12234. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12236. return
  12237. }
  12238. var respJSON map[string]interface{}
  12239. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12240. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12242. return
  12243. }
  12244. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12245. result, _ := json.Marshal(respJSON)
  12246. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12247. utils.ErrorLog("解析失败:%v", err)
  12248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12249. return
  12250. }
  12251. if res.Infcode == 0 {
  12252. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  12253. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12254. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  12255. resp, requestErr := http.Get(api)
  12256. if requestErr != nil {
  12257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12258. return
  12259. }
  12260. body, ioErr := ioutil.ReadAll(resp.Body)
  12261. if ioErr != nil {
  12262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12264. return
  12265. }
  12266. var respJSON map[string]interface{}
  12267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12270. return
  12271. }
  12272. var res Result2001
  12273. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12274. result2, _ := json.Marshal(respJSON)
  12275. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  12276. utils.ErrorLog("解析失败:%v", err)
  12277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12278. return
  12279. }
  12280. if res.Infcode == 0 {
  12281. c.ServeSuccessJSON(map[string]interface{}{
  12282. "msg": res.Output.Trtinfo,
  12283. })
  12284. }
  12285. } else {
  12286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12287. return
  12288. }
  12289. } else {
  12290. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12291. var dat map[string]interface{}
  12292. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12293. fmt.Println(dat)
  12294. } else {
  12295. fmt.Println(err)
  12296. }
  12297. userJSONBytes, _ := json.Marshal(dat)
  12298. var res ResultTwo
  12299. var res10265 ResultTwo10265
  12300. if miConfig.Code == "H15049901371" {
  12301. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12302. utils.ErrorLog("解析失败:%v", err)
  12303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12304. return
  12305. }
  12306. res.ErrMsg = res10265.ErrMsg
  12307. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12308. res.Infcode = infocode
  12309. res.Output = res10265.Output
  12310. res.InfRefmsgid = res10265.InfRefmsgid
  12311. } else {
  12312. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12313. utils.ErrorLog("解析失败:%v", err)
  12314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12315. return
  12316. }
  12317. }
  12318. var user_name string
  12319. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  12320. if role.ID == 0 {
  12321. user_name = "xxx"
  12322. } else {
  12323. user_name = role.UserName
  12324. }
  12325. baseParams := models.BaseParams{
  12326. SecretKey: miConfig.SecretKey,
  12327. FixmedinsCode: miConfig.Code,
  12328. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12329. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12330. OrgName: miConfig.OrgName,
  12331. Doctor: user_name,
  12332. }
  12333. if config.IsOpen == 1 {
  12334. if miConfig.Code == "H15049901371" {
  12335. if med_type == "14" {
  12336. if insutype == "390" {
  12337. med_type = "9933"
  12338. } else if insutype == "310" {
  12339. med_type = "990502"
  12340. }
  12341. } else if med_type == "11" {
  12342. med_type = "11"
  12343. }
  12344. }
  12345. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  12346. var dat map[string]interface{}
  12347. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12348. fmt.Println(dat)
  12349. } else {
  12350. fmt.Println(err)
  12351. }
  12352. var res Result2001
  12353. var res10265 Result2001Org10265
  12354. if miConfig.Code == "H15049901371" {
  12355. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12356. utils.ErrorLog("解析失败:%v", err)
  12357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12358. return
  12359. }
  12360. res.ErrMsg = res10265.ErrMsg
  12361. res.Output = res10265.Output
  12362. res.InfRefmsgid = res10265.InfRefmsgid
  12363. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12364. res.Infcode = infocode
  12365. } else {
  12366. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12367. utils.ErrorLog("解析失败:%v", err)
  12368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12369. return
  12370. }
  12371. }
  12372. if res.Infcode == 0 {
  12373. c.ServeSuccessJSON(map[string]interface{}{
  12374. "msg": res.Output.Trtinfo,
  12375. })
  12376. }
  12377. }
  12378. }
  12379. }
  12380. //func (c *HisApiController) PutRecord() {
  12381. // id, _ := c.GetInt64("id")
  12382. // record_time := c.GetString("record_time")
  12383. // timeLayout := "2006-01-02"
  12384. // loc, _ := time.LoadLocation("Local")
  12385. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12386. // if err != nil {
  12387. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12388. // return
  12389. // }
  12390. // recordDateTime := theTime.Unix()
  12391. //
  12392. // adminInfo := c.GetAdminUserInfo()
  12393. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  12394. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12395. //
  12396. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12397. //
  12398. // fmt.Println(miConfig.SecretKey)
  12399. //
  12400. // if patient == nil {
  12401. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12402. // return
  12403. // }
  12404. // if len(patient.IdCardNo) == 0 {
  12405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  12406. // return
  12407. // }
  12408. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  12409. // if config.IsOpen == 1 {
  12410. // 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
  12411. // resp, requestErr := http.Get(api)
  12412. // if requestErr != nil {
  12413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12414. // return
  12415. // }
  12416. // defer resp.Body.Close()
  12417. // body, ioErr := ioutil.ReadAll(resp.Body)
  12418. // if ioErr != nil {
  12419. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12420. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12421. // return
  12422. // }
  12423. // var respJSON map[string]interface{}
  12424. //
  12425. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12426. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12427. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12428. // return
  12429. // }
  12430. //
  12431. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12432. // userJSONBytes, _ := json.Marshal(userJSON)
  12433. // var res ResultTwo
  12434. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12435. // utils.ErrorLog("解析失败:%v", err)
  12436. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12437. // return
  12438. // }
  12439. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12440. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12441. // infoStr := string(Iinfos)
  12442. // idetinfoStr := string(Idetinfos)
  12443. //
  12444. // if res.Infcode == 0 {
  12445. // his := models.VMHisPatient{
  12446. // Status: 1,
  12447. // Ctime: time.Now().Unix(),
  12448. // Mtime: time.Now().Unix(),
  12449. // PsnNo: res.Output.Baseinfo.PsnNo,
  12450. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  12451. // Certno: res.Output.Baseinfo.Certno,
  12452. // PsnName: res.Output.Baseinfo.PsnName,
  12453. // Gend: res.Output.Baseinfo.Gend,
  12454. // Naty: res.Output.Baseinfo.Naty,
  12455. // Brdy: res.Output.Baseinfo.Brdy,
  12456. // Age: res.Output.Baseinfo.Age,
  12457. // Iinfo: infoStr,
  12458. // Idetinfo: idetinfoStr,
  12459. // PatientId: patient.ID,
  12460. // RecordDate: theTime.Unix(),
  12461. // UserOrgId: adminInfo.CurrentOrgId,
  12462. // AdminUserId: adminInfo.AdminUser.Id,
  12463. // IsReturn: 1,
  12464. // }
  12465. //
  12466. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  12467. // //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")
  12468. // //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")
  12469. //
  12470. // //var dat map[string]interface{}
  12471. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12472. // // fmt.Println(dat)
  12473. // //} else {
  12474. // // fmt.Println(err)
  12475. // //}
  12476. //
  12477. // var dat2 map[string]interface{}
  12478. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  12479. // fmt.Println(dat2)
  12480. // } else {
  12481. // fmt.Println(err)
  12482. // }
  12483. //
  12484. // } else {
  12485. // adminUser := c.GetAdminUserInfo()
  12486. // errlog := &models.HisOrderError{
  12487. // UserOrgId: adminUser.CurrentOrgId,
  12488. // Ctime: time.Now().Unix(),
  12489. // Mtime: time.Now().Unix(),
  12490. // ErrMsg: res.ErrMsg,
  12491. // Status: 1,
  12492. // PatientId: id,
  12493. // RecordTime: recordDateTime,
  12494. // Stage: 1,
  12495. // }
  12496. // service.CreateErrMsgLog(errlog)
  12497. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  12498. // return
  12499. // }
  12500. // }
  12501. //
  12502. //}
  12503. //func (c *HisApiController) GetUploadDiag() {
  12504. // id, _ := c.GetInt64("id")
  12505. // record_time := c.GetString("record_time")
  12506. //
  12507. // diagnosis_id, _ := c.GetInt64("diagnosis")
  12508. // sick_type, _ := c.GetInt64("sick_type")
  12509. // reg_type, _ := c.GetInt64("reg_type")
  12510. //
  12511. // timeLayout := "2006-01-02"
  12512. // loc, _ := time.LoadLocation("Local")
  12513. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12514. // if err != nil {
  12515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12516. // return
  12517. // }
  12518. //
  12519. // var patientPrescription models.HisPrescriptionInfo
  12520. // recordDateTime := theTime.Unix()
  12521. // adminInfo := c.GetAdminUserInfo()
  12522. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12523. //
  12524. // if patientPrescription.ID == 0 {
  12525. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12526. // }
  12527. //
  12528. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12529. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  12530. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12531. // sickConfig, _ := service.FindSickById(sick_type)
  12532. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12533. //
  12534. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  12535. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  12536. // "&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 +
  12537. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  12538. // resp2, requestErr2 := http.Get(api2)
  12539. // if requestErr2 != nil {
  12540. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12541. // return
  12542. // }
  12543. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  12544. // if ioErr2 != nil {
  12545. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  12546. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12547. // return
  12548. // }
  12549. // var respJSON2 map[string]interface{}
  12550. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  12551. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12552. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12553. // return
  12554. // }
  12555. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12556. // userJSONBytes2, _ := json.Marshal(respJSON2)
  12557. //
  12558. // var res2 ResultSix
  12559. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12560. // utils.ErrorLog("解析失败:%v", err)
  12561. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12562. // return
  12563. // }
  12564. // if res2.Infcode != 0 {
  12565. // adminUser := c.GetAdminUserInfo()
  12566. // errlog := &models.HisOrderError{
  12567. // UserOrgId: adminUser.CurrentOrgId,
  12568. // Ctime: time.Now().Unix(),
  12569. // Mtime: time.Now().Unix(),
  12570. // ErrMsg: res2.ErrMsg,
  12571. // Status: 1,
  12572. // PatientId: id,
  12573. // RecordTime: recordDateTime,
  12574. // Stage: 3,
  12575. // }
  12576. // service.CreateErrMsgLog(errlog)
  12577. //
  12578. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  12579. // return
  12580. // }
  12581. //
  12582. // c.ServeSuccessJSON(map[string]interface{}{
  12583. // "msg": "上传成功",
  12584. // })
  12585. //
  12586. //}
  12587. type QueryResult struct {
  12588. ID int64
  12589. Name string
  12590. Code string
  12591. List_type_code string
  12592. }
  12593. func (c *HisApiController) GetCheckCode() {
  12594. ids_str := c.GetString("ids")
  12595. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12596. ids_arr := strings.Split(ids_str, ",")
  12597. var queryResult []QueryResult
  12598. ids := make([]int64, 0)
  12599. for _, item := range ids_arr {
  12600. id, _ := strconv.ParseInt(item, 10, 64)
  12601. ids = append(ids, id)
  12602. }
  12603. if record_type == 1 {
  12604. drugs, _ := service.GetBatchDrugList(ids)
  12605. for _, item := range drugs {
  12606. result := QueryResult{
  12607. ID: item.ID,
  12608. Name: item.DrugName,
  12609. Code: item.MedicalInsuranceNumber,
  12610. List_type_code: "101",
  12611. }
  12612. queryResult = append(queryResult, result)
  12613. }
  12614. } else if record_type == 2 {
  12615. goods, _ := service.GetBatchGoodInformationList(ids)
  12616. for _, item := range goods {
  12617. result := QueryResult{
  12618. ID: item.ID,
  12619. Name: item.GoodName,
  12620. Code: item.MedicalInsuranceNumber,
  12621. List_type_code: "301",
  12622. }
  12623. queryResult = append(queryResult, result)
  12624. }
  12625. } else if record_type == 3 {
  12626. projects, _ := service.GetBathchMyPorjecgList(ids)
  12627. for _, item := range projects {
  12628. result := QueryResult{
  12629. ID: item.ID,
  12630. Name: item.ProjectName,
  12631. Code: item.MedicalCode,
  12632. List_type_code: "201",
  12633. }
  12634. queryResult = append(queryResult, result)
  12635. }
  12636. }
  12637. admin_user_id, _ := c.GetInt64("admin_user_id")
  12638. adminUser := c.GetAdminUserInfo()
  12639. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12640. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12641. var user_name string
  12642. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12643. if role.ID == 0 {
  12644. user_name = "xxx"
  12645. } else {
  12646. user_name = role.UserName
  12647. }
  12648. baseParams := &models.BaseParams{
  12649. SecretKey: miConfig.SecretKey,
  12650. FixmedinsCode: miConfig.Code,
  12651. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12652. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12653. OrgName: miConfig.OrgName,
  12654. Doctor: user_name,
  12655. }
  12656. if config.IsOpen == 1 {
  12657. for _, item := range queryResult {
  12658. var result string
  12659. if record_type == 1 {
  12660. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12661. } else if record_type == 2 {
  12662. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12663. } else if record_type == 3 {
  12664. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12665. }
  12666. var dat map[string]interface{}
  12667. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12668. fmt.Println(dat)
  12669. } else {
  12670. fmt.Println(err)
  12671. }
  12672. userJSONBytes, _ := json.Marshal(dat)
  12673. var res ResultSix
  12674. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12675. utils.ErrorLog("解析失败:%v", err)
  12676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12677. return
  12678. }
  12679. if res.Infcode == 0 {
  12680. if record_type == 1 {
  12681. service.UpdateBaseDrugById(item.ID)
  12682. } else if record_type == 2 {
  12683. service.UpdateGoodInformaitonByDetail(item.ID)
  12684. } else if record_type == 3 {
  12685. service.UpdateProjectById(item.ID)
  12686. }
  12687. c.ServeSuccessJSON(map[string]interface{}{
  12688. "failed_code": 0,
  12689. "msg": "目录对照成功",
  12690. })
  12691. } else {
  12692. c.ServeSuccessJSON(map[string]interface{}{
  12693. "failed_code": -10,
  12694. "msg": res.ErrMsg,
  12695. })
  12696. }
  12697. }
  12698. }
  12699. }
  12700. func (c *HisApiController) UnCheckCode() {
  12701. ids_str := c.GetString("ids")
  12702. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12703. admin_user_id, _ := c.GetInt64("admin_user_id")
  12704. ids_arr := strings.Split(ids_str, ",")
  12705. var queryResult []QueryResult
  12706. ids := make([]int64, 0)
  12707. for _, item := range ids_arr {
  12708. id, _ := strconv.ParseInt(item, 10, 64)
  12709. ids = append(ids, id)
  12710. }
  12711. if record_type == 1 {
  12712. drugs, _ := service.GetBatchDrugList(ids)
  12713. for _, item := range drugs {
  12714. result := QueryResult{
  12715. ID: item.ID,
  12716. Name: item.DrugName,
  12717. Code: item.MedicalInsuranceNumber,
  12718. List_type_code: "101",
  12719. }
  12720. queryResult = append(queryResult, result)
  12721. }
  12722. } else if record_type == 2 {
  12723. goods, _ := service.GetBatchGoodInformationList(ids)
  12724. for _, item := range goods {
  12725. result := QueryResult{
  12726. ID: item.ID,
  12727. Name: item.GoodName,
  12728. Code: item.MedicalInsuranceNumber,
  12729. List_type_code: "301",
  12730. }
  12731. queryResult = append(queryResult, result)
  12732. }
  12733. } else if record_type == 3 {
  12734. projects, _ := service.GetBathchMyPorjecgList(ids)
  12735. for _, item := range projects {
  12736. result := QueryResult{
  12737. ID: item.ID,
  12738. Name: item.ProjectName,
  12739. Code: item.MedicalCode,
  12740. List_type_code: "201",
  12741. }
  12742. queryResult = append(queryResult, result)
  12743. }
  12744. }
  12745. adminUser := c.GetAdminUserInfo()
  12746. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12747. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12748. var user_name string
  12749. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12750. if role.ID == 0 {
  12751. user_name = "xxx"
  12752. } else {
  12753. user_name = role.UserName
  12754. }
  12755. baseParams := &models.BaseParams{
  12756. SecretKey: miConfig.SecretKey,
  12757. FixmedinsCode: miConfig.Code,
  12758. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12759. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12760. OrgName: miConfig.OrgName,
  12761. Doctor: user_name,
  12762. }
  12763. if config.IsOpen == 1 {
  12764. for _, item := range queryResult {
  12765. var result string
  12766. if record_type == 1 {
  12767. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12768. } else if record_type == 2 {
  12769. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12770. } else if record_type == 3 {
  12771. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12772. }
  12773. var dat2 map[string]interface{}
  12774. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  12775. fmt.Println(dat2)
  12776. } else {
  12777. fmt.Println(err)
  12778. }
  12779. userJSONBytes, _ := json.Marshal(dat2)
  12780. var res ResultSix
  12781. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12782. utils.ErrorLog("解析失败:%v", err)
  12783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12784. return
  12785. }
  12786. if res.Infcode == 0 {
  12787. if record_type == 1 {
  12788. service.UpdateDrugByIdDetail(item.ID)
  12789. } else if record_type == 2 {
  12790. service.UpdateGoodInfoById(item.ID)
  12791. } else if record_type == 3 {
  12792. service.UpdateMyProjectById(item.ID)
  12793. }
  12794. c.ServeSuccessJSON(map[string]interface{}{
  12795. "failed_code": 0,
  12796. "msg": "撤销目录对照成功",
  12797. })
  12798. } else {
  12799. c.ServeSuccessJSON(map[string]interface{}{
  12800. "failed_code": -10,
  12801. "msg": res.ErrMsg,
  12802. })
  12803. }
  12804. }
  12805. }
  12806. }
  12807. func (c *HisApiController) GetPatientInfo() {
  12808. id_card_no := c.GetString("id_card_no")
  12809. admin_user_id, _ := c.GetInt64("admin_user_id")
  12810. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12811. if patient.ID == 0 {
  12812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12813. return
  12814. }
  12815. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12816. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12817. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  12818. if config.IsOpen == 1 {
  12819. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12820. var dat map[string]interface{}
  12821. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12822. fmt.Println(dat)
  12823. } else {
  12824. fmt.Println(err)
  12825. }
  12826. userJSONBytes, _ := json.Marshal(dat)
  12827. var res ResultTwo
  12828. var res10265 ResultTwo10265
  12829. if miConfig.Code == "H15049901371" {
  12830. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12831. utils.ErrorLog("解析失败:%v", err)
  12832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12833. return
  12834. }
  12835. res.ErrMsg = res10265.ErrMsg
  12836. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12837. res.Infcode = infocode
  12838. res.Output = res10265.Output
  12839. res.InfRefmsgid = res10265.InfRefmsgid
  12840. } else {
  12841. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12842. utils.ErrorLog("解析失败:%v", err)
  12843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12844. return
  12845. }
  12846. }
  12847. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12848. // utils.ErrorLog("解析失败:%v", err)
  12849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12850. // return
  12851. //}
  12852. if res.Infcode != 0 {
  12853. c.ServeSuccessJSON(map[string]interface{}{
  12854. "failed_code": -10,
  12855. "msg": res.ErrMsg,
  12856. })
  12857. } else {
  12858. c.ServeSuccessJSON(map[string]interface{}{
  12859. "failed_code": 0,
  12860. "info": res,
  12861. })
  12862. }
  12863. }
  12864. }
  12865. func (c *HisApiController) PsnPutOnRecord() {
  12866. record_type, _ := c.GetInt64("type")
  12867. patient_id, _ := c.GetInt64("patient_id")
  12868. admin_user_id, _ := c.GetInt64("admin_user_id")
  12869. start_time := c.GetString("start_time")
  12870. end_time := c.GetString("end_time")
  12871. adminUser := c.GetAdminUserInfo()
  12872. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12873. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12874. var patients []*models.Patients
  12875. if record_type == 1 { //全部备案
  12876. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  12877. patients = append(patients, patient...)
  12878. } else { //单个备案
  12879. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12880. patients = append(patients, patient)
  12881. }
  12882. var user_name string
  12883. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12884. if role.ID == 0 {
  12885. user_name = "xxx"
  12886. } else {
  12887. user_name = role.UserName
  12888. }
  12889. if config.IsOpen == 1 {
  12890. for _, item := range patients {
  12891. 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
  12892. resp, requestErr := http.Get(api)
  12893. if requestErr != nil {
  12894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12895. return
  12896. }
  12897. defer resp.Body.Close()
  12898. body, ioErr := ioutil.ReadAll(resp.Body)
  12899. if ioErr != nil {
  12900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12902. return
  12903. }
  12904. var respJSON map[string]interface{}
  12905. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12908. return
  12909. }
  12910. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12911. userJSONBytes, _ := json.Marshal(userJSON)
  12912. var res ResultTwo
  12913. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12914. utils.ErrorLog("解析失败:%v", err)
  12915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12916. return
  12917. }
  12918. if res.Infcode == 0 {
  12919. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  12920. var dat map[string]interface{}
  12921. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12922. fmt.Println(dat)
  12923. } else {
  12924. fmt.Println(err)
  12925. }
  12926. userJSONBytes, _ := json.Marshal(dat)
  12927. var res2 ResultThirteen
  12928. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12929. utils.ErrorLog("解析失败:%v", err)
  12930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12931. return
  12932. }
  12933. if res2.Infcode == 0 {
  12934. psnResult := &models.GdybPsnRecord{
  12935. UserOrgId: adminUser.CurrentOrgId,
  12936. PatientId: item.ID,
  12937. PsnNo: res.Output.Baseinfo.PsnNo,
  12938. Ctime: time.Now().Unix(),
  12939. Mtime: time.Now().Unix(),
  12940. Status: 1,
  12941. IsCancel: 1,
  12942. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  12943. }
  12944. service.CreatePsnRecord(psnResult)
  12945. } else {
  12946. c.ServeSuccessJSON(map[string]interface{}{
  12947. "failed_code": -10,
  12948. "msg": res2.ErrMsg,
  12949. })
  12950. return
  12951. }
  12952. }
  12953. }
  12954. }
  12955. }
  12956. func (c *HisApiController) PsnUnPutOnRecord() {
  12957. id, _ := c.GetInt64("id")
  12958. //record_type, _ := c.GetInt64("type")
  12959. admin_user_id, _ := c.GetInt64("admin_user_id")
  12960. adminUser := c.GetAdminUserInfo()
  12961. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12962. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12963. var user_name string
  12964. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12965. if role.ID == 0 {
  12966. user_name = "xxx"
  12967. } else {
  12968. user_name = role.UserName
  12969. }
  12970. psn_record, _ := service.GetPsnRecordById(id)
  12971. if psn_record.ID == 0 {
  12972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12973. return
  12974. }
  12975. if config.IsOpen == 1 {
  12976. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  12977. var dat map[string]interface{}
  12978. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12979. fmt.Println(dat)
  12980. } else {
  12981. fmt.Println(err)
  12982. }
  12983. userJSONBytes, _ := json.Marshal(dat)
  12984. var res ResultFourteen
  12985. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12986. utils.ErrorLog("解析失败:%v", err)
  12987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12988. return
  12989. }
  12990. if res.Infcode == 0 {
  12991. psn_record.IsCancel = 2
  12992. service.CreatePsnRecord(&psn_record)
  12993. } else {
  12994. c.ServeSuccessJSON(map[string]interface{}{
  12995. "failed_code": -10,
  12996. "msg": res.ErrMsg,
  12997. })
  12998. return
  12999. }
  13000. }
  13001. }
  13002. func (c *HisApiController) PsnPutNCDSOnRecord() {
  13003. patient_id, _ := c.GetInt64("patient_id")
  13004. insutype_two := c.GetString("insutype")
  13005. psn_no := c.GetString("psn_no")
  13006. doctor_id, _ := c.GetInt64("doctor_id")
  13007. sick_id, _ := c.GetInt64("sick_id")
  13008. department_id, _ := c.GetInt64("department_id")
  13009. start_time := c.GetString("start_time")
  13010. end_time := c.GetString("end_time")
  13011. check_time := c.GetString("check_time")
  13012. adminUser := c.GetAdminUserInfo()
  13013. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13014. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13015. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13016. sick, _ := service.FindSickById(sick_id)
  13017. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13018. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13019. var res ResultTwo
  13020. var res10265 ResultTwo10265
  13021. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13022. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  13023. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  13024. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13025. "&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
  13026. resp, requestErr := http.Get(api)
  13027. if requestErr != nil {
  13028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13029. return
  13030. }
  13031. body, ioErr := ioutil.ReadAll(resp.Body)
  13032. if ioErr != nil {
  13033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13035. return
  13036. }
  13037. var respJSON map[string]interface{}
  13038. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13041. return
  13042. }
  13043. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13044. result, _ := json.Marshal(respJSON)
  13045. fmt.Println("log")
  13046. fmt.Println(string(result))
  13047. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13048. utils.ErrorLog("解析失败:%v", err)
  13049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13050. return
  13051. }
  13052. res.ErrMsg = res10265.ErrMsg
  13053. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13054. res.Infcode = infocode
  13055. res.Output = res10265.Output
  13056. res.InfRefmsgid = res10265.InfRefmsgid
  13057. } else {
  13058. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13059. if miConfig.Code == "H15049901371" {
  13060. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13061. utils.ErrorLog("解析失败:%v", err)
  13062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13063. return
  13064. }
  13065. res.ErrMsg = res10265.ErrMsg
  13066. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13067. res.Infcode = infocode
  13068. res.Output = res10265.Output
  13069. res.InfRefmsgid = res10265.InfRefmsgid
  13070. } else {
  13071. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13072. utils.ErrorLog("解析失败:%v", err)
  13073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13074. return
  13075. }
  13076. }
  13077. }
  13078. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13079. infoStr := string(Iinfos)
  13080. var rf []*ResultFive
  13081. json.Unmarshal([]byte(infoStr), &rf)
  13082. var insuplc_admdvs string
  13083. var insutype string
  13084. var is390 int = 0
  13085. var is310 int = 0
  13086. var insutypes []*ResultFive
  13087. for _, item := range rf {
  13088. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13089. insutypes = append(insutypes, item)
  13090. }
  13091. }
  13092. if len(insutypes) == 1 {
  13093. insutype = insutypes[0].Insutype
  13094. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13095. } else {
  13096. for _, i := range insutypes {
  13097. if i.Insutype == "390" {
  13098. is390 = 1
  13099. }
  13100. if i.Insutype == "310" {
  13101. is310 = 1
  13102. }
  13103. }
  13104. }
  13105. if is390 == 1 {
  13106. insutype = "390"
  13107. }
  13108. if is310 == 1 {
  13109. insutype = "310"
  13110. }
  13111. if len(insutypes) == 2 {
  13112. insutype = insutype_two
  13113. }
  13114. if len(insutypes) == 0 {
  13115. insutype = "310"
  13116. }
  13117. insutype = insutype_two
  13118. fmt.Println(insutype)
  13119. for _, item := range rf {
  13120. fmt.Println(item.Insutype)
  13121. fmt.Println(insutype)
  13122. if item.Insutype == insutype {
  13123. fmt.Println(item.Insutype)
  13124. fmt.Println(insutype)
  13125. insuplc_admdvs = item.InsuplcAdmdvs
  13126. }
  13127. }
  13128. fmt.Println(insuplc_admdvs)
  13129. var res2 ResultThirteen
  13130. var res10265_2 ResultThirteen10265
  13131. if config.IsOpen == 1 {
  13132. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13133. } else {
  13134. 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)
  13135. var dat map[string]interface{}
  13136. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13137. fmt.Println(dat)
  13138. } else {
  13139. fmt.Println(err)
  13140. }
  13141. userJSONBytes, _ := json.Marshal(dat)
  13142. if miConfig.Code == "H15049901371" {
  13143. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  13144. utils.ErrorLog("解析失败:%v", err)
  13145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13146. return
  13147. }
  13148. res2.ErrMsg = res10265_2.ErrMsg
  13149. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  13150. res2.Infcode = infocode
  13151. res2.Output = res10265_2.Output
  13152. res2.InfRefmsgid = res10265_2.InfRefmsgid
  13153. } else {
  13154. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13155. utils.ErrorLog("解析失败:%v", err)
  13156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13157. return
  13158. }
  13159. }
  13160. }
  13161. if res2.Infcode == 0 {
  13162. psnResult := &models.GdybPsnNcdsRecord{
  13163. UserOrgId: adminUser.CurrentOrgId,
  13164. PatientId: patient.ID,
  13165. PsnNo: psn_no,
  13166. DoctorId: doctor.AdminUserId,
  13167. DepartmentId: department_id,
  13168. SickType: sick_id,
  13169. Insutype: insutype,
  13170. Ctime: time.Now().Unix(),
  13171. Mtime: time.Now().Unix(),
  13172. Status: 1,
  13173. IsCancel: 1,
  13174. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  13175. }
  13176. service.CreatePsnNCDSRecord(psnResult)
  13177. c.ServeSuccessJSON(map[string]interface{}{
  13178. "failed_code": 0,
  13179. "msg": "备案成功",
  13180. "result": psnResult,
  13181. })
  13182. } else {
  13183. c.ServeSuccessJSON(map[string]interface{}{
  13184. "failed_code": -10,
  13185. "msg": res2.ErrMsg,
  13186. })
  13187. return
  13188. }
  13189. }
  13190. }
  13191. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  13192. id, _ := c.GetInt64("id")
  13193. admin_user_id, _ := c.GetInt64("admin_user_id")
  13194. adminUser := c.GetAdminUserInfo()
  13195. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13196. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13197. //config, _ := service.Ge(adminUser.CurrentOrgId)
  13198. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  13199. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13200. //var user_name string
  13201. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13202. //if role.ID == 0 {
  13203. // user_name = "xxx"
  13204. //} else {
  13205. // user_name = role.UserName
  13206. //}
  13207. psn_record, _ := service.GetPsnNCDSRecordById(id)
  13208. if psn_record.ID == 0 {
  13209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13210. return
  13211. }
  13212. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13213. var res ResultTwo
  13214. var res10265 ResultTwo10265
  13215. if miConfig.Code == "H15049901371" {
  13216. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13217. utils.ErrorLog("解析失败:%v", err)
  13218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13219. return
  13220. }
  13221. res.ErrMsg = res10265.ErrMsg
  13222. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13223. res.Infcode = infocode
  13224. res.Output = res10265.Output
  13225. res.InfRefmsgid = res10265.InfRefmsgid
  13226. } else {
  13227. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13228. utils.ErrorLog("解析失败:%v", err)
  13229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13230. return
  13231. }
  13232. }
  13233. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13234. infoStr := string(Iinfos)
  13235. var rf []*ResultFive
  13236. json.Unmarshal([]byte(infoStr), &rf)
  13237. var insuplc_admdvs string
  13238. var insutype string
  13239. var is390 int = 0
  13240. var is310 int = 0
  13241. var insutypes []*ResultFive
  13242. for _, item := range rf {
  13243. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13244. insutypes = append(insutypes, item)
  13245. }
  13246. }
  13247. if len(insutypes) == 1 {
  13248. insutype = insutypes[0].Insutype
  13249. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13250. } else {
  13251. for _, i := range insutypes {
  13252. if i.Insutype == "390" {
  13253. is390 = 1
  13254. }
  13255. if i.Insutype == "310" {
  13256. is310 = 1
  13257. }
  13258. }
  13259. }
  13260. if is390 == 1 {
  13261. insutype = "390"
  13262. }
  13263. if is310 == 1 {
  13264. insutype = "310"
  13265. }
  13266. if len(insutypes) == 0 {
  13267. insutype = "310"
  13268. }
  13269. insutype = psn_record.Insutype
  13270. for _, item := range rf {
  13271. if item.Insutype == insutype {
  13272. insuplc_admdvs = item.InsuplcAdmdvs
  13273. }
  13274. }
  13275. if config.IsOpen == 1 {
  13276. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  13277. var dat map[string]interface{}
  13278. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13279. fmt.Println(dat)
  13280. } else {
  13281. fmt.Println(err)
  13282. }
  13283. userJSONBytes, _ := json.Marshal(dat)
  13284. var res ResultFourteen
  13285. var res10265 ResultFourteen10265
  13286. if miConfig.Code == "H15049901371" {
  13287. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13288. utils.ErrorLog("解析失败:%v", err)
  13289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13290. return
  13291. }
  13292. res.ErrMsg = res10265.ErrMsg
  13293. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13294. res.Infcode = infocode
  13295. res.Output = res10265.Output
  13296. res.InfRefmsgid = res10265.InfRefmsgid
  13297. } else {
  13298. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13299. utils.ErrorLog("解析失败:%v", err)
  13300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13301. return
  13302. }
  13303. }
  13304. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13305. // utils.ErrorLog("解析失败:%v", err)
  13306. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13307. // return
  13308. //}
  13309. if res.Infcode == 0 {
  13310. psn_record.IsCancel = 2
  13311. service.CreatePsnNCDSRecord(&psn_record)
  13312. c.ServeSuccessJSON(map[string]interface{}{
  13313. "failed_code": 0,
  13314. "msg": "撤销备案成功",
  13315. })
  13316. } else {
  13317. c.ServeSuccessJSON(map[string]interface{}{
  13318. "failed_code": -10,
  13319. "msg": res.ErrMsg,
  13320. })
  13321. return
  13322. }
  13323. }
  13324. }
  13325. func (c *HisApiController) TestTest() {
  13326. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  13327. fmt.Println(patient.Iinfo)
  13328. }
  13329. type CustomData struct {
  13330. MsgId string
  13331. PsnNo string
  13332. Info string
  13333. }
  13334. func (c *HisApiController) ReversalData() {
  13335. var customData []*CustomData
  13336. custom := &CustomData{
  13337. MsgId: "H44022900158202103301714472004",
  13338. PsnNo: "44020000001101329945",
  13339. Info: "2207",
  13340. }
  13341. customData = append(customData, custom)
  13342. custom1 := &CustomData{
  13343. MsgId: "H4402290015820210330172057803",
  13344. PsnNo: "44020000001101161813",
  13345. Info: "2207",
  13346. }
  13347. customData = append(customData, custom1)
  13348. custom2 := &CustomData{
  13349. MsgId: "H44022900158202103301705198813",
  13350. PsnNo: "44190000133097375417",
  13351. Info: "2207",
  13352. }
  13353. customData = append(customData, custom2)
  13354. custom3 := &CustomData{
  13355. MsgId: "H44022900158202103301715524756",
  13356. PsnNo: "44020000001100187221",
  13357. Info: "2207",
  13358. }
  13359. customData = append(customData, custom3)
  13360. custom4 := &CustomData{
  13361. MsgId: "H44022900158202103301730376224",
  13362. PsnNo: "44020000001101959155",
  13363. Info: "2207",
  13364. }
  13365. customData = append(customData, custom4)
  13366. custom5 := &CustomData{
  13367. MsgId: "H44022900158202103301748008725",
  13368. PsnNo: "44020000001104246641",
  13369. Info: "2207",
  13370. }
  13371. customData = append(customData, custom5)
  13372. custom6 := &CustomData{
  13373. MsgId: "H44022900158202103301718096755",
  13374. PsnNo: "44020000001102211860",
  13375. Info: "2207",
  13376. }
  13377. customData = append(customData, custom6)
  13378. custom7 := &CustomData{
  13379. MsgId: "H44022900158202103301736551640",
  13380. PsnNo: "44020000001102687718",
  13381. Info: "2207",
  13382. }
  13383. customData = append(customData, custom7)
  13384. custom8 := &CustomData{
  13385. MsgId: "H44022900158202103301743097676",
  13386. PsnNo: "44020000001102127785",
  13387. Info: "2207",
  13388. }
  13389. customData = append(customData, custom8)
  13390. custom9 := &CustomData{
  13391. MsgId: "H44022900158202103301712304203",
  13392. PsnNo: "44020000001101518097",
  13393. Info: "2207",
  13394. }
  13395. customData = append(customData, custom9)
  13396. custom10 := &CustomData{
  13397. MsgId: "H44022900158202103301738448785",
  13398. PsnNo: "44020000001100500813",
  13399. Info: "2207",
  13400. }
  13401. customData = append(customData, custom10)
  13402. custom11 := &CustomData{
  13403. MsgId: "H44022900158202103301732455843",
  13404. PsnNo: "44020000001102690557",
  13405. Info: "2207",
  13406. }
  13407. customData = append(customData, custom11)
  13408. custom12 := &CustomData{
  13409. MsgId: "H44022900158202103301745421708",
  13410. PsnNo: "44020000001102211928",
  13411. Info: "2207",
  13412. }
  13413. customData = append(customData, custom12)
  13414. custom1212 := &CustomData{
  13415. MsgId: "H440229001582021033017351627",
  13416. PsnNo: "44020000001102481733",
  13417. Info: "2207",
  13418. }
  13419. customData = append(customData, custom1212)
  13420. custom13 := &CustomData{
  13421. MsgId: "H44022900158202103301740327951",
  13422. PsnNo: "44020000001103174866",
  13423. Info: "2207",
  13424. }
  13425. customData = append(customData, custom13)
  13426. custom14 := &CustomData{
  13427. MsgId: "H4402290015820210330174922668",
  13428. PsnNo: "44020000001102927272",
  13429. Info: "2207",
  13430. }
  13431. customData = append(customData, custom14)
  13432. custom15 := &CustomData{
  13433. MsgId: "H44022900158202103301752362273",
  13434. PsnNo: "44020000001102942890",
  13435. Info: "2207",
  13436. }
  13437. customData = append(customData, custom15)
  13438. custom16 := &CustomData{
  13439. MsgId: "H44022900158202103301751082917",
  13440. PsnNo: "44020000001101662162",
  13441. Info: "2207",
  13442. }
  13443. customData = append(customData, custom16)
  13444. custom17 := &CustomData{
  13445. MsgId: "H44022900158202103301754147728",
  13446. PsnNo: "44020000000229014511",
  13447. Info: "2207",
  13448. }
  13449. customData = append(customData, custom17)
  13450. adminUser := c.GetAdminUserInfo()
  13451. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13452. for _, item := range customData {
  13453. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13454. fmt.Println(result)
  13455. }
  13456. }
  13457. //func (c *HisApiController) GetAllopatry() {
  13458. // year := c.GetString("year")
  13459. // month := c.GetString("month")
  13460. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13461. // adminUser := c.GetAdminUserInfo()
  13462. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13463. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13464. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13465. //
  13466. // var dat map[string]interface{}
  13467. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13468. // fmt.Println(dat)
  13469. // } else {
  13470. // fmt.Println(err)
  13471. // }
  13472. // userJSONBytes, _ := json.Marshal(dat)
  13473. // var res models.Result9001
  13474. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13475. // utils.ErrorLog("解析失败:%v", err)
  13476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13477. // return
  13478. // }
  13479. //
  13480. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13481. // var dat2 map[string]interface{}
  13482. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13483. // fmt.Println(dat)
  13484. // } else {
  13485. // fmt.Println(err)
  13486. // }
  13487. // userJSONBytes2, _ := json.Marshal(dat2)
  13488. // var res2 models.Result3260
  13489. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13490. // utils.ErrorLog("解析失败:%v", err)
  13491. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13492. // return
  13493. // }
  13494. // if res2.Infcode == 0 {
  13495. // c.ServeSuccessJSON(map[string]interface{}{
  13496. // "list": res2.Output.Data,
  13497. // })
  13498. // return
  13499. // } else {
  13500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13501. // return
  13502. // }
  13503. //
  13504. //}
  13505. //func (c *HisApiController) ComfirmAllopatry() {
  13506. // year := c.GetString("year")
  13507. // month := c.GetString("month")
  13508. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13509. // adminUser := c.GetAdminUserInfo()
  13510. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13511. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13512. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13513. // var dat map[string]interface{}
  13514. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13515. // fmt.Println(dat)
  13516. // } else {
  13517. // fmt.Println(err)
  13518. // }
  13519. // userJSONBytes, _ := json.Marshal(dat)
  13520. // var res models.Result9001
  13521. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13522. // utils.ErrorLog("解析失败:%v", err)
  13523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13524. // return
  13525. // }
  13526. //
  13527. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13528. // var dat2 map[string]interface{}
  13529. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13530. // fmt.Println(dat)
  13531. // } else {
  13532. // fmt.Println(err)
  13533. // }
  13534. // userJSONBytes2, _ := json.Marshal(dat2)
  13535. // var res2 models.Result3260
  13536. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13537. // utils.ErrorLog("解析失败:%v", err)
  13538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13539. // return
  13540. // }
  13541. //
  13542. // if res2.Infcode == 0 {
  13543. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  13544. // var dat map[string]interface{}
  13545. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13546. // fmt.Println(dat)
  13547. // } else {
  13548. // fmt.Println(err)
  13549. // }
  13550. // userJSONBytes, _ := json.Marshal(dat)
  13551. // var res3 models.Result3261
  13552. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  13553. // utils.ErrorLog("解析失败:%v", err)
  13554. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13555. // return
  13556. // }
  13557. //
  13558. // if res3.Infcode == 0 {
  13559. // record := &models.HisYidiClearRecord{
  13560. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13561. // Ctime: time.Now().Unix(),
  13562. // Mtime: time.Now().Unix(),
  13563. // Status: 1,
  13564. // MsgId: msgId,
  13565. // }
  13566. // service.SaveClearRecord(record)
  13567. // c.ServeSuccessJSON(map[string]interface{}{
  13568. // "msg": "提取成功",
  13569. // })
  13570. // }
  13571. // }
  13572. //}
  13573. func (c *HisApiController) RefundAllopatry() {
  13574. year := c.GetString("year")
  13575. month := c.GetString("month")
  13576. id, _ := c.GetInt64("id")
  13577. admin_user_id, _ := c.GetInt64("admin_user_id")
  13578. adminUser := c.GetAdminUserInfo()
  13579. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13580. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13581. record, _ := service.GetClearRecordById(id)
  13582. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  13583. var dat map[string]interface{}
  13584. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13585. fmt.Println(dat)
  13586. } else {
  13587. fmt.Println(err)
  13588. }
  13589. userJSONBytes, _ := json.Marshal(dat)
  13590. var empty ResultFourteen
  13591. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  13592. utils.ErrorLog("解析失败:%v", err)
  13593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13594. return
  13595. }
  13596. if empty.Infcode == 0 {
  13597. c.ServeSuccessJSON(map[string]interface{}{
  13598. "msg": "撤销成功",
  13599. })
  13600. return
  13601. }
  13602. }
  13603. func (c *HisApiController) ReversalOtherData() {
  13604. var customData []*CustomData
  13605. custom := &CustomData{
  13606. MsgId: "H44022900158202103301714472004",
  13607. PsnNo: "44020000001101329945",
  13608. Info: "2208",
  13609. }
  13610. customData = append(customData, custom)
  13611. custom1 := &CustomData{
  13612. MsgId: "H4402290015820210330172057803",
  13613. PsnNo: "44020000001101161813",
  13614. Info: "2208",
  13615. }
  13616. customData = append(customData, custom1)
  13617. custom2 := &CustomData{
  13618. MsgId: "H44022900158202103301705198813",
  13619. PsnNo: "44190000133097375417",
  13620. Info: "2208",
  13621. }
  13622. customData = append(customData, custom2)
  13623. custom3 := &CustomData{
  13624. MsgId: "H44022900158202103301715524756",
  13625. PsnNo: "44020000001100187221",
  13626. Info: "2208",
  13627. }
  13628. customData = append(customData, custom3)
  13629. custom4 := &CustomData{
  13630. MsgId: "H44022900158202103301730376224",
  13631. PsnNo: "44020000001101959155",
  13632. Info: "2208",
  13633. }
  13634. customData = append(customData, custom4)
  13635. custom5 := &CustomData{
  13636. MsgId: "H44022900158202103301748008725",
  13637. PsnNo: "44020000001104246641",
  13638. Info: "2208",
  13639. }
  13640. customData = append(customData, custom5)
  13641. custom6 := &CustomData{
  13642. MsgId: "H44022900158202103301718096755",
  13643. PsnNo: "44020000001102211860",
  13644. Info: "2208",
  13645. }
  13646. customData = append(customData, custom6)
  13647. custom7 := &CustomData{
  13648. MsgId: "H44022900158202103301736551640",
  13649. PsnNo: "44020000001102687718",
  13650. Info: "2208",
  13651. }
  13652. customData = append(customData, custom7)
  13653. custom8 := &CustomData{
  13654. MsgId: "H44022900158202103301743097676",
  13655. PsnNo: "44020000001102127785",
  13656. Info: "2208",
  13657. }
  13658. customData = append(customData, custom8)
  13659. custom9 := &CustomData{
  13660. MsgId: "H44022900158202103301712304203",
  13661. PsnNo: "44020000001101518097",
  13662. Info: "2208",
  13663. }
  13664. customData = append(customData, custom9)
  13665. custom10 := &CustomData{
  13666. MsgId: "H44022900158202103301738448785",
  13667. PsnNo: "44020000001100500813",
  13668. Info: "2208",
  13669. }
  13670. customData = append(customData, custom10)
  13671. custom11 := &CustomData{
  13672. MsgId: "H44022900158202103301732455843",
  13673. PsnNo: "44020000001102690557",
  13674. Info: "2208",
  13675. }
  13676. customData = append(customData, custom11)
  13677. custom12 := &CustomData{
  13678. MsgId: "H44022900158202103301745421708",
  13679. PsnNo: "44020000001102211928",
  13680. Info: "2208",
  13681. }
  13682. customData = append(customData, custom12)
  13683. custom1212 := &CustomData{
  13684. MsgId: "H440229001582021033017351627",
  13685. PsnNo: "44020000001102481733",
  13686. Info: "2208",
  13687. }
  13688. customData = append(customData, custom1212)
  13689. custom13 := &CustomData{
  13690. MsgId: "H44022900158202103301740327951",
  13691. PsnNo: "44020000001103174866",
  13692. Info: "2208",
  13693. }
  13694. customData = append(customData, custom13)
  13695. custom14 := &CustomData{
  13696. MsgId: "H4402290015820210330174922668",
  13697. PsnNo: "44020000001102927272",
  13698. Info: "2208",
  13699. }
  13700. customData = append(customData, custom14)
  13701. custom15 := &CustomData{
  13702. MsgId: "H44022900158202103301752362273",
  13703. PsnNo: "44020000001102942890",
  13704. Info: "2208",
  13705. }
  13706. customData = append(customData, custom15)
  13707. custom16 := &CustomData{
  13708. MsgId: "H44022900158202103301751082917",
  13709. PsnNo: "44020000001101662162",
  13710. Info: "2208",
  13711. }
  13712. customData = append(customData, custom16)
  13713. custom17 := &CustomData{
  13714. MsgId: "H44022900158202103301754147728",
  13715. PsnNo: "44020000000229014511",
  13716. Info: "2208",
  13717. }
  13718. customData = append(customData, custom17)
  13719. adminUser := c.GetAdminUserInfo()
  13720. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13721. for _, item := range customData {
  13722. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13723. fmt.Println(result)
  13724. }
  13725. }
  13726. func PathExists(path string) (bool, error) {
  13727. _, err := os.Stat(path)
  13728. if err == nil {
  13729. return true, nil
  13730. }
  13731. if os.IsNotExist(err) {
  13732. return false, nil
  13733. }
  13734. return false, err
  13735. }
  13736. //创建文件夹
  13737. func Mkdir(dir string) {
  13738. // 创建文件夹
  13739. exist, err := PathExists(dir)
  13740. if err != nil {
  13741. fmt.Println(err.Error())
  13742. } else {
  13743. if exist {
  13744. fmt.Println(dir + "文件夹已存在!")
  13745. } else {
  13746. // 文件夹名称,权限
  13747. err := os.Mkdir(dir, os.ModePerm)
  13748. if err != nil {
  13749. fmt.Println(dir+"文件夹创建失败:", err.Error())
  13750. } else {
  13751. fmt.Println(dir + "文件夹创建成功!")
  13752. }
  13753. }
  13754. }
  13755. }
  13756. //压缩文件
  13757. func Zip(srcFile string, destZip string) error {
  13758. zipfile, err := os.Create(destZip)
  13759. if err != nil {
  13760. return err
  13761. }
  13762. defer zipfile.Close()
  13763. archive := zip.NewWriter(zipfile)
  13764. defer archive.Close()
  13765. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  13766. if err != nil {
  13767. return err
  13768. }
  13769. header, err := zip.FileInfoHeader(info)
  13770. if err != nil {
  13771. return err
  13772. }
  13773. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  13774. // header.Name = path
  13775. if info.IsDir() {
  13776. header.Name += "/"
  13777. } else {
  13778. header.Method = zip.Deflate
  13779. }
  13780. writer, err := archive.CreateHeader(header)
  13781. if err != nil {
  13782. return err
  13783. }
  13784. if !info.IsDir() {
  13785. file, err := os.Open(path)
  13786. if err != nil {
  13787. return err
  13788. }
  13789. defer file.Close()
  13790. _, err = io.Copy(writer, file)
  13791. }
  13792. return err
  13793. })
  13794. return err
  13795. }
  13796. func ReadFile(filePath string) []byte {
  13797. f, err := os.Open(filePath)
  13798. if err != nil {
  13799. fmt.Println("read file fail", err)
  13800. return nil
  13801. }
  13802. defer f.Close()
  13803. fd, err := ioutil.ReadAll(f)
  13804. if err != nil {
  13805. fmt.Println("read to fd fail", err)
  13806. return nil
  13807. }
  13808. return fd
  13809. }
  13810. func saveLog(result string, request string, infno string, desc string) {
  13811. org_id, _ := beego.AppConfig.Int64("org_id")
  13812. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13813. dir := miConfig.OrgName + "日志"
  13814. utils.Mkdir(dir)
  13815. month := time.Unix(1557042972, 0).Format("1")
  13816. year := time.Now().Format("2006")
  13817. month = time.Now().Format("01")
  13818. day := time.Now().Format("02")
  13819. hour := time.Now().Format("15")
  13820. min := time.Now().Format("04")
  13821. sec := time.Now().Format("05")
  13822. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  13823. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  13824. file_name := file + ".txt"
  13825. file_path := miConfig.OrgName + "日志" + "/" + file_name
  13826. exist, _ := utils.PathExists(file_path)
  13827. if exist { //存在
  13828. fmt.Println("存在")
  13829. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  13830. if err != nil {
  13831. fmt.Println("read fail")
  13832. }
  13833. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  13834. n, _ := f.Seek(0, 2)
  13835. _, err = f.WriteAt([]byte(content), n)
  13836. } else { //不存在
  13837. fmt.Println("文件不存在,创建文件")
  13838. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  13839. defer f.Close()
  13840. if err != nil {
  13841. } else {
  13842. _, err = f.Write([]byte("记录日志"))
  13843. }
  13844. }
  13845. }
  13846. type Charset string
  13847. const (
  13848. UTF8 = Charset("UTF-8")
  13849. GB18030 = Charset("GB18030")
  13850. )
  13851. func ConvertToString(src string, srcCode string, tagCode string) string {
  13852. srcCoder := mahonia.NewDecoder(srcCode)
  13853. srcResult := srcCoder.ConvertString(src)
  13854. tagCoder := mahonia.NewDecoder(tagCode)
  13855. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  13856. result := string(cdata)
  13857. return result
  13858. }
  13859. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  13860. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  13861. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13862. var token string
  13863. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13864. var api string
  13865. if miConfig.MdtrtareaAdmvs == "320921" {
  13866. 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 +
  13867. "&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
  13868. fmt.Println(api)
  13869. } else {
  13870. 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 +
  13871. "&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
  13872. }
  13873. resp, requestErr := http.Get(api)
  13874. if requestErr != nil {
  13875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13876. return ""
  13877. }
  13878. body, ioErr := ioutil.ReadAll(resp.Body)
  13879. if ioErr != nil {
  13880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13882. return ""
  13883. }
  13884. var respJSON map[string]interface{}
  13885. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13888. return ""
  13889. }
  13890. var status string
  13891. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13892. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13893. var res ResultTwo //1101结果
  13894. var res10265 ResultTwo10265 //1101结果
  13895. if status == "0" { //读卡成功
  13896. var card_info string //卡信息
  13897. var busi_card_info string
  13898. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13899. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13900. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13901. fmt.Println(card_info)
  13902. fmt.Println(busi_card_info)
  13903. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13904. result, _ := json.Marshal(respJSON)
  13905. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13906. utils.ErrorLog("解析失败:%v", err)
  13907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13908. return ""
  13909. }
  13910. res.ErrMsg = res10265.ErrMsg
  13911. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13912. res.Infcode = infocode
  13913. res.Output = res10265.Output
  13914. res.InfRefmsgid = res10265.InfRefmsgid
  13915. if res.Infcode == 0 {
  13916. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13917. if err == gorm.ErrRecordNotFound {
  13918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13919. return ""
  13920. } else if err != nil {
  13921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13922. return ""
  13923. } else {
  13924. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13925. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13926. infoStr := string(Iinfos)
  13927. idetinfoStr := string(Idetinfos)
  13928. psn := &models.HisPsn{
  13929. PsnNo: res.Output.Baseinfo.PsnNo,
  13930. Age: res.Output.Baseinfo.Age,
  13931. PatientId: patient.ID,
  13932. Certno: res.Output.Baseinfo.Certno,
  13933. Brdy: res.Output.Baseinfo.Brdy,
  13934. Gend: res.Output.Baseinfo.Gend,
  13935. Naty: res.Output.Baseinfo.Naty,
  13936. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13937. PsnName: res.Output.Baseinfo.PsnName,
  13938. Idetinfo: idetinfoStr,
  13939. Insuinfo: infoStr,
  13940. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13941. CardInfo: card_info,
  13942. VerifyNumber: token,
  13943. }
  13944. service.CreateHisPsn(psn)
  13945. return token
  13946. }
  13947. }
  13948. } else {
  13949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13950. return ""
  13951. }
  13952. } else { //读卡失败
  13953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13954. return ""
  13955. }
  13956. return token
  13957. }
  13958. func DeleteExtraSpaceTwo(s string) string {
  13959. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  13960. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  13961. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  13962. reg, _ := regexp.Compile(regstr) //编译正则表达式
  13963. s2 := make([]byte, len(s1)) //定义字符数组切片
  13964. copy(s2, s1) //将字符串复制到切片
  13965. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  13966. for len(spc_index) > 0 { //找到适配项
  13967. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  13968. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  13969. }
  13970. return string(s2)
  13971. }
  13972. func Remove0000(s string) string {
  13973. str := make([]rune, 0, len(s))
  13974. for _, v := range []rune(s) {
  13975. if v == 0 {
  13976. continue
  13977. }
  13978. str = append(str, v)
  13979. }
  13980. return string(str)
  13981. }
  13982. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  13983. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  13984. readCard := DllDef.MustFindProc("EcQuery")
  13985. pCardInfo := make([]byte, 8192)
  13986. pBusiCardInfo := make([]byte, 8192)
  13987. data := make(map[string]interface{})
  13988. //pData := make(map[string]interface{})
  13989. inputData := make(map[string]interface{})
  13990. inputData["orgId"] = code
  13991. inputData["businessType"] = "01101"
  13992. inputData["operatorId"] = operator_id
  13993. inputData["operatorName"] = operator_name
  13994. inputData["officeId"] = "001"
  13995. inputData["officeName"] = "血透室"
  13996. //
  13997. data["data"] = inputData
  13998. data["transType"] = "ec.query"
  13999. data["orgId"] = code
  14000. bytesData, _ := json.Marshal(data)
  14001. pCardInfo = bytesData
  14002. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  14003. fmt.Println(ret2)
  14004. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  14005. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  14006. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  14007. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  14008. if ret2 != 0 {
  14009. return "", ""
  14010. }
  14011. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  14012. }
  14013. func DeleteExtraSpace(s string) string {
  14014. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  14015. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  14016. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  14017. reg, _ := regexp.Compile(regstr) //编译正则表达式
  14018. s2 := make([]byte, len(s1)) //定义字符数组切片
  14019. copy(s2, s1) //将字符串复制到切片
  14020. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  14021. for len(spc_index) > 0 { //找到适配项
  14022. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  14023. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  14024. }
  14025. return string(s2)
  14026. }
  14027. //对账
  14028. func (c *HisApiController) Post3202() {
  14029. start_time := c.GetString("start_time")
  14030. end_time := c.GetString("end_time")
  14031. //insutype := c.GetString("insutype")
  14032. clr_type := c.GetString("clr_type")
  14033. clr_org := c.GetString("clr_optins")
  14034. admin_user_id, _ := c.GetInt64("admin_user_id")
  14035. adminUser := c.GetAdminUserInfo()
  14036. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14037. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14038. if len(clr_org) == 0 {
  14039. clr_org = miConfig.MdtrtareaAdmvs
  14040. }
  14041. timeLayout := "2006-01-02"
  14042. loc, _ := time.LoadLocation("Local")
  14043. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  14044. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  14045. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  14046. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  14047. //fixmedins_setl_cnt := int64(len(orders))
  14048. var medfee_sumamt float64
  14049. var acct_pay float64
  14050. var fund_pay_sumamt float64
  14051. for _, item := range orders {
  14052. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  14053. acct_pay = acct_pay + item.AcctPay
  14054. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  14055. }
  14056. //var medfee_sumamt_two float64
  14057. //var acct_pay_two float64
  14058. //var fund_pay_sumamt_two float64
  14059. //for _, item := range orders_two {
  14060. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  14061. // acct_pay_two = acct_pay_two + item.AcctPay
  14062. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  14063. //}
  14064. //var user_name string
  14065. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14066. //if role.ID == 0 {
  14067. // user_name = "xxx"
  14068. //} else {
  14069. // user_name = role.UserName
  14070. //}
  14071. var res ResultSix
  14072. if config.IsOpen == 1 {
  14073. var bps []*models.BusinessParamsTwo
  14074. var bp models.BusinessParamsTwo
  14075. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  14076. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  14077. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  14078. bp.MedfeeSumamt = medfee_sumamt_str
  14079. bp.AcctPay = acct_pay_str
  14080. bp.FundPaySumamt = fund_pay_sumamt_str
  14081. bp.Insutype = "390"
  14082. bp.StmtBegndate = start_time
  14083. bp.ClrType = clr_type
  14084. bp.SetlOptins = clr_org
  14085. bp.StmtEnddate = end_time
  14086. bps = append(bps, &bp)
  14087. data := make(map[string]interface{})
  14088. data["bps"] = bps
  14089. data["org_name"] = miConfig.OrgName
  14090. data["doctor"] = role.UserName
  14091. data["fixmedins_code"] = miConfig.Code
  14092. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14093. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14094. if miConfig.MdtrtareaAdmvs == "421300" {
  14095. client := &http.Client{}
  14096. bytesData, _ := json.Marshal(data)
  14097. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  14098. resp, _ := client.Do(req)
  14099. defer resp.Body.Close()
  14100. body, ioErr := ioutil.ReadAll(resp.Body)
  14101. if ioErr != nil {
  14102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14104. return
  14105. }
  14106. var respJSON map[string]interface{}
  14107. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14110. return
  14111. }
  14112. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14113. userJSONBytes, _ := json.Marshal(respJSON)
  14114. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14115. utils.ErrorLog("解析失败:%v", err)
  14116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14117. return
  14118. }
  14119. }
  14120. if res.Infcode == 0 {
  14121. c.ServeSuccessJSON(map[string]interface{}{
  14122. "msg": "发起成功",
  14123. })
  14124. } else {
  14125. c.ServeSuccessJSON(map[string]interface{}{
  14126. "code": -10,
  14127. "msg": res.ErrMsg,
  14128. })
  14129. }
  14130. }
  14131. }
  14132. func (c *HisApiController) Post3501() {
  14133. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14134. data := make(map[string]interface{})
  14135. var struct3501s []models.Struct3501
  14136. var struct3501 models.Struct3501
  14137. struct3501.OrgName = miConfig.OrgName
  14138. struct3501.AccessKey = miConfig.AccessKey
  14139. struct3501.RequestUrl = miConfig.Url
  14140. struct3501.SecretKey = miConfig.SecretKey
  14141. struct3501.ManuDate = "2022-08-17"
  14142. struct3501.FixmedinsBchno = ""
  14143. struct3501.ManuLotnum = ""
  14144. struct3501.RxFlag = "0"
  14145. struct3501.ExpyEnd = "2022-08-17"
  14146. struct3501.Invdate = "2022-08-17"
  14147. struct3501.InvCnt = "20.25"
  14148. struct3501.Memo = ""
  14149. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14150. struct3501.FixmedinsHilistId = miConfig.Code
  14151. struct3501.FixmedinsHilistName = miConfig.OrgName
  14152. struct3501s = append(struct3501s, struct3501)
  14153. data["struct_3501s"] = struct3501s
  14154. client := &http.Client{}
  14155. bytesData, _ := json.Marshal(data)
  14156. var req *http.Request
  14157. if miConfig.MdtrtareaAdmvs == "320921" {
  14158. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14159. } else {
  14160. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14161. }
  14162. resp, _ := client.Do(req)
  14163. defer resp.Body.Close()
  14164. body, ioErr := ioutil.ReadAll(resp.Body)
  14165. if ioErr != nil {
  14166. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14168. return
  14169. }
  14170. var respJSON map[string]interface{}
  14171. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14172. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14174. return
  14175. }
  14176. var res ResultSix
  14177. var resSix10265 ResultSix10265 //1101结果
  14178. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14179. result, _ := json.Marshal(respJSON)
  14180. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14181. utils.ErrorLog("解析失败:%v", err)
  14182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14183. return
  14184. }
  14185. res.InfRefmsgid = resSix10265.InfRefmsgid
  14186. res.Output = resSix10265.Output
  14187. res.ErrMsg = resSix10265.ErrMsg
  14188. res.Cainfo = resSix10265.Cainfo
  14189. res.WarnMsg = resSix10265.WarnMsg
  14190. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14191. res.Infcode = infocode
  14192. if infocode == 0 {
  14193. c.ServeSuccessJSON(map[string]interface{}{
  14194. "msg": "上传成功",
  14195. })
  14196. return
  14197. } else {
  14198. c.ServeSuccessJSON(map[string]interface{}{
  14199. "failed_code": -10,
  14200. "msg": res.ErrMsg,
  14201. })
  14202. return
  14203. }
  14204. }
  14205. func (c *HisApiController) Post3502() {
  14206. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14207. data := make(map[string]interface{})
  14208. var struct3502s []models.Struct3502
  14209. var struct3502 models.Struct3502
  14210. struct3502.OrgName = miConfig.OrgName
  14211. struct3502.AccessKey = miConfig.AccessKey
  14212. struct3502.RequestUrl = miConfig.Url
  14213. struct3502.SecretKey = miConfig.SecretKey
  14214. struct3502.ManuDate = "2022-08-15"
  14215. struct3502.FixmedinsBchno = ""
  14216. struct3502.ManuLotnum = ""
  14217. struct3502.RxFlag = "0"
  14218. struct3502.ExpyEnd = "2022-08-15"
  14219. struct3502.Invdate = "2022-08-15"
  14220. struct3502.InvCnt = "20.25"
  14221. struct3502.Memo = ""
  14222. struct3502.MedListCodg = "XB01ABD056B002020200517"
  14223. struct3502.FixmedinsHilistId = miConfig.Code
  14224. struct3502.FixmedinsHilistName = miConfig.OrgName
  14225. struct3502s = append(struct3502s, struct3502)
  14226. data["struct_3502s"] = struct3502s
  14227. client := &http.Client{}
  14228. bytesData, _ := json.Marshal(data)
  14229. var req *http.Request
  14230. if miConfig.MdtrtareaAdmvs == "320921" {
  14231. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14232. } else {
  14233. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14234. }
  14235. resp, _ := client.Do(req)
  14236. defer resp.Body.Close()
  14237. body, ioErr := ioutil.ReadAll(resp.Body)
  14238. if ioErr != nil {
  14239. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14241. return
  14242. }
  14243. var respJSON map[string]interface{}
  14244. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14247. return
  14248. }
  14249. var res ResultSix
  14250. var resSix10265 ResultSix10265 //1101结果
  14251. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14252. result, _ := json.Marshal(respJSON)
  14253. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14254. utils.ErrorLog("解析失败:%v", err)
  14255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14256. return
  14257. }
  14258. res.InfRefmsgid = resSix10265.InfRefmsgid
  14259. res.Output = resSix10265.Output
  14260. res.ErrMsg = resSix10265.ErrMsg
  14261. res.Cainfo = resSix10265.Cainfo
  14262. res.WarnMsg = resSix10265.WarnMsg
  14263. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14264. res.Infcode = infocode
  14265. if infocode == 0 {
  14266. c.ServeSuccessJSON(map[string]interface{}{
  14267. "msg": "上传成功",
  14268. })
  14269. return
  14270. } else {
  14271. c.ServeSuccessJSON(map[string]interface{}{
  14272. "failed_code": -10,
  14273. "msg": res.ErrMsg,
  14274. })
  14275. return
  14276. }
  14277. }
  14278. func (c *HisApiController) Post3503() {
  14279. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14280. data := make(map[string]interface{})
  14281. var struct3501s []models.Struct3501
  14282. var struct3501 models.Struct3501
  14283. struct3501.OrgName = miConfig.OrgName
  14284. struct3501.AccessKey = miConfig.AccessKey
  14285. struct3501.RequestUrl = miConfig.Url
  14286. struct3501.SecretKey = miConfig.SecretKey
  14287. struct3501.ManuDate = "2022-08-15"
  14288. struct3501.FixmedinsBchno = ""
  14289. struct3501.ManuLotnum = ""
  14290. struct3501.RxFlag = "0"
  14291. struct3501.ExpyEnd = "2022-08-15"
  14292. struct3501.Invdate = "2022-08-15"
  14293. struct3501.InvCnt = "20.25"
  14294. struct3501.Memo = ""
  14295. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14296. struct3501.FixmedinsHilistId = miConfig.Code
  14297. struct3501.FixmedinsHilistName = miConfig.OrgName
  14298. struct3501s = append(struct3501s, struct3501)
  14299. data["struct_3501s"] = struct3501s
  14300. client := &http.Client{}
  14301. bytesData, _ := json.Marshal(data)
  14302. var req *http.Request
  14303. if miConfig.MdtrtareaAdmvs == "320921" {
  14304. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14305. } else {
  14306. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14307. }
  14308. resp, _ := client.Do(req)
  14309. defer resp.Body.Close()
  14310. body, ioErr := ioutil.ReadAll(resp.Body)
  14311. if ioErr != nil {
  14312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14314. return
  14315. }
  14316. var respJSON map[string]interface{}
  14317. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14320. return
  14321. }
  14322. var res ResultSix
  14323. var resSix10265 ResultSix10265 //1101结果
  14324. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14325. result, _ := json.Marshal(respJSON)
  14326. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14327. utils.ErrorLog("解析失败:%v", err)
  14328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14329. return
  14330. }
  14331. res.InfRefmsgid = resSix10265.InfRefmsgid
  14332. res.Output = resSix10265.Output
  14333. res.ErrMsg = resSix10265.ErrMsg
  14334. res.Cainfo = resSix10265.Cainfo
  14335. res.WarnMsg = resSix10265.WarnMsg
  14336. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14337. res.Infcode = infocode
  14338. if infocode == 0 {
  14339. c.ServeSuccessJSON(map[string]interface{}{
  14340. "msg": "上传成功",
  14341. })
  14342. return
  14343. } else {
  14344. c.ServeSuccessJSON(map[string]interface{}{
  14345. "failed_code": -10,
  14346. "msg": res.ErrMsg,
  14347. })
  14348. return
  14349. }
  14350. }
  14351. func (c *HisApiController) Post3504() {
  14352. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14353. data := make(map[string]interface{})
  14354. var struct3501s []models.Struct3501
  14355. var struct3501 models.Struct3501
  14356. struct3501.OrgName = miConfig.OrgName
  14357. struct3501.AccessKey = miConfig.AccessKey
  14358. struct3501.RequestUrl = miConfig.Url
  14359. struct3501.SecretKey = miConfig.SecretKey
  14360. struct3501.ManuDate = "2022-08-15"
  14361. struct3501.FixmedinsBchno = ""
  14362. struct3501.ManuLotnum = ""
  14363. struct3501.RxFlag = "0"
  14364. struct3501.ExpyEnd = "2022-08-15"
  14365. struct3501.Invdate = "2022-08-15"
  14366. struct3501.InvCnt = "20.25"
  14367. struct3501.Memo = ""
  14368. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14369. struct3501.FixmedinsHilistId = miConfig.Code
  14370. struct3501.FixmedinsHilistName = miConfig.OrgName
  14371. struct3501s = append(struct3501s, struct3501)
  14372. data["struct_3501s"] = struct3501s
  14373. client := &http.Client{}
  14374. bytesData, _ := json.Marshal(data)
  14375. var req *http.Request
  14376. if miConfig.MdtrtareaAdmvs == "320921" {
  14377. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14378. } else {
  14379. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14380. }
  14381. resp, _ := client.Do(req)
  14382. defer resp.Body.Close()
  14383. body, ioErr := ioutil.ReadAll(resp.Body)
  14384. if ioErr != nil {
  14385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14387. return
  14388. }
  14389. var respJSON map[string]interface{}
  14390. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14393. return
  14394. }
  14395. var res ResultSix
  14396. var resSix10265 ResultSix10265 //1101结果
  14397. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14398. result, _ := json.Marshal(respJSON)
  14399. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14400. utils.ErrorLog("解析失败:%v", err)
  14401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14402. return
  14403. }
  14404. res.InfRefmsgid = resSix10265.InfRefmsgid
  14405. res.Output = resSix10265.Output
  14406. res.ErrMsg = resSix10265.ErrMsg
  14407. res.Cainfo = resSix10265.Cainfo
  14408. res.WarnMsg = resSix10265.WarnMsg
  14409. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14410. res.Infcode = infocode
  14411. if infocode == 0 {
  14412. c.ServeSuccessJSON(map[string]interface{}{
  14413. "msg": "上传成功",
  14414. })
  14415. return
  14416. } else {
  14417. c.ServeSuccessJSON(map[string]interface{}{
  14418. "failed_code": -10,
  14419. "msg": res.ErrMsg,
  14420. })
  14421. return
  14422. }
  14423. }
  14424. func (c *HisApiController) Post3505() {
  14425. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14426. data := make(map[string]interface{})
  14427. var struct3501s []models.Struct3501
  14428. var struct3501 models.Struct3501
  14429. struct3501.OrgName = miConfig.OrgName
  14430. struct3501.AccessKey = miConfig.AccessKey
  14431. struct3501.RequestUrl = miConfig.Url
  14432. struct3501.SecretKey = miConfig.SecretKey
  14433. struct3501.ManuDate = "2022-08-15"
  14434. struct3501.FixmedinsBchno = ""
  14435. struct3501.ManuLotnum = ""
  14436. struct3501.RxFlag = "0"
  14437. struct3501.ExpyEnd = "2022-08-15"
  14438. struct3501.Invdate = "2022-08-15"
  14439. struct3501.InvCnt = "20.25"
  14440. struct3501.Memo = ""
  14441. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14442. struct3501.FixmedinsHilistId = miConfig.Code
  14443. struct3501.FixmedinsHilistName = miConfig.OrgName
  14444. struct3501s = append(struct3501s, struct3501)
  14445. data["struct_3501s"] = struct3501s
  14446. client := &http.Client{}
  14447. bytesData, _ := json.Marshal(data)
  14448. var req *http.Request
  14449. if miConfig.MdtrtareaAdmvs == "320921" {
  14450. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14451. } else {
  14452. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14453. }
  14454. resp, _ := client.Do(req)
  14455. defer resp.Body.Close()
  14456. body, ioErr := ioutil.ReadAll(resp.Body)
  14457. if ioErr != nil {
  14458. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14460. return
  14461. }
  14462. var respJSON map[string]interface{}
  14463. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14466. return
  14467. }
  14468. var res ResultSix
  14469. var resSix10265 ResultSix10265 //1101结果
  14470. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14471. result, _ := json.Marshal(respJSON)
  14472. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14473. utils.ErrorLog("解析失败:%v", err)
  14474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14475. return
  14476. }
  14477. res.InfRefmsgid = resSix10265.InfRefmsgid
  14478. res.Output = resSix10265.Output
  14479. res.ErrMsg = resSix10265.ErrMsg
  14480. res.Cainfo = resSix10265.Cainfo
  14481. res.WarnMsg = resSix10265.WarnMsg
  14482. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14483. res.Infcode = infocode
  14484. if infocode == 0 {
  14485. c.ServeSuccessJSON(map[string]interface{}{
  14486. "msg": "上传成功",
  14487. })
  14488. return
  14489. } else {
  14490. c.ServeSuccessJSON(map[string]interface{}{
  14491. "failed_code": -10,
  14492. "msg": res.ErrMsg,
  14493. })
  14494. return
  14495. }
  14496. }
  14497. func (c *HisApiController) Post3506() {
  14498. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14499. data := make(map[string]interface{})
  14500. var struct3501s []models.Struct3501
  14501. var struct3501 models.Struct3501
  14502. struct3501.OrgName = miConfig.OrgName
  14503. struct3501.AccessKey = miConfig.AccessKey
  14504. struct3501.RequestUrl = miConfig.Url
  14505. struct3501.SecretKey = miConfig.SecretKey
  14506. struct3501.ManuDate = "2022-08-15"
  14507. struct3501.FixmedinsBchno = ""
  14508. struct3501.ManuLotnum = ""
  14509. struct3501.RxFlag = "0"
  14510. struct3501.ExpyEnd = "2022-08-15"
  14511. struct3501.Invdate = "2022-08-15"
  14512. struct3501.InvCnt = "20.25"
  14513. struct3501.Memo = ""
  14514. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14515. struct3501.FixmedinsHilistId = miConfig.Code
  14516. struct3501.FixmedinsHilistName = miConfig.OrgName
  14517. struct3501s = append(struct3501s, struct3501)
  14518. data["struct_3501s"] = struct3501s
  14519. client := &http.Client{}
  14520. bytesData, _ := json.Marshal(data)
  14521. var req *http.Request
  14522. if miConfig.MdtrtareaAdmvs == "320921" {
  14523. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14524. } else {
  14525. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14526. }
  14527. resp, _ := client.Do(req)
  14528. defer resp.Body.Close()
  14529. body, ioErr := ioutil.ReadAll(resp.Body)
  14530. if ioErr != nil {
  14531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14533. return
  14534. }
  14535. var respJSON map[string]interface{}
  14536. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14539. return
  14540. }
  14541. var res ResultSix
  14542. var resSix10265 ResultSix10265 //1101结果
  14543. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14544. result, _ := json.Marshal(respJSON)
  14545. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14546. utils.ErrorLog("解析失败:%v", err)
  14547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14548. return
  14549. }
  14550. res.InfRefmsgid = resSix10265.InfRefmsgid
  14551. res.Output = resSix10265.Output
  14552. res.ErrMsg = resSix10265.ErrMsg
  14553. res.Cainfo = resSix10265.Cainfo
  14554. res.WarnMsg = resSix10265.WarnMsg
  14555. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14556. res.Infcode = infocode
  14557. if infocode == 0 {
  14558. c.ServeSuccessJSON(map[string]interface{}{
  14559. "msg": "上传成功",
  14560. })
  14561. return
  14562. } else {
  14563. c.ServeSuccessJSON(map[string]interface{}{
  14564. "failed_code": -10,
  14565. "msg": res.ErrMsg,
  14566. })
  14567. return
  14568. }
  14569. }
  14570. func (c *HisApiController) Post3507() {
  14571. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14572. data := make(map[string]interface{})
  14573. var struct3501s []models.Struct3501
  14574. var struct3501 models.Struct3501
  14575. struct3501.OrgName = miConfig.OrgName
  14576. struct3501.AccessKey = miConfig.AccessKey
  14577. struct3501.RequestUrl = miConfig.Url
  14578. struct3501.SecretKey = miConfig.SecretKey
  14579. struct3501.ManuDate = "2022-08-15"
  14580. struct3501.FixmedinsBchno = ""
  14581. struct3501.ManuLotnum = ""
  14582. struct3501.RxFlag = "0"
  14583. struct3501.ExpyEnd = "2022-08-15"
  14584. struct3501.Invdate = "2022-08-15"
  14585. struct3501.InvCnt = "20.25"
  14586. struct3501.Memo = ""
  14587. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14588. struct3501.FixmedinsHilistId = miConfig.Code
  14589. struct3501.FixmedinsHilistName = miConfig.OrgName
  14590. struct3501s = append(struct3501s, struct3501)
  14591. data["struct_3501s"] = struct3501s
  14592. client := &http.Client{}
  14593. bytesData, _ := json.Marshal(data)
  14594. var req *http.Request
  14595. if miConfig.MdtrtareaAdmvs == "320921" {
  14596. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14597. } else {
  14598. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14599. }
  14600. resp, _ := client.Do(req)
  14601. defer resp.Body.Close()
  14602. body, ioErr := ioutil.ReadAll(resp.Body)
  14603. if ioErr != nil {
  14604. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14606. return
  14607. }
  14608. var respJSON map[string]interface{}
  14609. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14612. return
  14613. }
  14614. var res ResultSix
  14615. var resSix10265 ResultSix10265 //1101结果
  14616. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14617. result, _ := json.Marshal(respJSON)
  14618. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14619. utils.ErrorLog("解析失败:%v", err)
  14620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14621. return
  14622. }
  14623. res.InfRefmsgid = resSix10265.InfRefmsgid
  14624. res.Output = resSix10265.Output
  14625. res.ErrMsg = resSix10265.ErrMsg
  14626. res.Cainfo = resSix10265.Cainfo
  14627. res.WarnMsg = resSix10265.WarnMsg
  14628. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14629. res.Infcode = infocode
  14630. if infocode == 0 {
  14631. c.ServeSuccessJSON(map[string]interface{}{
  14632. "msg": "上传成功",
  14633. })
  14634. return
  14635. } else {
  14636. c.ServeSuccessJSON(map[string]interface{}{
  14637. "failed_code": -10,
  14638. "msg": res.ErrMsg,
  14639. })
  14640. return
  14641. }
  14642. }