his_api_controller.go 591KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  79. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  80. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  81. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  82. //beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  83. //beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  84. //beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  85. //beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  86. //beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  87. //beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  88. //beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  89. //
  90. }
  91. func (c *HisApiController) Get2505() {
  92. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  93. service.Gdyb2505("44120000000010585742", "高慧裕", miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2022-12-23 09:00:00", "2023-12-31 23:00:00")
  94. }
  95. //func (c *HisApiController) Get4201A(){
  96. // order_id, _ := c.GetInt64("order_id")
  97. // admin_user_id, _ := c.GetInt64("admin_user_id")
  98. // order, _ := service.GetHisOrderByIDTwo(order_id)
  99. // his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  100. // order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  101. // order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  102. // order_info = append(order_info, order_info_two...)
  103. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  104. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  105. //
  106. // department,_ := service.GetDepartMentDetail(his.Departments)
  107. //
  108. //
  109. //
  110. //
  111. // if order.ID == 0 {
  112. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  113. // return
  114. // }
  115. // var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  116. // for _,items := range order_info{
  117. // var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  118. // fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  119. // fsiOPFLD.MedType = "14"
  120. // fsiOPFLD.BkkpSn = items.OrderNumber
  121. // fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime,0).Format("2006-01-02 15:04:05")
  122. // fsiOPFLD.FixmedinsCode = miConfig.Code
  123. // fsiOPFLD.FixmedinsName = miConfig.OrgName
  124. // fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  125. // fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  126. // fsiOPFLD.MedChrgitmType = "09"
  127. // fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.AdviceName
  128. // fsiOPFLD.BilgDeptCodg = department.Number
  129. // fsiOPFLD.BilgDeptName = department.Name
  130. //
  131. //
  132. //
  133. //
  134. //
  135. //
  136. // }
  137. //
  138. //
  139. //
  140. //
  141. //
  142. //
  143. //}
  144. //func (c *HisApiController) Get4202(){
  145. // order_id, _ := c.GetInt64("order_id")
  146. // admin_user_id, _ := c.GetInt64("admin_user_id")
  147. // order, _ := service.GetHisOrderByIDTwo(order_id)
  148. // his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  149. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  150. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  151. //
  152. // if order.ID == 0 {
  153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  154. // return
  155. // }
  156. //
  157. // var struct4202 models.Struct4202
  158. // struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  159. // struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  160. // struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  161. // struct4202.OwnPayPatnMdtrtD.PsnCertType ="01"
  162. // struct4202.OwnPayPatnMdtrtD.Certno =his.IdCardNo
  163. // struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  164. // struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  165. // struct4202.OwnPayPatnMdtrtD.MedType = "14"
  166. // struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  167. // struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f",order.MedfeeSumamt)
  168. //
  169. //
  170. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  171. // var config []*models.HisXtDiagnoseConfig
  172. // for _, item := range diagnosis_ids {
  173. // id, _ := strconv.ParseInt(item, 10, 64)
  174. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  175. // config = append(config, &diagnosisConfig)
  176. // }
  177. // var tempDiaginfos []models.OwnPayPatnDiagListD
  178. // for index, item := range config {
  179. // if index == 0 {
  180. // var tempDiaginfo models.OwnPayPatnDiagListD
  181. // tempDiaginfo.InoutDiagType = "1"
  182. // tempDiaginfo.DiagCode = item.CountryCode
  183. // tempDiaginfo.DiagName = item.CountryContentName
  184. // tempDiaginfo.DiagType = "1"
  185. // tempDiaginfo.DiagSrtNo = "1"
  186. // tempDiaginfo.MaindiagFlag = "1"
  187. // tempDiaginfo.ValiFlag = "1"
  188. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  189. // } else {
  190. //
  191. // var tempDiaginfo models.OwnPayPatnDiagListD
  192. // tempDiaginfo.DiagCode = item.CountryCode
  193. // tempDiaginfo.DiagName = item.CountryContentName
  194. // tempDiaginfo.DiagType = "2"
  195. // tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1),10)
  196. // tempDiaginfo.MaindiagFlag = "0"
  197. // tempDiaginfo.ValiFlag = "1"
  198. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  199. // }
  200. // }
  201. // struct4202.ODiagListD = tempDiaginfos
  202. // service.Gdyb4202(miConfig.OrgName,curRoles.UserName,miConfig.Code,miConfig.InsuplcAdmdvs,miConfig.MdtrtareaAdmvs,miConfig.SecretKey,struct4202)
  203. //
  204. //
  205. //
  206. //
  207. //}
  208. //func (c *HisApiController) Get4203(){
  209. //
  210. //
  211. //}
  212. //func (c *HisApiController) Get4205(){
  213. //
  214. //
  215. //}
  216. //func (c *HisApiController) Get4207(){
  217. //
  218. //
  219. //}
  220. //func (c *HisApiController) Get4208(){
  221. //
  222. //
  223. //}
  224. //func (c *HisApiController) Get4209(){
  225. //
  226. //
  227. //}
  228. type Result3101 struct {
  229. Infcode string `json:"infcode"`
  230. InfRefmsgid string `json:"inf_refmsgid"`
  231. RefmsgTime string `json:"refmsg_time"`
  232. RespondTime string `json:"respond_time"`
  233. Enctype string `json:"enctype"`
  234. Signtype string `json:"signtype"`
  235. ErrMsg string `json:"err_msg"`
  236. Output struct {
  237. Result []struct {
  238. JudgeResultDetailDtos []struct {
  239. VolaItemType string `json:"vola_item_type"`
  240. MdtrtID string `json:"mdtrt_id"`
  241. JrdID string `json:"jrd_id"`
  242. PatnID string `json:"patn_id"`
  243. RxID string `json:"rx_id"`
  244. VolaAmt interface{} `json:"vola_amt"`
  245. } `json:"judge_result_detail_dtos"`
  246. RuleID string `json:"rule_id"`
  247. VolaEvid string `json:"vola_evid"`
  248. MdtrtID string `json:"mdtrt_id"`
  249. RuleName string `json:"rule_name"`
  250. VolaAmtStas string `json:"vola_amt_stas"`
  251. JrID string `json:"jr_id"`
  252. PatnID string `json:"patn_id"`
  253. SevDeg string `json:"sev_deg"`
  254. VolaAmt float64 `json:"vola_amt"`
  255. VolaBhvrType string `json:"vola_bhvr_type"`
  256. VolaCont string `json:"vola_cont"`
  257. } `json:"result"`
  258. } `json:"output"`
  259. }
  260. func (c *HisApiController) ReadEleToken() {
  261. admin_user_id, _ := c.GetInt64("admin_user_id")
  262. his_patient_id, _ := c.GetInt64("his_patient_id")
  263. adminUser := c.GetAdminUserInfo()
  264. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  265. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  266. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  267. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  268. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  269. if len(tokens) > 0 {
  270. c.ServeSuccessJSON(map[string]interface{}{
  271. "msg": "读取成功",
  272. })
  273. } else {
  274. c.ServeSuccessJSON(map[string]interface{}{
  275. "failed_code": -10,
  276. "msg": "读取失败",
  277. })
  278. }
  279. } else if miConfig.MdtrtareaAdmvs == "440305" || miConfig.MdtrtareaAdmvs == "440305" || miConfig.MdtrtareaAdmvs == "441202" {
  280. if initFlag == 0 {
  281. c.TestGetBasBaseInit()
  282. }
  283. token := c.GetEleBaseInfo()
  284. token = Remove0000(token)
  285. if len(token) > 0 {
  286. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  287. saveLog(result2, requestLog2, "1101", "获取人员信息")
  288. var res ResultTwo
  289. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  290. utils.ErrorLog("解析失败:%v", err)
  291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  292. return
  293. }
  294. if res.Infcode == 0 {
  295. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  296. if err == gorm.ErrRecordNotFound {
  297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  298. return
  299. } else if err != nil {
  300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  301. return
  302. } else {
  303. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  304. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  305. infoStr := string(Iinfos)
  306. idetinfoStr := string(Idetinfos)
  307. psn := &models.HisPsn{
  308. PsnNo: res.Output.Baseinfo.PsnNo,
  309. Age: res.Output.Baseinfo.Age,
  310. PatientId: patient.ID,
  311. Certno: res.Output.Baseinfo.Certno,
  312. Brdy: res.Output.Baseinfo.Brdy,
  313. Gend: res.Output.Baseinfo.Gend,
  314. Naty: res.Output.Baseinfo.Naty,
  315. PsnCertType: res.Output.Baseinfo.PsnCertType,
  316. PsnName: res.Output.Baseinfo.PsnName,
  317. Idetinfo: idetinfoStr,
  318. Insuinfo: infoStr,
  319. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  320. CardInfo: "",
  321. VerifyNumber: token,
  322. }
  323. service.CreateHisPsn(psn)
  324. c.ServeSuccessJSON(map[string]interface{}{
  325. "msg": "读取成功",
  326. })
  327. }
  328. } else {
  329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  330. return
  331. }
  332. } else {
  333. c.ServeSuccessJSON(map[string]interface{}{
  334. "failed_code": -10,
  335. "msg": "读取失败",
  336. })
  337. }
  338. } else if miConfig.MdtrtareaAdmvs == "350500" {
  339. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  340. if len(errMsg) == 0 {
  341. type ELeData struct {
  342. Data struct {
  343. IdNo string `json:"idNo"`
  344. IdType string `json:"idType"`
  345. UserName string `json:"userName"`
  346. EcToken string `json:"ecToken"`
  347. InsuOrg string `json:"insuOrg"`
  348. Gender string `json:"gender"`
  349. Birthday string `json:"birthday"`
  350. Nationality string `json:"nationality"`
  351. Email string `json:"email"`
  352. Extra string `json:"extra"`
  353. } `json:"data"`
  354. Code int `json:"code"`
  355. Message string `json:"message"`
  356. }
  357. var ele ELeData
  358. err := json.Unmarshal([]byte(outPutInfo), &ele)
  359. if err != nil {
  360. utils.ErrorLog("解析失败:%v", err)
  361. }
  362. token := ele.Data.EcToken
  363. if len(token) > 0 {
  364. psn := &models.HisPsn{
  365. PsnNo: his.PsnNo,
  366. Age: 0,
  367. PatientId: his.PatientId,
  368. Certno: his.Certno,
  369. Brdy: his.Brdy,
  370. Gend: his.Gend,
  371. Naty: his.Naty,
  372. PsnCertType: his.PsnCertType,
  373. PsnName: his.PsnName,
  374. Idetinfo: his.Idetinfo,
  375. Insuinfo: his.Iinfo,
  376. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  377. CardInfo: outPutInfo,
  378. VerifyNumber: token,
  379. }
  380. service.CreateHisPsn(psn)
  381. }
  382. if len(token) > 0 {
  383. c.ServeSuccessJSON(map[string]interface{}{
  384. "msg": "读取成功",
  385. })
  386. } else {
  387. c.ServeSuccessJSON(map[string]interface{}{
  388. "failed_code": -10,
  389. "msg": "读取失败",
  390. })
  391. }
  392. }
  393. } else if miConfig.MdtrtareaAdmvs == "360399" {
  394. if initFlag == 0 {
  395. c.TestGetJiangXiBasBaseInit()
  396. }
  397. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  398. type ELeData struct {
  399. Data struct {
  400. IdNo string `json:"idNo"`
  401. IdType string `json:"idType"`
  402. UserName string `json:"userName"`
  403. EcToken string `json:"ecToken"`
  404. InsuOrg string `json:"insuOrg"`
  405. Gender string `json:"gender"`
  406. Birthday string `json:"birthday"`
  407. Nationality string `json:"nationality"`
  408. Email string `json:"email"`
  409. Extra string `json:"extra"`
  410. } `json:"data"`
  411. Code int `json:"code"`
  412. Message string `json:"message"`
  413. }
  414. var ele ELeData
  415. err := json.Unmarshal([]byte(json_result), &ele)
  416. if err != nil {
  417. utils.ErrorLog("解析失败:%v", err)
  418. }
  419. token := ele.Data.EcToken
  420. token = Remove0000(token)
  421. fmt.Println(ele.Data.UserName)
  422. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  423. saveLog(result2, requestLog2, "1101", "获取人员信息")
  424. var res ResultTwo
  425. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  426. utils.ErrorLog("解析失败:%v", err)
  427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  428. return
  429. }
  430. if res.Infcode == 0 {
  431. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  432. if err == gorm.ErrRecordNotFound {
  433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  434. return
  435. } else if err != nil {
  436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  437. return
  438. } else {
  439. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  440. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  441. infoStr := string(Iinfos)
  442. idetinfoStr := string(Idetinfos)
  443. psn := &models.HisPsn{
  444. PsnNo: res.Output.Baseinfo.PsnNo,
  445. Age: res.Output.Baseinfo.Age,
  446. PatientId: patient.ID,
  447. Certno: res.Output.Baseinfo.Certno,
  448. Brdy: res.Output.Baseinfo.Brdy,
  449. Gend: res.Output.Baseinfo.Gend,
  450. Naty: res.Output.Baseinfo.Naty,
  451. PsnCertType: res.Output.Baseinfo.PsnCertType,
  452. PsnName: res.Output.Baseinfo.PsnName,
  453. Idetinfo: idetinfoStr,
  454. Insuinfo: infoStr,
  455. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  456. CardInfo: "",
  457. VerifyNumber: token,
  458. }
  459. service.CreateHisPsn(psn)
  460. c.ServeSuccessJSON(map[string]interface{}{
  461. "patient": patient,
  462. "number": token,
  463. })
  464. }
  465. } else {
  466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  467. return
  468. }
  469. } else if miConfig.MdtrtareaAdmvs == "430800" {
  470. if initFlag == 0 {
  471. c.TestGetJiangXiBasBaseInit()
  472. }
  473. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  474. type ELeData struct {
  475. Data struct {
  476. IdNo string `json:"idNo"`
  477. IdType string `json:"idType"`
  478. UserName string `json:"userName"`
  479. EcToken string `json:"ecToken"`
  480. InsuOrg string `json:"insuOrg"`
  481. Gender string `json:"gender"`
  482. Birthday string `json:"birthday"`
  483. Nationality string `json:"nationality"`
  484. Email string `json:"email"`
  485. Extra string `json:"extra"`
  486. } `json:"data"`
  487. Code int `json:"code"`
  488. Message string `json:"message"`
  489. }
  490. var ele ELeData
  491. err := json.Unmarshal([]byte(json_result), &ele)
  492. if err != nil {
  493. utils.ErrorLog("解析失败:%v", err)
  494. }
  495. token := ele.Data.EcToken
  496. token = Remove0000(token)
  497. fmt.Println(ele.Data.UserName)
  498. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  499. saveLog(result2, requestLog2, "1101", "获取人员信息")
  500. var res ResultTwo
  501. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  502. utils.ErrorLog("解析失败:%v", err)
  503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  504. return
  505. }
  506. if res.Infcode == 0 {
  507. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  508. if err == gorm.ErrRecordNotFound {
  509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  510. return
  511. } else if err != nil {
  512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  513. return
  514. } else {
  515. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  516. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  517. infoStr := string(Iinfos)
  518. idetinfoStr := string(Idetinfos)
  519. psn := &models.HisPsn{
  520. PsnNo: res.Output.Baseinfo.PsnNo,
  521. Age: res.Output.Baseinfo.Age,
  522. PatientId: patient.ID,
  523. Certno: res.Output.Baseinfo.Certno,
  524. Brdy: res.Output.Baseinfo.Brdy,
  525. Gend: res.Output.Baseinfo.Gend,
  526. Naty: res.Output.Baseinfo.Naty,
  527. PsnCertType: res.Output.Baseinfo.PsnCertType,
  528. PsnName: res.Output.Baseinfo.PsnName,
  529. Idetinfo: idetinfoStr,
  530. Insuinfo: infoStr,
  531. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  532. CardInfo: "",
  533. VerifyNumber: token,
  534. }
  535. service.CreateHisPsn(psn)
  536. c.ServeSuccessJSON(map[string]interface{}{
  537. "patient": patient,
  538. "number": token,
  539. })
  540. }
  541. } else {
  542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  543. return
  544. }
  545. }
  546. }
  547. func (c *HisApiController) Get9001() {
  548. adminUser := c.GetAdminUserInfo()
  549. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  550. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  551. if miConfig.MdtrtareaAdmvs == "350500" {
  552. service.GetFjAuthorizationInfo(miConfig.Code)
  553. } else if miConfig.MdtrtareaAdmvs == "131023" {
  554. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  555. var dat map[string]interface{}
  556. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  557. fmt.Println(dat)
  558. } else {
  559. fmt.Println(err)
  560. }
  561. userJSONBytes, _ := json.Marshal(dat)
  562. var res models.Result9001
  563. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  564. utils.ErrorLog("解析失败:%v", err)
  565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  566. return
  567. }
  568. } else {
  569. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  570. var dat map[string]interface{}
  571. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  572. fmt.Println(dat)
  573. } else {
  574. fmt.Println(err)
  575. }
  576. userJSONBytes, _ := json.Marshal(dat)
  577. var res models.Result9001
  578. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  579. utils.ErrorLog("解析失败:%v", err)
  580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  581. return
  582. }
  583. }
  584. }
  585. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Result3101) {
  586. var res Result3101
  587. adminUser := c.GetAdminUserInfo()
  588. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  589. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  590. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  591. //record_time := c.GetString("record_time")
  592. //trig_scen := c.GetString("trig_scen")
  593. timeLayout := "2006-01-02"
  594. loc, _ := time.LoadLocation("Local")
  595. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  596. if err != nil {
  597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  598. return res
  599. }
  600. recordDateTime := theTime.Unix()
  601. var patientPrescription models.HisPrescriptionInfo
  602. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  603. //if patientPrescription.ID == 0 {
  604. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  605. //}
  606. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  607. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  608. //
  609. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  610. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  611. var pp models.PublicParams
  612. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  613. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  614. pp.FixmedinsName = miConfig.OrgName
  615. pp.FixmedinsCode = miConfig.Code
  616. pp.RequestUrl = miConfig.Url
  617. pp.Cainfo = miConfig.Cainfo
  618. pp.SecretKey = miConfig.SecretKey
  619. pp.AccessKey = miConfig.AccessKey
  620. pp.OpterName = roles.UserName
  621. var config []*models.HisXtDiagnoseConfig
  622. for _, item := range diagnosis_ids {
  623. id, _ := strconv.ParseInt(item, 10, 64)
  624. diagnosisConfig, _ := service.FindDiagnoseById(id)
  625. config = append(config, &diagnosisConfig)
  626. }
  627. var pd models.PatientDtos
  628. pd.PatnID = his.PsnNo
  629. pd.PatnName = his.Name
  630. pd.Gend = his.Gend
  631. pd.Brdy = his.Brdy
  632. pd.Poolarea = miConfig.MdtrtareaAdmvs
  633. pd.CurrMdtrtID = his.Number
  634. var fed models.FsiEncounterDtos
  635. fed.MdtrtID = his.Number
  636. fed.MedinsID = miConfig.Code
  637. fed.MedinsName = miConfig.OrgName
  638. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  639. fed.MedMdtrtType = "1"
  640. fed.MedinsType = "1"
  641. fed.MedinsLv = "11"
  642. tm := time.Unix(his.RecordDate, 0)
  643. s_tm := tm.Format("2006-01-02 15:04:05")
  644. fed.AdmDate = s_tm
  645. fed.DscgDate = s_tm
  646. fed.DscgMainDiseCodg = config[0].CountryCode
  647. fed.DscgMainDiseName = config[0].CountryContentName
  648. //诊断信息
  649. var fdds []*models.FsiDiagnoseDtos
  650. for index, item := range config {
  651. if index == 0 {
  652. var fdd models.FsiDiagnoseDtos
  653. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  654. fdd.InoutDiseType = "1"
  655. fdd.MaindiseFlag = "1"
  656. fdd.DiseDate = s_tm
  657. fdd.DiasSrtNo = "1"
  658. fdd.DiseName = item.CountryContentName
  659. fdd.DiseCodg = item.CountryCode
  660. fdds = append(fdds, &fdd)
  661. } else {
  662. var fdd models.FsiDiagnoseDtos
  663. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  664. fdd.InoutDiseType = "1"
  665. fdd.MaindiseFlag = "1"
  666. fdd.DiseDate = s_tm
  667. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  668. fdd.DiseName = item.CountryContentName
  669. fdd.DiseCodg = item.CountryCode
  670. fdds = append(fdds, &fdd)
  671. }
  672. }
  673. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  674. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  675. fed.AdmDeptName = department.Name
  676. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  677. fed.DscgDeptName = department.Name
  678. fed.MedMdtrtType = "1"
  679. fed.MedType = "11"
  680. //if his.Insutype == "390" {
  681. // fed.MedType = "1402"
  682. //} else {
  683. // fed.MedType = "9933"
  684. //}
  685. var orders []*models.FsiOrderDtos
  686. if trig_scen == "2" {
  687. //处方医嘱信息
  688. for _, item := range prescriptions {
  689. for _, subItem := range item.HisDoctorAdviceInfo {
  690. var order models.FsiOrderDtos
  691. order.RxID = strconv.FormatInt(item.ID, 10)
  692. order.Rxno = strconv.FormatInt(item.ID, 10)
  693. order.LongDrordFlag = "0"
  694. order.HilistType = "1"
  695. order.ChrgType = "1"
  696. order.DrordBhvr = "-"
  697. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  698. order.HosplistName = subItem.BaseDrugLib.DrugName
  699. order.HilistLv = "1"
  700. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  701. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  702. order.HosplistName = subItem.BaseDrugLib.DrugName
  703. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  704. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  705. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  706. order.OwnpayAmt = ""
  707. order.SelfpayAmt = ""
  708. order.Spec = ""
  709. order.SpecUnt = ""
  710. order.DrordBegnDate = s_tm
  711. order.DrordStopDate = ""
  712. order.DrordDrCodg = "1"
  713. order.DrordDeptName = department.Name
  714. order.DrordDrCodg = "1"
  715. order.DrordDrName = doctor_info.UserName
  716. order.DrordDrProfttl = ""
  717. order.CurrDrordFlag = "1"
  718. orders = append(orders, &order)
  719. }
  720. for _, subItem := range item.HisPrescriptionProject {
  721. if subItem.Type == 2 {
  722. var order models.FsiOrderDtos
  723. order.RxID = strconv.FormatInt(item.ID, 10)
  724. order.Rxno = strconv.FormatInt(item.ID, 10)
  725. order.LongDrordFlag = "0"
  726. order.HilistType = "1"
  727. order.ChrgType = "1"
  728. order.DrordBhvr = "-"
  729. order.HilistCode = subItem.HisProject.MedicalCode
  730. order.HosplistName = subItem.HisProject.ProjectName
  731. order.HilistLv = "1"
  732. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  733. order.HosplistCode = subItem.HisProject.MedicalCode
  734. order.HosplistName = subItem.HisProject.ProjectName
  735. order.Cnt = subItem.Count
  736. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  737. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  738. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  739. order.OwnpayAmt = ""
  740. order.SelfpayAmt = ""
  741. order.Spec = ""
  742. order.SpecUnt = ""
  743. order.DrordBegnDate = s_tm
  744. order.DrordStopDate = ""
  745. order.DrordDrCodg = "1"
  746. order.DrordDeptName = department.Name
  747. order.DrordDrCodg = "1"
  748. order.DrordDrName = doctor_info.UserName
  749. order.DrordDrProfttl = ""
  750. order.CurrDrordFlag = "1"
  751. orders = append(orders, &order)
  752. }
  753. if subItem.Type == 3 {
  754. var order models.FsiOrderDtos
  755. order.RxID = strconv.FormatInt(item.ID, 10)
  756. order.Rxno = strconv.FormatInt(item.ID, 10)
  757. order.LongDrordFlag = "0"
  758. order.HilistType = "1"
  759. order.ChrgType = "1"
  760. order.DrordBhvr = "-"
  761. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  762. order.HosplistName = subItem.GoodInfo.GoodName
  763. order.HilistLv = "1"
  764. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  765. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  766. order.HosplistName = subItem.GoodInfo.GoodName
  767. order.Cnt = subItem.Count
  768. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  769. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  770. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  771. order.OwnpayAmt = ""
  772. order.SelfpayAmt = ""
  773. order.Spec = ""
  774. order.SpecUnt = ""
  775. order.DrordBegnDate = s_tm
  776. order.DrordStopDate = ""
  777. order.DrordDrCodg = "1"
  778. order.DrordDeptName = department.Name
  779. order.DrordDrCodg = "1"
  780. order.DrordDrName = doctor_info.UserName
  781. order.DrordDrProfttl = ""
  782. order.CurrDrordFlag = "1"
  783. orders = append(orders, &order)
  784. }
  785. }
  786. }
  787. //处方医嘱信息
  788. }
  789. fed.MatnStas = "0"
  790. fed.MedfeeSumamt = "0"
  791. fed.OwnpayAmt = "0"
  792. fed.SelfpayAmt = "0"
  793. fed.AcctPayamt = "0"
  794. fed.MaAmt = "0"
  795. fed.HifpPayamt = "0"
  796. fed.SetlTotlnum = "1"
  797. fed.Insutype = his.Insutype
  798. fed.ReimFlag = "0"
  799. fed.OutSetlFlag = "0"
  800. var fopd []*models.FsiOperationDtosData
  801. data := make(map[string]interface{})
  802. data["fed"] = fed
  803. data["fdd"] = fdds
  804. data["fod"] = orders
  805. data["pd"] = pd
  806. data["pp"] = pp
  807. data["fopd"] = fopd
  808. data["trig_scen"] = trig_scen
  809. fmt.Println(data)
  810. fmt.Println(fed)
  811. fmt.Println(fdds)
  812. fmt.Println(orders)
  813. fmt.Println(pd)
  814. fmt.Println(pp)
  815. fmt.Println(fopd)
  816. client := &http.Client{}
  817. bytesData, _ := json.Marshal(data)
  818. var req *http.Request
  819. if miConfig.MdtrtareaAdmvs == "320921" {
  820. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  821. } else {
  822. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  823. }
  824. resp, _ := client.Do(req)
  825. defer resp.Body.Close()
  826. body, ioErr := ioutil.ReadAll(resp.Body)
  827. if ioErr != nil {
  828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  830. return res
  831. }
  832. var respJSON map[string]interface{}
  833. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  836. return res
  837. }
  838. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  839. fmt.Println(respJSON)
  840. result, _ := json.Marshal(respJSON)
  841. fmt.Println(result)
  842. if err := json.Unmarshal([]byte(result), &res); err != nil {
  843. utils.ErrorLog("解析失败:%v", err)
  844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  845. return res
  846. }
  847. return res
  848. }
  849. func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  850. adminUser := c.GetAdminUserInfo()
  851. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  852. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  853. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  854. //record_time := c.GetString("record_time")
  855. //trig_scen := c.GetString("trig_scen")
  856. timeLayout := "2006-01-02"
  857. loc, _ := time.LoadLocation("Local")
  858. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  859. if err != nil {
  860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  861. return res
  862. }
  863. recordDateTime := theTime.Unix()
  864. var patientPrescription models.HisPrescriptionInfo
  865. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  866. if patientPrescription.ID == 0 {
  867. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  868. }
  869. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  870. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  871. //
  872. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  873. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  874. var pp models.PublicParams
  875. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  876. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  877. pp.FixmedinsName = miConfig.OrgName
  878. pp.FixmedinsCode = miConfig.Code
  879. pp.RequestUrl = miConfig.Url
  880. pp.Cainfo = miConfig.Cainfo
  881. pp.SecretKey = miConfig.SecretKey
  882. pp.AccessKey = miConfig.AccessKey
  883. pp.OpterName = roles.UserName
  884. var config []*models.HisXtDiagnoseConfig
  885. for _, item := range diagnosis_ids {
  886. id, _ := strconv.ParseInt(item, 10, 64)
  887. diagnosisConfig, _ := service.FindDiagnoseById(id)
  888. config = append(config, &diagnosisConfig)
  889. }
  890. var pd models.PatientDtos
  891. pd.PatnID = his.PsnNo
  892. pd.PatnName = his.Name
  893. pd.Gend = his.Gend
  894. pd.Brdy = his.Brdy
  895. pd.Poolarea = his.InsuplcAdmdvs
  896. pd.CurrMdtrtID = his.Number
  897. var fed models.FsiEncounterDtos
  898. fed.MdtrtID = his.Number
  899. fed.MedinsID = miConfig.Code
  900. fed.MedinsName = miConfig.OrgName
  901. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  902. fed.MedMdtrtType = "1"
  903. fed.MedinsType = "1"
  904. fed.MedinsLv = "11"
  905. tm := time.Unix(his.RecordDate, 0)
  906. s_tm := tm.Format("2006-01-02 15:04:05")
  907. fed.AdmDate = s_tm
  908. fed.DscgDate = s_tm
  909. fed.DscgMainDiseCodg = config[0].CountryCode
  910. fed.DscgMainDiseName = config[0].CountryContentName
  911. //诊断信息
  912. var fdds []*models.FsiDiagnoseDtos
  913. for index, item := range config {
  914. if index == 0 {
  915. var fdd models.FsiDiagnoseDtos
  916. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  917. fdd.InoutDiseType = "1"
  918. fdd.MaindiseFlag = "1"
  919. fdd.DiseDate = s_tm
  920. fdd.DiasSrtNo = "1"
  921. fdd.DiseName = item.CountryContentName
  922. fdd.DiseCodg = item.CountryCode
  923. fdds = append(fdds, &fdd)
  924. } else {
  925. var fdd models.FsiDiagnoseDtos
  926. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  927. fdd.InoutDiseType = "1"
  928. fdd.MaindiseFlag = "1"
  929. fdd.DiseDate = s_tm
  930. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  931. fdd.DiseName = item.CountryContentName
  932. fdd.DiseCodg = item.CountryCode
  933. fdds = append(fdds, &fdd)
  934. }
  935. }
  936. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  937. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  938. fed.AdmDeptName = department.Name
  939. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  940. fed.DscgDeptName = department.Name
  941. fed.MedMdtrtType = "1"
  942. fed.MedType = "11"
  943. //if his.Insutype == "390" {
  944. // fed.MedType = "1402"
  945. //} else {
  946. // fed.MedType = "9933"
  947. //}
  948. var orders []*models.FsiOrderDtos
  949. if trig_scen == "2" {
  950. //处方医嘱信息
  951. for _, item := range prescriptions {
  952. for _, subItem := range item.HisDoctorAdviceInfo {
  953. var order models.FsiOrderDtos
  954. order.RxID = strconv.FormatInt(item.ID, 10)
  955. order.Rxno = strconv.FormatInt(item.ID, 10)
  956. order.LongDrordFlag = "0"
  957. order.HilistType = "1"
  958. order.ChrgType = "1"
  959. order.DrordBhvr = "-"
  960. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  961. order.HosplistName = subItem.BaseDrugLib.DrugName
  962. order.HilistLv = "1"
  963. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  964. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  965. order.HosplistName = subItem.BaseDrugLib.DrugName
  966. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  967. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  968. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  969. order.OwnpayAmt = ""
  970. order.SelfpayAmt = ""
  971. order.Spec = ""
  972. order.SpecUnt = ""
  973. order.DrordBegnDate = s_tm
  974. order.DrordStopDate = ""
  975. order.DrordDrCodg = "1"
  976. order.DrordDeptName = department.Name
  977. order.DrordDrCodg = "1"
  978. order.DrordDrName = doctor_info.UserName
  979. order.DrordDrProfttl = ""
  980. order.CurrDrordFlag = "1"
  981. orders = append(orders, &order)
  982. }
  983. for _, subItem := range item.HisPrescriptionProject {
  984. if subItem.Type == 2 {
  985. var order models.FsiOrderDtos
  986. order.RxID = strconv.FormatInt(item.ID, 10)
  987. order.Rxno = strconv.FormatInt(item.ID, 10)
  988. order.LongDrordFlag = "0"
  989. order.HilistType = "1"
  990. order.ChrgType = "1"
  991. order.DrordBhvr = "-"
  992. order.HilistCode = subItem.HisProject.MedicalCode
  993. order.HosplistName = subItem.HisProject.ProjectName
  994. order.HilistLv = "1"
  995. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  996. order.HosplistCode = subItem.HisProject.MedicalCode
  997. order.HosplistName = subItem.HisProject.ProjectName
  998. order.Cnt = subItem.Count
  999. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1000. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1001. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1002. order.OwnpayAmt = ""
  1003. order.SelfpayAmt = ""
  1004. order.Spec = ""
  1005. order.SpecUnt = ""
  1006. order.DrordBegnDate = s_tm
  1007. order.DrordStopDate = ""
  1008. order.DrordDrCodg = "1"
  1009. order.DrordDeptName = department.Name
  1010. order.DrordDrCodg = "1"
  1011. order.DrordDrName = doctor_info.UserName
  1012. order.DrordDrProfttl = ""
  1013. order.CurrDrordFlag = "1"
  1014. orders = append(orders, &order)
  1015. }
  1016. if subItem.Type == 3 {
  1017. var order models.FsiOrderDtos
  1018. order.RxID = strconv.FormatInt(item.ID, 10)
  1019. order.Rxno = strconv.FormatInt(item.ID, 10)
  1020. order.LongDrordFlag = "0"
  1021. order.HilistType = "1"
  1022. order.ChrgType = "1"
  1023. order.DrordBhvr = "-"
  1024. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1025. order.HosplistName = subItem.GoodInfo.GoodName
  1026. order.HilistLv = "1"
  1027. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1028. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1029. order.HosplistName = subItem.GoodInfo.GoodName
  1030. order.Cnt = subItem.Count
  1031. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1032. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1033. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1034. order.OwnpayAmt = ""
  1035. order.SelfpayAmt = ""
  1036. order.Spec = ""
  1037. order.SpecUnt = ""
  1038. order.DrordBegnDate = s_tm
  1039. order.DrordStopDate = ""
  1040. order.DrordDrCodg = "1"
  1041. order.DrordDeptName = department.Name
  1042. order.DrordDrCodg = "1"
  1043. order.DrordDrName = doctor_info.UserName
  1044. order.DrordDrProfttl = ""
  1045. order.CurrDrordFlag = "1"
  1046. orders = append(orders, &order)
  1047. }
  1048. }
  1049. }
  1050. //处方医嘱信息
  1051. }
  1052. fed.MatnStas = "0"
  1053. fed.MedfeeSumamt = "0"
  1054. fed.OwnpayAmt = "0"
  1055. fed.SelfpayAmt = "0"
  1056. fed.AcctPayamt = "0"
  1057. fed.MaAmt = "0"
  1058. fed.HifpPayamt = "0"
  1059. fed.SetlTotlnum = "1"
  1060. fed.Insutype = his.Insutype
  1061. fed.ReimFlag = "0"
  1062. fed.OutSetlFlag = "0"
  1063. var fopd []*models.FsiOperationDtosData
  1064. data := make(map[string]interface{})
  1065. data["fed"] = fed
  1066. data["fdd"] = fdds
  1067. data["fod"] = orders
  1068. data["pd"] = pd
  1069. data["pp"] = pp
  1070. data["fopd"] = fopd
  1071. data["trig_scen"] = trig_scen
  1072. fmt.Println(data)
  1073. fmt.Println(fed)
  1074. fmt.Println(fdds)
  1075. fmt.Println(orders)
  1076. fmt.Println(pd)
  1077. fmt.Println(pp)
  1078. fmt.Println(fopd)
  1079. client := &http.Client{}
  1080. bytesData, _ := json.Marshal(data)
  1081. var req *http.Request
  1082. if miConfig.MdtrtareaAdmvs == "320921" {
  1083. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1084. } else {
  1085. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1086. }
  1087. resp, _ := client.Do(req)
  1088. defer resp.Body.Close()
  1089. body, ioErr := ioutil.ReadAll(resp.Body)
  1090. if ioErr != nil {
  1091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1093. return res
  1094. }
  1095. var respJSON map[string]interface{}
  1096. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1099. return res
  1100. }
  1101. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1102. result, _ := json.Marshal(respJSON)
  1103. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1104. utils.ErrorLog("解析失败:%v", err)
  1105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1106. return res
  1107. }
  1108. return res
  1109. }
  1110. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  1111. ////patient_id, _ := c.GetInt64("patient_id")
  1112. //order_id, _ := c.GetInt64("order_id")
  1113. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  1114. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  1115. //trig_scen := c.GetString("trig_scen")
  1116. adminUser := c.GetAdminUserInfo()
  1117. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1118. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1119. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1120. record_time := c.GetString("record_time")
  1121. order, _ := service.GetHisOrderByID(order_id)
  1122. timeLayout := "2006-01-02"
  1123. loc, _ := time.LoadLocation("Local")
  1124. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1125. if err != nil {
  1126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1127. return
  1128. }
  1129. recordDateTime := theTime.Unix()
  1130. var patientPrescription models.HisPrescriptionInfo
  1131. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1132. if patientPrescription.ID == 0 {
  1133. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1134. }
  1135. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1136. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1137. //
  1138. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1139. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1140. var pp models.PublicParams
  1141. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1142. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1143. pp.FixmedinsName = miConfig.OrgName
  1144. pp.FixmedinsCode = miConfig.Code
  1145. pp.RequestUrl = miConfig.Url
  1146. pp.Cainfo = miConfig.Cainfo
  1147. pp.SecretKey = miConfig.SecretKey
  1148. pp.AccessKey = miConfig.AccessKey
  1149. pp.OpterName = roles.UserName
  1150. var config []*models.HisXtDiagnoseConfig
  1151. for _, item := range diagnosis_ids {
  1152. id, _ := strconv.ParseInt(item, 10, 64)
  1153. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1154. config = append(config, &diagnosisConfig)
  1155. }
  1156. var pd models.PatientDtos
  1157. pd.PatnID = his.PsnNo
  1158. pd.PatnName = his.Name
  1159. pd.Gend = his.Gend
  1160. pd.Brdy = his.Brdy
  1161. pd.Poolarea = his.InsuplcAdmdvs
  1162. pd.CurrMdtrtID = his.Number
  1163. var fed models.FsiEncounterDtos
  1164. fed.MdtrtID = his.Number
  1165. fed.MedinsID = miConfig.Code
  1166. fed.MedinsName = miConfig.OrgName
  1167. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1168. fed.MedMdtrtType = "1"
  1169. fed.MedinsType = "1"
  1170. fed.MedinsLv = "11"
  1171. tm := time.Unix(his.RecordDate, 0)
  1172. s_tm := tm.Format("2006-01-02 15:04:05")
  1173. fed.AdmDate = s_tm
  1174. fed.DscgDate = s_tm
  1175. fed.DscgMainDiseCodg = config[0].CountryCode
  1176. fed.DscgMainDiseName = config[0].CountryContentName
  1177. //诊断信息
  1178. var fdds []*models.FsiDiagnoseDtos
  1179. for index, item := range config {
  1180. if index == 0 {
  1181. var fdd models.FsiDiagnoseDtos
  1182. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1183. fdd.InoutDiseType = "1"
  1184. fdd.MaindiseFlag = "1"
  1185. fdd.DiseDate = s_tm
  1186. fdd.DiasSrtNo = "1"
  1187. fdd.DiseName = item.CountryContentName
  1188. fdd.DiseCodg = item.CountryCode
  1189. fdds = append(fdds, &fdd)
  1190. } else {
  1191. var fdd models.FsiDiagnoseDtos
  1192. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1193. fdd.InoutDiseType = "1"
  1194. fdd.MaindiseFlag = "1"
  1195. fdd.DiseDate = s_tm
  1196. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1197. fdd.DiseName = item.CountryContentName
  1198. fdd.DiseCodg = item.CountryCode
  1199. fdds = append(fdds, &fdd)
  1200. }
  1201. }
  1202. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1203. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1204. fed.AdmDeptName = department.Name
  1205. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1206. fed.DscgDeptName = department.Name
  1207. fed.MedType = order.MedType
  1208. //处方医嘱信息
  1209. var orders []*models.FsiOrderDtos
  1210. //for _, item := range prescriptions {
  1211. // for _, subItem := range item.HisDoctorAdviceInfo {
  1212. // var order models.FsiOrderDtos
  1213. // order.RxID = strconv.FormatInt(item.ID, 10)
  1214. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1215. // order.LongDrordFlag = "0"
  1216. // order.HilistType = "1"
  1217. // order.ChrgType = "1"
  1218. // order.DrordBhvr = "-"
  1219. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1220. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1221. // order.HilistLv = "1"
  1222. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1223. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1224. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1225. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  1226. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1227. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  1228. // order.OwnpayAmt = ""
  1229. // order.SelfpayAmt = ""
  1230. // order.Spec = ""
  1231. // order.SpecUnt = ""
  1232. // order.DrordBegnDate = s_tm
  1233. // order.DrordStopDate = ""
  1234. // order.DrordDrCodg = "1"
  1235. // order.DrordDeptName = department.Name
  1236. // order.DrordDrCodg = "1"
  1237. // order.DrordDrName = doctor_info.UserName
  1238. // order.DrordDrProfttl = ""
  1239. // order.CurrDrordFlag = "1"
  1240. // orders = append(orders, &order)
  1241. // }
  1242. // for _, subItem := range item.HisPrescriptionProject {
  1243. // if subItem.Type == 2 {
  1244. // var order models.FsiOrderDtos
  1245. // order.RxID = strconv.FormatInt(item.ID, 10)
  1246. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1247. // order.LongDrordFlag = "0"
  1248. // order.HilistType = "1"
  1249. // order.ChrgType = "1"
  1250. // order.DrordBhvr = "-"
  1251. // order.HilistCode = subItem.HisProject.MedicalCode
  1252. // order.HosplistName = subItem.HisProject.ProjectName
  1253. // order.HilistLv = "1"
  1254. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1255. // order.HosplistCode = subItem.HisProject.MedicalCode
  1256. // order.HosplistName = subItem.HisProject.ProjectName
  1257. // order.Cnt = subItem.Count
  1258. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1259. //
  1260. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1261. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1262. // order.OwnpayAmt = ""
  1263. // order.SelfpayAmt = ""
  1264. // order.Spec = ""
  1265. // order.SpecUnt = ""
  1266. // order.DrordBegnDate = s_tm
  1267. // order.DrordStopDate = ""
  1268. // order.DrordDrCodg = "1"
  1269. // order.DrordDeptName = department.Name
  1270. // order.DrordDrCodg = "1"
  1271. // order.DrordDrName = doctor_info.UserName
  1272. // order.DrordDrProfttl = ""
  1273. // order.CurrDrordFlag = "1"
  1274. // orders = append(orders, &order)
  1275. //
  1276. // }
  1277. // if subItem.Type == 3 {
  1278. //
  1279. // var order models.FsiOrderDtos
  1280. // order.RxID = strconv.FormatInt(item.ID, 10)
  1281. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1282. // order.LongDrordFlag = "0"
  1283. // order.HilistType = "1"
  1284. // order.ChrgType = "1"
  1285. // order.DrordBhvr = "-"
  1286. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1287. // order.HosplistName = subItem.GoodInfo.GoodName
  1288. // order.HilistLv = "1"
  1289. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1290. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1291. // order.HosplistName = subItem.GoodInfo.GoodName
  1292. // order.Cnt = subItem.Count
  1293. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1294. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1295. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1296. // order.OwnpayAmt = ""
  1297. // order.SelfpayAmt = ""
  1298. // order.Spec = ""
  1299. // order.SpecUnt = ""
  1300. // order.DrordBegnDate = s_tm
  1301. // order.DrordStopDate = ""
  1302. // order.DrordDrCodg = "1"
  1303. // order.DrordDeptName = department.Name
  1304. // order.DrordDrCodg = "1"
  1305. // order.DrordDrName = doctor_info.UserName
  1306. // order.DrordDrProfttl = ""
  1307. // order.CurrDrordFlag = "1"
  1308. // orders = append(orders, &order)
  1309. //
  1310. // }
  1311. // }
  1312. //}
  1313. for _, item := range prescriptions {
  1314. for _, subItem := range item.HisDoctorAdviceInfo {
  1315. var order models.FsiOrderDtos
  1316. order.RxID = strconv.FormatInt(item.ID, 10)
  1317. order.Rxno = strconv.FormatInt(item.ID, 10)
  1318. order.LongDrordFlag = "0"
  1319. order.HilistType = "1"
  1320. order.ChrgType = "1"
  1321. order.DrordBhvr = "-"
  1322. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1323. order.HosplistName = subItem.BaseDrugLib.DrugName
  1324. order.HilistLv = "1"
  1325. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1326. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1327. order.HosplistName = subItem.BaseDrugLib.DrugName
  1328. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1329. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1330. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1331. order.OwnpayAmt = ""
  1332. order.SelfpayAmt = ""
  1333. order.Spec = ""
  1334. order.SpecUnt = ""
  1335. order.DrordBegnDate = s_tm
  1336. order.DrordStopDate = ""
  1337. order.DrordDrCodg = "1"
  1338. order.DrordDeptName = department.Name
  1339. order.DrordDrCodg = "1"
  1340. order.DrordDrName = doctor_info.UserName
  1341. order.DrordDrProfttl = ""
  1342. order.CurrDrordFlag = "1"
  1343. orders = append(orders, &order)
  1344. }
  1345. for _, subItem := range item.HisPrescriptionProject {
  1346. if subItem.Type == 2 {
  1347. var order models.FsiOrderDtos
  1348. order.RxID = strconv.FormatInt(item.ID, 10)
  1349. order.Rxno = strconv.FormatInt(item.ID, 10)
  1350. order.LongDrordFlag = "0"
  1351. order.HilistType = "1"
  1352. order.ChrgType = "1"
  1353. order.DrordBhvr = "-"
  1354. order.HilistCode = subItem.HisProject.MedicalCode
  1355. order.HosplistName = subItem.HisProject.ProjectName
  1356. order.HilistLv = "1"
  1357. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1358. order.HosplistCode = subItem.HisProject.MedicalCode
  1359. order.HosplistName = subItem.HisProject.ProjectName
  1360. order.Cnt = subItem.Count
  1361. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1362. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1363. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1364. order.OwnpayAmt = ""
  1365. order.SelfpayAmt = ""
  1366. order.Spec = ""
  1367. order.SpecUnt = ""
  1368. order.DrordBegnDate = s_tm
  1369. order.DrordStopDate = ""
  1370. order.DrordDrCodg = "1"
  1371. order.DrordDeptName = department.Name
  1372. order.DrordDrCodg = "1"
  1373. order.DrordDrName = doctor_info.UserName
  1374. order.DrordDrProfttl = ""
  1375. order.CurrDrordFlag = "1"
  1376. orders = append(orders, &order)
  1377. }
  1378. if subItem.Type == 3 {
  1379. var order models.FsiOrderDtos
  1380. order.RxID = strconv.FormatInt(item.ID, 10)
  1381. order.Rxno = strconv.FormatInt(item.ID, 10)
  1382. order.LongDrordFlag = "0"
  1383. order.HilistType = "1"
  1384. order.ChrgType = "1"
  1385. order.DrordBhvr = "-"
  1386. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1387. order.HosplistName = subItem.GoodInfo.GoodName
  1388. order.HilistLv = "1"
  1389. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1390. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1391. order.HosplistName = subItem.GoodInfo.GoodName
  1392. order.Cnt = subItem.Count
  1393. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1394. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1395. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1396. order.OwnpayAmt = ""
  1397. order.SelfpayAmt = ""
  1398. order.Spec = ""
  1399. order.SpecUnt = ""
  1400. order.DrordBegnDate = s_tm
  1401. order.DrordStopDate = ""
  1402. order.DrordDrCodg = "1"
  1403. order.DrordDeptName = department.Name
  1404. order.DrordDrCodg = "1"
  1405. order.DrordDrName = doctor_info.UserName
  1406. order.DrordDrProfttl = ""
  1407. order.CurrDrordFlag = "1"
  1408. orders = append(orders, &order)
  1409. }
  1410. }
  1411. }
  1412. //处方医嘱信息
  1413. fed.MatnStas = "0"
  1414. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1415. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  1416. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  1417. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  1418. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  1419. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  1420. fed.SetlTotlnum = "1"
  1421. fed.Insutype = his.Insutype
  1422. fed.ReimFlag = "0"
  1423. fed.OutSetlFlag = "0"
  1424. var fopd []*models.FsiOperationDtosData
  1425. data := make(map[string]interface{})
  1426. data["fed"] = fed
  1427. data["fdd"] = fdds
  1428. data["fod"] = orders
  1429. data["pd"] = pd
  1430. data["pp"] = pp
  1431. data["fopd"] = fopd
  1432. data["trig_scen"] = trig_scen
  1433. client := &http.Client{}
  1434. bytesData, _ := json.Marshal(data)
  1435. var req *http.Request
  1436. if miConfig.MdtrtareaAdmvs == "320921" {
  1437. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1438. } else {
  1439. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1440. }
  1441. resp, _ := client.Do(req)
  1442. defer resp.Body.Close()
  1443. body, ioErr := ioutil.ReadAll(resp.Body)
  1444. if ioErr != nil {
  1445. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1447. return res
  1448. }
  1449. var respJSON map[string]interface{}
  1450. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1453. return res
  1454. }
  1455. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1456. result, _ := json.Marshal(respJSON)
  1457. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1458. utils.ErrorLog("解析失败:%v", err)
  1459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1460. return res
  1461. }
  1462. return res
  1463. //手术操作集合
  1464. //手术操作集合
  1465. }
  1466. func (c *HisApiController) Check() {
  1467. psn_no := c.GetString("psn_no")
  1468. in := c.GetString("in")
  1469. mt := c.GetString("mt")
  1470. baseParams := models.BaseParams{
  1471. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1472. FixmedinsCode: "H15049901371",
  1473. InsuplcAdmdvs: "150499",
  1474. MdtrtareaAdmvs: "150499",
  1475. OrgName: "赤峰费森血液透析中心",
  1476. Doctor: "1111",
  1477. }
  1478. service.Gdyb2001(baseParams, psn_no, in, mt)
  1479. }
  1480. func (c *HisApiController) GetPsnNcdsInfo() {
  1481. admin_user_id, _ := c.GetInt64("admin_user_id")
  1482. patient_id, _ := c.GetInt64("patient_id")
  1483. id, _ := c.GetInt64("id")
  1484. adminUser := c.GetAdminUserInfo()
  1485. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1486. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1487. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1488. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1489. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1490. //
  1491. //if psn_record.ID == 0 {
  1492. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1493. // return
  1494. //}
  1495. var res Result5301
  1496. var res10265 Result5301For10265
  1497. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1498. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1499. var api string
  1500. if miConfig.MdtrtareaAdmvs == "320921" {
  1501. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  1502. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1503. } else {
  1504. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  1505. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1506. }
  1507. resp, requestErr := http.Get(api)
  1508. if requestErr != nil {
  1509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1510. return
  1511. }
  1512. body, ioErr := ioutil.ReadAll(resp.Body)
  1513. if ioErr != nil {
  1514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1516. return
  1517. }
  1518. var respJSON map[string]interface{}
  1519. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1522. return
  1523. }
  1524. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1525. result, _ := json.Marshal(respJSON)
  1526. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1527. utils.ErrorLog("解析失败:%v", err)
  1528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1529. return
  1530. }
  1531. res.ErrMsg = res10265.ErrMsg
  1532. res.Output = res10265.Output
  1533. res.InfRefmsgid = res10265.InfRefmsgid
  1534. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1535. res.Infcode = infocode
  1536. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1537. p, _ := service.GetHisPatientById(patient_id)
  1538. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1539. var dat map[string]interface{}
  1540. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1541. fmt.Println(dat)
  1542. } else {
  1543. fmt.Println(err)
  1544. }
  1545. userJSONBytes, _ := json.Marshal(dat)
  1546. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1547. utils.ErrorLog("解析失败:%v", err)
  1548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1549. return
  1550. }
  1551. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1552. p, _ := service.GetHisPatientById(patient_id)
  1553. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1554. var dat map[string]interface{}
  1555. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1556. fmt.Println(dat)
  1557. } else {
  1558. fmt.Println(err)
  1559. }
  1560. userJSONBytes, _ := json.Marshal(dat)
  1561. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1562. utils.ErrorLog("解析失败:%v", err)
  1563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1564. return
  1565. }
  1566. } else {
  1567. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1568. var dat map[string]interface{}
  1569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1570. fmt.Println(dat)
  1571. } else {
  1572. fmt.Println(err)
  1573. }
  1574. userJSONBytes, _ := json.Marshal(dat)
  1575. if miConfig.Code == "H15049901371" {
  1576. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1577. utils.ErrorLog("解析失败:%v", err)
  1578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1579. return
  1580. }
  1581. res.InfRefmsgid = res10265.InfRefmsgid
  1582. res.Output = res10265.Output
  1583. res.ErrMsg = res10265.ErrMsg
  1584. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1585. res.Infcode = infocode
  1586. } else {
  1587. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1588. utils.ErrorLog("解析失败:%v", err)
  1589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1590. return
  1591. }
  1592. }
  1593. }
  1594. if res.Infcode == 0 {
  1595. c.ServeSuccessJSON(map[string]interface{}{
  1596. "result": res.Output.Result,
  1597. })
  1598. }
  1599. }
  1600. func (c *HisApiController) CheckInsutype() {
  1601. his_patient_id, _ := c.GetInt64("his_patient_id")
  1602. admin_user_id, _ := c.GetInt64("admin_user_id")
  1603. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1604. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1605. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1606. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1607. var dat map[string]interface{}
  1608. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1609. fmt.Println(dat)
  1610. } else {
  1611. fmt.Println(err)
  1612. }
  1613. userJSONBytes, _ := json.Marshal(dat)
  1614. var res Result90100
  1615. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1616. utils.ErrorLog("解析失败:%v", err)
  1617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1618. return
  1619. }
  1620. if res.Infcode != 0 {
  1621. c.ServeSuccessJSON(map[string]interface{}{
  1622. "failed_code": -10,
  1623. "msg": res.ErrMsg,
  1624. })
  1625. return
  1626. } else {
  1627. fmt.Println(res)
  1628. }
  1629. }
  1630. func (c *HisApiController) CheckCardPWD() {
  1631. card_pwd := c.GetString("card_pwd")
  1632. his_patient_id, _ := c.GetInt64("his_patient_id")
  1633. admin_user_id, _ := c.GetInt64("admin_user_id")
  1634. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1635. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1636. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1637. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1638. bas := strings.Split(psn.CardInfo, "|")
  1639. basNumber := bas[2]
  1640. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1641. var dat map[string]interface{}
  1642. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1643. fmt.Println(dat)
  1644. } else {
  1645. fmt.Println(err)
  1646. }
  1647. userJSONBytes, _ := json.Marshal(dat)
  1648. var res Result90991
  1649. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1650. utils.ErrorLog("解析失败:%v", err)
  1651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1652. return
  1653. }
  1654. if res.Infcode != 0 {
  1655. c.ServeSuccessJSON(map[string]interface{}{
  1656. "failed_code": -10,
  1657. "msg": res.ErrMsg,
  1658. })
  1659. return
  1660. } else {
  1661. if res.Output.Result.SscnoCheckStat == "0" {
  1662. var msg string
  1663. switch res.Output.Result.CardStat {
  1664. case "00":
  1665. msg = "未激活"
  1666. break
  1667. case "10":
  1668. msg = "激活"
  1669. break
  1670. case "20":
  1671. msg = "窗口挂失"
  1672. break
  1673. case "21":
  1674. msg = "电话挂失"
  1675. break
  1676. case "22":
  1677. msg = "单位网上申报挂失"
  1678. break
  1679. case "23":
  1680. msg = "保健办挂失"
  1681. break
  1682. case "24":
  1683. msg = "个人网上挂失"
  1684. break
  1685. case "25":
  1686. msg = "网上服务大厅挂失"
  1687. break
  1688. case "30":
  1689. msg = "注销"
  1690. break
  1691. case "40":
  1692. msg = "回收"
  1693. break
  1694. case "99":
  1695. msg = "制卡中(无效卡)"
  1696. break
  1697. }
  1698. c.ServeSuccessJSON(map[string]interface{}{
  1699. "failed_code": -10,
  1700. "msg": msg,
  1701. })
  1702. return
  1703. } else {
  1704. c.ServeSuccessJSON(map[string]interface{}{
  1705. "msg": "校验成功",
  1706. })
  1707. return
  1708. }
  1709. }
  1710. }
  1711. func (c *HisApiController) CheckCardPWDTwo() {
  1712. //card_pwd := c.GetString("card_pwd")
  1713. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1714. admin_user_id, _ := c.GetInt64("admin_user_id")
  1715. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1716. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1717. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1718. var dat map[string]interface{}
  1719. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1720. fmt.Println(dat)
  1721. } else {
  1722. fmt.Println(err)
  1723. }
  1724. userJSONBytes, _ := json.Marshal(dat)
  1725. var res Result90991
  1726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1727. utils.ErrorLog("解析失败:%v", err)
  1728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1729. return
  1730. }
  1731. if res.Infcode != 0 {
  1732. c.ServeSuccessJSON(map[string]interface{}{
  1733. "failed_code": -10,
  1734. "msg": res.ErrMsg,
  1735. })
  1736. return
  1737. } else {
  1738. if res.Output.Result.SscnoCheckStat == "0" {
  1739. var msg string
  1740. switch res.Output.Result.CardStat {
  1741. case "00":
  1742. msg = "未激活"
  1743. break
  1744. case "10":
  1745. msg = "激活"
  1746. break
  1747. case "20":
  1748. msg = "窗口挂失"
  1749. break
  1750. case "21":
  1751. msg = "电话挂失"
  1752. break
  1753. case "22":
  1754. msg = "单位网上申报挂失"
  1755. break
  1756. case "23":
  1757. msg = "保健办挂失"
  1758. break
  1759. case "24":
  1760. msg = "个人网上挂失"
  1761. break
  1762. case "25":
  1763. msg = "网上服务大厅挂失"
  1764. break
  1765. case "30":
  1766. msg = "注销"
  1767. break
  1768. case "40":
  1769. msg = "回收"
  1770. break
  1771. case "99":
  1772. msg = "制卡中(无效卡)"
  1773. break
  1774. }
  1775. c.ServeSuccessJSON(map[string]interface{}{
  1776. "failed_code": -10,
  1777. "msg": msg,
  1778. })
  1779. return
  1780. } else {
  1781. c.ServeSuccessJSON(map[string]interface{}{
  1782. "msg": "校验成功",
  1783. })
  1784. return
  1785. }
  1786. }
  1787. }
  1788. type ELeCertData struct {
  1789. Data struct {
  1790. Extra string `json:"extra"`
  1791. IDNo string `json:"idNo"`
  1792. IDType string `json:"idType"`
  1793. EcToken string `json:"ecToken"`
  1794. InsuOrg string `json:"insuOrg"`
  1795. UserName string `json:"userName"`
  1796. EcIndexNo string `json:"ecIndexNo"`
  1797. Gender string `json:"gender"`
  1798. Birthday string `json:"birthday"`
  1799. Nationality string `json:"nationality"`
  1800. Email string `json:"email"`
  1801. } `json:"OutData"`
  1802. }
  1803. func (c *HisApiController) ReadCard() {
  1804. id_card_type, _ := c.GetInt64("id_card_type")
  1805. admin_user_id, _ := c.GetInt64("admin_user_id")
  1806. certificates, _ := c.GetInt64("certificates")
  1807. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1808. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1809. switch id_card_type {
  1810. case 1:
  1811. if miConfig.MdtrtareaAdmvs == "421300" {
  1812. var res ResultTwo
  1813. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1814. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1815. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  1816. resp, requestErr := http.Get(api)
  1817. if requestErr != nil {
  1818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1819. return
  1820. }
  1821. body, ioErr := ioutil.ReadAll(resp.Body)
  1822. if ioErr != nil {
  1823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1825. return
  1826. }
  1827. var respJSON map[string]interface{}
  1828. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1831. return
  1832. }
  1833. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1834. result, _ := json.Marshal(respJSON)
  1835. fmt.Println("log")
  1836. fmt.Println(string(result))
  1837. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1838. utils.ErrorLog("解析失败:%v", err)
  1839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1840. return
  1841. }
  1842. if res.Infcode == 0 {
  1843. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1844. if err == gorm.ErrRecordNotFound {
  1845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1846. return
  1847. } else if err != nil {
  1848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1849. return
  1850. } else {
  1851. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1852. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1853. infoStr := string(Iinfos)
  1854. idetinfoStr := string(Idetinfos)
  1855. psn := &models.HisPsn{
  1856. PsnNo: res.Output.Baseinfo.PsnNo,
  1857. Age: res.Output.Baseinfo.Age,
  1858. PatientId: patient.ID,
  1859. Certno: res.Output.Baseinfo.Certno,
  1860. Brdy: res.Output.Baseinfo.Brdy,
  1861. Gend: res.Output.Baseinfo.Gend,
  1862. Naty: res.Output.Baseinfo.Naty,
  1863. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1864. PsnName: res.Output.Baseinfo.PsnName,
  1865. Idetinfo: idetinfoStr,
  1866. Insuinfo: infoStr,
  1867. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1868. }
  1869. service.CreateHisPsn(psn)
  1870. c.ServeSuccessJSON(map[string]interface{}{
  1871. "patient": patient,
  1872. "number": res.Output.Baseinfo.Certno,
  1873. })
  1874. }
  1875. } else {
  1876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1877. return
  1878. }
  1879. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1880. var api string
  1881. if miConfig.MdtrtareaAdmvs == "320921" {
  1882. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1883. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  1884. fmt.Println(api)
  1885. } else {
  1886. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1887. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1888. }
  1889. resp, requestErr := http.Get(api)
  1890. if requestErr != nil {
  1891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1892. return
  1893. }
  1894. body, ioErr := ioutil.ReadAll(resp.Body)
  1895. if ioErr != nil {
  1896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1898. return
  1899. }
  1900. var respJSON map[string]interface{}
  1901. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1904. return
  1905. }
  1906. var status string
  1907. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1908. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1909. //console.log()
  1910. fmt.Println("type===")
  1911. fmt.Println(card_type)
  1912. var token string
  1913. var res ResultTwo //1101结果
  1914. var res10265 ResultTwo10265 //1101结果
  1915. var card_info string //卡信息
  1916. var busi_card_info string
  1917. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1918. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1919. if status == "0" { //读卡成功
  1920. if card_type == "1" {
  1921. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1922. result, _ := json.Marshal(respJSON)
  1923. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1924. utils.ErrorLog("解析失败:%v", err)
  1925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1926. return
  1927. }
  1928. res.ErrMsg = res10265.ErrMsg
  1929. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1930. res.Infcode = infocode
  1931. res.Output = res10265.Output
  1932. res.InfRefmsgid = res10265.InfRefmsgid
  1933. } else {
  1934. //var card_info string //卡信息
  1935. //var busi_card_info string
  1936. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1937. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1938. //fmt.Println(card_info)
  1939. //fmt.Println(busi_card_info)
  1940. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1941. result, _ := json.Marshal(respJSON)
  1942. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1943. utils.ErrorLog("解析失败:%v", err)
  1944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1945. return
  1946. }
  1947. res.ErrMsg = res10265.ErrMsg
  1948. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1949. res.Infcode = infocode
  1950. res.Output = res10265.Output
  1951. res.InfRefmsgid = res10265.InfRefmsgid
  1952. }
  1953. if res.Infcode == 0 {
  1954. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1955. if err == gorm.ErrRecordNotFound {
  1956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1957. return
  1958. } else if err != nil {
  1959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1960. return
  1961. } else {
  1962. if card_type == "1" {
  1963. bas := strings.Split(card_info, "|")
  1964. basNumber := bas[2]
  1965. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1966. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1967. infoStr := string(Iinfos)
  1968. idetinfoStr := string(Idetinfos)
  1969. psn := &models.HisPsn{
  1970. PsnNo: res.Output.Baseinfo.PsnNo,
  1971. Age: res.Output.Baseinfo.Age,
  1972. PatientId: patient.ID,
  1973. Certno: res.Output.Baseinfo.Certno,
  1974. Brdy: res.Output.Baseinfo.Brdy,
  1975. Gend: res.Output.Baseinfo.Gend,
  1976. Naty: res.Output.Baseinfo.Naty,
  1977. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1978. PsnName: res.Output.Baseinfo.PsnName,
  1979. Idetinfo: idetinfoStr,
  1980. Insuinfo: infoStr,
  1981. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1982. CardInfo: card_info,
  1983. VerifyNumber: busi_card_info,
  1984. }
  1985. service.CreateHisPsn(psn)
  1986. var rf []*ResultFive
  1987. json.Unmarshal([]byte(infoStr), &rf)
  1988. var insutypes []*ResultFive
  1989. var insutype string
  1990. var is390 int = 0
  1991. var is310 int = 0
  1992. for _, item := range rf {
  1993. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1994. insutypes = append(insutypes, item)
  1995. }
  1996. }
  1997. if len(insutypes) == 1 {
  1998. insutype = insutypes[0].Insutype
  1999. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2000. } else {
  2001. for _, i := range insutypes {
  2002. if i.Insutype == "390" {
  2003. is390 = 1
  2004. }
  2005. if i.Insutype == "310" {
  2006. is310 = 1
  2007. }
  2008. }
  2009. }
  2010. if is390 == 1 {
  2011. insutype = "390"
  2012. }
  2013. if is310 == 1 {
  2014. insutype = "310"
  2015. }
  2016. if len(insutypes) == 0 {
  2017. insutype = "310"
  2018. }
  2019. c.ServeSuccessJSON(map[string]interface{}{
  2020. "patient": patient,
  2021. "number": basNumber,
  2022. "insutype": insutype,
  2023. })
  2024. } else {
  2025. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2026. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2027. infoStr := string(Iinfos)
  2028. idetinfoStr := string(Idetinfos)
  2029. psn := &models.HisPsn{
  2030. PsnNo: res.Output.Baseinfo.PsnNo,
  2031. Age: res.Output.Baseinfo.Age,
  2032. PatientId: patient.ID,
  2033. Certno: res.Output.Baseinfo.Certno,
  2034. Brdy: res.Output.Baseinfo.Brdy,
  2035. Gend: res.Output.Baseinfo.Gend,
  2036. Naty: res.Output.Baseinfo.Naty,
  2037. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2038. PsnName: res.Output.Baseinfo.PsnName,
  2039. Idetinfo: idetinfoStr,
  2040. Insuinfo: infoStr,
  2041. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2042. CardInfo: card_info,
  2043. VerifyNumber: token,
  2044. }
  2045. service.CreateHisPsn(psn)
  2046. c.ServeSuccessJSON(map[string]interface{}{
  2047. "patient": patient,
  2048. "number": token,
  2049. })
  2050. }
  2051. }
  2052. } else {
  2053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2054. return
  2055. }
  2056. } else { //读卡失败
  2057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2058. return
  2059. }
  2060. } else if miConfig.MdtrtareaAdmvs == "350500" {
  2061. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  2062. cardnum = DeleteExtraSpaceTwo(cardnum)
  2063. cardCode = DeleteExtraSpaceTwo(cardCode)
  2064. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  2065. name = DeleteExtraSpaceTwo(name)
  2066. errmsg = DeleteExtraSpaceTwo(errmsg)
  2067. cardnum = Remove0000(cardnum)
  2068. cardCode = Remove0000(cardCode)
  2069. id_card_no = Remove0000(id_card_no)
  2070. name = Remove0000(name)
  2071. errmsg = Remove0000(errmsg)
  2072. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  2073. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  2074. saveLog(result, requestLog, "1101", "获取人员信息")
  2075. fmt.Println(errMsgLog)
  2076. if len(errMsgLog) > 0 {
  2077. } else {
  2078. var dat map[string]interface{}
  2079. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2080. fmt.Println(dat)
  2081. } else {
  2082. fmt.Println(err)
  2083. }
  2084. userJSONBytes, _ := json.Marshal(dat)
  2085. var res ResultTwo
  2086. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2087. utils.ErrorLog("解析失败:%v", err)
  2088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2089. return
  2090. }
  2091. res.ErrMsg = errMsgLog
  2092. if res.Infcode == 0 {
  2093. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  2094. if err == gorm.ErrRecordNotFound {
  2095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2096. return
  2097. } else if err != nil {
  2098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2099. return
  2100. } else {
  2101. fmt.Println(res)
  2102. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2103. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2104. infoStr := string(Iinfos)
  2105. idetinfoStr := string(Idetinfos)
  2106. psn := &models.HisPsn{
  2107. PsnNo: res.Output.Baseinfo.PsnNo,
  2108. Age: res.Output.Baseinfo.Age,
  2109. PatientId: patient.ID,
  2110. Certno: res.Output.Baseinfo.Certno,
  2111. Brdy: res.Output.Baseinfo.Brdy,
  2112. Gend: res.Output.Baseinfo.Gend,
  2113. Naty: res.Output.Baseinfo.Naty,
  2114. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2115. PsnName: res.Output.Baseinfo.PsnName,
  2116. Idetinfo: idetinfoStr,
  2117. Insuinfo: infoStr,
  2118. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2119. CardInfo: basStr,
  2120. VerifyNumber: "",
  2121. }
  2122. service.CreateHisPsn(psn)
  2123. var rf []*ResultFive
  2124. json.Unmarshal([]byte(infoStr), &rf)
  2125. var insutypes []*ResultFive
  2126. var insutype string
  2127. var is390 int = 0
  2128. var is310 int = 0
  2129. for _, item := range rf {
  2130. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2131. insutypes = append(insutypes, item)
  2132. }
  2133. }
  2134. if len(insutypes) == 1 {
  2135. insutype = insutypes[0].Insutype
  2136. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2137. } else {
  2138. for _, i := range insutypes {
  2139. if i.Insutype == "390" {
  2140. is390 = 1
  2141. }
  2142. if i.Insutype == "310" {
  2143. is310 = 1
  2144. }
  2145. }
  2146. }
  2147. if is390 == 1 {
  2148. insutype = "390"
  2149. }
  2150. if is310 == 1 {
  2151. insutype = "310"
  2152. }
  2153. if len(insutypes) == 0 {
  2154. insutype = "310"
  2155. }
  2156. c.ServeSuccessJSON(map[string]interface{}{
  2157. "patient": patient,
  2158. "number": cardnum,
  2159. "insutype": insutype,
  2160. })
  2161. }
  2162. } else {
  2163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2164. return
  2165. }
  2166. }
  2167. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2168. fmt.Println(initFlag)
  2169. fmt.Println("initFlag")
  2170. if initFlag == 0 {
  2171. c.TestGetJiangXiBasBaseInit()
  2172. }
  2173. basStr := c.GetBasBaseInfo()
  2174. if len(basStr) == 0 {
  2175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2176. return
  2177. }
  2178. fmt.Println(basStr)
  2179. bas := strings.Split(basStr, "|")
  2180. basNumber := bas[1]
  2181. fmt.Println(basNumber)
  2182. card_sn := bas[3]
  2183. fmt.Println(card_sn)
  2184. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  2185. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2186. var dat map[string]interface{}
  2187. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2188. fmt.Println(dat)
  2189. } else {
  2190. fmt.Println(err)
  2191. }
  2192. userJSONBytes, _ := json.Marshal(dat)
  2193. var res ResultTwo
  2194. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2195. utils.ErrorLog("解析失败:%v", err)
  2196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2197. return
  2198. }
  2199. if res.Infcode == 0 {
  2200. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2201. if err == gorm.ErrRecordNotFound {
  2202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2203. return
  2204. } else if err != nil {
  2205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2206. return
  2207. } else {
  2208. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2209. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2210. infoStr := string(Iinfos)
  2211. idetinfoStr := string(Idetinfos)
  2212. psn := &models.HisPsn{
  2213. PsnNo: res.Output.Baseinfo.PsnNo,
  2214. Age: res.Output.Baseinfo.Age,
  2215. PatientId: patient.ID,
  2216. Certno: res.Output.Baseinfo.Certno,
  2217. Brdy: res.Output.Baseinfo.Brdy,
  2218. Gend: res.Output.Baseinfo.Gend,
  2219. Naty: res.Output.Baseinfo.Naty,
  2220. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2221. PsnName: res.Output.Baseinfo.PsnName,
  2222. Idetinfo: idetinfoStr,
  2223. Insuinfo: infoStr,
  2224. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2225. CardInfo: basStr,
  2226. VerifyNumber: "",
  2227. }
  2228. service.CreateHisPsn(psn)
  2229. var rf []*ResultFive
  2230. json.Unmarshal([]byte(infoStr), &rf)
  2231. var insutypes []*ResultFive
  2232. var insutype string
  2233. var is390 int = 0
  2234. var is310 int = 0
  2235. for _, item := range rf {
  2236. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2237. insutypes = append(insutypes, item)
  2238. }
  2239. }
  2240. if len(insutypes) == 1 {
  2241. insutype = insutypes[0].Insutype
  2242. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2243. } else {
  2244. for _, i := range insutypes {
  2245. if i.Insutype == "390" {
  2246. is390 = 1
  2247. }
  2248. if i.Insutype == "310" {
  2249. is310 = 1
  2250. }
  2251. }
  2252. }
  2253. if is390 == 1 {
  2254. insutype = "390"
  2255. }
  2256. if is310 == 1 {
  2257. insutype = "310"
  2258. }
  2259. if len(insutypes) == 0 {
  2260. insutype = "310"
  2261. }
  2262. c.ServeSuccessJSON(map[string]interface{}{
  2263. "patient": patient,
  2264. "number": basNumber,
  2265. "insutype": insutype,
  2266. })
  2267. }
  2268. } else {
  2269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2270. return
  2271. }
  2272. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2273. fmt.Println(initFlag)
  2274. fmt.Println("initFlag")
  2275. if initFlag == 0 {
  2276. c.TestGetHnBasBaseInit()
  2277. }
  2278. basStr := c.GetBasBaseInfo()
  2279. if len(basStr) == 0 {
  2280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2281. return
  2282. }
  2283. fmt.Println(basStr)
  2284. bas := strings.Split(basStr, "|")
  2285. basNumber := bas[1]
  2286. fmt.Println(basNumber)
  2287. card_sn := bas[3]
  2288. card_no := bas[2]
  2289. fmt.Println(card_sn)
  2290. name := bas[4]
  2291. name = ConvertToString(name, "gbk", "utf-8")
  2292. result, _ := service.Hnyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "", name, card_no)
  2293. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2294. var dat map[string]interface{}
  2295. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2296. fmt.Println(dat)
  2297. } else {
  2298. fmt.Println(err)
  2299. }
  2300. userJSONBytes, _ := json.Marshal(dat)
  2301. var res ResultTwo
  2302. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2303. utils.ErrorLog("解析失败:%v", err)
  2304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2305. return
  2306. }
  2307. if res.Infcode == 0 {
  2308. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2309. if err == gorm.ErrRecordNotFound {
  2310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2311. return
  2312. } else if err != nil {
  2313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2314. return
  2315. } else {
  2316. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2317. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2318. infoStr := string(Iinfos)
  2319. idetinfoStr := string(Idetinfos)
  2320. psn := &models.HisPsn{
  2321. PsnNo: res.Output.Baseinfo.PsnNo,
  2322. Age: res.Output.Baseinfo.Age,
  2323. PatientId: patient.ID,
  2324. Certno: res.Output.Baseinfo.Certno,
  2325. Brdy: res.Output.Baseinfo.Brdy,
  2326. Gend: res.Output.Baseinfo.Gend,
  2327. Naty: res.Output.Baseinfo.Naty,
  2328. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2329. PsnName: res.Output.Baseinfo.PsnName,
  2330. Idetinfo: idetinfoStr,
  2331. Insuinfo: infoStr,
  2332. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2333. CardInfo: basStr,
  2334. VerifyNumber: "",
  2335. }
  2336. service.CreateHisPsn(psn)
  2337. var rf []*ResultFive
  2338. json.Unmarshal([]byte(infoStr), &rf)
  2339. var insutypes []*ResultFive
  2340. var insutype string
  2341. var is390 int = 0
  2342. var is310 int = 0
  2343. for _, item := range rf {
  2344. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2345. insutypes = append(insutypes, item)
  2346. }
  2347. }
  2348. if len(insutypes) == 1 {
  2349. insutype = insutypes[0].Insutype
  2350. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2351. } else {
  2352. for _, i := range insutypes {
  2353. if i.Insutype == "390" {
  2354. is390 = 1
  2355. }
  2356. if i.Insutype == "310" {
  2357. is310 = 1
  2358. }
  2359. }
  2360. }
  2361. if is390 == 1 {
  2362. insutype = "390"
  2363. }
  2364. if is310 == 1 {
  2365. insutype = "310"
  2366. }
  2367. if len(insutypes) == 0 {
  2368. insutype = "310"
  2369. }
  2370. c.ServeSuccessJSON(map[string]interface{}{
  2371. "patient": patient,
  2372. "number": basNumber,
  2373. "insutype": insutype,
  2374. })
  2375. }
  2376. } else {
  2377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2378. return
  2379. }
  2380. } else {
  2381. if initFlag == 0 {
  2382. c.TestGetBasBaseInit()
  2383. }
  2384. basStr := c.GetBasBaseInfo()
  2385. if len(basStr) == 0 {
  2386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2387. return
  2388. }
  2389. fmt.Println(basStr)
  2390. bas := strings.Split(basStr, "|")
  2391. basNumber := bas[1]
  2392. fmt.Println(basNumber)
  2393. card_sn := bas[3]
  2394. fmt.Println(card_sn)
  2395. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2396. var dat map[string]interface{}
  2397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2398. fmt.Println(dat)
  2399. } else {
  2400. fmt.Println(err)
  2401. }
  2402. userJSONBytes, _ := json.Marshal(dat)
  2403. var res ResultTwo
  2404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2405. utils.ErrorLog("解析失败:%v", err)
  2406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2407. return
  2408. }
  2409. if res.Infcode == 0 {
  2410. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2411. if err == gorm.ErrRecordNotFound {
  2412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2413. return
  2414. } else if err != nil {
  2415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2416. return
  2417. } else {
  2418. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2419. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2420. infoStr := string(Iinfos)
  2421. idetinfoStr := string(Idetinfos)
  2422. psn := &models.HisPsn{
  2423. PsnNo: res.Output.Baseinfo.PsnNo,
  2424. Age: res.Output.Baseinfo.Age,
  2425. PatientId: patient.ID,
  2426. Certno: res.Output.Baseinfo.Certno,
  2427. Brdy: res.Output.Baseinfo.Brdy,
  2428. Gend: res.Output.Baseinfo.Gend,
  2429. Naty: res.Output.Baseinfo.Naty,
  2430. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2431. PsnName: res.Output.Baseinfo.PsnName,
  2432. Idetinfo: idetinfoStr,
  2433. Insuinfo: infoStr,
  2434. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2435. CardInfo: basStr,
  2436. VerifyNumber: "",
  2437. }
  2438. service.CreateHisPsn(psn)
  2439. c.ServeSuccessJSON(map[string]interface{}{
  2440. "patient": patient,
  2441. "number": basNumber,
  2442. })
  2443. }
  2444. } else {
  2445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2446. return
  2447. }
  2448. break
  2449. }
  2450. case 2:
  2451. if miConfig.MdtrtareaAdmvs == "430800" {
  2452. if initFlag == 0 {
  2453. c.TestGetHnBasBaseInit()
  2454. }
  2455. SFZStr := c.GetSFZBaseInfo()
  2456. if len(SFZStr) == 0 {
  2457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2458. return
  2459. }
  2460. fmt.Println(SFZStr)
  2461. id_card_str := strings.Split(SFZStr, "^")
  2462. card_no := id_card_str[0]
  2463. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  2464. //name := id_card_str[1]
  2465. //name = ConvertToString(name, "gbk", "utf-8")
  2466. result, _ := service.Hnyb1101(card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", patient.Name, card_no)
  2467. var dat map[string]interface{}
  2468. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2469. fmt.Println(dat)
  2470. } else {
  2471. fmt.Println(err)
  2472. }
  2473. userJSONBytes, _ := json.Marshal(dat)
  2474. var res ResultTwo
  2475. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2476. utils.ErrorLog("解析失败:%v", err)
  2477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2478. return
  2479. }
  2480. if res.Infcode == 0 {
  2481. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  2482. if err == gorm.ErrRecordNotFound {
  2483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2484. return
  2485. } else if err != nil {
  2486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2487. return
  2488. } else {
  2489. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2490. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2491. infoStr := string(Iinfos)
  2492. idetinfoStr := string(Idetinfos)
  2493. psn := &models.HisPsn{
  2494. PsnNo: res.Output.Baseinfo.PsnNo,
  2495. Age: res.Output.Baseinfo.Age,
  2496. PatientId: patient.ID,
  2497. Certno: res.Output.Baseinfo.Certno,
  2498. Brdy: res.Output.Baseinfo.Brdy,
  2499. Gend: res.Output.Baseinfo.Gend,
  2500. Naty: res.Output.Baseinfo.Naty,
  2501. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2502. PsnName: res.Output.Baseinfo.PsnName,
  2503. Idetinfo: idetinfoStr,
  2504. Insuinfo: infoStr,
  2505. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2506. CardInfo: SFZStr,
  2507. VerifyNumber: "",
  2508. }
  2509. service.CreateHisPsn(psn)
  2510. var rf []*ResultFive
  2511. json.Unmarshal([]byte(infoStr), &rf)
  2512. var insutypes []*ResultFive
  2513. var insutype string
  2514. var is390 int = 0
  2515. var is310 int = 0
  2516. for _, item := range rf {
  2517. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2518. insutypes = append(insutypes, item)
  2519. }
  2520. }
  2521. if len(insutypes) == 1 {
  2522. insutype = insutypes[0].Insutype
  2523. } else {
  2524. for _, i := range insutypes {
  2525. if i.Insutype == "390" {
  2526. is390 = 1
  2527. }
  2528. if i.Insutype == "310" {
  2529. is310 = 1
  2530. }
  2531. }
  2532. }
  2533. if is390 == 1 {
  2534. insutype = "390"
  2535. }
  2536. if is310 == 1 {
  2537. insutype = "310"
  2538. }
  2539. if len(insutypes) == 0 {
  2540. insutype = "310"
  2541. }
  2542. c.ServeSuccessJSON(map[string]interface{}{
  2543. "patient": patient,
  2544. "number": card_no,
  2545. "insutype": insutype,
  2546. })
  2547. }
  2548. } else {
  2549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2550. return
  2551. }
  2552. } else {
  2553. SFZStr := c.GetSFZBaseInfo()
  2554. id_card_str := strings.Split(SFZStr, "^")
  2555. id_card_number := id_card_str[0]
  2556. card_sn := ""
  2557. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2558. var dat map[string]interface{}
  2559. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2560. fmt.Println(dat)
  2561. } else {
  2562. fmt.Println(err)
  2563. }
  2564. userJSONBytes, _ := json.Marshal(dat)
  2565. var res ResultTwo
  2566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2567. utils.ErrorLog("解析失败:%v", err)
  2568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2569. return
  2570. }
  2571. if res.Infcode == 0 {
  2572. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  2573. if err == gorm.ErrRecordNotFound {
  2574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2575. return
  2576. } else if err != nil {
  2577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2578. return
  2579. } else {
  2580. c.ServeSuccessJSON(map[string]interface{}{
  2581. "patient": patient,
  2582. "number": id_card_number,
  2583. })
  2584. }
  2585. } else {
  2586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2587. return
  2588. }
  2589. }
  2590. break
  2591. case 3:
  2592. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2593. var api string
  2594. if miConfig.MdtrtareaAdmvs == "320921" {
  2595. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2596. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  2597. fmt.Println(api)
  2598. } else {
  2599. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2600. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  2601. }
  2602. resp, requestErr := http.Get(api)
  2603. if requestErr != nil {
  2604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2605. return
  2606. }
  2607. body, ioErr := ioutil.ReadAll(resp.Body)
  2608. if ioErr != nil {
  2609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2611. return
  2612. }
  2613. var respJSON map[string]interface{}
  2614. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2617. return
  2618. }
  2619. var status string
  2620. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2621. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2622. var token string
  2623. var res ResultTwo //1101结果
  2624. var res10265 ResultTwo10265 //1101结果
  2625. var card_info string //卡信息
  2626. var busi_card_info string
  2627. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2628. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2629. if status == "0" { //读卡成功
  2630. if card_type == "1" {
  2631. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2632. result, _ := json.Marshal(respJSON)
  2633. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2634. utils.ErrorLog("解析失败:%v", err)
  2635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2636. return
  2637. }
  2638. res.ErrMsg = res10265.ErrMsg
  2639. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2640. res.Infcode = infocode
  2641. res.Output = res10265.Output
  2642. res.InfRefmsgid = res10265.InfRefmsgid
  2643. } else {
  2644. //var card_info string //卡信息
  2645. //var busi_card_info string
  2646. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2647. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2648. //fmt.Println(card_info)
  2649. //fmt.Println(busi_card_info)
  2650. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2651. result, _ := json.Marshal(respJSON)
  2652. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2653. utils.ErrorLog("解析失败:%v", err)
  2654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2655. return
  2656. }
  2657. res.ErrMsg = res10265.ErrMsg
  2658. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2659. res.Infcode = infocode
  2660. res.Output = res10265.Output
  2661. res.InfRefmsgid = res10265.InfRefmsgid
  2662. }
  2663. if res.Infcode == 0 {
  2664. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2665. if err == gorm.ErrRecordNotFound {
  2666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2667. return
  2668. } else if err != nil {
  2669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2670. return
  2671. } else {
  2672. if card_type == "1" {
  2673. bas := strings.Split(card_info, "|")
  2674. basNumber := bas[2]
  2675. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2676. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2677. infoStr := string(Iinfos)
  2678. idetinfoStr := string(Idetinfos)
  2679. psn := &models.HisPsn{
  2680. PsnNo: res.Output.Baseinfo.PsnNo,
  2681. Age: res.Output.Baseinfo.Age,
  2682. PatientId: patient.ID,
  2683. Certno: res.Output.Baseinfo.Certno,
  2684. Brdy: res.Output.Baseinfo.Brdy,
  2685. Gend: res.Output.Baseinfo.Gend,
  2686. Naty: res.Output.Baseinfo.Naty,
  2687. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2688. PsnName: res.Output.Baseinfo.PsnName,
  2689. Idetinfo: idetinfoStr,
  2690. Insuinfo: infoStr,
  2691. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2692. CardInfo: card_info,
  2693. VerifyNumber: busi_card_info,
  2694. }
  2695. service.CreateHisPsn(psn)
  2696. c.ServeSuccessJSON(map[string]interface{}{
  2697. "patient": patient,
  2698. "number": basNumber,
  2699. })
  2700. } else {
  2701. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2702. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2703. infoStr := string(Iinfos)
  2704. idetinfoStr := string(Idetinfos)
  2705. psn := &models.HisPsn{
  2706. PsnNo: res.Output.Baseinfo.PsnNo,
  2707. Age: res.Output.Baseinfo.Age,
  2708. PatientId: patient.ID,
  2709. Certno: res.Output.Baseinfo.Certno,
  2710. Brdy: res.Output.Baseinfo.Brdy,
  2711. Gend: res.Output.Baseinfo.Gend,
  2712. Naty: res.Output.Baseinfo.Naty,
  2713. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2714. PsnName: res.Output.Baseinfo.PsnName,
  2715. Idetinfo: idetinfoStr,
  2716. Insuinfo: infoStr,
  2717. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2718. CardInfo: card_info,
  2719. VerifyNumber: token,
  2720. }
  2721. service.CreateHisPsn(psn)
  2722. var rf []*ResultFive
  2723. json.Unmarshal([]byte(infoStr), &rf)
  2724. var insutypes []*ResultFive
  2725. var insutype string
  2726. var is390 int = 0
  2727. var is310 int = 0
  2728. for _, item := range rf {
  2729. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2730. insutypes = append(insutypes, item)
  2731. }
  2732. }
  2733. if len(insutypes) == 1 {
  2734. insutype = insutypes[0].Insutype
  2735. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2736. } else {
  2737. for _, i := range insutypes {
  2738. if i.Insutype == "390" {
  2739. is390 = 1
  2740. }
  2741. if i.Insutype == "310" {
  2742. is310 = 1
  2743. }
  2744. }
  2745. }
  2746. if is390 == 1 {
  2747. insutype = "390"
  2748. }
  2749. if is310 == 1 {
  2750. insutype = "310"
  2751. }
  2752. if len(insutypes) == 0 {
  2753. insutype = "310"
  2754. }
  2755. c.ServeSuccessJSON(map[string]interface{}{
  2756. "patient": patient,
  2757. "number": token,
  2758. "insutype": insutype,
  2759. })
  2760. }
  2761. }
  2762. } else {
  2763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2764. return
  2765. }
  2766. } else { //读卡失败
  2767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2768. return
  2769. }
  2770. }
  2771. break
  2772. case 4:
  2773. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2774. var api string
  2775. if miConfig.MdtrtareaAdmvs == "320921" {
  2776. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2777. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  2778. fmt.Println(api)
  2779. } else {
  2780. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2781. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  2782. }
  2783. resp, requestErr := http.Get(api)
  2784. if requestErr != nil {
  2785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2786. return
  2787. }
  2788. body, ioErr := ioutil.ReadAll(resp.Body)
  2789. if ioErr != nil {
  2790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2792. return
  2793. }
  2794. var respJSON map[string]interface{}
  2795. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2798. return
  2799. }
  2800. var status string
  2801. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2802. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2803. var token string
  2804. var res ResultTwo //1101结果
  2805. var res10265 ResultTwo10265 //1101结果
  2806. if status == "0" { //读卡成功
  2807. var card_info string //卡信息
  2808. var busi_card_info string
  2809. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2810. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2811. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2812. fmt.Println(card_info)
  2813. fmt.Println(busi_card_info)
  2814. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2815. result, _ := json.Marshal(respJSON)
  2816. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2817. utils.ErrorLog("解析失败:%v", err)
  2818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2819. return
  2820. }
  2821. res.ErrMsg = res10265.ErrMsg
  2822. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2823. res.Infcode = infocode
  2824. res.Output = res10265.Output
  2825. res.InfRefmsgid = res10265.InfRefmsgid
  2826. if res.Infcode == 0 {
  2827. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2828. if err == gorm.ErrRecordNotFound {
  2829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2830. return
  2831. } else if err != nil {
  2832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2833. return
  2834. } else {
  2835. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2836. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2837. infoStr := string(Iinfos)
  2838. idetinfoStr := string(Idetinfos)
  2839. psn := &models.HisPsn{
  2840. PsnNo: res.Output.Baseinfo.PsnNo,
  2841. Age: res.Output.Baseinfo.Age,
  2842. PatientId: patient.ID,
  2843. Certno: res.Output.Baseinfo.Certno,
  2844. Brdy: res.Output.Baseinfo.Brdy,
  2845. Gend: res.Output.Baseinfo.Gend,
  2846. Naty: res.Output.Baseinfo.Naty,
  2847. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2848. PsnName: res.Output.Baseinfo.PsnName,
  2849. Idetinfo: idetinfoStr,
  2850. Insuinfo: infoStr,
  2851. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2852. CardInfo: card_info,
  2853. VerifyNumber: token,
  2854. }
  2855. var rf []*ResultFive
  2856. json.Unmarshal([]byte(infoStr), &rf)
  2857. var insutypes []*ResultFive
  2858. var insutype string
  2859. var is390 int = 0
  2860. var is310 int = 0
  2861. for _, item := range rf {
  2862. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2863. insutypes = append(insutypes, item)
  2864. }
  2865. }
  2866. if len(insutypes) == 1 {
  2867. insutype = insutypes[0].Insutype
  2868. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2869. } else {
  2870. for _, i := range insutypes {
  2871. if i.Insutype == "390" {
  2872. is390 = 1
  2873. }
  2874. if i.Insutype == "310" {
  2875. is310 = 1
  2876. }
  2877. }
  2878. }
  2879. if is390 == 1 {
  2880. insutype = "390"
  2881. }
  2882. if is310 == 1 {
  2883. insutype = "310"
  2884. }
  2885. if len(insutypes) == 0 {
  2886. insutype = "310"
  2887. }
  2888. service.CreateHisPsn(psn)
  2889. c.ServeSuccessJSON(map[string]interface{}{
  2890. "patient": patient,
  2891. "number": token,
  2892. "insutype": insutype,
  2893. })
  2894. }
  2895. } else {
  2896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2897. return
  2898. }
  2899. } else { //读卡失败
  2900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2901. return
  2902. }
  2903. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  2904. if initFlag == 0 {
  2905. c.TestGetBasBaseInit()
  2906. }
  2907. token := c.GetEleBaseInfo()
  2908. token = Remove0000(token)
  2909. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  2910. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2911. //
  2912. var res ResultTwo
  2913. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2914. utils.ErrorLog("解析失败:%v", err)
  2915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2916. return
  2917. }
  2918. if res.Infcode == 0 {
  2919. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2920. if err == gorm.ErrRecordNotFound {
  2921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2922. return
  2923. } else if err != nil {
  2924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2925. return
  2926. } else {
  2927. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2928. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2929. infoStr := string(Iinfos)
  2930. idetinfoStr := string(Idetinfos)
  2931. psn := &models.HisPsn{
  2932. PsnNo: res.Output.Baseinfo.PsnNo,
  2933. Age: res.Output.Baseinfo.Age,
  2934. PatientId: patient.ID,
  2935. Certno: res.Output.Baseinfo.Certno,
  2936. Brdy: res.Output.Baseinfo.Brdy,
  2937. Gend: res.Output.Baseinfo.Gend,
  2938. Naty: res.Output.Baseinfo.Naty,
  2939. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2940. PsnName: res.Output.Baseinfo.PsnName,
  2941. Idetinfo: idetinfoStr,
  2942. Insuinfo: infoStr,
  2943. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2944. CardInfo: "",
  2945. VerifyNumber: token,
  2946. }
  2947. service.CreateHisPsn(psn)
  2948. c.ServeSuccessJSON(map[string]interface{}{
  2949. "patient": patient,
  2950. "number": token,
  2951. })
  2952. }
  2953. } else {
  2954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2955. return
  2956. }
  2957. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2958. if initFlag == 0 {
  2959. c.TestGetBasBaseInit()
  2960. }
  2961. token := c.GetEleBaseInfo()
  2962. token = Remove0000(token)
  2963. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", "", "")
  2964. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2965. //
  2966. var res ResultTwo
  2967. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2968. utils.ErrorLog("解析失败:%v", err)
  2969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2970. return
  2971. }
  2972. if res.Infcode == 0 {
  2973. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2974. if err == gorm.ErrRecordNotFound {
  2975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2976. return
  2977. } else if err != nil {
  2978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2979. return
  2980. } else {
  2981. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2982. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2983. infoStr := string(Iinfos)
  2984. idetinfoStr := string(Idetinfos)
  2985. psn := &models.HisPsn{
  2986. PsnNo: res.Output.Baseinfo.PsnNo,
  2987. Age: res.Output.Baseinfo.Age,
  2988. PatientId: patient.ID,
  2989. Certno: res.Output.Baseinfo.Certno,
  2990. Brdy: res.Output.Baseinfo.Brdy,
  2991. Gend: res.Output.Baseinfo.Gend,
  2992. Naty: res.Output.Baseinfo.Naty,
  2993. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2994. PsnName: res.Output.Baseinfo.PsnName,
  2995. Idetinfo: idetinfoStr,
  2996. Insuinfo: infoStr,
  2997. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2998. CardInfo: "",
  2999. VerifyNumber: token,
  3000. }
  3001. service.CreateHisPsn(psn)
  3002. c.ServeSuccessJSON(map[string]interface{}{
  3003. "patient": patient,
  3004. "number": token,
  3005. })
  3006. }
  3007. } else {
  3008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3009. return
  3010. }
  3011. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3012. //if initFlag == 0 {
  3013. c.TestGetJiangXiBasBaseInit()
  3014. //}
  3015. //if initEleFlag == 0 {
  3016. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3017. //}
  3018. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3019. type ELeData struct {
  3020. Data struct {
  3021. IdNo string `json:"idNo"`
  3022. IdType string `json:"idType"`
  3023. UserName string `json:"userName"`
  3024. EcToken string `json:"ecToken"`
  3025. InsuOrg string `json:"insuOrg"`
  3026. Gender string `json:"gender"`
  3027. Birthday string `json:"birthday"`
  3028. Nationality string `json:"nationality"`
  3029. Email string `json:"email"`
  3030. Extra string `json:"extra"`
  3031. } `json:"data"`
  3032. Code int `json:"code"`
  3033. Message string `json:"message"`
  3034. }
  3035. var ele ELeData
  3036. err := json.Unmarshal([]byte(json_result), &ele)
  3037. if err != nil {
  3038. utils.ErrorLog("解析失败:%v", err)
  3039. }
  3040. token := ele.Data.EcToken
  3041. token = Remove0000(token)
  3042. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  3043. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3044. var res ResultTwo
  3045. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3046. utils.ErrorLog("解析失败:%v", err)
  3047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3048. return
  3049. }
  3050. if res.Infcode == 0 {
  3051. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3052. if err == gorm.ErrRecordNotFound {
  3053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3054. return
  3055. } else if err != nil {
  3056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3057. return
  3058. } else {
  3059. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3060. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3061. infoStr := string(Iinfos)
  3062. idetinfoStr := string(Idetinfos)
  3063. psn := &models.HisPsn{
  3064. PsnNo: res.Output.Baseinfo.PsnNo,
  3065. Age: res.Output.Baseinfo.Age,
  3066. PatientId: patient.ID,
  3067. Certno: res.Output.Baseinfo.Certno,
  3068. Brdy: res.Output.Baseinfo.Brdy,
  3069. Gend: res.Output.Baseinfo.Gend,
  3070. Naty: res.Output.Baseinfo.Naty,
  3071. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3072. PsnName: res.Output.Baseinfo.PsnName,
  3073. Idetinfo: idetinfoStr,
  3074. Insuinfo: infoStr,
  3075. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3076. CardInfo: "",
  3077. VerifyNumber: token,
  3078. }
  3079. service.CreateHisPsn(psn)
  3080. var rf []*ResultFive
  3081. json.Unmarshal([]byte(infoStr), &rf)
  3082. var insutypes []*ResultFive
  3083. var insutype string
  3084. var is390 int = 0
  3085. var is310 int = 0
  3086. for _, item := range rf {
  3087. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3088. insutypes = append(insutypes, item)
  3089. }
  3090. }
  3091. if len(insutypes) == 1 {
  3092. insutype = insutypes[0].Insutype
  3093. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3094. } else {
  3095. for _, i := range insutypes {
  3096. if i.Insutype == "390" {
  3097. is390 = 1
  3098. }
  3099. if i.Insutype == "310" {
  3100. is310 = 1
  3101. }
  3102. }
  3103. }
  3104. if is390 == 1 {
  3105. insutype = "390"
  3106. }
  3107. if is310 == 1 {
  3108. insutype = "310"
  3109. }
  3110. if len(insutypes) == 0 {
  3111. insutype = "310"
  3112. }
  3113. c.ServeSuccessJSON(map[string]interface{}{
  3114. "patient": patient,
  3115. "number": token,
  3116. "insutype": insutype,
  3117. })
  3118. }
  3119. } else {
  3120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3121. return
  3122. }
  3123. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3124. //if initFlag == 0 {
  3125. c.TestGetJiangXiBasBaseInit()
  3126. //}
  3127. //if initEleFlag == 0 {
  3128. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3129. //}
  3130. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3131. type ELeData struct {
  3132. Data struct {
  3133. IdNo string `json:"idNo"`
  3134. IdType string `json:"idType"`
  3135. UserName string `json:"userName"`
  3136. EcToken string `json:"ecToken"`
  3137. InsuOrg string `json:"insuOrg"`
  3138. Gender string `json:"gender"`
  3139. Birthday string `json:"birthday"`
  3140. Nationality string `json:"nationality"`
  3141. Email string `json:"email"`
  3142. Extra string `json:"extra"`
  3143. } `json:"data"`
  3144. Code int `json:"code"`
  3145. Message string `json:"message"`
  3146. }
  3147. var ele ELeData
  3148. err := json.Unmarshal([]byte(json_result), &ele)
  3149. if err != nil {
  3150. utils.ErrorLog("解析失败:%v", err)
  3151. }
  3152. token := ele.Data.EcToken
  3153. token = Remove0000(token)
  3154. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  3155. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3156. var res ResultTwo
  3157. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3158. utils.ErrorLog("解析失败:%v", err)
  3159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3160. return
  3161. }
  3162. if res.Infcode == 0 {
  3163. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3164. if err == gorm.ErrRecordNotFound {
  3165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3166. return
  3167. } else if err != nil {
  3168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3169. return
  3170. } else {
  3171. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3172. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3173. infoStr := string(Iinfos)
  3174. idetinfoStr := string(Idetinfos)
  3175. psn := &models.HisPsn{
  3176. PsnNo: res.Output.Baseinfo.PsnNo,
  3177. Age: res.Output.Baseinfo.Age,
  3178. PatientId: patient.ID,
  3179. Certno: res.Output.Baseinfo.Certno,
  3180. Brdy: res.Output.Baseinfo.Brdy,
  3181. Gend: res.Output.Baseinfo.Gend,
  3182. Naty: res.Output.Baseinfo.Naty,
  3183. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3184. PsnName: res.Output.Baseinfo.PsnName,
  3185. Idetinfo: idetinfoStr,
  3186. Insuinfo: infoStr,
  3187. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3188. CardInfo: "",
  3189. VerifyNumber: token,
  3190. }
  3191. service.CreateHisPsn(psn)
  3192. var rf []*ResultFive
  3193. json.Unmarshal([]byte(infoStr), &rf)
  3194. var insutypes []*ResultFive
  3195. var insutype string
  3196. var is390 int = 0
  3197. var is310 int = 0
  3198. for _, item := range rf {
  3199. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3200. insutypes = append(insutypes, item)
  3201. }
  3202. }
  3203. if len(insutypes) == 1 {
  3204. insutype = insutypes[0].Insutype
  3205. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3206. } else {
  3207. for _, i := range insutypes {
  3208. if i.Insutype == "390" {
  3209. is390 = 1
  3210. }
  3211. if i.Insutype == "310" {
  3212. is310 = 1
  3213. }
  3214. }
  3215. }
  3216. if is390 == 1 {
  3217. insutype = "390"
  3218. }
  3219. if is310 == 1 {
  3220. insutype = "310"
  3221. }
  3222. if len(insutypes) == 0 {
  3223. insutype = "310"
  3224. }
  3225. c.ServeSuccessJSON(map[string]interface{}{
  3226. "patient": patient,
  3227. "number": token,
  3228. "insutype": insutype,
  3229. })
  3230. }
  3231. } else {
  3232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3233. return
  3234. }
  3235. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3236. type ELeData struct {
  3237. Code string `json:"code"`
  3238. Data struct {
  3239. Aac002 string `json:"aac002"`
  3240. Aaz500 string `json:"aaz500"`
  3241. ActCardNo string `json:"actCardNo"`
  3242. Bab520 string `json:"bab520"`
  3243. Bkz543 string `json:"bkz543"`
  3244. BusinessType string `json:"businessType"`
  3245. CertfCodg string `json:"certfCodg"`
  3246. EcIndexNo string `json:"ecIndexNo"`
  3247. EcToken string `json:"ecToken"`
  3248. ID0000 string `json:"id0000"`
  3249. IDNo string `json:"idNo"`
  3250. IDType string `json:"idType"`
  3251. Idcode string `json:"idcode"`
  3252. IdentityToken string `json:"identity_token"`
  3253. InsuOrg string `json:"insuOrg"`
  3254. OfficeID string `json:"officeId"`
  3255. OfficeName string `json:"officeName"`
  3256. OperatorID string `json:"operatorId"`
  3257. OperatorName string `json:"operatorName"`
  3258. OrgID string `json:"orgId"`
  3259. UserName string `json:"userName"`
  3260. } `json:"data"`
  3261. Infno interface{} `json:"infno"`
  3262. Message string `json:"message"`
  3263. OrgID string `json:"orgId"`
  3264. TransType string `json:"transType"`
  3265. }
  3266. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  3267. outPutInfo = Remove0000(outPutInfo)
  3268. if len(outPutInfo) > 0 {
  3269. var ele ELeData
  3270. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3271. if err != nil {
  3272. utils.ErrorLog("解析失败:%v", err)
  3273. }
  3274. token := ele.Data.EcToken
  3275. fmt.Println(inputInfo)
  3276. fmt.Println(outPutInfo)
  3277. result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IDNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, "", 1, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token, ele.Data.UserName)
  3278. saveLog(result, requestLog, "1101", "获取人员信息")
  3279. var dat map[string]interface{}
  3280. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3281. fmt.Println(dat)
  3282. } else {
  3283. fmt.Println(err)
  3284. }
  3285. userJSONBytes, _ := json.Marshal(dat)
  3286. var res ResultTwo
  3287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3288. utils.ErrorLog("解析失败:%v", err)
  3289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3290. return
  3291. }
  3292. res.ErrMsg = errMsgLog
  3293. if res.Infcode == 0 {
  3294. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  3295. if err == gorm.ErrRecordNotFound {
  3296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3297. return
  3298. } else if err != nil {
  3299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3300. return
  3301. } else {
  3302. fmt.Println(res)
  3303. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3304. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3305. infoStr := string(Iinfos)
  3306. idetinfoStr := string(Idetinfos)
  3307. psn := &models.HisPsn{
  3308. PsnNo: res.Output.Baseinfo.PsnNo,
  3309. Age: res.Output.Baseinfo.Age,
  3310. PatientId: patient.ID,
  3311. Certno: res.Output.Baseinfo.Certno,
  3312. Brdy: res.Output.Baseinfo.Brdy,
  3313. Gend: res.Output.Baseinfo.Gend,
  3314. Naty: res.Output.Baseinfo.Naty,
  3315. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3316. PsnName: res.Output.Baseinfo.PsnName,
  3317. Idetinfo: idetinfoStr,
  3318. Insuinfo: infoStr,
  3319. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3320. CardInfo: outPutInfo,
  3321. VerifyNumber: token,
  3322. }
  3323. service.CreateHisPsn(psn)
  3324. var rf []*ResultFive
  3325. json.Unmarshal([]byte(infoStr), &rf)
  3326. var insutypes []*ResultFive
  3327. var insutype string
  3328. var is390 int = 0
  3329. var is310 int = 0
  3330. for _, item := range rf {
  3331. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3332. insutypes = append(insutypes, item)
  3333. }
  3334. }
  3335. if len(insutypes) == 1 {
  3336. insutype = insutypes[0].Insutype
  3337. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3338. } else {
  3339. for _, i := range insutypes {
  3340. if i.Insutype == "390" {
  3341. is390 = 1
  3342. }
  3343. if i.Insutype == "310" {
  3344. is310 = 1
  3345. }
  3346. }
  3347. }
  3348. if is390 == 1 {
  3349. insutype = "390"
  3350. }
  3351. if is310 == 1 {
  3352. insutype = "310"
  3353. }
  3354. if len(insutypes) == 0 {
  3355. insutype = "310"
  3356. }
  3357. c.ServeSuccessJSON(map[string]interface{}{
  3358. "patient": patient,
  3359. "number": token,
  3360. "insutype": insutype,
  3361. })
  3362. }
  3363. } else {
  3364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3365. return
  3366. }
  3367. }
  3368. }
  3369. break
  3370. }
  3371. }
  3372. var initFlag int64 = 0
  3373. var initEleFlag int64 = 0
  3374. func (c *HisApiController) TestGetBasBaseInit() {
  3375. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3376. Iinit := DllDef.MustFindProc("Init")
  3377. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3378. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  3379. if ret != 0 {
  3380. fmt.Println("SSCard的报错原因:", err)
  3381. fmt.Println("SSCard的运算结果为:", ret)
  3382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3383. return
  3384. }
  3385. result := int(ret)
  3386. fmt.Println("SSCard的运算结果为1:", result)
  3387. initFlag = 1
  3388. return
  3389. }
  3390. func (c *HisApiController) HandleJiangXiReadCard() {
  3391. fmt.Println("~~~~~~")
  3392. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3393. admin_user_id, _ := c.GetInt64("admin_user_id")
  3394. id_card_type, _ := c.GetInt64("id_card_type")
  3395. //certificates, _ := c.GetInt64("certificates")
  3396. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3397. if initFlag == 0 {
  3398. c.TestGetJiangXiBasBaseInit()
  3399. }
  3400. basStr := c.GetBasBaseInfo()
  3401. if len(basStr) == 0 {
  3402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3403. return
  3404. }
  3405. fmt.Println(basStr)
  3406. bas := strings.Split(basStr, "|")
  3407. basNumber := bas[1]
  3408. fmt.Println(basNumber)
  3409. card_sn := bas[3]
  3410. fmt.Println(card_sn)
  3411. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  3412. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3413. var dat map[string]interface{}
  3414. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3415. fmt.Println(dat)
  3416. } else {
  3417. fmt.Println(err)
  3418. }
  3419. userJSONBytes, _ := json.Marshal(dat)
  3420. var res ResultTwo
  3421. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3422. utils.ErrorLog("解析失败:%v", err)
  3423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3424. return
  3425. }
  3426. if res.Infcode == 0 {
  3427. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3428. if err == gorm.ErrRecordNotFound {
  3429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3430. return
  3431. } else if err != nil {
  3432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3433. return
  3434. } else {
  3435. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3436. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3437. infoStr := string(Iinfos)
  3438. idetinfoStr := string(Idetinfos)
  3439. psn := &models.HisPsn{
  3440. PsnNo: res.Output.Baseinfo.PsnNo,
  3441. Age: res.Output.Baseinfo.Age,
  3442. PatientId: patient.ID,
  3443. Certno: res.Output.Baseinfo.Certno,
  3444. Brdy: res.Output.Baseinfo.Brdy,
  3445. Gend: res.Output.Baseinfo.Gend,
  3446. Naty: res.Output.Baseinfo.Naty,
  3447. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3448. PsnName: res.Output.Baseinfo.PsnName,
  3449. Idetinfo: idetinfoStr,
  3450. Insuinfo: infoStr,
  3451. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3452. CardInfo: basStr,
  3453. VerifyNumber: "",
  3454. }
  3455. service.CreateHisPsn(psn)
  3456. c.ServeSuccessJSON(map[string]interface{}{
  3457. "patient": patient,
  3458. "number": basNumber,
  3459. })
  3460. }
  3461. } else {
  3462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3463. return
  3464. }
  3465. }
  3466. func (c *HisApiController) TestGetHnBasBaseInit() {
  3467. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3468. Iinit := DllDef.MustFindProc("Init")
  3469. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3470. //http://10.77.211.236/CSB/hsa-fsi-1303
  3471. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  3472. if ret != 0 {
  3473. fmt.Println("SSCard的报错原因:", err)
  3474. fmt.Println("SSCard的运算结果为:", ret)
  3475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3476. return
  3477. }
  3478. result := int(ret)
  3479. fmt.Println("SSCard的运算结果为1:", result)
  3480. initFlag = 1
  3481. return
  3482. }
  3483. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  3484. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3485. Iinit := DllDef.MustFindProc("Init")
  3486. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3487. //http://10.77.211.236/CSB/hsa-fsi-1303
  3488. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  3489. if ret != 0 {
  3490. fmt.Println("SSCard的报错原因:", err)
  3491. fmt.Println("SSCard的运算结果为:", ret)
  3492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3493. return
  3494. }
  3495. result := int(ret)
  3496. fmt.Println("SSCard的运算结果为1:", result)
  3497. initFlag = 1
  3498. return
  3499. }
  3500. func (c *HisApiController) GetSFZBaseInfo() string {
  3501. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3502. readCard := DllDef.MustFindProc("ReadSFZ")
  3503. if readCard == nil {
  3504. fmt.Println("readcard is nil")
  3505. readCard = DllDef.MustFindProc("ReadSFZ")
  3506. }
  3507. str := make([]byte, 8096)
  3508. str1 := make([]byte, 8096)
  3509. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  3510. fmt.Println(r)
  3511. return Remove0000(string(str))
  3512. }
  3513. func (c *HisApiController) GetEleBaseInfo() string {
  3514. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3515. readCard := DllDef.MustFindProc("GetQRBase")
  3516. fmt.Println(readCard)
  3517. if readCard == nil {
  3518. fmt.Println("readcard is nil")
  3519. readCard = DllDef.MustFindProc("GetQRBase")
  3520. }
  3521. str := make([]byte, 1024)
  3522. str1 := make([]byte, 1024)
  3523. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3524. fmt.Println(ret2)
  3525. fmt.Println(string(str1))
  3526. fmt.Println(string(str))
  3527. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3528. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3529. if ret2 != 0 {
  3530. return ""
  3531. }
  3532. return string(str)
  3533. }
  3534. func GetJxEleBaseInfo(org_id int64) string {
  3535. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3536. readCard := DllDef.MustFindProc("NationEcTrans")
  3537. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3538. if readCard == nil {
  3539. fmt.Println("readcard is nil")
  3540. readCard = DllDef.MustFindProc("NationEcTrans")
  3541. }
  3542. str1 := make([]byte, 1024)
  3543. data := make(map[string]interface{})
  3544. inputData := make(map[string]interface{})
  3545. inputData["orgId"] = miConfig.Code
  3546. inputData["businessType"] = "01101"
  3547. inputData["operatorId"] = "test001"
  3548. inputData["operatorName"] = "cn"
  3549. inputData["officeId"] = "32760"
  3550. inputData["officeName"] = "waike"
  3551. inputData["deviceType"] = ""
  3552. data["data"] = inputData
  3553. data["transType"] = "ec.query"
  3554. data["extra "] = ""
  3555. data["orgId"] = miConfig.Code
  3556. bytesData, _ := json.Marshal(data)
  3557. //bytesData, _ := json.Marshal(data)
  3558. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3559. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3560. fmt.Println(ret2)
  3561. fmt.Println(string(str1))
  3562. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3563. if ret2 != 0 {
  3564. return ""
  3565. }
  3566. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3567. }
  3568. func GetJxEleBaseInitInfo(org_id int64) string {
  3569. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3570. readCard := DllDef.MustFindProc("NationEcTrans")
  3571. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3572. if readCard == nil {
  3573. fmt.Println("readcard is nil")
  3574. readCard = DllDef.MustFindProc("NationEcTrans")
  3575. }
  3576. str1 := make([]byte, 2048)
  3577. data := make(map[string]interface{})
  3578. inputData := make(map[string]interface{})
  3579. inputData["orgId"] = miConfig.Code
  3580. inputData["businessType"] = "01101"
  3581. inputData["operatorId"] = "1"
  3582. inputData["operatorName"] = "huangchuang"
  3583. inputData["officeId"] = "101"
  3584. inputData["officeName"] = "xuetou"
  3585. inputData["deviceType"] = ""
  3586. data["data"] = inputData
  3587. data["transType"] = "ec.query"
  3588. data["orgId"] = miConfig.Code
  3589. bytesData, _ := json.Marshal(data)
  3590. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3591. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3592. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  3593. fmt.Println(ret2)
  3594. fmt.Println(string(str1))
  3595. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3596. if ret2 != 0 {
  3597. return ""
  3598. }
  3599. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  3600. initEleFlag = 1
  3601. }
  3602. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3603. }
  3604. func (c *HisApiController) GetBasBaseInfo() string {
  3605. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3606. readCard := DllDef.MustFindProc("ReadCardBas")
  3607. if readCard == nil {
  3608. fmt.Println("readcard is nil")
  3609. readCard = DllDef.MustFindProc("ReadCardBas")
  3610. }
  3611. str := make([]byte, 1024)
  3612. str1 := make([]byte, 1024)
  3613. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3614. fmt.Println(string(str1))
  3615. fmt.Println(string(str))
  3616. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3617. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3618. if ret2 != 0 {
  3619. return ""
  3620. }
  3621. return string(str)
  3622. }
  3623. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  3624. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  3625. readCard := DllDef.MustFindProc("read_cardinfo")
  3626. if readCard == nil {
  3627. fmt.Println("readcard is nil")
  3628. readCard = DllDef.MustFindProc("read_cardinfo")
  3629. }
  3630. str := make([]byte, 1024) //卡号
  3631. str1 := make([]byte, 1024) //卡识别码
  3632. str2 := make([]byte, 1024) //身份证号
  3633. str3 := make([]byte, 1024) //姓名
  3634. str4 := make([]byte, 1024) //错误信息
  3635. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])), (uintptr)(unsafe.Pointer(&str2[0])), (uintptr)(unsafe.Pointer(&str3[0])), (uintptr)(unsafe.Pointer(&str4[0])))
  3636. fmt.Println(string(str1))
  3637. fmt.Println(string(str))
  3638. fmt.Println(string(str2))
  3639. fmt.Println(string(str3))
  3640. fmt.Println(string(str4))
  3641. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3642. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3643. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  3644. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3645. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  3646. if ret2 != 0 {
  3647. return "", "", "", "", ""
  3648. }
  3649. return string(str), string(str1), string(str2), string(str3), string(str4)
  3650. }
  3651. type CustomFundPay struct {
  3652. FundPayType string `json:"fund_pay_type"`
  3653. FundPayamt float64 `json:"fund_payamt"`
  3654. }
  3655. func (c *HisApiController) GetSettleList() {
  3656. order_id, _ := c.GetInt64("order_id")
  3657. admin_user_id, _ := c.GetInt64("admin_user_id")
  3658. order, _ := service.GetHisOrderByIDTwo(order_id)
  3659. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3660. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3661. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3662. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3663. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3664. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3665. if order.ID == 0 {
  3666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3667. return
  3668. }
  3669. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  3670. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  3671. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  3672. fmt.Println(count)
  3673. var zero string
  3674. number := count + 1
  3675. if number >= 1000 {
  3676. zero = "0000" + strconv.FormatInt(number, 10)
  3677. } else if number >= 10000 {
  3678. zero = "000" + strconv.FormatInt(number, 10)
  3679. } else if number >= 100000 {
  3680. zero = "00" + strconv.FormatInt(number, 10)
  3681. } else if number >= 1000000 {
  3682. zero = "0" + strconv.FormatInt(number, 10)
  3683. } else {
  3684. zero = strconv.FormatInt(number, 10)
  3685. }
  3686. fmt.Println(zero)
  3687. struct4101 := service.Struct4101{
  3688. PsnNo: order.PsnNo,
  3689. MdtrtId: order.MdtrtId,
  3690. SetlId: order.SetlId,
  3691. PsnName: order.PsnName,
  3692. Gend: order.Gend,
  3693. Brdy: his.Brdy,
  3694. Age: his.Age,
  3695. Naty: order.Naty,
  3696. PatnCertType: "01",
  3697. Certno: order.Certno,
  3698. Prfs: "90",
  3699. ConerName: roles[0].UserName,
  3700. PatnRlts: "99",
  3701. ConerAddr: miConfig.OrgName,
  3702. ConerTel: admin.Mobile,
  3703. HiType: order.Insutype,
  3704. Insuplc: miConfig.InsuplcAdmdvs,
  3705. MaindiagFlag: "1",
  3706. BillCode: order.SetlId,
  3707. BillNo: order.SetlId,
  3708. BizSn: order.Number,
  3709. PsnSelfPay: order.PsnPartAmt,
  3710. PsnOwnPay: order.PsnPartAmt,
  3711. AcctPay: order.AcctPay,
  3712. PsnCashpay: order.PsnCashPay,
  3713. HiPaymtd: "1",
  3714. Hsorg: miConfig.InsuplcAdmdvs,
  3715. HsorgOpter: miConfig.InsuplcAdmdvs,
  3716. MedinsFillPsn: curRoles.UserName,
  3717. MedinsFillDept: depart.Name,
  3718. IptMedType: "2",
  3719. }
  3720. struct4101.SetlBegnDate = order.SetlTime
  3721. struct4101.SetlEndDate = order.SetlTime
  3722. time_arr := strings.Split(order.SetlTime, " ")
  3723. struct4101.AdmTime = time_arr[0]
  3724. struct4101.AdmEndTime = time_arr[0]
  3725. var rf []CustomFundPay
  3726. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3727. var tempFunPays []service.CustomStruct
  3728. for _, item := range rf {
  3729. var tempFunPay service.CustomStruct
  3730. tempFunPay.FundPayamt = item.FundPayamt
  3731. tempFunPay.FundPayType = item.FundPayType
  3732. tempFunPays = append(tempFunPays, tempFunPay)
  3733. }
  3734. struct4101.CustomStruct = tempFunPays
  3735. var tempDiaginfos []service.DiaginfoStructTwo
  3736. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3737. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3738. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3739. var config []*models.HisXtDiagnoseConfig
  3740. for _, item := range diagnosis_ids {
  3741. id, _ := strconv.ParseInt(item, 10, 64)
  3742. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3743. config = append(config, &diagnosisConfig)
  3744. }
  3745. for index, item := range config {
  3746. if index == 0 {
  3747. var tempDiaginfo service.DiaginfoStructTwo
  3748. tempDiaginfo.DiagCode = item.CountryCode
  3749. tempDiaginfo.DiagName = item.CountryContentName
  3750. tempDiaginfo.DiagType = "1"
  3751. tempDiaginfo.MaindiagFlag = "1"
  3752. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3753. } else {
  3754. var tempDiaginfo service.DiaginfoStructTwo
  3755. tempDiaginfo.DiagCode = item.CountryCode
  3756. tempDiaginfo.DiagName = item.CountryContentName
  3757. tempDiaginfo.DiagType = "2"
  3758. tempDiaginfo.MaindiagFlag = "0"
  3759. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3760. }
  3761. }
  3762. struct4101.Diseinfo = tempDiaginfos
  3763. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3764. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3765. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3766. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  3767. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  3768. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3769. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3770. var iteminfo service.IteminfoStruct
  3771. var bedCostTotal float64 = 0 //床位总费
  3772. var bedCostSelfTotal float64 = 0 //床位自费
  3773. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3774. var operationCostTotal float64 = 0 //手术费
  3775. var operationCostSelfTotal float64 = 0 //手术费
  3776. var operationCostPartSelfTotal float64 = 0 //手术费
  3777. var otherCostTotal float64 = 0 //其他费用
  3778. var otherCostSelfTotal float64 = 0 //其他费用
  3779. var otherCostPartSelfTotal float64 = 0 //其他费用
  3780. var materialCostTotal float64 = 0 //材料费
  3781. var materialCostSelfTotal float64 = 0 //材料费
  3782. var materialCostPartSelfTotal float64 = 0 //材料费
  3783. var westernMedicineCostTotal float64 = 0 //西药费
  3784. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3785. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3786. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3787. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3788. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3789. var checkCostTotal float64 = 0 //检查费
  3790. var checkCostSelfTotal float64 = 0 //检查费
  3791. var checkCostPartSelfTotal float64 = 0 //检查费
  3792. var laboratoryCostTotal float64 = 0 //化验费
  3793. var laboratoryCostSelfTotal float64 = 0 //化验费
  3794. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3795. var treatCostTotal float64 = 0 //治疗费用
  3796. var treatCostSelfTotal float64 = 0 //治疗费用
  3797. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3798. decimal.DivisionPrecision = 2
  3799. var bed_fulamt_ownpay_amt float64 = 0
  3800. var operation_fulamt_ownpay_amt float64 = 0
  3801. var other_fulamt_ownpay_amt float64 = 0
  3802. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3803. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3804. var check_fulamt_ownpay_amt float64 = 0
  3805. var material_fulamt_ownpay_amt float64 = 0
  3806. var laboratory_fulamt_ownpay_amt float64 = 0
  3807. var treat_fulamt_ownpay_amt float64 = 0
  3808. var bed_claa_sunmfee float64 = 0
  3809. var bed_clab_amt float64 = 0
  3810. var bed_other_amt float64 = 0
  3811. var operation_claa_sunmfee float64 = 0
  3812. var operation_clab_amt float64 = 0
  3813. var operation_other_amt float64 = 0
  3814. var other_claa_sunmfee float64 = 0
  3815. var other_clab_amt float64 = 0
  3816. var other_other_amt float64 = 0
  3817. var westernMedicine_claa_sunmfee float64 = 0
  3818. var westernMedicine_clab_amt float64 = 0
  3819. var westernMedicine_other_amt float64 = 0
  3820. var chineseTraditional_claa_sunmfee float64 = 0
  3821. var chineseTraditional_clab_amt float64 = 0
  3822. var chineseTraditional_other_amt float64 = 0
  3823. var check_claa_sunmfee float64 = 0
  3824. var check_clab_amt float64 = 0
  3825. var check_other_amt float64 = 0
  3826. var material_claa_sunmfee float64 = 0
  3827. var material_clab_amt float64 = 0
  3828. var material_other_amt float64 = 0
  3829. var laboratory_claa_sunmfee float64 = 0
  3830. var laboratory_clab_amt float64 = 0
  3831. var laboratory_other_amt float64 = 0
  3832. var treat_claa_sunmfee float64 = 0
  3833. var treat_clab_amt float64 = 0
  3834. var treat_other_amt float64 = 0
  3835. for _, item := range order.HisOrderInfo {
  3836. if item.MedChrgitmType == "01" { //床位费
  3837. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3838. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3839. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3840. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3841. if item.ChrgitmLv == "1" {
  3842. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3843. }
  3844. if item.ChrgitmLv == "2" {
  3845. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3846. }
  3847. if item.ChrgitmLv == "3" {
  3848. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3849. }
  3850. }
  3851. if item.MedChrgitmType == "03" { //检查费
  3852. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3853. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3854. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3855. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3856. if item.ChrgitmLv == "1" {
  3857. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3858. }
  3859. if item.ChrgitmLv == "2" {
  3860. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3861. }
  3862. if item.ChrgitmLv == "3" {
  3863. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3864. }
  3865. }
  3866. if item.MedChrgitmType == "04" { //化验费
  3867. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3868. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3869. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3870. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3871. if item.ChrgitmLv == "1" {
  3872. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3873. }
  3874. if item.ChrgitmLv == "2" {
  3875. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3876. }
  3877. if item.ChrgitmLv == "3" {
  3878. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3879. }
  3880. }
  3881. if item.MedChrgitmType == "05" { //治疗费
  3882. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3883. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3884. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3885. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3886. if item.ChrgitmLv == "1" {
  3887. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3888. }
  3889. if item.ChrgitmLv == "2" {
  3890. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3891. }
  3892. if item.ChrgitmLv == "3" {
  3893. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3894. }
  3895. }
  3896. if item.MedChrgitmType == "06" { //手术费
  3897. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3898. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3899. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3900. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3901. if item.ChrgitmLv == "1" {
  3902. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3903. }
  3904. if item.ChrgitmLv == "2" {
  3905. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3906. }
  3907. if item.ChrgitmLv == "3" {
  3908. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3909. }
  3910. }
  3911. if item.MedChrgitmType == "08" { //材料费
  3912. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3913. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3914. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3915. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3916. if item.ChrgitmLv == "1" {
  3917. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3918. }
  3919. if item.ChrgitmLv == "2" {
  3920. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3921. }
  3922. if item.ChrgitmLv == "3" {
  3923. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3924. }
  3925. }
  3926. if item.MedChrgitmType == "09" { //西药费
  3927. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3928. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3929. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3930. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3931. if item.ChrgitmLv == "1" {
  3932. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3933. }
  3934. if item.ChrgitmLv == "2" {
  3935. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3936. }
  3937. if item.ChrgitmLv == "3" {
  3938. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3939. }
  3940. }
  3941. if item.MedChrgitmType == "11" { //中成费
  3942. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3943. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3944. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3945. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3946. if item.ChrgitmLv == "1" {
  3947. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3948. }
  3949. if item.ChrgitmLv == "2" {
  3950. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3951. }
  3952. if item.ChrgitmLv == "3" {
  3953. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3954. }
  3955. }
  3956. if item.MedChrgitmType == "14" { //其他费
  3957. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3958. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3959. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3960. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3961. if item.ChrgitmLv == "1" {
  3962. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3963. }
  3964. if item.ChrgitmLv == "2" {
  3965. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3966. }
  3967. if item.ChrgitmLv == "3" {
  3968. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3969. }
  3970. }
  3971. }
  3972. var iteminfoStructs []service.IteminfoStruct
  3973. if bedCostTotal != 0 {
  3974. iteminfo.MedChrgitm = "01"
  3975. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3976. iteminfo.Amt = bedCostTotal
  3977. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3978. iteminfo.ClabAmt = bed_clab_amt
  3979. iteminfo.OthAmt = bed_other_amt
  3980. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3981. }
  3982. if checkCostTotal != 0 {
  3983. iteminfo.MedChrgitm = "03"
  3984. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3985. iteminfo.Amt = checkCostTotal
  3986. iteminfo.ClaaSumfee = check_claa_sunmfee
  3987. iteminfo.ClabAmt = check_clab_amt
  3988. iteminfo.OthAmt = check_other_amt
  3989. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3990. }
  3991. if laboratoryCostTotal != 0 {
  3992. iteminfo.MedChrgitm = "04"
  3993. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3994. iteminfo.Amt = laboratoryCostTotal
  3995. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3996. iteminfo.ClabAmt = laboratory_clab_amt
  3997. iteminfo.OthAmt = laboratory_other_amt
  3998. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3999. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4000. }
  4001. if treatCostTotal != 0 {
  4002. iteminfo.MedChrgitm = "05"
  4003. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4004. iteminfo.Amt = treatCostTotal
  4005. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4006. iteminfo.ClabAmt = treat_clab_amt
  4007. iteminfo.OthAmt = treat_other_amt
  4008. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4009. //(struct4101.IteminfoStruct, iteminfo)
  4010. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4011. }
  4012. if operationCostTotal != 0 {
  4013. iteminfo.MedChrgitm = "06"
  4014. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4015. iteminfo.Amt = operationCostTotal
  4016. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4017. iteminfo.ClabAmt = operation_clab_amt
  4018. iteminfo.OthAmt = operation_other_amt
  4019. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4020. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4021. }
  4022. if materialCostTotal != 0 {
  4023. iteminfo.MedChrgitm = "08"
  4024. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4025. iteminfo.Amt = materialCostTotal
  4026. iteminfo.ClaaSumfee = material_claa_sunmfee
  4027. iteminfo.ClabAmt = material_clab_amt
  4028. iteminfo.OthAmt = material_other_amt
  4029. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4030. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4031. }
  4032. if westernMedicineCostTotal != 0 {
  4033. iteminfo.MedChrgitm = "09"
  4034. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4035. iteminfo.Amt = westernMedicineCostTotal
  4036. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4037. iteminfo.ClabAmt = westernMedicine_clab_amt
  4038. iteminfo.OthAmt = westernMedicine_other_amt
  4039. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4040. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4041. }
  4042. if chineseTraditionalMedicineCostTotal != 0 {
  4043. iteminfo.MedChrgitm = "11"
  4044. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4045. iteminfo.Amt = westernMedicineCostTotal
  4046. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4047. iteminfo.ClabAmt = westernMedicine_clab_amt
  4048. iteminfo.OthAmt = westernMedicine_other_amt
  4049. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4050. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4051. }
  4052. if otherCostTotal != 0 {
  4053. iteminfo.MedChrgitm = "14"
  4054. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4055. iteminfo.Amt = otherCostTotal
  4056. iteminfo.ClaaSumfee = other_claa_sunmfee
  4057. iteminfo.ClabAmt = other_clab_amt
  4058. iteminfo.OthAmt = other_other_amt
  4059. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4060. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4061. }
  4062. struct4101.IteminfoStruct = iteminfoStructs
  4063. struct4101.Ntly = "中国"
  4064. struct4101.AdmCaty = "A03.06"
  4065. var res ResultSeventeen
  4066. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4067. struct4101.BillCode = order.Number
  4068. struct4101.BillNo = order.SetlId
  4069. var resOther ResultSeventeenOther
  4070. var pp models.PublicParams
  4071. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4072. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4073. pp.FixmedinsName = miConfig.OrgName
  4074. pp.FixmedinsCode = miConfig.Code
  4075. pp.RequestUrl = miConfig.Url
  4076. pp.Cainfo = miConfig.Cainfo
  4077. pp.SecretKey = miConfig.SecretKey
  4078. pp.AccessKey = miConfig.AccessKey
  4079. pp.OpterName = curRoles.UserName
  4080. client := &http.Client{}
  4081. var req *http.Request
  4082. data := make(map[string]interface{})
  4083. data["struct4101"] = struct4101
  4084. data["pp"] = pp
  4085. bytesData, _ := json.Marshal(data)
  4086. if miConfig.MdtrtareaAdmvs == "320921" {
  4087. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4088. } else {
  4089. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4090. }
  4091. resp, _ := client.Do(req)
  4092. defer resp.Body.Close()
  4093. body, ioErr := ioutil.ReadAll(resp.Body)
  4094. if ioErr != nil {
  4095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4097. return
  4098. }
  4099. var respJSON map[string]interface{}
  4100. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4103. return
  4104. }
  4105. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4106. userJSONBytes, _ := json.Marshal(respJSON)
  4107. fmt.Println("log")
  4108. fmt.Println(string(userJSONBytes))
  4109. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4110. utils.ErrorLog("解析失败:%v", err)
  4111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4112. return
  4113. }
  4114. res.InfRefmsgid = resOther.InfRefmsgid
  4115. res.Output = resOther.Output
  4116. res.ErrMsg = resOther.ErrMsg
  4117. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4118. res.Infcode = infocode
  4119. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4120. var pp models.PublicParams
  4121. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4122. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4123. pp.FixmedinsName = miConfig.OrgName
  4124. pp.FixmedinsCode = miConfig.Code
  4125. pp.RequestUrl = miConfig.Url
  4126. pp.Cainfo = miConfig.Cainfo
  4127. pp.SecretKey = miConfig.SecretKey
  4128. pp.AccessKey = miConfig.AccessKey
  4129. pp.OpterName = curRoles.UserName
  4130. result, _ := service.Jxyb4101(struct4101, pp)
  4131. var dat map[string]interface{}
  4132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4133. fmt.Println(dat)
  4134. } else {
  4135. fmt.Println(err)
  4136. }
  4137. userJSONBytes, _ := json.Marshal(dat)
  4138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4139. utils.ErrorLog("解析失败:%v", err)
  4140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4141. return
  4142. }
  4143. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4144. var pp models.PublicParams
  4145. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4146. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4147. pp.FixmedinsName = miConfig.OrgName
  4148. pp.FixmedinsCode = miConfig.Code
  4149. pp.RequestUrl = miConfig.Url
  4150. pp.Cainfo = miConfig.Cainfo
  4151. pp.SecretKey = miConfig.SecretKey
  4152. pp.AccessKey = miConfig.AccessKey
  4153. pp.OpterName = curRoles.UserName
  4154. result, _ := service.Hnyb4101(struct4101, pp)
  4155. var dat map[string]interface{}
  4156. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4157. fmt.Println(dat)
  4158. } else {
  4159. fmt.Println(err)
  4160. }
  4161. userJSONBytes, _ := json.Marshal(dat)
  4162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4163. utils.ErrorLog("解析失败:%v", err)
  4164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4165. return
  4166. }
  4167. } else {
  4168. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4169. var dat map[string]interface{}
  4170. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4171. fmt.Println(dat)
  4172. } else {
  4173. fmt.Println(err)
  4174. }
  4175. userJSONBytes, _ := json.Marshal(dat)
  4176. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4177. utils.ErrorLog("解析失败:%v", err)
  4178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4179. return
  4180. }
  4181. }
  4182. if res.Infcode != 0 {
  4183. c.ServeSuccessJSON(map[string]interface{}{
  4184. "failed_code": -10,
  4185. "msg": res.ErrMsg,
  4186. })
  4187. return
  4188. } else {
  4189. order.FaPiaoNumber = zero
  4190. order.FaPiaoCode = last_order.FaPiaoCode
  4191. service.UpdateOrder(order)
  4192. hisFundSettleListResult := &models.HisFundSettleListResult{
  4193. Number: res.Output.SetlListId,
  4194. Status: 1,
  4195. Ctime: time.Now().Unix(),
  4196. Mtime: time.Now().Unix(),
  4197. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4198. IsUpload: 1,
  4199. OrderId: order_id,
  4200. }
  4201. service.CreateUploadRecord(hisFundSettleListResult)
  4202. c.ServeSuccessJSON(map[string]interface{}{
  4203. "msg": "上传成功",
  4204. "result": hisFundSettleListResult,
  4205. })
  4206. return
  4207. }
  4208. }
  4209. func (c *HisApiController) GetSettleListHospital() {
  4210. order_id, _ := c.GetInt64("order_id")
  4211. admin_user_id, _ := c.GetInt64("admin_user_id")
  4212. order, _ := service.GetHisOrderByIDTwo(order_id)
  4213. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4214. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4215. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4216. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4217. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4218. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4219. if order.ID == 0 {
  4220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4221. return
  4222. }
  4223. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  4224. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  4225. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  4226. fmt.Println(count)
  4227. var zero string
  4228. number := count + 1
  4229. if number >= 1000 {
  4230. zero = "0000" + strconv.FormatInt(number, 10)
  4231. } else if number >= 10000 {
  4232. zero = "000" + strconv.FormatInt(number, 10)
  4233. } else if number >= 100000 {
  4234. zero = "00" + strconv.FormatInt(number, 10)
  4235. } else if number >= 1000000 {
  4236. zero = "0" + strconv.FormatInt(number, 10)
  4237. } else {
  4238. zero = strconv.FormatInt(number, 10)
  4239. }
  4240. fmt.Println(zero)
  4241. struct4101 := service.Struct4101{
  4242. PsnNo: order.PsnNo,
  4243. MdtrtId: order.MdtrtId,
  4244. SetlId: order.SetlId,
  4245. PsnName: order.PsnName,
  4246. Gend: order.Gend,
  4247. Brdy: his.Brdy,
  4248. Age: int64(order.Age),
  4249. Naty: order.Naty,
  4250. PatnCertType: "01",
  4251. Certno: order.Certno,
  4252. Prfs: "90",
  4253. ConerName: roles[0].UserName,
  4254. PatnRlts: "99",
  4255. ConerAddr: miConfig.OrgName,
  4256. ConerTel: admin.Mobile,
  4257. HiType: order.Insutype,
  4258. Insuplc: miConfig.InsuplcAdmdvs,
  4259. MaindiagFlag: "1",
  4260. BillCode: order.SetlId,
  4261. BillNo: order.SetlId,
  4262. BizSn: order.Number,
  4263. PsnSelfPay: order.PsnPartAmt,
  4264. PsnOwnPay: order.PsnPartAmt,
  4265. AcctPay: order.AcctPay,
  4266. PsnCashpay: order.PsnCashPay,
  4267. HiPaymtd: "1",
  4268. Hsorg: miConfig.InsuplcAdmdvs,
  4269. HsorgOpter: miConfig.InsuplcAdmdvs,
  4270. MedinsFillPsn: curRoles.UserName,
  4271. MedinsFillDept: depart.Name,
  4272. IptMedType: "2",
  4273. AdmTime: his.InHosptialTime,
  4274. AdmEndTime: his.OutHosptialTime,
  4275. }
  4276. struct4101.SetlBegnDate = order.SetlTime
  4277. struct4101.SetlEndDate = order.SetlTime
  4278. var rf []CustomFundPay
  4279. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4280. var tempFunPays []service.CustomStruct
  4281. for _, item := range rf {
  4282. var tempFunPay service.CustomStruct
  4283. tempFunPay.FundPayamt = item.FundPayamt
  4284. tempFunPay.FundPayType = item.FundPayType
  4285. tempFunPays = append(tempFunPays, tempFunPay)
  4286. }
  4287. struct4101.CustomStruct = tempFunPays
  4288. var tempDiaginfos []service.DiaginfoStructTwo
  4289. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4290. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4291. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4292. var config []*models.HisXtDiagnoseConfig
  4293. for _, item := range diagnosis_ids {
  4294. id, _ := strconv.ParseInt(item, 10, 64)
  4295. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4296. config = append(config, &diagnosisConfig)
  4297. }
  4298. for index, item := range config {
  4299. if index == 0 {
  4300. var tempDiaginfo service.DiaginfoStructTwo
  4301. tempDiaginfo.DiagCode = item.CountryCode
  4302. tempDiaginfo.DiagName = item.CountryContentName
  4303. tempDiaginfo.DiagType = "1"
  4304. tempDiaginfo.MaindiagFlag = "1"
  4305. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4306. } else {
  4307. var tempDiaginfo service.DiaginfoStructTwo
  4308. tempDiaginfo.DiagCode = item.CountryCode
  4309. tempDiaginfo.DiagName = item.CountryContentName
  4310. tempDiaginfo.DiagType = "2"
  4311. tempDiaginfo.MaindiagFlag = "0"
  4312. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4313. }
  4314. }
  4315. struct4101.Diseinfo = tempDiaginfos
  4316. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4317. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4318. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4319. tempOpspdiseinfo2.OprnOprtCode = ""
  4320. tempOpspdiseinfo2.OprnOprtName = ""
  4321. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4322. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4323. var iteminfo service.IteminfoStruct
  4324. var bedCostTotal float64 = 0 //床位总费
  4325. var bedCostSelfTotal float64 = 0 //床位自费
  4326. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4327. var operationCostTotal float64 = 0 //手术费
  4328. var operationCostSelfTotal float64 = 0 //手术费
  4329. var operationCostPartSelfTotal float64 = 0 //手术费
  4330. var otherCostTotal float64 = 0 //其他费用
  4331. var otherCostSelfTotal float64 = 0 //其他费用
  4332. var otherCostPartSelfTotal float64 = 0 //其他费用
  4333. var materialCostTotal float64 = 0 //材料费
  4334. var materialCostSelfTotal float64 = 0 //材料费
  4335. var materialCostPartSelfTotal float64 = 0 //材料费
  4336. var westernMedicineCostTotal float64 = 0 //西药费
  4337. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4338. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4339. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4340. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4341. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4342. var checkCostTotal float64 = 0 //检查费
  4343. var checkCostSelfTotal float64 = 0 //检查费
  4344. var checkCostPartSelfTotal float64 = 0 //检查费
  4345. var laboratoryCostTotal float64 = 0 //化验费
  4346. var laboratoryCostSelfTotal float64 = 0 //化验费
  4347. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4348. var treatCostTotal float64 = 0 //治疗费用
  4349. var treatCostSelfTotal float64 = 0 //治疗费用
  4350. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4351. decimal.DivisionPrecision = 2
  4352. var bed_fulamt_ownpay_amt float64 = 0
  4353. var operation_fulamt_ownpay_amt float64 = 0
  4354. var other_fulamt_ownpay_amt float64 = 0
  4355. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4356. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4357. var check_fulamt_ownpay_amt float64 = 0
  4358. var material_fulamt_ownpay_amt float64 = 0
  4359. var laboratory_fulamt_ownpay_amt float64 = 0
  4360. var treat_fulamt_ownpay_amt float64 = 0
  4361. var bed_claa_sunmfee float64 = 0
  4362. var bed_clab_amt float64 = 0
  4363. var bed_other_amt float64 = 0
  4364. var operation_claa_sunmfee float64 = 0
  4365. var operation_clab_amt float64 = 0
  4366. var operation_other_amt float64 = 0
  4367. var other_claa_sunmfee float64 = 0
  4368. var other_clab_amt float64 = 0
  4369. var other_other_amt float64 = 0
  4370. var westernMedicine_claa_sunmfee float64 = 0
  4371. var westernMedicine_clab_amt float64 = 0
  4372. var westernMedicine_other_amt float64 = 0
  4373. var chineseTraditional_claa_sunmfee float64 = 0
  4374. var chineseTraditional_clab_amt float64 = 0
  4375. var chineseTraditional_other_amt float64 = 0
  4376. var check_claa_sunmfee float64 = 0
  4377. var check_clab_amt float64 = 0
  4378. var check_other_amt float64 = 0
  4379. var material_claa_sunmfee float64 = 0
  4380. var material_clab_amt float64 = 0
  4381. var material_other_amt float64 = 0
  4382. var laboratory_claa_sunmfee float64 = 0
  4383. var laboratory_clab_amt float64 = 0
  4384. var laboratory_other_amt float64 = 0
  4385. var treat_claa_sunmfee float64 = 0
  4386. var treat_clab_amt float64 = 0
  4387. var treat_other_amt float64 = 0
  4388. for _, item := range order.HisOrderInfo {
  4389. if item.MedChrgitmType == "01" { //床位费
  4390. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4391. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4392. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4393. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4394. if item.ChrgitmLv == "1" {
  4395. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4396. }
  4397. if item.ChrgitmLv == "2" {
  4398. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4399. }
  4400. if item.ChrgitmLv == "3" {
  4401. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4402. }
  4403. }
  4404. if item.MedChrgitmType == "03" { //检查费
  4405. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4406. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4407. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4408. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4409. if item.ChrgitmLv == "1" {
  4410. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4411. }
  4412. if item.ChrgitmLv == "2" {
  4413. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4414. }
  4415. if item.ChrgitmLv == "3" {
  4416. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4417. }
  4418. }
  4419. if item.MedChrgitmType == "04" { //化验费
  4420. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4421. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4422. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4423. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4424. if item.ChrgitmLv == "1" {
  4425. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4426. }
  4427. if item.ChrgitmLv == "2" {
  4428. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4429. }
  4430. if item.ChrgitmLv == "3" {
  4431. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4432. }
  4433. }
  4434. if item.MedChrgitmType == "05" { //治疗费
  4435. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4436. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4437. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4438. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4439. if item.ChrgitmLv == "1" {
  4440. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4441. }
  4442. if item.ChrgitmLv == "2" {
  4443. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4444. }
  4445. if item.ChrgitmLv == "3" {
  4446. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4447. }
  4448. }
  4449. if item.MedChrgitmType == "06" { //手术费
  4450. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4451. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4452. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4453. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4454. if item.ChrgitmLv == "1" {
  4455. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4456. }
  4457. if item.ChrgitmLv == "2" {
  4458. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4459. }
  4460. if item.ChrgitmLv == "3" {
  4461. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4462. }
  4463. }
  4464. if item.MedChrgitmType == "08" { //材料费
  4465. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4466. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4467. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4468. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4469. if item.ChrgitmLv == "1" {
  4470. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4471. }
  4472. if item.ChrgitmLv == "2" {
  4473. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4474. }
  4475. if item.ChrgitmLv == "3" {
  4476. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4477. }
  4478. }
  4479. if item.MedChrgitmType == "09" { //西药费
  4480. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4481. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4482. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4483. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4484. if item.ChrgitmLv == "1" {
  4485. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4486. }
  4487. if item.ChrgitmLv == "2" {
  4488. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4489. }
  4490. if item.ChrgitmLv == "3" {
  4491. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4492. }
  4493. }
  4494. if item.MedChrgitmType == "11" { //中成费
  4495. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4496. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4497. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4498. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4499. if item.ChrgitmLv == "1" {
  4500. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4501. }
  4502. if item.ChrgitmLv == "2" {
  4503. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4504. }
  4505. if item.ChrgitmLv == "3" {
  4506. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4507. }
  4508. }
  4509. if item.MedChrgitmType == "14" { //其他费
  4510. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4511. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4512. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4513. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4514. if item.ChrgitmLv == "1" {
  4515. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4516. }
  4517. if item.ChrgitmLv == "2" {
  4518. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4519. }
  4520. if item.ChrgitmLv == "3" {
  4521. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4522. }
  4523. }
  4524. }
  4525. var iteminfoStructs []service.IteminfoStruct
  4526. if bedCostTotal != 0 {
  4527. iteminfo.MedChrgitm = "01"
  4528. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4529. iteminfo.Amt = bedCostTotal
  4530. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4531. iteminfo.ClabAmt = bed_clab_amt
  4532. iteminfo.OthAmt = bed_other_amt
  4533. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4534. }
  4535. if checkCostTotal != 0 {
  4536. iteminfo.MedChrgitm = "03"
  4537. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4538. iteminfo.Amt = checkCostTotal
  4539. iteminfo.ClaaSumfee = check_claa_sunmfee
  4540. iteminfo.ClabAmt = check_clab_amt
  4541. iteminfo.OthAmt = check_other_amt
  4542. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4543. }
  4544. if laboratoryCostTotal != 0 {
  4545. iteminfo.MedChrgitm = "04"
  4546. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4547. iteminfo.Amt = laboratoryCostTotal
  4548. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4549. iteminfo.ClabAmt = laboratory_clab_amt
  4550. iteminfo.OthAmt = laboratory_other_amt
  4551. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4552. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4553. }
  4554. if treatCostTotal != 0 {
  4555. iteminfo.MedChrgitm = "05"
  4556. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4557. iteminfo.Amt = treatCostTotal
  4558. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4559. iteminfo.ClabAmt = treat_clab_amt
  4560. iteminfo.OthAmt = treat_other_amt
  4561. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4562. //(struct4101.IteminfoStruct, iteminfo)
  4563. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4564. }
  4565. if operationCostTotal != 0 {
  4566. iteminfo.MedChrgitm = "06"
  4567. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4568. iteminfo.Amt = operationCostTotal
  4569. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4570. iteminfo.ClabAmt = operation_clab_amt
  4571. iteminfo.OthAmt = operation_other_amt
  4572. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4573. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4574. }
  4575. if materialCostTotal != 0 {
  4576. iteminfo.MedChrgitm = "08"
  4577. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4578. iteminfo.Amt = materialCostTotal
  4579. iteminfo.ClaaSumfee = material_claa_sunmfee
  4580. iteminfo.ClabAmt = material_clab_amt
  4581. iteminfo.OthAmt = material_other_amt
  4582. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4583. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4584. }
  4585. if westernMedicineCostTotal != 0 {
  4586. iteminfo.MedChrgitm = "09"
  4587. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4588. iteminfo.Amt = westernMedicineCostTotal
  4589. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4590. iteminfo.ClabAmt = westernMedicine_clab_amt
  4591. iteminfo.OthAmt = westernMedicine_other_amt
  4592. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4593. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4594. }
  4595. if chineseTraditionalMedicineCostTotal != 0 {
  4596. iteminfo.MedChrgitm = "11"
  4597. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4598. iteminfo.Amt = westernMedicineCostTotal
  4599. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4600. iteminfo.ClabAmt = westernMedicine_clab_amt
  4601. iteminfo.OthAmt = westernMedicine_other_amt
  4602. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4603. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4604. }
  4605. if otherCostTotal != 0 {
  4606. iteminfo.MedChrgitm = "14"
  4607. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4608. iteminfo.Amt = otherCostTotal
  4609. iteminfo.ClaaSumfee = other_claa_sunmfee
  4610. iteminfo.ClabAmt = other_clab_amt
  4611. iteminfo.OthAmt = other_other_amt
  4612. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4613. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4614. }
  4615. struct4101.IteminfoStruct = iteminfoStructs
  4616. struct4101.Ntly = "中国"
  4617. struct4101.AdmCaty = "A03.06"
  4618. var resOther ResultSeventeenOther
  4619. var res ResultSeventeen
  4620. if miConfig.MdtrtareaAdmvs == "150499" {
  4621. var pp models.PublicParams
  4622. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4623. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4624. pp.FixmedinsName = miConfig.OrgName
  4625. pp.FixmedinsCode = miConfig.Code
  4626. pp.RequestUrl = miConfig.Url
  4627. pp.Cainfo = miConfig.Cainfo
  4628. pp.SecretKey = miConfig.SecretKey
  4629. pp.AccessKey = miConfig.AccessKey
  4630. pp.OpterName = curRoles.UserName
  4631. client := &http.Client{}
  4632. var req *http.Request
  4633. data := make(map[string]interface{})
  4634. data["struct4101"] = struct4101
  4635. data["pp"] = pp
  4636. bytesData, _ := json.Marshal(data)
  4637. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  4638. resp, _ := client.Do(req)
  4639. defer resp.Body.Close()
  4640. body, ioErr := ioutil.ReadAll(resp.Body)
  4641. if ioErr != nil {
  4642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4644. return
  4645. }
  4646. var respJSON map[string]interface{}
  4647. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4650. return
  4651. }
  4652. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4653. userJSONBytes, _ := json.Marshal(respJSON)
  4654. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4655. utils.ErrorLog("解析失败:%v", err)
  4656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4657. return
  4658. }
  4659. res.InfRefmsgid = resOther.InfRefmsgid
  4660. res.Output = resOther.Output
  4661. res.ErrMsg = resOther.ErrMsg
  4662. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4663. res.Infcode = infocode
  4664. } else {
  4665. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4666. var dat map[string]interface{}
  4667. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4668. fmt.Println(dat)
  4669. } else {
  4670. fmt.Println(err)
  4671. }
  4672. userJSONBytes, _ := json.Marshal(dat)
  4673. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4674. utils.ErrorLog("解析失败:%v", err)
  4675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4676. return
  4677. }
  4678. }
  4679. if res.Infcode != 0 {
  4680. c.ServeSuccessJSON(map[string]interface{}{
  4681. "failed_code": -10,
  4682. "msg": res.ErrMsg,
  4683. })
  4684. return
  4685. } else {
  4686. if miConfig.MdtrtareaAdmvs != "150499" {
  4687. order.FaPiaoNumber = zero
  4688. order.FaPiaoCode = last_order.FaPiaoCode
  4689. service.UpdateOrder(order)
  4690. }
  4691. hisFundSettleListResult := &models.HisFundSettleListResult{
  4692. Number: res.Output.SetlListId,
  4693. Status: 1,
  4694. Ctime: time.Now().Unix(),
  4695. Mtime: time.Now().Unix(),
  4696. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4697. IsUpload: 1,
  4698. OrderId: order_id,
  4699. }
  4700. service.CreateUploadRecord(hisFundSettleListResult)
  4701. c.ServeSuccessJSON(map[string]interface{}{
  4702. "msg": "上传成功",
  4703. "result": hisFundSettleListResult,
  4704. })
  4705. return
  4706. }
  4707. }
  4708. func (c *HisApiController) GetBatchSettleList() {
  4709. orders, _ := service.GetAllHisOrder(10106)
  4710. for _, item := range orders {
  4711. order_id := item.ID
  4712. order, _ := service.GetHisOrderByIDTwo(order_id)
  4713. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4714. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4715. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4716. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  4717. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4718. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4719. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4720. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4721. if order.ID == 0 {
  4722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4723. return
  4724. }
  4725. if his.BalanceAccountsType == 2 {
  4726. continue
  4727. }
  4728. struct4101 := service.Struct4101{
  4729. PsnNo: order.PsnNo,
  4730. MdtrtId: order.MdtrtId,
  4731. SetlId: order.SetlId,
  4732. PsnName: order.PsnName,
  4733. Gend: order.Gend,
  4734. Brdy: his.Brdy,
  4735. Age: his.Age,
  4736. Naty: order.Naty,
  4737. PatnCertType: "01",
  4738. Certno: order.Certno,
  4739. Prfs: "90",
  4740. ConerName: roles[0].UserName,
  4741. PatnRlts: "99",
  4742. ConerAddr: miConfig.OrgName,
  4743. ConerTel: admin.Mobile,
  4744. HiType: order.Insutype,
  4745. Insuplc: his.InsuplcAdmdvs,
  4746. MaindiagFlag: "1",
  4747. BillCode: order.SetlId,
  4748. BillNo: order.SetlId,
  4749. BizSn: order.Number,
  4750. PsnSelfPay: order.PsnPartAmt,
  4751. PsnOwnPay: order.PsnPartAmt,
  4752. AcctPay: order.AcctPay,
  4753. PsnCashpay: order.PsnCashPay,
  4754. HiPaymtd: "1",
  4755. Hsorg: his.InsuplcAdmdvs,
  4756. HsorgOpter: his.InsuplcAdmdvs,
  4757. MedinsFillPsn: curRoles.UserName,
  4758. MedinsFillDept: depart.Name,
  4759. IptMedType: "2",
  4760. }
  4761. struct4101.SetlBegnDate = order.SetlTime
  4762. struct4101.SetlEndDate = order.SetlTime
  4763. //if order.SettleType == 1 {
  4764. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  4765. // dateStr := t.Format("2006-01-02")
  4766. // struct4101.SetlBegnDate = dateStr
  4767. // struct4101.SetlEndDate = dateStr
  4768. //} else {
  4769. // t := time.Unix(int64(order.SettleStartTime), 0)
  4770. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  4771. // dateStartStr := t.Format("2006-01-02")
  4772. // dateEndStr := t2.Format("2006-01-02")
  4773. // struct4101.SetlBegnDate = dateStartStr
  4774. // struct4101.SetlEndDate = dateEndStr
  4775. //}
  4776. var rf []CustomFundPay
  4777. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4778. var tempFunPays []service.CustomStruct
  4779. var tempFunPay610100 service.CustomStruct
  4780. for _, item := range rf {
  4781. if item.FundPayType == "610100" {
  4782. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  4783. tempFunPay610100.FundPayType = item.FundPayType
  4784. } else {
  4785. var tempFunPay service.CustomStruct
  4786. tempFunPay.FundPayamt = item.FundPayamt
  4787. tempFunPay.FundPayType = item.FundPayType
  4788. tempFunPays = append(tempFunPays, tempFunPay)
  4789. }
  4790. }
  4791. tempFunPays = append(tempFunPays, tempFunPay610100)
  4792. struct4101.CustomStruct = tempFunPays
  4793. var tempDiaginfos []service.DiaginfoStructTwo
  4794. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4795. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4796. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4797. var config []*models.HisXtDiagnoseConfig
  4798. for _, item := range diagnosis_ids {
  4799. id, _ := strconv.ParseInt(item, 10, 64)
  4800. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4801. config = append(config, &diagnosisConfig)
  4802. }
  4803. for index, item := range config {
  4804. if index == 0 {
  4805. var tempDiaginfo service.DiaginfoStructTwo
  4806. tempDiaginfo.DiagCode = item.CountryCode
  4807. tempDiaginfo.DiagName = item.CountryContentName
  4808. tempDiaginfo.DiagType = "1"
  4809. tempDiaginfo.MaindiagFlag = "1"
  4810. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4811. } else {
  4812. var tempDiaginfo service.DiaginfoStructTwo
  4813. tempDiaginfo.DiagCode = item.CountryCode
  4814. tempDiaginfo.DiagName = item.CountryContentName
  4815. tempDiaginfo.DiagType = "2"
  4816. tempDiaginfo.MaindiagFlag = "0"
  4817. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4818. }
  4819. }
  4820. struct4101.Diseinfo = tempDiaginfos
  4821. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4822. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4823. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4824. tempOpspdiseinfo2.OprnOprtCode = ""
  4825. tempOpspdiseinfo2.OprnOprtName = ""
  4826. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4827. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4828. var iteminfo service.IteminfoStruct
  4829. var bedCostTotal float64 = 0 //床位总费
  4830. var bedCostSelfTotal float64 = 0 //床位自费
  4831. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4832. var examineCostTotal float64 = 0 //诊查总费
  4833. var examineCostSelfTotal float64 = 0 //诊查自费
  4834. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  4835. var nursingCostTotal float64 = 0 //护理总费
  4836. var nursingCostSelfTotal float64 = 0 //护理自费
  4837. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  4838. var chineseMedicineCostTotal float64 = 0 //中成药
  4839. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  4840. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  4841. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  4842. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  4843. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  4844. var registerCostTotal float64 = 0 //一般诊疗费
  4845. var registerCostSelfTotal float64 = 0 //一般诊疗费
  4846. var registerPartSelfTotal float64 = 0 //一般诊疗费
  4847. var operationCostTotal float64 = 0 //手术费
  4848. var operationCostSelfTotal float64 = 0 //手术费
  4849. var operationCostPartSelfTotal float64 = 0 //手术费
  4850. var otherCostTotal float64 = 0 //其他费用
  4851. var otherCostSelfTotal float64 = 0 //其他费用
  4852. var otherCostPartSelfTotal float64 = 0 //其他费用
  4853. var materialCostTotal float64 = 0 //材料费
  4854. var materialCostSelfTotal float64 = 0 //材料费
  4855. var materialCostPartSelfTotal float64 = 0 //材料费
  4856. var westernMedicineCostTotal float64 = 0 //西药费
  4857. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4858. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4859. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4860. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4861. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4862. var checkCostTotal float64 = 0 //检查费
  4863. var checkCostSelfTotal float64 = 0 //检查费
  4864. var checkCostPartSelfTotal float64 = 0 //检查费
  4865. var laboratoryCostTotal float64 = 0 //化验费
  4866. var laboratoryCostSelfTotal float64 = 0 //化验费
  4867. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4868. var treatCostTotal float64 = 0 //治疗费用
  4869. var treatCostSelfTotal float64 = 0 //治疗费用
  4870. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4871. decimal.DivisionPrecision = 2
  4872. var bed_fulamt_ownpay_amt float64 = 0
  4873. var examine_fulamt_ownpay_amt float64 = 0
  4874. var nursing_fulamt_ownpay_amt float64 = 0
  4875. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  4876. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  4877. var register_fulamt_ownpay_amt float64 = 0
  4878. var operation_fulamt_ownpay_amt float64 = 0
  4879. var other_fulamt_ownpay_amt float64 = 0
  4880. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4881. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4882. var check_fulamt_ownpay_amt float64 = 0
  4883. var material_fulamt_ownpay_amt float64 = 0
  4884. var laboratory_fulamt_ownpay_amt float64 = 0
  4885. var treat_fulamt_ownpay_amt float64 = 0
  4886. var bed_claa_sunmfee float64 = 0
  4887. var bed_clab_amt float64 = 0
  4888. var bed_other_amt float64 = 0
  4889. var examine_claa_sunmfee float64 = 0
  4890. var examine_clab_amt float64 = 0
  4891. var examine_other_amt float64 = 0
  4892. var nursing_claa_sunmfee float64 = 0
  4893. var nursing_clab_amt float64 = 0
  4894. var nursing_other_amt float64 = 0
  4895. var chinese_medicine_claa_sunmfee float64 = 0
  4896. var chinese_medicine_clab_amt float64 = 0
  4897. var chinese_medicine_other_amt float64 = 0
  4898. var commonly_treatment_claa_sunmfee float64 = 0
  4899. var commonly_treatment_clab_amt float64 = 0
  4900. var commonly_treatment_other_amt float64 = 0
  4901. var operation_claa_sunmfee float64 = 0
  4902. var operation_clab_amt float64 = 0
  4903. var operation_other_amt float64 = 0
  4904. var other_claa_sunmfee float64 = 0
  4905. var other_clab_amt float64 = 0
  4906. var other_other_amt float64 = 0
  4907. var westernMedicine_claa_sunmfee float64 = 0
  4908. var westernMedicine_clab_amt float64 = 0
  4909. var westernMedicine_other_amt float64 = 0
  4910. var chineseTraditional_claa_sunmfee float64 = 0
  4911. var chineseTraditional_clab_amt float64 = 0
  4912. var chineseTraditional_other_amt float64 = 0
  4913. var check_claa_sunmfee float64 = 0
  4914. var check_clab_amt float64 = 0
  4915. var check_other_amt float64 = 0
  4916. var material_claa_sunmfee float64 = 0
  4917. var material_clab_amt float64 = 0
  4918. var material_other_amt float64 = 0
  4919. var laboratory_claa_sunmfee float64 = 0
  4920. var laboratory_clab_amt float64 = 0
  4921. var laboratory_other_amt float64 = 0
  4922. var treat_claa_sunmfee float64 = 0
  4923. var treat_clab_amt float64 = 0
  4924. var treat_other_amt float64 = 0
  4925. var register_claa_sunmfee float64 = 0
  4926. var register_clab_amt float64 = 0
  4927. var register_other_amt float64 = 0
  4928. for _, item := range order.HisOrderInfo {
  4929. if item.MedChrgitmType == "01" { //床位费
  4930. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4931. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4932. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4933. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4934. if item.ChrgitmLv == "1" {
  4935. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4936. }
  4937. if item.ChrgitmLv == "2" {
  4938. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4939. }
  4940. if item.ChrgitmLv == "3" {
  4941. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4942. }
  4943. }
  4944. if item.MedChrgitmType == "02" { //诊查
  4945. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4946. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4947. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4948. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4949. if item.ChrgitmLv == "1" {
  4950. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4951. }
  4952. if item.ChrgitmLv == "2" {
  4953. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4954. }
  4955. if item.ChrgitmLv == "3" {
  4956. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4957. }
  4958. }
  4959. if item.MedChrgitmType == "03" { //检查费
  4960. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4961. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4962. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4963. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4964. if item.ChrgitmLv == "1" {
  4965. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4966. }
  4967. if item.ChrgitmLv == "2" {
  4968. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4969. }
  4970. if item.ChrgitmLv == "3" {
  4971. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4972. }
  4973. }
  4974. if item.MedChrgitmType == "04" { //化验费
  4975. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4976. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4977. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4978. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4979. if item.ChrgitmLv == "1" {
  4980. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4981. }
  4982. if item.ChrgitmLv == "2" {
  4983. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4984. }
  4985. if item.ChrgitmLv == "3" {
  4986. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4987. }
  4988. }
  4989. if item.MedChrgitmType == "05" { //治疗费
  4990. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4991. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4992. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4993. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4994. if item.ChrgitmLv == "1" {
  4995. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4996. }
  4997. if item.ChrgitmLv == "2" {
  4998. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4999. }
  5000. if item.ChrgitmLv == "3" {
  5001. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5002. }
  5003. }
  5004. if item.MedChrgitmType == "06" { //手术费
  5005. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5006. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5007. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5008. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5009. if item.ChrgitmLv == "1" {
  5010. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5011. }
  5012. if item.ChrgitmLv == "2" {
  5013. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5014. }
  5015. if item.ChrgitmLv == "3" {
  5016. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5017. }
  5018. }
  5019. if item.MedChrgitmType == "07" { //手术费
  5020. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5021. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5022. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5023. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5024. if item.ChrgitmLv == "1" {
  5025. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5026. }
  5027. if item.ChrgitmLv == "2" {
  5028. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5029. }
  5030. if item.ChrgitmLv == "3" {
  5031. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5032. }
  5033. }
  5034. if item.MedChrgitmType == "08" { //材料费
  5035. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5036. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5037. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5038. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5039. if item.ChrgitmLv == "1" {
  5040. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5041. }
  5042. if item.ChrgitmLv == "2" {
  5043. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5044. }
  5045. if item.ChrgitmLv == "3" {
  5046. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5047. }
  5048. }
  5049. if item.MedChrgitmType == "09" { //西药费
  5050. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5051. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5052. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5053. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5054. if item.ChrgitmLv == "1" {
  5055. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5056. }
  5057. if item.ChrgitmLv == "2" {
  5058. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5059. }
  5060. if item.ChrgitmLv == "3" {
  5061. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5062. }
  5063. }
  5064. if item.MedChrgitmType == "10" { //中药饮片
  5065. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5066. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5067. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5068. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5069. if item.ChrgitmLv == "1" {
  5070. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5071. }
  5072. if item.ChrgitmLv == "2" {
  5073. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5074. }
  5075. if item.ChrgitmLv == "3" {
  5076. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5077. }
  5078. }
  5079. if item.MedChrgitmType == "11" { //中成费
  5080. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5081. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5082. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5083. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5084. if item.ChrgitmLv == "1" {
  5085. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5086. }
  5087. if item.ChrgitmLv == "2" {
  5088. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5089. }
  5090. if item.ChrgitmLv == "3" {
  5091. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5092. }
  5093. }
  5094. if item.MedChrgitmType == "12" { //中成费
  5095. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5096. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5097. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5098. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5099. if item.ChrgitmLv == "1" {
  5100. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5101. }
  5102. if item.ChrgitmLv == "2" {
  5103. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5104. }
  5105. if item.ChrgitmLv == "3" {
  5106. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5107. }
  5108. }
  5109. if item.MedChrgitmType == "13" { //中成费
  5110. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5111. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5112. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5113. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5114. if item.ChrgitmLv == "1" {
  5115. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5116. }
  5117. if item.ChrgitmLv == "2" {
  5118. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5119. }
  5120. if item.ChrgitmLv == "3" {
  5121. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5122. }
  5123. }
  5124. if item.MedChrgitmType == "14" { //其他费
  5125. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5126. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5127. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5128. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5129. if item.ChrgitmLv == "1" {
  5130. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5131. }
  5132. if item.ChrgitmLv == "2" {
  5133. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5134. }
  5135. if item.ChrgitmLv == "3" {
  5136. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5137. }
  5138. }
  5139. }
  5140. var iteminfoStructs []service.IteminfoStruct
  5141. if bedCostTotal != 0 {
  5142. iteminfo.MedChrgitm = "01"
  5143. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5144. iteminfo.Amt = bedCostTotal
  5145. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5146. iteminfo.ClabAmt = bed_clab_amt
  5147. iteminfo.OthAmt = bed_other_amt
  5148. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5149. }
  5150. if examineCostTotal != 0 {
  5151. iteminfo.MedChrgitm = "02"
  5152. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  5153. iteminfo.Amt = examineCostTotal
  5154. iteminfo.ClaaSumfee = examine_claa_sunmfee
  5155. iteminfo.ClabAmt = examine_clab_amt
  5156. iteminfo.OthAmt = examine_other_amt
  5157. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5158. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5159. }
  5160. if checkCostTotal != 0 {
  5161. iteminfo.MedChrgitm = "03"
  5162. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5163. iteminfo.Amt = checkCostTotal
  5164. iteminfo.ClaaSumfee = check_claa_sunmfee
  5165. iteminfo.ClabAmt = check_clab_amt
  5166. iteminfo.OthAmt = check_other_amt
  5167. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5168. }
  5169. if laboratoryCostTotal != 0 {
  5170. iteminfo.MedChrgitm = "04"
  5171. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5172. iteminfo.Amt = laboratoryCostTotal
  5173. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5174. iteminfo.ClabAmt = laboratory_clab_amt
  5175. iteminfo.OthAmt = laboratory_other_amt
  5176. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5177. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5178. }
  5179. if treatCostTotal != 0 {
  5180. iteminfo.MedChrgitm = "05"
  5181. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5182. iteminfo.Amt = treatCostTotal
  5183. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5184. iteminfo.ClabAmt = treat_clab_amt
  5185. iteminfo.OthAmt = treat_other_amt
  5186. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5187. //(struct4101.IteminfoStruct, iteminfo)
  5188. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5189. }
  5190. if operationCostTotal != 0 {
  5191. iteminfo.MedChrgitm = "06"
  5192. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5193. iteminfo.Amt = operationCostTotal
  5194. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5195. iteminfo.ClabAmt = operation_clab_amt
  5196. iteminfo.OthAmt = operation_other_amt
  5197. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5198. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5199. }
  5200. if nursingCostTotal != 0 {
  5201. iteminfo.MedChrgitm = "07"
  5202. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  5203. iteminfo.Amt = nursingCostTotal
  5204. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  5205. iteminfo.ClabAmt = nursing_clab_amt
  5206. iteminfo.OthAmt = nursing_other_amt
  5207. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5208. }
  5209. if materialCostTotal != 0 {
  5210. iteminfo.MedChrgitm = "08"
  5211. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5212. iteminfo.Amt = materialCostTotal
  5213. iteminfo.ClaaSumfee = material_claa_sunmfee
  5214. iteminfo.ClabAmt = material_clab_amt
  5215. iteminfo.OthAmt = material_other_amt
  5216. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5217. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5218. }
  5219. if westernMedicineCostTotal != 0 {
  5220. iteminfo.MedChrgitm = "09"
  5221. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5222. iteminfo.Amt = westernMedicineCostTotal
  5223. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5224. iteminfo.ClabAmt = westernMedicine_clab_amt
  5225. iteminfo.OthAmt = westernMedicine_other_amt
  5226. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5227. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5228. }
  5229. if chineseMedicineCostTotal != 0 {
  5230. iteminfo.MedChrgitm = "10"
  5231. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  5232. iteminfo.Amt = chineseMedicineCostTotal
  5233. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  5234. iteminfo.ClabAmt = chinese_medicine_clab_amt
  5235. iteminfo.OthAmt = chinese_medicine_other_amt
  5236. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5237. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5238. }
  5239. if chineseTraditionalMedicineCostTotal != 0 {
  5240. iteminfo.MedChrgitm = "11"
  5241. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5242. iteminfo.Amt = westernMedicineCostTotal
  5243. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5244. iteminfo.ClabAmt = westernMedicine_clab_amt
  5245. iteminfo.OthAmt = westernMedicine_other_amt
  5246. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5247. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5248. }
  5249. if commonlyTreatmentCostTotal != 0 {
  5250. iteminfo.MedChrgitm = "12"
  5251. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  5252. iteminfo.Amt = commonlyTreatmentCostTotal
  5253. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  5254. iteminfo.ClabAmt = commonly_treatment_clab_amt
  5255. iteminfo.OthAmt = commonly_treatment_other_amt
  5256. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5257. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5258. }
  5259. if registerCostTotal != 0 {
  5260. iteminfo.MedChrgitm = "13"
  5261. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  5262. iteminfo.Amt = registerCostTotal
  5263. iteminfo.ClaaSumfee = register_claa_sunmfee
  5264. iteminfo.ClabAmt = register_clab_amt
  5265. iteminfo.OthAmt = register_other_amt
  5266. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5267. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5268. }
  5269. if otherCostTotal != 0 {
  5270. iteminfo.MedChrgitm = "14"
  5271. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5272. iteminfo.Amt = otherCostTotal
  5273. iteminfo.ClaaSumfee = other_claa_sunmfee
  5274. iteminfo.ClabAmt = other_clab_amt
  5275. iteminfo.OthAmt = other_other_amt
  5276. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5277. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5278. }
  5279. struct4101.IteminfoStruct = iteminfoStructs
  5280. time_arr := strings.Split(order.SetlTime, " ")
  5281. struct4101.AdmTime = time_arr[0]
  5282. struct4101.AdmEndTime = time_arr[0]
  5283. struct4101.DoctorName = doctor.UserName
  5284. struct4101.DoctorCode = doctor.DoctorNumber
  5285. struct4101.Ntly = "中国"
  5286. struct4101.AdmCaty = "A03.06"
  5287. var res ResultSeventeen
  5288. if miConfig.MdtrtareaAdmvs == "421300" {
  5289. data := make(map[string]interface{})
  5290. data["struct4101"] = struct4101
  5291. data["secret_key"] = miConfig.SecretKey
  5292. data["org_name"] = miConfig.OrgName
  5293. data["opera"] = curRoles.UserName
  5294. data["code"] = miConfig.Code
  5295. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5296. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5297. client := &http.Client{}
  5298. bytesData, _ := json.Marshal(data)
  5299. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  5300. resp, _ := client.Do(req)
  5301. defer resp.Body.Close()
  5302. body, ioErr := ioutil.ReadAll(resp.Body)
  5303. if ioErr != nil {
  5304. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5306. return
  5307. }
  5308. var respJSON map[string]interface{}
  5309. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5310. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5312. return
  5313. }
  5314. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5315. userJSONBytes, _ := json.Marshal(respJSON)
  5316. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5317. utils.ErrorLog("解析失败:%v", err)
  5318. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5319. adminUser := c.GetAdminUserInfo()
  5320. errlog := &models.HisOrderError{
  5321. UserOrgId: adminUser.CurrentOrgId,
  5322. Ctime: time.Now().Unix(),
  5323. Mtime: time.Now().Unix(),
  5324. ErrMsg: res.ErrMsg + "解析失败",
  5325. Status: 1,
  5326. PatientId: order_id,
  5327. Stage: 10088,
  5328. }
  5329. service.CreateErrMsgLog(errlog)
  5330. continue
  5331. }
  5332. } else {
  5333. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  5334. fmt.Println(result)
  5335. var dat map[string]interface{}
  5336. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5337. fmt.Println(dat)
  5338. } else {
  5339. fmt.Println(err)
  5340. }
  5341. userJSONBytes, _ := json.Marshal(dat)
  5342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5343. utils.ErrorLog("解析失败:%v", err)
  5344. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5345. adminUser := c.GetAdminUserInfo()
  5346. errlog := &models.HisOrderError{
  5347. UserOrgId: adminUser.CurrentOrgId,
  5348. Ctime: time.Now().Unix(),
  5349. Mtime: time.Now().Unix(),
  5350. ErrMsg: res.ErrMsg + "解析失败",
  5351. Status: 1,
  5352. PatientId: order_id,
  5353. Stage: 10106,
  5354. }
  5355. service.CreateErrMsgLog(errlog)
  5356. continue
  5357. }
  5358. }
  5359. if res.Infcode != 0 {
  5360. adminUser := c.GetAdminUserInfo()
  5361. errlog := &models.HisOrderError{
  5362. UserOrgId: adminUser.CurrentOrgId,
  5363. Ctime: time.Now().Unix(),
  5364. Mtime: time.Now().Unix(),
  5365. ErrMsg: res.ErrMsg,
  5366. Status: 1,
  5367. PatientId: order_id,
  5368. Stage: 10106,
  5369. }
  5370. service.CreateErrMsgLog(errlog)
  5371. continue
  5372. } else {
  5373. hisFundSettleListResult := &models.HisFundSettleListResult{
  5374. Number: res.Output.SetlListId,
  5375. Status: 1,
  5376. Ctime: time.Now().Unix(),
  5377. Mtime: time.Now().Unix(),
  5378. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5379. IsUpload: 1,
  5380. OrderId: order_id,
  5381. }
  5382. service.CreateUploadRecord(hisFundSettleListResult)
  5383. continue
  5384. }
  5385. }
  5386. }
  5387. func (c *HisApiController) GetOrgInfo() {
  5388. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  5389. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  5390. }
  5391. func (c *HisApiController) GetHisPatientInfo() {
  5392. medical_insurance_card := c.GetString("medical_insurance_card")
  5393. id_card_type, _ := c.GetInt64("id_card_type")
  5394. id_card := c.GetString("id_card")
  5395. adminInfo := c.GetAdminUserInfo()
  5396. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  5397. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5398. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  5399. IdCardNo := ""
  5400. if id_card_type == 1 {
  5401. IdCardNo = medical_insurance_card
  5402. } else if id_card_type == 2 {
  5403. IdCardNo = id_card
  5404. }
  5405. if config.IsOpen == 1 {
  5406. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5407. resp, requestErr := http.Get(api)
  5408. if requestErr != nil {
  5409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5410. return
  5411. }
  5412. defer resp.Body.Close()
  5413. body, ioErr := ioutil.ReadAll(resp.Body)
  5414. if ioErr != nil {
  5415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5417. return
  5418. }
  5419. var respJSON map[string]interface{}
  5420. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5423. return
  5424. }
  5425. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5426. userJSONBytes, _ := json.Marshal(userJSON)
  5427. var res ResultTwo
  5428. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5429. utils.ErrorLog("解析失败:%v", err)
  5430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5431. return
  5432. }
  5433. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5434. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5435. infoStr := string(Iinfos)
  5436. idetinfoStr := string(Idetinfos)
  5437. if res.Infcode == 0 {
  5438. his := models.VMHisPatient{
  5439. Status: 1,
  5440. Ctime: time.Now().Unix(),
  5441. Mtime: time.Now().Unix(),
  5442. PsnNo: res.Output.Baseinfo.PsnNo,
  5443. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5444. Certno: res.Output.Baseinfo.Certno,
  5445. PsnName: res.Output.Baseinfo.PsnName,
  5446. Gend: res.Output.Baseinfo.Gend,
  5447. Naty: res.Output.Baseinfo.Naty,
  5448. Brdy: res.Output.Baseinfo.Brdy,
  5449. Age: res.Output.Baseinfo.Age,
  5450. Iinfo: infoStr,
  5451. Idetinfo: idetinfoStr,
  5452. UserOrgId: adminInfo.CurrentOrgId,
  5453. IsReturn: 1,
  5454. IdCardType: id_card_type,
  5455. }
  5456. c.ServeSuccessJSON(map[string]interface{}{
  5457. "info": his,
  5458. })
  5459. } else {
  5460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5461. return
  5462. }
  5463. }
  5464. }
  5465. //func GetBasBaseInfo() (jsonStr string, err error) {
  5466. //
  5467. // handle := syscall.NewLazyDLL("SSCard.dll")
  5468. // add := handle.NewProc("ReadCardBas")
  5469. // str := make([]byte, 1024)
  5470. // str1 := make([]byte, 1024)
  5471. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5472. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  5473. //
  5474. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  5475. //
  5476. // fmt.Println("> Add(4,5)的结果为:", ret)
  5477. // handle.Release()
  5478. //
  5479. // return "", nil
  5480. //
  5481. //}
  5482. //func GetQRBaseInfo() (jsonStr string, err error) {
  5483. // handle := syscall.LoadDLL("SSCard.dll")
  5484. // ReadCardBas := handle.FindProc("GetQRBase")
  5485. //
  5486. // str := make([]byte, 256)
  5487. // str1 := make([]byte, 256)
  5488. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5489. //
  5490. // fmt.Println(string(str))
  5491. // fmt.Println(r)
  5492. // return string(str), nil
  5493. //}
  5494. //func CardInit() int {
  5495. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  5496. // add := DllTestDef.MustFindProc("Init")
  5497. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5498. // if err != nil {
  5499. // fmt.Println("SSCard的运算结果为:", ret)
  5500. // }
  5501. // result := int(ret)
  5502. // return result
  5503. //}
  5504. //func CardInit() int {
  5505. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5506. // if err != nil {
  5507. // fmt.Println("SSCard的运算结果为:", ret)
  5508. // }
  5509. // fmt.Println(err)
  5510. // result := int(ret)
  5511. // return result
  5512. //}
  5513. func IntPtr(n int) uintptr {
  5514. return uintptr(n)
  5515. }
  5516. func StrPtr(s string) uintptr {
  5517. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  5518. }
  5519. type Result2001 struct {
  5520. Cainfo interface{} `json:"cainfo"`
  5521. ErrMsg string `json:"err_msg"`
  5522. InfRefmsgid string `json:"inf_refmsgid"`
  5523. Infcode int64 `json:"infcode"`
  5524. Output struct {
  5525. Trtinfo struct {
  5526. PsnNo string `json:"psn_no"`
  5527. TrtChkType string `json:"trt_chk_type"`
  5528. FundPayType string `json:"fund_pay_type"`
  5529. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5530. Begndate string `json:"begndate"`
  5531. Enddate string `json:"enddate"`
  5532. TrtChkRslt string `json:"trt_chk_rslt"`
  5533. } `json:"trtinfo"`
  5534. } `json:"output"`
  5535. RefmsgTime string `json:"refmsg_time"`
  5536. RespondTime string `json:"respond_time"`
  5537. Signtype interface{} `json:"signtype"`
  5538. WarnMsg interface{} `json:"warn_msg"`
  5539. }
  5540. type Result2001Org10265 struct {
  5541. Cainfo interface{} `json:"cainfo"`
  5542. ErrMsg string `json:"err_msg"`
  5543. InfRefmsgid string `json:"inf_refmsgid"`
  5544. Infcode string `json:"infcode"`
  5545. Output struct {
  5546. Trtinfo struct {
  5547. PsnNo string `json:"psn_no"`
  5548. TrtChkType string `json:"trt_chk_type"`
  5549. FundPayType string `json:"fund_pay_type"`
  5550. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5551. Begndate string `json:"begndate"`
  5552. Enddate string `json:"enddate"`
  5553. TrtChkRslt string `json:"trt_chk_rslt"`
  5554. } `json:"trtinfo"`
  5555. } `json:"output"`
  5556. RefmsgTime string `json:"refmsg_time"`
  5557. RespondTime string `json:"respond_time"`
  5558. Signtype interface{} `json:"signtype"`
  5559. WarnMsg interface{} `json:"warn_msg"`
  5560. }
  5561. type ResultTwo struct {
  5562. ErrMsg string `json:"err_msg"`
  5563. InfRefmsgid string `json:"inf_refmsgid"`
  5564. Infcode int64 `json:"infcode"`
  5565. Output struct {
  5566. Baseinfo struct {
  5567. Age float64 `json:"age"`
  5568. Brdy string `json:"brdy"`
  5569. Certno string `json:"certno"`
  5570. Gend string `json:"gend"`
  5571. Naty string `json:"naty"`
  5572. PsnCertType string `json:"psn_cert_type"`
  5573. PsnName string `json:"psn_name"`
  5574. PsnNo string `json:"psn_no"`
  5575. } `json:"baseinfo"`
  5576. Idetinfo []interface{} `json:"idetinfo"`
  5577. Iinfo []struct {
  5578. Balc float64 `json:"balc"`
  5579. CvlservFlag string `json:"cvlserv_flag"`
  5580. EmpName string `json:"emp_name"`
  5581. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5582. Insutype string `json:"insutype"`
  5583. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5584. PausInsuDate string `json:"paus_insu_date"`
  5585. PsnInsuDate string `json:"psn_insu_date"`
  5586. PsnInsuStas string `json:"psn_insu_stas"`
  5587. PsnType string `json:"psn_type"`
  5588. } `json:"insuinfo"`
  5589. } `json:"output"`
  5590. RefmsgTime string `json:"refmsg_time"`
  5591. RespondTime string `json:"respond_time"`
  5592. Signtype interface{} `json:"signtype"`
  5593. WarnInfo interface{} `json:"warn_info"`
  5594. }
  5595. type ResultTwo10265 struct {
  5596. ErrMsg string `json:"err_msg"`
  5597. InfRefmsgid string `json:"inf_refmsgid"`
  5598. Infcode string `json:"infcode"`
  5599. Output struct {
  5600. Baseinfo struct {
  5601. Age float64 `json:"age"`
  5602. Brdy string `json:"brdy"`
  5603. Certno string `json:"certno"`
  5604. Gend string `json:"gend"`
  5605. Naty string `json:"naty"`
  5606. PsnCertType string `json:"psn_cert_type"`
  5607. PsnName string `json:"psn_name"`
  5608. PsnNo string `json:"psn_no"`
  5609. } `json:"baseinfo"`
  5610. Idetinfo []interface{} `json:"idetinfo"`
  5611. Iinfo []struct {
  5612. Balc float64 `json:"balc"`
  5613. CvlservFlag string `json:"cvlserv_flag"`
  5614. EmpName string `json:"emp_name"`
  5615. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5616. Insutype string `json:"insutype"`
  5617. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5618. PausInsuDate string `json:"paus_insu_date"`
  5619. PsnInsuDate string `json:"psn_insu_date"`
  5620. PsnInsuStas string `json:"psn_insu_stas"`
  5621. PsnType string `json:"psn_type"`
  5622. } `json:"insuinfo"`
  5623. } `json:"output"`
  5624. RefmsgTime string `json:"refmsg_time"`
  5625. RespondTime string `json:"respond_time"`
  5626. Signtype interface{} `json:"signtype"`
  5627. WarnInfo interface{} `json:"warn_info"`
  5628. }
  5629. type ResultThree struct {
  5630. Cainfo interface{} `json:"cainfo"`
  5631. ErrMsg string `json:"err_msg"`
  5632. InfRefmsgid string `json:"inf_refmsgid"`
  5633. Infcode int64 `json:"infcode"`
  5634. Output struct {
  5635. Data struct {
  5636. IptOtpNo string `json:"ipt_otp_no"`
  5637. MdtrtID string `json:"mdtrt_id"`
  5638. PsnNo string `json:"psn_no"`
  5639. } `json:"data"`
  5640. } `json:"output"`
  5641. RefmsgTime string `json:"refmsg_time"`
  5642. RespondTime string `json:"respond_time"`
  5643. Signtype interface{} `json:"signtype"`
  5644. WarnMsg interface{} `json:"warn_msg"`
  5645. }
  5646. type ResultThree10265 struct {
  5647. Cainfo interface{} `json:"cainfo"`
  5648. ErrMsg string `json:"err_msg"`
  5649. InfRefmsgid string `json:"inf_refmsgid"`
  5650. Infcode string `json:"infcode"`
  5651. Output struct {
  5652. Data struct {
  5653. IptOtpNo string `json:"ipt_otp_no"`
  5654. MdtrtID string `json:"mdtrt_id"`
  5655. PsnNo string `json:"psn_no"`
  5656. } `json:"data"`
  5657. } `json:"output"`
  5658. RefmsgTime string `json:"refmsg_time"`
  5659. RespondTime string `json:"respond_time"`
  5660. Signtype interface{} `json:"signtype"`
  5661. WarnMsg interface{} `json:"warn_msg"`
  5662. }
  5663. type ResultFour struct {
  5664. Cainfo string `json:"cainfo"`
  5665. ErrMsg string `json:"err_msg"`
  5666. InfRefmsgid string `json:"inf_refmsgid"`
  5667. Infcode int64 `json:"infcode"`
  5668. Output struct {
  5669. Result []struct {
  5670. BasMednFlag string `json:"bas_medn_flag"`
  5671. ChldMedcFlag string `json:"chld_medc_flag"`
  5672. ChrgitmLv string `json:"chrgitm_lv"`
  5673. Cnt float64 `json:"cnt"`
  5674. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5675. DrtReimFlag string `json:"drt_reim_flag"`
  5676. FeedetlSn string `json:"feedetl_sn"`
  5677. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5678. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5679. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5680. ListSpItemFlag string `json:"list_sp_item_flag"`
  5681. LmtUsedFlag string `json:"lmt_used_flag"`
  5682. MedChrgitmType string `json:"med_chrgitm_type"`
  5683. Memo string `json:"memo"`
  5684. OverlmtAmt float64 `json:"overlmt_amt"`
  5685. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5686. Pric float64 `json:"pric"`
  5687. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5688. SelfpayProp float64 `json:"selfpay_prop"`
  5689. } `json:"result"`
  5690. } `json:"output"`
  5691. RefmsgTime string `json:"refmsg_time"`
  5692. RespondTime string `json:"respond_time"`
  5693. Signtype string `json:"signtype"`
  5694. WarnMsg string `json:"warn_msg"`
  5695. }
  5696. type ResultFour10265 struct {
  5697. Cainfo string `json:"cainfo"`
  5698. ErrMsg string `json:"err_msg"`
  5699. InfRefmsgid string `json:"inf_refmsgid"`
  5700. Infcode string `json:"infcode"`
  5701. Output struct {
  5702. Result []struct {
  5703. BasMednFlag string `json:"bas_medn_flag"`
  5704. ChldMedcFlag string `json:"chld_medc_flag"`
  5705. ChrgitmLv string `json:"chrgitm_lv"`
  5706. Cnt float64 `json:"cnt"`
  5707. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5708. DrtReimFlag string `json:"drt_reim_flag"`
  5709. FeedetlSn string `json:"feedetl_sn"`
  5710. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5711. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5712. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5713. ListSpItemFlag string `json:"list_sp_item_flag"`
  5714. LmtUsedFlag string `json:"lmt_used_flag"`
  5715. MedChrgitmType string `json:"med_chrgitm_type"`
  5716. Memo string `json:"memo"`
  5717. OverlmtAmt float64 `json:"overlmt_amt"`
  5718. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5719. Pric float64 `json:"pric"`
  5720. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5721. SelfpayProp float64 `json:"selfpay_prop"`
  5722. } `json:"result"`
  5723. } `json:"output"`
  5724. RefmsgTime string `json:"refmsg_time"`
  5725. RespondTime string `json:"respond_time"`
  5726. Signtype string `json:"signtype"`
  5727. WarnMsg string `json:"warn_msg"`
  5728. }
  5729. type ResultMemo struct {
  5730. InsuAdmdvs string `json:"insuAdmdvs"`
  5731. }
  5732. //[{"begntime":"2022-01-01 00:00:00","endtime":"2022-12-31 00:00:00","memo":"{\"matIdetCode\":\"20\",\"insuAdmdvs\":\"350481\"}","psn_idet_type":"23","psn_type_lv":null}]
  5733. type ResultIDInfo struct {
  5734. Begntime string `json:"begntime"`
  5735. Endtime string `json:"endtime"`
  5736. Memo string `json:"memo"`
  5737. }
  5738. type ResultFive struct {
  5739. Balc float64 `json:"balc"`
  5740. CvlservFlag string `json:"cvlserv_flag"`
  5741. EmpName string `json:"emp_name"`
  5742. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5743. Insutype string `json:"insutype"`
  5744. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5745. PausInsuDate string `json:"paus_insu_date"`
  5746. PsnInsuDate string `json:"psn_insu_date"`
  5747. PsnInsuStas string `json:"psn_insu_stas"`
  5748. PsnType string `json:"psn_type"`
  5749. }
  5750. type ResultSix struct {
  5751. Cainfo interface{} `json:"cainfo"`
  5752. ErrMsg string `json:"err_msg"`
  5753. InfRefmsgid string `json:"inf_refmsgid"`
  5754. Infcode int64 `json:"infcode"`
  5755. Output struct {
  5756. } `json:"output"`
  5757. RefmsgTime string `json:"refmsg_time"`
  5758. RespondTime string `json:"respond_time"`
  5759. Signtype interface{} `json:"signtype"`
  5760. WarnMsg interface{} `json:"warn_msg"`
  5761. }
  5762. type ResultSix10265 struct {
  5763. Cainfo interface{} `json:"cainfo"`
  5764. ErrMsg string `json:"err_msg"`
  5765. InfRefmsgid string `json:"inf_refmsgid"`
  5766. Infcode string `json:"infcode"`
  5767. Output struct {
  5768. } `json:"output"`
  5769. RefmsgTime string `json:"refmsg_time"`
  5770. RespondTime string `json:"respond_time"`
  5771. Signtype interface{} `json:"signtype"`
  5772. WarnMsg interface{} `json:"warn_msg"`
  5773. }
  5774. type ResultSeven struct {
  5775. Cainfo string `json:"cainfo"`
  5776. ErrMsg string `json:"err_msg"`
  5777. InfRefmsgid string `json:"inf_refmsgid"`
  5778. Infcode int64 `json:"infcode"`
  5779. Output struct {
  5780. Setldetail []interface{} `json:"setldetail"`
  5781. Setlinfo struct {
  5782. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5783. AcctPay float64 `json:"acct_pay"`
  5784. ActPayDedc float64 `json:"act_pay_dedc"`
  5785. Age float64 `json:"age"`
  5786. Balc float64 `json:"balc"`
  5787. Brdy string `json:"brdy"`
  5788. Certno string `json:"certno"`
  5789. ClrOptins string `json:"clr_optins"`
  5790. ClrType string `json:"clr_type"`
  5791. ClrWay string `json:"clr_way"`
  5792. CvlservFlag string `json:"cvlserv_flag"`
  5793. CvlservPay float64 `json:"cvlserv_pay"`
  5794. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5795. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5796. Gend string `json:"gend"`
  5797. HifesPay float64 `json:"hifes_pay"`
  5798. HifmiPay float64 `json:"hifmi_pay"`
  5799. HifpPay float64 `json:"hifp_pay"`
  5800. HospPartAmt float64 `json:"hosp_part_amt"`
  5801. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5802. Insutype string `json:"insutype"`
  5803. MafPay float64 `json:"maf_pay"`
  5804. MdtrtCertType string `json:"mdtrt_cert_type"`
  5805. HifobPay float64 `json:"hifob_pay"`
  5806. MdtrtID string `json:"mdtrt_id"`
  5807. MedType string `json:"med_type"`
  5808. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5809. MedinsSetlID string `json:"medins_setl_id"`
  5810. Naty string `json:"naty"`
  5811. OthPay float64 `json:"oth_pay"`
  5812. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5813. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5814. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5815. PsnCashPay float64 `json:"psn_cash_pay"`
  5816. PsnCertType string `json:"psn_cert_type"`
  5817. PsnName string `json:"psn_name"`
  5818. PsnNo string `json:"psn_no"`
  5819. PsnPartAmt float64 `json:"psn_part_amt"`
  5820. PsnType string `json:"psn_type"`
  5821. SetlID string `json:"setl_id"`
  5822. SetlTime string `json:"setl_time"`
  5823. } `json:"setlinfo"`
  5824. } `json:"output"`
  5825. RefmsgTime string `json:"refmsg_time"`
  5826. RespondTime string `json:"respond_time"`
  5827. Signtype interface{} `json:"signtype"`
  5828. WarnMsg interface{} `json:"warn_msg"`
  5829. }
  5830. type ResultSeven10265 struct {
  5831. Cainfo string `json:"cainfo"`
  5832. ErrMsg string `json:"err_msg"`
  5833. InfRefmsgid string `json:"inf_refmsgid"`
  5834. Infcode string `json:"infcode"`
  5835. Output struct {
  5836. Setldetail []interface{} `json:"setldetail"`
  5837. Setlinfo struct {
  5838. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5839. AcctPay float64 `json:"acct_pay"`
  5840. ActPayDedc float64 `json:"act_pay_dedc"`
  5841. Age float64 `json:"age"`
  5842. Balc float64 `json:"balc"`
  5843. Brdy string `json:"brdy"`
  5844. Certno string `json:"certno"`
  5845. ClrOptins string `json:"clr_optins"`
  5846. ClrType string `json:"clr_type"`
  5847. ClrWay string `json:"clr_way"`
  5848. CvlservFlag string `json:"cvlserv_flag"`
  5849. CvlservPay float64 `json:"cvlserv_pay"`
  5850. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5851. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5852. Gend string `json:"gend"`
  5853. HifesPay float64 `json:"hifes_pay"`
  5854. HifmiPay float64 `json:"hifmi_pay"`
  5855. HifpPay float64 `json:"hifp_pay"`
  5856. HospPartAmt float64 `json:"hosp_part_amt"`
  5857. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5858. Insutype string `json:"insutype"`
  5859. MafPay float64 `json:"maf_pay"`
  5860. MdtrtCertType string `json:"mdtrt_cert_type"`
  5861. HifobPay float64 `json:"hifob_pay"`
  5862. MdtrtID string `json:"mdtrt_id"`
  5863. MedType string `json:"med_type"`
  5864. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5865. MedinsSetlID string `json:"medins_setl_id"`
  5866. Naty string `json:"naty"`
  5867. OthPay float64 `json:"oth_pay"`
  5868. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5869. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5870. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5871. PsnCashPay float64 `json:"psn_cash_pay"`
  5872. PsnCertType string `json:"psn_cert_type"`
  5873. PsnName string `json:"psn_name"`
  5874. PsnNo string `json:"psn_no"`
  5875. PsnPartAmt float64 `json:"psn_part_amt"`
  5876. PsnType string `json:"psn_type"`
  5877. SetlID string `json:"setl_id"`
  5878. SetlTime string `json:"setl_time"`
  5879. } `json:"setlinfo"`
  5880. } `json:"output"`
  5881. RefmsgTime string `json:"refmsg_time"`
  5882. RespondTime string `json:"respond_time"`
  5883. Signtype interface{} `json:"signtype"`
  5884. WarnMsg interface{} `json:"warn_msg"`
  5885. }
  5886. type ResultEight struct {
  5887. Cainfo string `json:"cainfo"`
  5888. ErrMsg string `json:"err_msg"`
  5889. InfRefmsgid string `json:"inf_refmsgid"`
  5890. Infcode int64 `json:"infcode"`
  5891. Output struct {
  5892. Stmtinfo struct {
  5893. SetlOptins string `json:"setl_optins"`
  5894. StmtRslt string `json:"stmt_rslt"`
  5895. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5896. } `json:"stmtinfo"`
  5897. } `json:"output"`
  5898. RefmsgTime string `json:"refmsg_time"`
  5899. RespondTime string `json:"respond_time"`
  5900. Signtype interface{} `json:"signtype"`
  5901. WarnMsg interface{} `json:"warn_msg"`
  5902. }
  5903. type ResultEightFor10188 struct {
  5904. Cainfo string `json:"cainfo"`
  5905. ErrMsg string `json:"err_msg"`
  5906. InfRefmsgid string `json:"inf_refmsgid"`
  5907. Infcode string `json:"infcode"`
  5908. Output struct {
  5909. Stmtinfo struct {
  5910. SetlOptins string `json:"setl_optins"`
  5911. StmtRslt string `json:"stmt_rslt"`
  5912. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5913. } `json:"stmtinfo"`
  5914. } `json:"output"`
  5915. RefmsgTime string `json:"refmsg_time"`
  5916. RespondTime string `json:"respond_time"`
  5917. Signtype interface{} `json:"signtype"`
  5918. WarnMsg interface{} `json:"warn_msg"`
  5919. }
  5920. type ResultNine struct {
  5921. Cainfo string `json:"cainfo"`
  5922. ErrMsg string `json:"err_msg"`
  5923. InfRefmsgid string `json:"inf_refmsgid"`
  5924. Infcode int64 `json:"infcode"`
  5925. Output struct {
  5926. FileQuryNo string `json:"file_qury_no"`
  5927. } `json:"output"`
  5928. RefmsgTime string `json:"refmsg_time"`
  5929. RespondTime string `json:"respond_time"`
  5930. Signtype interface{} `json:"signtype"`
  5931. WarnMsg interface{} `json:"warn_msg"`
  5932. }
  5933. type ResultTen struct {
  5934. Cainfo string `json:"cainfo"`
  5935. ErrMsg string `json:"err_msg"`
  5936. InfRefmsgid string `json:"inf_refmsgid"`
  5937. Infcode int64 `json:"infcode"`
  5938. Output struct {
  5939. DldEndtime string `json:"dld_endtime"`
  5940. FileQuryNo string `json:"file_qury_no"`
  5941. Filename string `json:"filename"`
  5942. } `json:"output"`
  5943. RefmsgTime string `json:"refmsg_time"`
  5944. RespondTime string `json:"respond_time"`
  5945. Signtype interface{} `json:"signtype"`
  5946. WarnMsg interface{} `json:"warn_msg"`
  5947. }
  5948. //type Autogenerated struct {
  5949. // Output struct {
  5950. // Setlinfo struct {
  5951. // SetlTime string `json:"setl_time"`
  5952. // CvlservPay float64 `json:"cvlserv_pay"`
  5953. // Year string `json:"year"`
  5954. // MedType string `json:"med_type"`
  5955. // PsnPay float64 `json:"psn_pay"`
  5956. // OpterID string `json:"opter_id"`
  5957. // Begndate string `json:"begndate"`
  5958. // FlxempeFlag string `json:"flxempe_flag"`
  5959. // HifmiPay float64 `json:"hifmi_pay"`
  5960. // PsnNo string `json:"psn_no"`
  5961. // ActPayDedc float64 `json:"act_pay_dedc"`
  5962. // MedinsSetlID interface{} `json:"medins_setl_id"`
  5963. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5964. // ClrWay string `json:"clr_way"`
  5965. // OthPay float64 `json:"oth_pay"`
  5966. // Gend string `json:"gend"`
  5967. // MdtrtID string `json:"mdtrt_id"`
  5968. // AcctPay float64 `json:"acct_pay"`
  5969. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  5970. // Insutype string `json:"insutype"`
  5971. // Invono interface{} `json:"invono"`
  5972. // Enddate string `json:"enddate"`
  5973. // CashPayamt float64 `json:"cash_payamt"`
  5974. // PsnType string `json:"psn_type"`
  5975. // FixmedinsName string `json:"fixmedins_name"`
  5976. // HifpPay float64 `json:"hifp_pay"`
  5977. // NewFlag interface{} `json:"new_flag"`
  5978. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5979. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  5980. // PayLoc string `json:"pay_loc"`
  5981. // ClrType string `json:"clr_type"`
  5982. // RefdSetlFlag string `json:"refd_setl_flag"`
  5983. // CvlservFlag string `json:"cvlserv_flag"`
  5984. // EmpName string `json:"emp_name"`
  5985. // Brdy string `json:"brdy"`
  5986. // Naty string `json:"naty"`
  5987. // Certno string `json:"certno"`
  5988. // DiseCode string `json:"dise_code"`
  5989. // FixmedinsCode string `json:"fixmedins_code"`
  5990. // DedcHospLv string `json:"dedc_hosp_lv"`
  5991. // OpterName string `json:"opter_name"`
  5992. // Balc float64 `json:"balc"`
  5993. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  5994. // PsnCertType string `json:"psn_cert_type"`
  5995. // HifobPay float64 `json:"hifob_pay"`
  5996. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  5997. // HifesPay float64 `json:"hifes_pay"`
  5998. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5999. // OptTime string `json:"opt_time"`
  6000. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6001. // SetlID string `json:"setl_id"`
  6002. // MafPay float64 `json:"maf_pay"`
  6003. // PsnName string `json:"psn_name"`
  6004. // InsuOptins interface{} `json:"insu_optins"`
  6005. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6006. // ClrOptins string `json:"clr_optins"`
  6007. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6008. // DiseName string `json:"dise_name"`
  6009. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6010. // Age float64 `json:"age"`
  6011. // DtrtCertType string `json:"dtrt_cert_type"`
  6012. // HospLv string `json:"hosp_lv"`
  6013. // } `json:"setlinfo"`
  6014. // Setldetail []struct {
  6015. // FundPayType string `json:"fund_pay_type"`
  6016. // FundPayamt float64 `json:"fund_payamt"`
  6017. // SetlProcInfo interface{} `json:"setl_proc_info"`
  6018. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  6019. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  6020. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  6021. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6022. // } `json:"setldetail"`
  6023. // } `json:"output"`
  6024. // Infcode int `json:"infcode"`
  6025. // WarnMsg interface{} `json:"warn_msg"`
  6026. // Cainfo interface{} `json:"cainfo"`
  6027. // ErrMsg interface{} `json:"err_msg"`
  6028. // RefmsgTime string `json:"refmsg_time"`
  6029. // Signtype interface{} `json:"signtype"`
  6030. // RespondTime string `json:"respond_time"`
  6031. // InfRefmsgid string `json:"inf_refmsgid"`
  6032. //}
  6033. type ResultEleven struct {
  6034. Cainfo string `json:"cainfo"`
  6035. ErrMsg string `json:"err_msg"`
  6036. InfRefmsgid string `json:"inf_refmsgid"`
  6037. Infcode int64 `json:"infcode"`
  6038. Output struct {
  6039. Setlinfo struct {
  6040. SetlTime string `json:"setl_time"`
  6041. CvlservPay float64 `json:"cvlserv_pay"`
  6042. Year string `json:"year"`
  6043. MedType string `json:"med_type"`
  6044. PsnPay float64 `json:"psn_pay"`
  6045. OpterID string `json:"opter_id"`
  6046. Begndate string `json:"begndate"`
  6047. FlxempeFlag string `json:"flxempe_flag"`
  6048. HifmiPay float64 `json:"hifmi_pay"`
  6049. PsnNo string `json:"psn_no"`
  6050. ActPayDedc float64 `json:"act_pay_dedc"`
  6051. MedinsSetlID interface{} `json:"medins_setl_id"`
  6052. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6053. ClrWay string `json:"clr_way"`
  6054. OthPay float64 `json:"oth_pay"`
  6055. Gend string `json:"gend"`
  6056. MdtrtID string `json:"mdtrt_id"`
  6057. AcctPay float64 `json:"acct_pay"`
  6058. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6059. Insutype string `json:"insutype"`
  6060. Invono interface{} `json:"invono"`
  6061. Enddate string `json:"enddate"`
  6062. CashPayamt float64 `json:"cash_payamt"`
  6063. PsnType string `json:"psn_type"`
  6064. FixmedinsName string `json:"fixmedins_name"`
  6065. HifpPay float64 `json:"hifp_pay"`
  6066. NewFlag interface{} `json:"new_flag"`
  6067. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6068. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6069. PayLoc string `json:"pay_loc"`
  6070. ClrType string `json:"clr_type"`
  6071. RefdSetlFlag string `json:"refd_setl_flag"`
  6072. CvlservFlag string `json:"cvlserv_flag"`
  6073. EmpName string `json:"emp_name"`
  6074. Brdy string `json:"brdy"`
  6075. Naty string `json:"naty"`
  6076. Certno string `json:"certno"`
  6077. DiseCode string `json:"dise_code"`
  6078. FixmedinsCode string `json:"fixmedins_code"`
  6079. DedcHospLv string `json:"dedc_hosp_lv"`
  6080. OpterName string `json:"opter_name"`
  6081. Balc float64 `json:"balc"`
  6082. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6083. PsnCertType string `json:"psn_cert_type"`
  6084. HifobPay float64 `json:"hifob_pay"`
  6085. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6086. HifesPay float64 `json:"hifes_pay"`
  6087. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6088. OptTime string `json:"opt_time"`
  6089. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6090. SetlID string `json:"setl_id"`
  6091. MafPay float64 `json:"maf_pay"`
  6092. PsnName string `json:"psn_name"`
  6093. InsuOptins interface{} `json:"insu_optins"`
  6094. PrefFundPay interface{} `json:"pref_fund_pay"`
  6095. ClrOptins string `json:"clr_optins"`
  6096. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6097. DiseName string `json:"dise_name"`
  6098. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6099. Age float64 `json:"age"`
  6100. DtrtCertType string `json:"dtrt_cert_type"`
  6101. HospLv string `json:"hosp_lv"`
  6102. PsnCashPay float64
  6103. } `json:"setlinfo"`
  6104. } `json:"output"`
  6105. RefmsgTime string `json:"refmsg_time"`
  6106. RespondTime string `json:"respond_time"`
  6107. Signtype interface{} `json:"signtype"`
  6108. WarnMsg interface{} `json:"warn_msg"`
  6109. }
  6110. type ResultEleven10265 struct {
  6111. Cainfo string `json:"cainfo"`
  6112. ErrMsg string `json:"err_msg"`
  6113. InfRefmsgid string `json:"inf_refmsgid"`
  6114. Infcode string `json:"infcode"`
  6115. Output struct {
  6116. Setlinfo struct {
  6117. SetlTime string `json:"setl_time"`
  6118. CvlservPay float64 `json:"cvlserv_pay"`
  6119. Year string `json:"year"`
  6120. MedType string `json:"med_type"`
  6121. PsnPay float64 `json:"psn_pay"`
  6122. OpterID string `json:"opter_id"`
  6123. Begndate string `json:"begndate"`
  6124. FlxempeFlag string `json:"flxempe_flag"`
  6125. HifmiPay float64 `json:"hifmi_pay"`
  6126. PsnNo string `json:"psn_no"`
  6127. ActPayDedc float64 `json:"act_pay_dedc"`
  6128. MedinsSetlID interface{} `json:"medins_setl_id"`
  6129. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6130. ClrWay string `json:"clr_way"`
  6131. OthPay float64 `json:"oth_pay"`
  6132. Gend string `json:"gend"`
  6133. MdtrtID string `json:"mdtrt_id"`
  6134. AcctPay float64 `json:"acct_pay"`
  6135. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6136. Insutype string `json:"insutype"`
  6137. Invono interface{} `json:"invono"`
  6138. Enddate string `json:"enddate"`
  6139. CashPayamt float64 `json:"cash_payamt"`
  6140. PsnType string `json:"psn_type"`
  6141. FixmedinsName string `json:"fixmedins_name"`
  6142. HifpPay float64 `json:"hifp_pay"`
  6143. NewFlag interface{} `json:"new_flag"`
  6144. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6145. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6146. PayLoc string `json:"pay_loc"`
  6147. ClrType string `json:"clr_type"`
  6148. RefdSetlFlag string `json:"refd_setl_flag"`
  6149. CvlservFlag string `json:"cvlserv_flag"`
  6150. EmpName string `json:"emp_name"`
  6151. Brdy string `json:"brdy"`
  6152. Naty string `json:"naty"`
  6153. Certno string `json:"certno"`
  6154. DiseCode string `json:"dise_code"`
  6155. FixmedinsCode string `json:"fixmedins_code"`
  6156. DedcHospLv string `json:"dedc_hosp_lv"`
  6157. OpterName string `json:"opter_name"`
  6158. Balc float64 `json:"balc"`
  6159. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6160. PsnCertType string `json:"psn_cert_type"`
  6161. HifobPay float64 `json:"hifob_pay"`
  6162. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6163. HifesPay float64 `json:"hifes_pay"`
  6164. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6165. OptTime string `json:"opt_time"`
  6166. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6167. SetlID string `json:"setl_id"`
  6168. MafPay float64 `json:"maf_pay"`
  6169. PsnName string `json:"psn_name"`
  6170. InsuOptins interface{} `json:"insu_optins"`
  6171. PrefFundPay interface{} `json:"pref_fund_pay"`
  6172. ClrOptins string `json:"clr_optins"`
  6173. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6174. DiseName string `json:"dise_name"`
  6175. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6176. Age float64 `json:"age"`
  6177. DtrtCertType string `json:"dtrt_cert_type"`
  6178. HospLv string `json:"hosp_lv"`
  6179. PsnCashPay float64
  6180. } `json:"setlinfo"`
  6181. } `json:"output"`
  6182. RefmsgTime string `json:"refmsg_time"`
  6183. RespondTime string `json:"respond_time"`
  6184. Signtype interface{} `json:"signtype"`
  6185. WarnMsg interface{} `json:"warn_msg"`
  6186. }
  6187. type ResultTwelve struct {
  6188. Cainfo string `json:"cainfo"`
  6189. ErrMsg string `json:"err_msg"`
  6190. InfRefmsgid string `json:"inf_refmsgid"`
  6191. Infcode int64 `json:"infcode"`
  6192. Output struct {
  6193. MdtrtId string `json:"mdtrt_id"`
  6194. ChrgBchno string `json:"chrg_bchno"`
  6195. PsnNo string `json:"psn_no"`
  6196. } `json:"output"`
  6197. RefmsgTime string `json:"refmsg_time"`
  6198. RespondTime string `json:"respond_time"`
  6199. Signtype interface{} `json:"signtype"`
  6200. WarnMsg interface{} `json:"warn_msg"`
  6201. }
  6202. type ResultThirteen struct {
  6203. ErrMsg string `json:"err_msg"`
  6204. InfRefmsgid string `json:"inf_refmsgid"`
  6205. Infcode int64 `json:"infcode"`
  6206. Output struct {
  6207. Result struct {
  6208. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6209. } `json:"result"`
  6210. } `json:"output"`
  6211. RefmsgTime string `json:"refmsg_time"`
  6212. RespondTime string `json:"respond_time"`
  6213. Signtype interface{} `json:"signtype"`
  6214. WarnInfo interface{} `json:"warn_info"`
  6215. }
  6216. type ResultThirteen10265 struct {
  6217. ErrMsg string `json:"err_msg"`
  6218. InfRefmsgid string `json:"inf_refmsgid"`
  6219. Infcode string `json:"infcode"`
  6220. Output struct {
  6221. Result struct {
  6222. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6223. } `json:"result"`
  6224. } `json:"output"`
  6225. RefmsgTime string `json:"refmsg_time"`
  6226. RespondTime string `json:"respond_time"`
  6227. Signtype interface{} `json:"signtype"`
  6228. WarnInfo interface{} `json:"warn_info"`
  6229. }
  6230. type ResultFourteen struct {
  6231. ErrMsg string `json:"err_msg"`
  6232. InfRefmsgid string `json:"inf_refmsgid"`
  6233. Infcode int64 `json:"infcode"`
  6234. Output struct {
  6235. } `json:"output"`
  6236. RefmsgTime string `json:"refmsg_time"`
  6237. RespondTime string `json:"respond_time"`
  6238. Signtype interface{} `json:"signtype"`
  6239. WarnInfo interface{} `json:"warn_info"`
  6240. }
  6241. type ResultFourteen10265 struct {
  6242. ErrMsg string `json:"err_msg"`
  6243. InfRefmsgid string `json:"inf_refmsgid"`
  6244. Infcode string `json:"infcode"`
  6245. Output struct {
  6246. } `json:"output"`
  6247. RefmsgTime string `json:"refmsg_time"`
  6248. RespondTime string `json:"respond_time"`
  6249. Signtype interface{} `json:"signtype"`
  6250. WarnInfo interface{} `json:"warn_info"`
  6251. }
  6252. type ResultSixteen struct {
  6253. Cainfo string `json:"cainfo"`
  6254. ErrMsg string `json:"err_msg"`
  6255. InfRefmsgid string `json:"inf_refmsgid"`
  6256. Infcode int64 `json:"infcode"`
  6257. Output struct {
  6258. Setldetail []interface{} `json:"setldetail"`
  6259. Setlinfo struct {
  6260. MdtrtID string `json:"mdtrt_id"`
  6261. SetlID string `json:"setl_id"`
  6262. ClrOptins string `json:"clr_optins"`
  6263. SetlTime string `json:"setl_time"`
  6264. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6265. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6266. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6267. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6268. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6269. ActPayDedc float64 `json:"act_pay_dedc"`
  6270. HifpPay float64 `json:"hifp_pay"`
  6271. PoolPropSe float64 `json:"pool_prop_selfpay"`
  6272. Lfpay float64 `json:"selfpay"`
  6273. CvlservPay float64 `json:"cvlserv_pay"`
  6274. HifesPay float64 `json:"hifes_pay"`
  6275. HifmiPay float64 `json:"hifmi_pay"`
  6276. HifobPay float64 `json:"hifob_pay"`
  6277. MafPay float64 `json:"maf_pay"`
  6278. OthPay float64 `json:"oth_pay"`
  6279. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6280. PsnPartAmt float64 `json:"psn_part_amt"`
  6281. AcctPay float64 `json:"acct_pay"`
  6282. Balc float64 `json:"balc"`
  6283. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6284. HospPartAmt float64 `json:"hosp_part_amt"`
  6285. MedinsSetlID string `json:"medins_setl_id"`
  6286. PdnCashPay string `json:"pdn_cash_pay"`
  6287. } `json:"setlinfo"`
  6288. } `json:"output"`
  6289. RefmsgTime string `json:"refmsg_time"`
  6290. RespondTime string `json:"respond_time"`
  6291. Signtype interface{} `json:"signtype"`
  6292. WarnMsg interface{} `json:"warn_msg"`
  6293. }
  6294. type ResultSixteen10265 struct {
  6295. Cainfo string `json:"cainfo"`
  6296. ErrMsg string `json:"err_msg"`
  6297. InfRefmsgid string `json:"inf_refmsgid"`
  6298. Infcode string `json:"infcode"`
  6299. Output struct {
  6300. Setldetail []interface{} `json:"setldetail"`
  6301. Setlinfo struct {
  6302. MdtrtID string `json:"mdtrt_id"`
  6303. SetlID string `json:"setl_id"`
  6304. ClrOptins string `json:"clr_optins"`
  6305. SetlTime string `json:"setl_time"`
  6306. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6307. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6308. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6309. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6310. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6311. ActPayDedc float64 `json:"act_pay_dedc"`
  6312. HifpPay float64 `json:"hifp_pay"`
  6313. PoolPropSe float64 `json:"pool_prop_selfpay"`
  6314. Lfpay float64 `json:"selfpay"`
  6315. CvlservPay float64 `json:"cvlserv_pay"`
  6316. HifesPay float64 `json:"hifes_pay"`
  6317. HifmiPay float64 `json:"hifmi_pay"`
  6318. HifobPay float64 `json:"hifob_pay"`
  6319. MafPay float64 `json:"maf_pay"`
  6320. OthPay float64 `json:"oth_pay"`
  6321. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6322. PsnPartAmt float64 `json:"psn_part_amt"`
  6323. AcctPay float64 `json:"acct_pay"`
  6324. Balc float64 `json:"balc"`
  6325. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6326. HospPartAmt float64 `json:"hosp_part_amt"`
  6327. MedinsSetlID string `json:"medins_setl_id"`
  6328. PdnCashPay string `json:"pdn_cash_pay"`
  6329. } `json:"setlinfo"`
  6330. } `json:"output"`
  6331. RefmsgTime string `json:"refmsg_time"`
  6332. RespondTime string `json:"respond_time"`
  6333. Signtype interface{} `json:"signtype"`
  6334. WarnMsg interface{} `json:"warn_msg"`
  6335. }
  6336. type ResultSeventeen struct {
  6337. ErrMsg string `json:"err_msg"`
  6338. InfRefmsgid string `json:"inf_refmsgid"`
  6339. Infcode int64 `json:"infcode"`
  6340. Output struct {
  6341. SetlListId string `json:"setl_list_id"`
  6342. } `json:"output"`
  6343. RefmsgTime string `json:"refmsg_time"`
  6344. RespondTime string `json:"respond_time"`
  6345. Signtype string `json:"signtype"`
  6346. WarnInfo string `json:"warn_info"`
  6347. }
  6348. type ResultSeventeenOther struct {
  6349. ErrMsg string `json:"err_msg"`
  6350. InfRefmsgid string `json:"inf_refmsgid"`
  6351. Infcode string `json:"infcode"`
  6352. Output struct {
  6353. SetlListId string `json:"setl_list_id"`
  6354. } `json:"output"`
  6355. RefmsgTime string `json:"refmsg_time"`
  6356. RespondTime string `json:"respond_time"`
  6357. Signtype string `json:"signtype"`
  6358. WarnInfo string `json:"warn_info"`
  6359. }
  6360. type Result90991 struct {
  6361. ErrMsg string `json:"err_msg"`
  6362. InfRefmsgid string `json:"inf_refmsgid"`
  6363. Infcode int64 `json:"infcode"`
  6364. Output struct {
  6365. Result struct {
  6366. PsnNo string `json:"psn_no"`
  6367. CardStat string `json:"card_stat"`
  6368. Certno string `json:"certno"`
  6369. PsnName string `json:"psn_name"`
  6370. CheckStat string `json:"check_stat"`
  6371. SscnoCheckStat string `json:"sscno_check_stat"`
  6372. } `json:"result"`
  6373. } `json:"output"`
  6374. RefmsgTime string `json:"refmsg_time"`
  6375. RespondTime string `json:"respond_time"`
  6376. Signtype interface{} `json:"signtype"`
  6377. WarnInfo interface{} `json:"warn_info"`
  6378. }
  6379. type Result90100 struct {
  6380. ErrMsg string `json:"err_msg"`
  6381. InfRefmsgid string `json:"inf_refmsgid"`
  6382. Infcode int64 `json:"infcode"`
  6383. Output struct {
  6384. PoolareaNo string `json:"poolarea_no"`
  6385. PoolareaNoName string `json:"poolarea_no_name"`
  6386. Insutype string `json:"insutype"`
  6387. InsutypeName string `json:"insutype_name"`
  6388. ClctType string `json:"clct_type"`
  6389. ClctTypeName string `json:"clct_type_name"`
  6390. ClctFlag string `json:"clct_flag"`
  6391. ClctFlagName string `json:"clct_flag_name"`
  6392. AccrymBegn string `json:"accrym_begn"`
  6393. AccrymEnd string `json:"accrym_end"`
  6394. ClctTime string `json:"clct_time"`
  6395. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  6396. } `json:"output"`
  6397. RefmsgTime string `json:"refmsg_time"`
  6398. RespondTime string `json:"respond_time"`
  6399. Signtype interface{} `json:"signtype"`
  6400. WarnInfo interface{} `json:"warn_info"`
  6401. }
  6402. type Custom struct {
  6403. DetItemFeeSumamt string
  6404. Cut string
  6405. FeedetlSn string
  6406. Price string
  6407. MedListCodg string
  6408. Type int64
  6409. AdviceId int64
  6410. ProjectId int64
  6411. ItemId int64
  6412. }
  6413. type Result5301 struct {
  6414. ErrMsg string `json:"err_msg"`
  6415. InfRefmsgid string `json:"inf_refmsgid"`
  6416. Infcode int64 `json:"infcode"`
  6417. Output struct {
  6418. Result []struct {
  6419. OpspDiseCode string `json:"opsp_dise_code"`
  6420. OpspDiseName string `json:"opsp_dise_name"`
  6421. Begndate string `json:"begndate"`
  6422. Enddate string `json:"enddate"`
  6423. } `json:"feedetail"`
  6424. } `json:"output"`
  6425. RefmsgTime string `json:"refmsg_time"`
  6426. RespondTime string `json:"respond_time"`
  6427. Signtype interface{} `json:"signtype"`
  6428. WarnInfo interface{} `json:"warn_info"`
  6429. }
  6430. type Result5301For10265 struct {
  6431. ErrMsg string `json:"err_msg"`
  6432. InfRefmsgid string `json:"inf_refmsgid"`
  6433. Infcode string `json:"infcode"`
  6434. Output struct {
  6435. Result []struct {
  6436. OpspDiseCode string `json:"opsp_dise_code"`
  6437. OpspDiseName string `json:"opsp_dise_name"`
  6438. Begndate string `json:"begndate"`
  6439. Enddate string `json:"enddate"`
  6440. } `json:"feedetail"`
  6441. } `json:"output"`
  6442. RefmsgTime string `json:"refmsg_time"`
  6443. RespondTime string `json:"respond_time"`
  6444. Signtype interface{} `json:"signtype"`
  6445. WarnInfo interface{} `json:"warn_info"`
  6446. }
  6447. //获取个人信息----挂号-----上传就诊信息
  6448. func (c *HisApiController) GetRegisterInfo() {
  6449. id, _ := c.GetInt64("id")
  6450. record_time := c.GetString("record_time")
  6451. settlementValue, _ := c.GetInt64("settlement_value")
  6452. medical_insurance_card := c.GetString("medical_insurance_card")
  6453. name := c.GetString("name")
  6454. id_card_type, _ := c.GetInt64("id_card_type")
  6455. certificates, _ := c.GetInt64("certificates")
  6456. medical_care, _ := c.GetInt64("medical_care")
  6457. birthday := c.GetString("birthday")
  6458. id_card := c.GetString("id_card")
  6459. register_type, _ := c.GetInt64("register")
  6460. doctor, _ := c.GetInt64("doctor")
  6461. department, _ := c.GetInt64("department")
  6462. gender, _ := c.GetInt64("sex")
  6463. registration_fee, _ := c.GetFloat("registration_fee")
  6464. medical_expenses, _ := c.GetFloat("medical_expenses")
  6465. social_type, _ := c.GetInt64("social_type")
  6466. med_type := c.GetString("social_type")
  6467. admin_user_id, _ := c.GetInt64("admin_user_id")
  6468. insuplc_admdvs := c.GetString("insuplc_admdvs")
  6469. timeLayout := "2006-01-02"
  6470. loc, _ := time.LoadLocation("Local")
  6471. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  6472. birthUnix := birthdays.Unix()
  6473. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6474. if err != nil {
  6475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6476. return
  6477. }
  6478. recordDateTime := theTime.Unix()
  6479. adminInfo := c.GetAdminUserInfo()
  6480. var patient service.Patients
  6481. if id == 0 {
  6482. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  6483. } else {
  6484. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  6485. }
  6486. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6487. if patientPrescription.ID == 0 {
  6488. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6489. }
  6490. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6491. if patient.ID == 0 {
  6492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6493. return
  6494. }
  6495. if len(patient.IdCardNo) == 0 {
  6496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  6497. return
  6498. }
  6499. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6500. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  6501. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  6502. //就诊结算未完成,不能进行二次挂号
  6503. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  6504. if len(his) >= 1 {
  6505. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  6506. if len(his) >= 1 && order.ID == 0 {
  6507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  6508. return
  6509. }
  6510. }
  6511. //var register_log string
  6512. if config.IsOpen == 1 {
  6513. var res ResultTwo
  6514. var res10265 ResultTwo10265
  6515. var PsnNo string
  6516. var PsnCertType string
  6517. var Certno string
  6518. var PsnName string
  6519. var Gend string
  6520. var Naty string
  6521. var Brdy string
  6522. var Age float64
  6523. var infoStr string
  6524. var idetinfoStr string
  6525. var infocode int64
  6526. var verify_number string
  6527. fmt.Println(verify_number)
  6528. if miConfig.MdtrtareaAdmvs == "421300" {
  6529. psn_info, _ := service.GetPsnByPatientId(id)
  6530. PsnNo = psn_info.PsnNo
  6531. PsnCertType = psn_info.PsnCertType
  6532. Certno = psn_info.Certno
  6533. PsnName = psn_info.PsnName
  6534. Gend = psn_info.Gend
  6535. Naty = psn_info.Naty
  6536. Brdy = psn_info.Brdy
  6537. Age = psn_info.Age
  6538. infoStr = psn_info.Insuinfo
  6539. idetinfoStr = psn_info.Idetinfo
  6540. infocode = 0
  6541. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6542. psn_info, _ := service.GetPsnByPatientId(id)
  6543. PsnNo = psn_info.PsnNo
  6544. PsnCertType = psn_info.PsnCertType
  6545. Certno = psn_info.Certno
  6546. PsnName = psn_info.PsnName
  6547. Gend = psn_info.Gend
  6548. Naty = psn_info.Naty
  6549. Brdy = psn_info.Brdy
  6550. Age = psn_info.Age
  6551. infoStr = psn_info.Insuinfo
  6552. idetinfoStr = psn_info.Idetinfo
  6553. infocode = 0
  6554. verify_number = psn_info.VerifyNumber
  6555. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6556. if id_card_type == 1 {
  6557. psn_info, _ := service.GetPsnByPatientId(id)
  6558. PsnNo = psn_info.PsnNo
  6559. PsnCertType = psn_info.PsnCertType
  6560. Certno = psn_info.Certno
  6561. PsnName = psn_info.PsnName
  6562. Gend = psn_info.Gend
  6563. Naty = psn_info.Naty
  6564. Brdy = psn_info.Brdy
  6565. Age = psn_info.Age
  6566. infoStr = psn_info.Insuinfo
  6567. idetinfoStr = psn_info.Idetinfo
  6568. infocode = 0
  6569. verify_number = psn_info.VerifyNumber
  6570. } else if id_card_type == 2 {
  6571. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  6572. fmt.Println(errMsgLog)
  6573. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6574. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6575. utils.ErrorLog("解析失败:%v", err)
  6576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6577. return
  6578. }
  6579. PsnNo = res.Output.Baseinfo.PsnNo
  6580. PsnCertType = res.Output.Baseinfo.PsnCertType
  6581. Certno = res.Output.Baseinfo.Certno
  6582. PsnName = res.Output.Baseinfo.PsnName
  6583. Gend = res.Output.Baseinfo.Gend
  6584. Naty = res.Output.Baseinfo.Naty
  6585. Brdy = res.Output.Baseinfo.Brdy
  6586. Age = res.Output.Baseinfo.Age
  6587. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6588. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6589. infoStr = string(Iinfos)
  6590. idetinfoStr = string(Idetinfos)
  6591. infocode = res.Infcode
  6592. }
  6593. } else if miConfig.MdtrtareaAdmvs == "360399" {
  6594. if id_card_type == 1 {
  6595. psn_info, _ := service.GetPsnByPatientId(id)
  6596. PsnNo = psn_info.PsnNo
  6597. PsnCertType = psn_info.PsnCertType
  6598. Certno = psn_info.Certno
  6599. PsnName = psn_info.PsnName
  6600. Gend = psn_info.Gend
  6601. Naty = psn_info.Naty
  6602. Brdy = psn_info.Brdy
  6603. Age = psn_info.Age
  6604. infoStr = psn_info.Insuinfo
  6605. idetinfoStr = psn_info.Idetinfo
  6606. infocode = 0
  6607. verify_number = psn_info.VerifyNumber
  6608. } else if id_card_type == 2 {
  6609. result, requestLog := service.Jxyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "")
  6610. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6611. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6612. utils.ErrorLog("解析失败:%v", err)
  6613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6614. return
  6615. }
  6616. PsnNo = res.Output.Baseinfo.PsnNo
  6617. PsnCertType = res.Output.Baseinfo.PsnCertType
  6618. Certno = res.Output.Baseinfo.Certno
  6619. PsnName = res.Output.Baseinfo.PsnName
  6620. Gend = res.Output.Baseinfo.Gend
  6621. Naty = res.Output.Baseinfo.Naty
  6622. Brdy = res.Output.Baseinfo.Brdy
  6623. Age = res.Output.Baseinfo.Age
  6624. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6625. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6626. infoStr = string(Iinfos)
  6627. idetinfoStr = string(Idetinfos)
  6628. infocode = res.Infcode
  6629. }
  6630. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6631. if id_card_type == 1 {
  6632. psn_info, _ := service.GetPsnByPatientId(id)
  6633. PsnNo = psn_info.PsnNo
  6634. PsnCertType = psn_info.PsnCertType
  6635. Certno = psn_info.Certno
  6636. PsnName = psn_info.PsnName
  6637. Gend = psn_info.Gend
  6638. Naty = psn_info.Naty
  6639. Brdy = psn_info.Brdy
  6640. Age = psn_info.Age
  6641. infoStr = psn_info.Insuinfo
  6642. idetinfoStr = psn_info.Idetinfo
  6643. infocode = 0
  6644. verify_number = psn_info.VerifyNumber
  6645. } else if id_card_type == 2 {
  6646. result, requestLog := service.Hnyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", "", Certno)
  6647. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6648. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6649. utils.ErrorLog("解析失败:%v", err)
  6650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6651. return
  6652. }
  6653. PsnNo = res.Output.Baseinfo.PsnNo
  6654. PsnCertType = res.Output.Baseinfo.PsnCertType
  6655. Certno = res.Output.Baseinfo.Certno
  6656. PsnName = res.Output.Baseinfo.PsnName
  6657. Gend = res.Output.Baseinfo.Gend
  6658. Naty = res.Output.Baseinfo.Naty
  6659. Brdy = res.Output.Baseinfo.Brdy
  6660. Age = res.Output.Baseinfo.Age
  6661. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6662. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6663. infoStr = string(Iinfos)
  6664. idetinfoStr = string(Idetinfos)
  6665. infocode = res.Infcode
  6666. }
  6667. } else if miConfig.MdtrtareaAdmvs == "131023" {
  6668. var result string
  6669. var requestLog string
  6670. result, requestLog = service.HeBeiyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), "")
  6671. if id_card_type == 4 {
  6672. psn_info, _ := service.GetPsnByPatientId(id)
  6673. PsnNo = psn_info.PsnNo
  6674. PsnCertType = psn_info.PsnCertType
  6675. Certno = psn_info.Certno
  6676. PsnName = psn_info.PsnName
  6677. Gend = psn_info.Gend
  6678. Naty = psn_info.Naty
  6679. Brdy = psn_info.Brdy
  6680. Age = psn_info.Age
  6681. infoStr = psn_info.Insuinfo
  6682. idetinfoStr = psn_info.Idetinfo
  6683. infocode = 0
  6684. verify_number = psn_info.VerifyNumber
  6685. } else {
  6686. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6687. if miConfig.Code == "H15049901371" {
  6688. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6689. utils.ErrorLog("解析失败:%v", err)
  6690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6691. return
  6692. }
  6693. res.ErrMsg = res10265.ErrMsg
  6694. res.Output = res10265.Output
  6695. res.InfRefmsgid = res10265.InfRefmsgid
  6696. } else {
  6697. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6698. utils.ErrorLog("解析失败:%v", err)
  6699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6700. return
  6701. }
  6702. }
  6703. PsnNo = res.Output.Baseinfo.PsnNo
  6704. PsnCertType = res.Output.Baseinfo.PsnCertType
  6705. Certno = res.Output.Baseinfo.Certno
  6706. PsnName = res.Output.Baseinfo.PsnName
  6707. Gend = res.Output.Baseinfo.Gend
  6708. Naty = res.Output.Baseinfo.Naty
  6709. Brdy = res.Output.Baseinfo.Brdy
  6710. Age = res.Output.Baseinfo.Age
  6711. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6712. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6713. infoStr = string(Iinfos)
  6714. idetinfoStr = string(Idetinfos)
  6715. if miConfig.Code == "H15049901371" {
  6716. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  6717. } else {
  6718. infocode = res.Infcode
  6719. }
  6720. }
  6721. } else {
  6722. var result string
  6723. var requestLog string
  6724. if miConfig.UserOrgId == 10138 {
  6725. if id_card_type != 4 {
  6726. //psn_info, _ := service.GetPsnByPatientId(id)
  6727. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  6728. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  6729. }
  6730. } else {
  6731. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  6732. }
  6733. if id_card_type == 4 {
  6734. psn_info, _ := service.GetPsnByPatientId(id)
  6735. PsnNo = psn_info.PsnNo
  6736. PsnCertType = psn_info.PsnCertType
  6737. Certno = psn_info.Certno
  6738. PsnName = psn_info.PsnName
  6739. Gend = psn_info.Gend
  6740. Naty = psn_info.Naty
  6741. Brdy = psn_info.Brdy
  6742. Age = psn_info.Age
  6743. infoStr = psn_info.Insuinfo
  6744. idetinfoStr = psn_info.Idetinfo
  6745. infocode = 0
  6746. verify_number = psn_info.VerifyNumber
  6747. } else {
  6748. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6749. if miConfig.Code == "H15049901371" {
  6750. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6751. utils.ErrorLog("解析失败:%v", err)
  6752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6753. return
  6754. }
  6755. res.ErrMsg = res10265.ErrMsg
  6756. res.Output = res10265.Output
  6757. res.InfRefmsgid = res10265.InfRefmsgid
  6758. } else {
  6759. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6760. utils.ErrorLog("解析失败:%v", err)
  6761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6762. return
  6763. }
  6764. }
  6765. PsnNo = res.Output.Baseinfo.PsnNo
  6766. PsnCertType = res.Output.Baseinfo.PsnCertType
  6767. Certno = res.Output.Baseinfo.Certno
  6768. PsnName = res.Output.Baseinfo.PsnName
  6769. Gend = res.Output.Baseinfo.Gend
  6770. Naty = res.Output.Baseinfo.Naty
  6771. Brdy = res.Output.Baseinfo.Brdy
  6772. Age = res.Output.Baseinfo.Age
  6773. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6774. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6775. infoStr = string(Iinfos)
  6776. idetinfoStr = string(Idetinfos)
  6777. if miConfig.Code == "H15049901371" {
  6778. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  6779. } else {
  6780. infocode = res.Infcode
  6781. }
  6782. }
  6783. }
  6784. if infocode == 0 {
  6785. his := models.VMHisPatient{
  6786. Name: name,
  6787. Gender: gender,
  6788. Birthday: birthUnix,
  6789. MedicalTreatmentType: medical_care,
  6790. IdType: certificates,
  6791. IdCardNo: id_card,
  6792. BalanceAccountsType: settlementValue,
  6793. SocialType: social_type,
  6794. MedicalInsuranceNumber: medical_insurance_card,
  6795. RegisterType: register_type,
  6796. RegisterCost: registration_fee,
  6797. TreatmentCost: medical_expenses,
  6798. Status: 1,
  6799. Ctime: time.Now().Unix(),
  6800. Mtime: time.Now().Unix(),
  6801. PsnNo: PsnNo,
  6802. PsnCertType: PsnCertType,
  6803. Certno: Certno,
  6804. PsnName: PsnName,
  6805. Gend: Gend,
  6806. Naty: Naty,
  6807. Brdy: Brdy,
  6808. Age: Age,
  6809. Iinfo: infoStr,
  6810. Idetinfo: idetinfoStr,
  6811. PatientId: patient.ID,
  6812. RecordDate: theTime.Unix(),
  6813. UserOrgId: adminInfo.CurrentOrgId,
  6814. AdminUserId: admin_user_id,
  6815. IsReturn: 1,
  6816. IdCardType: id_card_type,
  6817. Doctor: doctor,
  6818. Departments: department,
  6819. }
  6820. timestamp := time.Now().Unix()
  6821. tempTime := time.Unix(timestamp, 0)
  6822. timeFormat := tempTime.Format("20060102150405")
  6823. chrgBchno := rand.Intn(100000) + 10000
  6824. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6825. his.Number = ipt_otp_no
  6826. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  6827. department, _ := service.GetDepartMentDetail(department)
  6828. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  6829. IdCardNo := ""
  6830. if id_card_type == 1 {
  6831. // IdCardNo = medical_insurance_card
  6832. IdCardNo = patient.IdCardNo
  6833. } else {
  6834. IdCardNo = patient.IdCardNo
  6835. }
  6836. var rf []*ResultFive
  6837. json.Unmarshal([]byte(his.Iinfo), &rf)
  6838. var insutypes []*ResultFive
  6839. var insutype string
  6840. var insuplc_admdvs_temp string
  6841. var is390 int = 0
  6842. var is310 int = 0
  6843. for _, item := range rf {
  6844. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6845. insutypes = append(insutypes, item)
  6846. }
  6847. }
  6848. if len(insutypes) == 1 {
  6849. insutype = insutypes[0].Insutype
  6850. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6851. } else {
  6852. for _, i := range insutypes {
  6853. if i.Insutype == "390" {
  6854. is390 = 1
  6855. }
  6856. if i.Insutype == "310" {
  6857. is310 = 1
  6858. }
  6859. }
  6860. }
  6861. if is390 == 1 {
  6862. insutype = "390"
  6863. }
  6864. if is310 == 1 {
  6865. insutype = "310"
  6866. }
  6867. if len(insutypes) == 0 {
  6868. insutype = "310"
  6869. }
  6870. if len(insutypes) == 2 {
  6871. insutype = med_type
  6872. }
  6873. if len(med_type) > 0 {
  6874. insutype = med_type
  6875. }
  6876. var infocode int64
  6877. var resThree ResultThree
  6878. var resThree10265 ResultThree10265
  6879. if len(insuplc_admdvs) == 0 {
  6880. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  6881. } else {
  6882. insuplc_admdvs_temp = insuplc_admdvs
  6883. }
  6884. if miConfig.MdtrtareaAdmvs == "350500" {
  6885. var rf []ResultIDInfo
  6886. psn_info, _ := service.GetPsnByPatientId(id)
  6887. fmt.Println(psn_info.Idetinfo)
  6888. fmt.Println("11111111111111112222222")
  6889. json.Unmarshal([]byte(psn_info.Idetinfo), &rf)
  6890. fmt.Println("11111111111111112222222")
  6891. fmt.Println(rf)
  6892. fmt.Println("11111111111111112222222")
  6893. if len(rf) > 0 {
  6894. fmt.Println("222222222222222222222222c22222222222222222")
  6895. fmt.Println(rf[0].Memo)
  6896. fmt.Println(rf[0].Memo.InsuAdmdvs)
  6897. if len(rf[0].Memo.InsuAdmdvs) > 0 {
  6898. insuplc_admdvs_temp = rf[0].Memo.InsuAdmdvs
  6899. }
  6900. }
  6901. }
  6902. if miConfig.MdtrtareaAdmvs == "421300" {
  6903. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  6904. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  6905. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6906. "&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
  6907. resp, requestErr := http.Get(api)
  6908. if requestErr != nil {
  6909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6910. return
  6911. }
  6912. body, ioErr := ioutil.ReadAll(resp.Body)
  6913. if ioErr != nil {
  6914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6916. return
  6917. }
  6918. var respJSON map[string]interface{}
  6919. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6922. return
  6923. }
  6924. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6925. result, _ := json.Marshal(respJSON)
  6926. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6927. utils.ErrorLog("解析失败:%v", err)
  6928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6929. return
  6930. }
  6931. infocode = resThree.Infcode
  6932. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6933. psn_info, _ := service.GetPsnByPatientId(id)
  6934. his.PsnNo = psn_info.PsnNo
  6935. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6936. var cert_no string
  6937. if id_card_type == 3 {
  6938. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  6939. cert_no = IdCardNo
  6940. } else if id_card_type == 4 {
  6941. cert_no = IdCardNo
  6942. psn_info.VerifyNumber = psn_info.VerifyNumber
  6943. } else {
  6944. bas := strings.Split(psn_info.CardInfo, "|")
  6945. cert_no = bas[2]
  6946. }
  6947. var hisPrescription []*models.HisPrescription
  6948. for _, item := range rf {
  6949. if item.Insutype == insutype {
  6950. //insuplc_admdvs = item.InsuplcAdmdvs
  6951. his.InsuplcAdmdvs = insuplc_admdvs
  6952. }
  6953. }
  6954. his.Insutype = insutype
  6955. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  6956. fmt.Println(res3101)
  6957. fmt.Println(res3101.Infcode)
  6958. if res3101.Infcode == "0" {
  6959. fmt.Println("33333333")
  6960. if len(res3101.Output.Result) > 0 {
  6961. fmt.Println("222222")
  6962. for _, item := range res3101.Output.Result {
  6963. if len(res3101.ErrMsg) == 0 {
  6964. res3101.ErrMsg = item.VolaCont
  6965. } else {
  6966. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  6967. }
  6968. }
  6969. c.ServeSuccessJSON(map[string]interface{}{
  6970. "failed_code": -10,
  6971. "msg": res3101.ErrMsg,
  6972. })
  6973. return
  6974. } else {
  6975. fmt.Println("11111")
  6976. var api string
  6977. if miConfig.MdtrtareaAdmvs == "320921" {
  6978. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6979. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6980. "&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
  6981. } else {
  6982. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6983. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6984. "&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
  6985. }
  6986. resp, requestErr := http.Get(api)
  6987. if requestErr != nil {
  6988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6989. return
  6990. }
  6991. body, ioErr := ioutil.ReadAll(resp.Body)
  6992. if ioErr != nil {
  6993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6995. return
  6996. }
  6997. var respJSON map[string]interface{}
  6998. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7001. return
  7002. }
  7003. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7004. result, _ := json.Marshal(respJSON)
  7005. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7006. utils.ErrorLog("解析失败:%v", err)
  7007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7008. return
  7009. }
  7010. resThree.ErrMsg = resThree10265.ErrMsg
  7011. resThree.Output = resThree10265.Output
  7012. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7013. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7014. }
  7015. } else if res3101.Infcode != "0" {
  7016. c.ServeSuccessJSON(map[string]interface{}{
  7017. "failed_code": -10,
  7018. "msg": res3101.ErrMsg,
  7019. })
  7020. return
  7021. }
  7022. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7023. psn_info, _ := service.GetPsnByPatientId(id)
  7024. var cert_no string
  7025. if id_card_type == 1 {
  7026. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  7027. } else if id_card_type == 4 {
  7028. cert_no = psn_info.VerifyNumber
  7029. } else {
  7030. cert_no = psn_info.VerifyNumber
  7031. }
  7032. 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)
  7033. saveLog(result, requestLog, "2201", "挂号")
  7034. if miConfig.Code == "H15049901371" {
  7035. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7036. utils.ErrorLog("解析失败:%v", err)
  7037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7038. return
  7039. }
  7040. resThree.ErrMsg = resThree10265.ErrMsg
  7041. resThree.Output = resThree10265.Output
  7042. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7043. } else {
  7044. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7045. utils.ErrorLog("解析失败:%v", err)
  7046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7047. return
  7048. }
  7049. }
  7050. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7051. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  7052. psn_info, _ := service.GetPsnByPatientId(id)
  7053. var result string
  7054. var requestLog string
  7055. if id_card_type == 1 {
  7056. bas := strings.Split(psn_info.CardInfo, "|")
  7057. basNumber := bas[2]
  7058. card_sn := bas[3]
  7059. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.MdtrtareaAdmvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn)
  7060. saveLog(result, requestLog, "2201A", "挂号")
  7061. } else if id_card_type == 2 {
  7062. 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, "", "")
  7063. saveLog(result, requestLog, "2201A", "挂号")
  7064. } else {
  7065. 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, "", "")
  7066. saveLog(result, requestLog, "2201A", "挂号")
  7067. }
  7068. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7069. utils.ErrorLog("解析失败:%v", err)
  7070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7071. return
  7072. }
  7073. infocode = resThree.Infcode
  7074. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  7075. psn_info, _ := service.GetPsnByPatientId(id)
  7076. var result string
  7077. var requestLog string
  7078. if id_card_type == 1 {
  7079. bas := strings.Split(psn_info.CardInfo, "|")
  7080. basNumber := bas[2]
  7081. card_sn := bas[3]
  7082. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.MdtrtareaAdmvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn)
  7083. saveLog(result, requestLog, "2201A", "挂号")
  7084. } else if id_card_type == 2 {
  7085. 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, "", "")
  7086. saveLog(result, requestLog, "2201A", "挂号")
  7087. } else {
  7088. 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, "", "")
  7089. saveLog(result, requestLog, "2201A", "挂号")
  7090. }
  7091. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7092. utils.ErrorLog("解析失败:%v", err)
  7093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7094. return
  7095. }
  7096. infocode = resThree.Infcode
  7097. } else if miConfig.MdtrtareaAdmvs == "131023" {
  7098. psn_info, _ := service.GetPsnByPatientId(id)
  7099. 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)
  7100. saveLog(result, requestLog, "2201A", "挂号")
  7101. if miConfig.Code == "H15049901371" {
  7102. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7103. utils.ErrorLog("解析失败:%v", err)
  7104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7105. return
  7106. }
  7107. resThree.ErrMsg = resThree10265.ErrMsg
  7108. resThree.Output = resThree10265.Output
  7109. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7110. } else {
  7111. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7112. utils.ErrorLog("解析失败:%v", err)
  7113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7114. return
  7115. }
  7116. }
  7117. if miConfig.Code == "H15049901371" {
  7118. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7119. } else {
  7120. infocode = resThree.Infcode
  7121. }
  7122. } else {
  7123. psn_info, _ := service.GetPsnByPatientId(id)
  7124. 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)
  7125. saveLog(result, requestLog, "2201A", "挂号")
  7126. if miConfig.Code == "H15049901371" {
  7127. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7128. utils.ErrorLog("解析失败:%v", err)
  7129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7130. return
  7131. }
  7132. resThree.ErrMsg = resThree10265.ErrMsg
  7133. resThree.Output = resThree10265.Output
  7134. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7135. } else {
  7136. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7137. utils.ErrorLog("解析失败:%v", err)
  7138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7139. return
  7140. }
  7141. }
  7142. if miConfig.Code == "H15049901371" {
  7143. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7144. } else {
  7145. infocode = resThree.Infcode
  7146. }
  7147. }
  7148. if infocode != 0 {
  7149. adminUser := c.GetAdminUserInfo()
  7150. errlog := &models.HisOrderError{
  7151. UserOrgId: adminUser.CurrentOrgId,
  7152. Ctime: time.Now().Unix(),
  7153. Mtime: time.Now().Unix(),
  7154. ErrMsg: resThree.ErrMsg,
  7155. Status: 1,
  7156. PatientId: id,
  7157. RecordTime: recordDateTime,
  7158. Stage: 2,
  7159. }
  7160. service.CreateErrMsgLog(errlog)
  7161. c.ServeSuccessJSON(map[string]interface{}{
  7162. "failed_code": -10,
  7163. "msg": resThree.ErrMsg,
  7164. })
  7165. return
  7166. }
  7167. his.Number = resThree.Output.Data.MdtrtID
  7168. his.PsnNo = resThree.Output.Data.PsnNo
  7169. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  7170. his.IdCardNo = patient.IdCardNo
  7171. his.PhoneNumber = patient.Phone
  7172. his.UserOrgId = adminInfo.CurrentOrgId
  7173. his.Insutype = insutype
  7174. his.Ctime = time.Now().Unix()
  7175. his.Mtime = time.Now().Unix()
  7176. his.InsuplcAdmdvs = insuplc_admdvs_temp
  7177. his.Status = 1
  7178. service.UpdateHisPatientStatus(&his)
  7179. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  7180. c.ServeSuccessJSON(map[string]interface{}{
  7181. "his_info": his,
  7182. })
  7183. } else {
  7184. adminUser := c.GetAdminUserInfo()
  7185. errlog := &models.HisOrderError{
  7186. UserOrgId: adminUser.CurrentOrgId,
  7187. Ctime: time.Now().Unix(),
  7188. Mtime: time.Now().Unix(),
  7189. ErrMsg: res.ErrMsg,
  7190. Status: 1,
  7191. PatientId: id,
  7192. RecordTime: recordDateTime,
  7193. Stage: 1,
  7194. }
  7195. service.CreateErrMsgLog(errlog)
  7196. c.ServeSuccessJSON(map[string]interface{}{
  7197. "failed_code": -10,
  7198. "msg": res.ErrMsg,
  7199. })
  7200. return
  7201. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7202. }
  7203. }
  7204. }
  7205. //上传明细----预结算----确认订单
  7206. func (c *HisApiController) GetUploadInfo() {
  7207. id, _ := c.GetInt64("id")
  7208. record_time := c.GetString("record_time")
  7209. his_patient_id, _ := c.GetInt64("his_patient_id")
  7210. order_id, _ := c.GetInt64("order_id")
  7211. pay_way, _ := c.GetInt64("pay_way")
  7212. pay_price, _ := c.GetFloat("pay_price")
  7213. pay_card_no := c.GetString("pay_card_no")
  7214. discount_price, _ := c.GetFloat("discount_price")
  7215. preferential_price, _ := c.GetFloat("preferential_price")
  7216. reality_price, _ := c.GetFloat("reality_price")
  7217. found_price, _ := c.GetFloat("found_price")
  7218. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7219. private_price, _ := c.GetFloat("private_price")
  7220. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7221. admin_user_id, _ := c.GetInt64("admin_user_id")
  7222. fapiao_code := c.GetString("fapiao_code")
  7223. fapiao_number := c.GetString("fapiao_number")
  7224. diagnosis_id := c.GetString("diagnosis")
  7225. sick_type, _ := c.GetInt64("sick_type")
  7226. reg_type, _ := c.GetInt64("p_type")
  7227. begin_time := c.GetString("begin_time")
  7228. id_str := c.GetString("ids")
  7229. ids_arr := strings.Split(id_str, ",")
  7230. timeLayout := "2006-01-02"
  7231. loc, _ := time.LoadLocation("Local")
  7232. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7233. if err != nil {
  7234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7235. return
  7236. }
  7237. recordDateTime := theTime.Unix()
  7238. adminUser := c.GetAdminUserInfo()
  7239. var tempOrder models.HisOrder
  7240. tempOrder, _ = service.GetHisOrderByID(order_id)
  7241. var prescriptions []*models.HisPrescription
  7242. var start_time int64
  7243. var end_time int64
  7244. //押金模块
  7245. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  7246. tmp_decimal := c.GetString("tmp_decimal")
  7247. var decimal float64 //本次使用的押金
  7248. var errmsg error
  7249. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  7250. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  7251. return
  7252. }
  7253. if len(tmp_decimal) > 0 {
  7254. if tmp_decimal[0] == 45 {
  7255. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  7256. return
  7257. }
  7258. }
  7259. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  7260. fmt.Println(errs)
  7261. decimal = tt
  7262. //if adminUser.CurrentOrgId == 10106{
  7263. // if len(fapiao_code) == 0{
  7264. // fapiao_code = "144072080589"
  7265. // }
  7266. // if len(fapiao_number) == 0{
  7267. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  7268. // if order.ID == 0{
  7269. // fapiao_number = "00001520"
  7270. // }else{
  7271. // //fapiao_code = "00001520"
  7272. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  7273. // var zero string
  7274. // if fpNumber >= 1000{
  7275. // zero = "0000" + strconv.Itoa(fpNumber)
  7276. // }else if fpNumber >= 10000{
  7277. // zero = "000" + strconv.Itoa(fpNumber)
  7278. // } else if fpNumber >= 100000{
  7279. // zero = "00" + strconv.Itoa(fpNumber)
  7280. // } else if fpNumber >= 1000000{
  7281. // zero = "0" + strconv.Itoa(fpNumber)
  7282. // }else {
  7283. // zero = strconv.Itoa(fpNumber)
  7284. // }
  7285. // fapiao_number = zero
  7286. // }
  7287. // }
  7288. //}
  7289. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7290. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7291. var patientPrescription models.HisPrescriptionInfo
  7292. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7293. if patientPrescription.ID == 0 {
  7294. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7295. }
  7296. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7297. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7298. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7299. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7300. var config []*models.HisXtDiagnoseConfig
  7301. for _, item := range diagnosis_ids {
  7302. id, _ := strconv.ParseInt(item, 10, 64)
  7303. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7304. config = append(config, &diagnosisConfig)
  7305. }
  7306. sickConfig, _ := service.FindSickById(sick_type)
  7307. //if tempOrder.ID == 0 {
  7308. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  7309. //}
  7310. if tempOrder.ID == 0 {
  7311. var result string
  7312. var requestLog string
  7313. var res2 ResultSix
  7314. var ressix10265 ResultSix10265
  7315. if miConfig.MdtrtareaAdmvs == "421300" {
  7316. data := make(map[string]interface{})
  7317. client := &http.Client{}
  7318. data["psn_no"] = his.PsnNo
  7319. data["mdtrt_id"] = his.Number
  7320. data["opter"] = roles.UserName
  7321. data["org_name"] = miConfig.OrgName
  7322. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7323. data["doctor_id"] = doctor_info.DoctorNumber
  7324. data["doctor_name"] = doctor_info.UserName
  7325. data["department"] = department.Name
  7326. data["fixmedins_code"] = miConfig.Code
  7327. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7328. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7329. data["secret_key"] = miConfig.SecretKey
  7330. data["sick_code"] = sickConfig.CountryCode
  7331. data["sick_name"] = sickConfig.ClassName
  7332. data["dept"] = strconv.FormatInt(department.ID, 10)
  7333. data["config"] = config
  7334. data["begin_time"] = begin_time
  7335. bytesData, _ := json.Marshal(data)
  7336. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7337. resp, _ := client.Do(req)
  7338. defer resp.Body.Close()
  7339. body, ioErr := ioutil.ReadAll(resp.Body)
  7340. if ioErr != nil {
  7341. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7343. return
  7344. }
  7345. var respJSON map[string]interface{}
  7346. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7347. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7349. return
  7350. }
  7351. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7352. userJSONBytes, _ := json.Marshal(respJSON)
  7353. fmt.Println("log")
  7354. fmt.Println(string(userJSONBytes))
  7355. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7356. utils.ErrorLog("解析失败:%v", err)
  7357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7358. return
  7359. }
  7360. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7361. data := make(map[string]interface{})
  7362. client := &http.Client{}
  7363. data["psn_no"] = his.PsnNo
  7364. data["mdtrt_id"] = his.Number
  7365. data["doctor"] = roles.UserName
  7366. data["department"] = department.Name
  7367. data["org_name"] = miConfig.OrgName
  7368. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7369. data["doctor_id"] = doctor_info.DoctorNumber
  7370. data["new_doctor_name"] = doctor_info.UserName
  7371. data["fixmedins_code"] = miConfig.Code
  7372. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7373. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7374. data["secret_key"] = miConfig.SecretKey
  7375. data["sick_code"] = sickConfig.CountryCode
  7376. data["sick_name"] = sickConfig.ClassName
  7377. data["url"] = miConfig.Url
  7378. data["ak"] = miConfig.AccessKey
  7379. data["begin_time"] = begin_time
  7380. data["cainfo"] = miConfig.Cainfo
  7381. data["dept"] = strconv.FormatInt(department.ID, 10)
  7382. data["config"] = config
  7383. bytesData, _ := json.Marshal(data)
  7384. var req *http.Request
  7385. if miConfig.MdtrtareaAdmvs == "320921" {
  7386. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7387. //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 +
  7388. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7389. } else {
  7390. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7391. }
  7392. resp, _ := client.Do(req)
  7393. defer resp.Body.Close()
  7394. body, ioErr := ioutil.ReadAll(resp.Body)
  7395. if ioErr != nil {
  7396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7398. return
  7399. }
  7400. var respJSON map[string]interface{}
  7401. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7404. return
  7405. }
  7406. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7407. userJSONBytes, _ := json.Marshal(respJSON)
  7408. fmt.Println("log")
  7409. fmt.Println(string(userJSONBytes))
  7410. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  7411. utils.ErrorLog("解析失败:%v", err)
  7412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7413. return
  7414. }
  7415. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7416. res2.Output = ressix10265.Output
  7417. res2.ErrMsg = ressix10265.ErrMsg
  7418. res2.Cainfo = ressix10265.Cainfo
  7419. res2.WarnMsg = ressix10265.WarnMsg
  7420. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7421. res2.Infcode = infocode
  7422. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7423. 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)
  7424. saveLog(result, requestLog, "2203", "上传就诊信息")
  7425. var respJSON2 map[string]interface{}
  7426. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7429. return
  7430. }
  7431. userJSONBytes2, _ := json.Marshal(respJSON2)
  7432. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7433. utils.ErrorLog("解析失败:%v", err)
  7434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7435. return
  7436. }
  7437. } else {
  7438. if miConfig.MdtrtareaAdmvs == "440781" { //
  7439. 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)
  7440. } else {
  7441. if miConfig.Code == "H15049901371" {
  7442. //赤峰地区国家医保医疗类别
  7443. //职工透析:医疗类别选特殊情况门诊990502
  7444. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7445. var med_type string
  7446. if his.Insutype == "390" {
  7447. if reg_type == 14 {
  7448. med_type = "9933"
  7449. } else if reg_type == 11 {
  7450. med_type = "11"
  7451. }
  7452. } else if his.Insutype == "310" {
  7453. if reg_type == 14 {
  7454. med_type = "990502"
  7455. } else if reg_type == 11 {
  7456. med_type = "11"
  7457. }
  7458. }
  7459. 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)
  7460. } else {
  7461. 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)
  7462. }
  7463. }
  7464. saveLog(result, requestLog, "2203", "上传就诊信息")
  7465. var respJSON2 map[string]interface{}
  7466. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7469. return
  7470. }
  7471. userJSONBytes2, _ := json.Marshal(respJSON2)
  7472. if miConfig.Code == "H15049901371" {
  7473. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  7474. utils.ErrorLog("解析失败:%v", err)
  7475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7476. return
  7477. }
  7478. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7479. res2.Output = ressix10265.Output
  7480. res2.ErrMsg = ressix10265.ErrMsg
  7481. res2.Cainfo = ressix10265.Cainfo
  7482. res2.WarnMsg = ressix10265.WarnMsg
  7483. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7484. res2.Infcode = infocode
  7485. } else {
  7486. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7487. utils.ErrorLog("解析失败:%v", err)
  7488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7489. return
  7490. }
  7491. }
  7492. }
  7493. if res2.Infcode != 0 {
  7494. adminUser := c.GetAdminUserInfo()
  7495. errlog := &models.HisOrderError{
  7496. UserOrgId: adminUser.CurrentOrgId,
  7497. Ctime: time.Now().Unix(),
  7498. Mtime: time.Now().Unix(),
  7499. ErrMsg: res2.ErrMsg,
  7500. Status: 1,
  7501. PatientId: id,
  7502. RecordTime: recordDateTime,
  7503. Stage: 3,
  7504. }
  7505. service.CreateErrMsgLog(errlog)
  7506. c.ServeSuccessJSON(map[string]interface{}{
  7507. "failed_code": -10,
  7508. "msg": res2.ErrMsg,
  7509. })
  7510. return
  7511. } else {
  7512. his.Diagnosis = diagnosis_id
  7513. his.SickType = sickConfig.ID
  7514. //var p_type int64
  7515. //if reg_type == 1111 || reg_type == 1112 {
  7516. // p_type = 11
  7517. //
  7518. //}
  7519. his.PType = fmt.Sprintf("%d", reg_type)
  7520. service.UpdateHisPatientThree(&his)
  7521. data := make(map[string]interface{})
  7522. if settle_accounts_type == 1 { //日结
  7523. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7524. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7525. } else {
  7526. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7527. }
  7528. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  7529. data["pre"] = prescriptions
  7530. } else { //月结
  7531. start_time_str := c.GetString("start_time")
  7532. end_time_str := c.GetString("end_time")
  7533. timeLayout := "2006-01-02"
  7534. loc, _ := time.LoadLocation("Local")
  7535. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7536. if err != nil {
  7537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7538. return
  7539. }
  7540. recordStartTime := theStartTime.Unix()
  7541. start_time = recordStartTime
  7542. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7543. if err != nil {
  7544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7545. return
  7546. }
  7547. recordEndTime := theEndTime.Unix()
  7548. end_time = recordEndTime
  7549. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7550. data["pre"] = prescriptions
  7551. }
  7552. timestamp := time.Now().Unix()
  7553. tempTime := time.Unix(timestamp, 0)
  7554. timeFormat := tempTime.Format("20060102150405")
  7555. chrgBchno := rand.Intn(100000) + 10000
  7556. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7557. strconv.FormatInt(his.PatientId, 10)
  7558. client := &http.Client{}
  7559. data["psn_no"] = his.PsnNo
  7560. data["mdtrt_id"] = his.Number
  7561. data["chrg_bchno"] = chrg_bchno
  7562. data["org_name"] = miConfig.OrgName
  7563. data["doctor"] = doctor_info.UserName
  7564. data["doctor_id"] = doctor_info.DoctorNumber
  7565. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7566. data["fixmedins_code"] = miConfig.Code
  7567. data["opter"] = roles.UserName
  7568. data["dept_code"] = department.Number
  7569. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7570. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7571. data["secret_key"] = miConfig.SecretKey
  7572. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7573. data["url"] = miConfig.Url
  7574. data["ak"] = miConfig.AccessKey
  7575. data["new_doctor_name"] = patientPrescription.Doctor
  7576. data["diag_code"] = sickConfig.CountryCode
  7577. data["cainfo"] = miConfig.Cainfo
  7578. data["opter"] = roles.UserName
  7579. var ids []int64
  7580. for _, item := range prescriptions {
  7581. ids = append(ids, item.ID)
  7582. }
  7583. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7584. if config.IsOpen == 1 { //对接了医保,走医保流程
  7585. var res ResultFour
  7586. var resFour10265 ResultFour10265
  7587. if miConfig.MdtrtareaAdmvs == "421300" {
  7588. bytesData, _ := json.Marshal(data)
  7589. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7590. resp, _ := client.Do(req)
  7591. defer resp.Body.Close()
  7592. body, ioErr := ioutil.ReadAll(resp.Body)
  7593. if ioErr != nil {
  7594. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7596. return
  7597. }
  7598. var respJSON map[string]interface{}
  7599. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7602. return
  7603. }
  7604. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7605. userJSONBytes, _ := json.Marshal(respJSON)
  7606. fmt.Println("log")
  7607. fmt.Println(string(userJSONBytes))
  7608. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7609. utils.ErrorLog("解析失败:%v", err)
  7610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7611. return
  7612. }
  7613. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7614. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7615. if result3101.Infcode == "0" {
  7616. if len(result3101.Output.Result) > 0 {
  7617. var errMsgs []string
  7618. for _, item := range result3101.Output.Result {
  7619. errMsgs = append(errMsgs, item.VolaCont)
  7620. }
  7621. c.ServeSuccessJSON(map[string]interface{}{
  7622. "failed_code": -10,
  7623. "msg": errMsgs,
  7624. })
  7625. return
  7626. }
  7627. }
  7628. if miConfig.MdtrtareaAdmvs == "320921" {
  7629. data["doctor_id"] = "D320923012139"
  7630. } else {
  7631. data["doctor_id"] = "D371621008686"
  7632. }
  7633. bytesData, _ := json.Marshal(data)
  7634. var req *http.Request
  7635. if miConfig.MdtrtareaAdmvs == "320921" {
  7636. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7637. } else {
  7638. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7639. }
  7640. resp, _ := client.Do(req)
  7641. defer resp.Body.Close()
  7642. body, ioErr := ioutil.ReadAll(resp.Body)
  7643. if ioErr != nil {
  7644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7646. return
  7647. }
  7648. var respJSON map[string]interface{}
  7649. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7652. return
  7653. }
  7654. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7655. userJSONBytes, _ := json.Marshal(respJSON)
  7656. fmt.Println("log")
  7657. fmt.Println(string(userJSONBytes))
  7658. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7659. utils.ErrorLog("解析失败:%v", err)
  7660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7661. return
  7662. }
  7663. res.InfRefmsgid = resFour10265.InfRefmsgid
  7664. res.Output = resFour10265.Output
  7665. res.ErrMsg = resFour10265.ErrMsg
  7666. res.Cainfo = resFour10265.Cainfo
  7667. res.WarnMsg = resFour10265.WarnMsg
  7668. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7669. res.Infcode = infocode
  7670. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7671. 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)
  7672. var dat map[string]interface{}
  7673. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7674. fmt.Println(dat)
  7675. } else {
  7676. fmt.Println(err)
  7677. }
  7678. saveLog(result, request_log, "2204", "上传费用明细")
  7679. userJSONBytes, _ := json.Marshal(dat)
  7680. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7681. utils.ErrorLog("解析失败:%v", err)
  7682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7683. return
  7684. }
  7685. res.InfRefmsgid = resFour10265.InfRefmsgid
  7686. res.Output = resFour10265.Output
  7687. res.ErrMsg = resFour10265.ErrMsg
  7688. res.Cainfo = resFour10265.Cainfo
  7689. res.WarnMsg = resFour10265.WarnMsg
  7690. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7691. res.Infcode = infocode
  7692. } else {
  7693. if miConfig.Code == "H15049901371" {
  7694. 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)
  7695. var dat map[string]interface{}
  7696. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7697. fmt.Println(dat)
  7698. } else {
  7699. fmt.Println(err)
  7700. }
  7701. saveLog(result, request_log, "2204", "上传费用明细")
  7702. userJSONBytes, _ := json.Marshal(dat)
  7703. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7704. utils.ErrorLog("解析失败:%v", err)
  7705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7706. return
  7707. }
  7708. res.InfRefmsgid = resFour10265.InfRefmsgid
  7709. res.Output = resFour10265.Output
  7710. res.ErrMsg = resFour10265.ErrMsg
  7711. res.Cainfo = resFour10265.Cainfo
  7712. res.WarnMsg = resFour10265.WarnMsg
  7713. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7714. res.Infcode = infocode
  7715. } else {
  7716. 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)
  7717. var dat map[string]interface{}
  7718. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7719. fmt.Println(dat)
  7720. } else {
  7721. fmt.Println(err)
  7722. }
  7723. saveLog(result, request_log, "2204", "上传费用明细")
  7724. userJSONBytes, _ := json.Marshal(dat)
  7725. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7726. utils.ErrorLog("解析失败:%v", err)
  7727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7728. return
  7729. }
  7730. }
  7731. }
  7732. if res.Infcode == 0 {
  7733. order := &models.HisOrder{
  7734. UserOrgId: adminUser.CurrentOrgId,
  7735. HisPatientId: his.ID,
  7736. PatientId: his.PatientId,
  7737. SettleAccountsDate: recordDateTime,
  7738. MdtrtId: his.Number,
  7739. PsnNo: his.PsnNo,
  7740. MedType: strconv.FormatInt(reg_type, 10),
  7741. Ctime: time.Now().Unix(),
  7742. Mtime: time.Now().Unix(),
  7743. Status: 1,
  7744. Number: chrg_bchno,
  7745. Infcode: res.Infcode,
  7746. WarnMsg: res.WarnMsg,
  7747. Cainfo: res.Cainfo,
  7748. ErrMsg: res.ErrMsg,
  7749. RespondTime: res.RefmsgTime,
  7750. InfRefmsgid: res.InfRefmsgid,
  7751. OrderStatus: 1,
  7752. PayWay: pay_way,
  7753. PayPrice: pay_price,
  7754. PayCardNo: pay_card_no,
  7755. DiscountPrice: discount_price,
  7756. PreferentialPrice: preferential_price,
  7757. RealityPrice: reality_price,
  7758. FoundPrice: found_price,
  7759. MedicalInsurancePrice: medical_insurance_price,
  7760. PrivatePrice: private_price,
  7761. IsMedicineInsurance: 1,
  7762. SettleType: settle_accounts_type,
  7763. SettleStartTime: start_time,
  7764. SettleEndTime: end_time,
  7765. Creator: roles.AdminUserId,
  7766. Modify: roles.AdminUserId,
  7767. FaPiaoNumber: fapiao_number,
  7768. FaPiaoCode: fapiao_code,
  7769. PType: 2,
  7770. Diagnosis: diagnosis_id,
  7771. }
  7772. err = service.CreateOrder(order)
  7773. if err != nil {
  7774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7775. return
  7776. }
  7777. for _, item := range res.Output.Result {
  7778. temp := strings.Split(item.FeedetlSn, "-")
  7779. var advice_id int64 = 0
  7780. var project_id int64 = 0
  7781. var types int64 = 0
  7782. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7783. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7784. if temp[1] == "1" {
  7785. advice_id = id
  7786. project_id = 0
  7787. } else if temp[1] == "2" {
  7788. advice_id = 0
  7789. project_id = id
  7790. }
  7791. if item.MedChrgitmType == "9" {
  7792. item.MedChrgitmType = "09"
  7793. }
  7794. info := &models.HisOrderInfo{
  7795. OrderNumber: order.Number,
  7796. FeedetlSn: item.FeedetlSn,
  7797. UploadDate: time.Now().Unix(),
  7798. AdviceId: advice_id,
  7799. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7800. Cnt: item.Cnt,
  7801. Pric: float64(item.Pric),
  7802. PatientId: his.PatientId,
  7803. PricUplmtAmt: item.PricUplmtAmt,
  7804. SelfpayProp: item.SelfpayProp,
  7805. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7806. OverlmtAmt: item.OverlmtAmt,
  7807. PreselfpayAmt: item.PreselfpayAmt,
  7808. BasMednFlag: item.BasMednFlag,
  7809. MedChrgitmType: item.MedChrgitmType,
  7810. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7811. Status: 1,
  7812. Memo: item.Memo,
  7813. Mtime: time.Now().Unix(),
  7814. InscpScpAmt: item.InscpScpAmt,
  7815. DrtReimFlag: item.DrtReimFlag,
  7816. Ctime: time.Now().Unix(),
  7817. ListSpItemFlag: item.ListSpItemFlag,
  7818. ChldMedcFlag: item.ChldMedcFlag,
  7819. LmtUsedFlag: item.LmtUsedFlag,
  7820. ChrgitmLv: item.ChrgitmLv,
  7821. UserOrgId: adminUser.CurrentOrgId,
  7822. HisPatientId: his.ID,
  7823. OrderId: order.ID,
  7824. ProjectId: project_id,
  7825. Type: types,
  7826. }
  7827. service.CreateOrderInfo(info)
  7828. }
  7829. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7830. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7831. var total float64
  7832. for _, item := range prescriptions {
  7833. if item.Type == 1 { //药品
  7834. for _, subItem := range item.HisDoctorAdviceInfo {
  7835. total = total + (subItem.Price * subItem.PrescribingNumber)
  7836. }
  7837. }
  7838. if item.Type == 2 { //项目
  7839. for _, subItem := range item.HisPrescriptionProject {
  7840. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7841. total = total + (subItem.Price * cnt)
  7842. }
  7843. }
  7844. }
  7845. for _, item := range prescriptions {
  7846. for _, subItem := range item.HisAdditionalCharge {
  7847. total = total + (subItem.Price * float64(subItem.Count))
  7848. }
  7849. }
  7850. var allTotal string
  7851. if adminUser.CurrentOrgId == 9919 {
  7852. allTotal = fmt.Sprintf("%.4f", total)
  7853. } else {
  7854. allTotal = fmt.Sprintf("%.4f", total)
  7855. }
  7856. if res.Infcode == 0 {
  7857. var rf []*ResultFive
  7858. json.Unmarshal([]byte(his.Iinfo), &rf)
  7859. chrg_bchno := chrg_bchno
  7860. cert_no := his.Certno
  7861. var insutypes []string
  7862. var insutype string
  7863. var is390 int = 0
  7864. var is310 int = 0
  7865. for _, item := range rf {
  7866. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7867. insutypes = append(insutypes, item.Insutype)
  7868. }
  7869. }
  7870. if len(insutypes) == 1 {
  7871. insutype = insutypes[0]
  7872. } else {
  7873. for _, i := range insutypes {
  7874. if i == "390" {
  7875. is390 = 1
  7876. }
  7877. if i == "310" {
  7878. is310 = 1
  7879. }
  7880. }
  7881. }
  7882. if is390 == 1 {
  7883. insutype = "390"
  7884. }
  7885. if is310 == 1 {
  7886. insutype = "310"
  7887. }
  7888. if len(insutypes) == 0 {
  7889. insutype = "310"
  7890. }
  7891. if len(insutypes) == 2 {
  7892. insutype = strconv.FormatInt(his.SocialType, 10)
  7893. }
  7894. insutype = strconv.FormatInt(his.SocialType, 10)
  7895. //insutype = "390"
  7896. if his.IdCardType == 1 {
  7897. // cert_no = his.MedicalInsuranceNumber
  7898. cert_no = his.Certno
  7899. } else {
  7900. cert_no = his.Certno
  7901. }
  7902. var res ResultSeven
  7903. var resSeven10265 ResultSeven10265
  7904. var src_resquest string
  7905. var result2 string
  7906. var acct_used_flag string
  7907. fmt.Println("pay_way")
  7908. fmt.Println(pay_way)
  7909. fmt.Println("pay_way")
  7910. if pay_way == 4 {
  7911. acct_used_flag = "1"
  7912. } else {
  7913. acct_used_flag = "0"
  7914. }
  7915. if miConfig.MdtrtareaAdmvs == "421300" {
  7916. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7917. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7918. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7919. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7920. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7921. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7922. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  7923. resp, requestErr := http.Get(api)
  7924. if requestErr != nil {
  7925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7926. return
  7927. }
  7928. body, ioErr := ioutil.ReadAll(resp.Body)
  7929. if ioErr != nil {
  7930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7932. return
  7933. }
  7934. var respJSON map[string]interface{}
  7935. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7938. return
  7939. }
  7940. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7941. result, _ := json.Marshal(respJSON)
  7942. if miConfig.Code == "H15049901371" {
  7943. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7944. utils.ErrorLog("解析失败:%v", err)
  7945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7946. return
  7947. }
  7948. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7949. res.Output = resSeven10265.Output
  7950. res.ErrMsg = resSeven10265.ErrMsg
  7951. res.Cainfo = resSeven10265.Cainfo
  7952. res.WarnMsg = resSeven10265.WarnMsg
  7953. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7954. res.Infcode = infocode
  7955. } else {
  7956. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7957. utils.ErrorLog("解析失败:%v", err)
  7958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7959. return
  7960. }
  7961. }
  7962. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7963. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  7964. if result3101.Infcode == "0" {
  7965. if len(result3101.Output.Result) > 0 {
  7966. var errMsgs []string
  7967. for _, item := range result3101.Output.Result {
  7968. errMsgs = append(errMsgs, item.VolaCont)
  7969. }
  7970. c.ServeSuccessJSON(map[string]interface{}{
  7971. "failed_code": -10,
  7972. "msg": errMsgs,
  7973. })
  7974. return
  7975. } else {
  7976. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7977. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7978. bas := strings.Split(psn_info.CardInfo, "|")
  7979. if his.IdCardType == 1 {
  7980. cert_no = bas[2]
  7981. } else if his.IdCardType == 3 {
  7982. cert_no = his.Certno
  7983. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  7984. } else if his.IdCardType == 4 {
  7985. cert_no = his.Certno
  7986. psn_info.VerifyNumber = psn_info.VerifyNumber
  7987. }
  7988. var api string
  7989. if miConfig.MdtrtareaAdmvs == "320921" {
  7990. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7991. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7992. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7993. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7994. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7995. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7996. "&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
  7997. } else {
  7998. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7999. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8000. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8001. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8002. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8003. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8004. "&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
  8005. }
  8006. resp, requestErr := http.Get(api)
  8007. if requestErr != nil {
  8008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8009. return
  8010. }
  8011. body, ioErr := ioutil.ReadAll(resp.Body)
  8012. if ioErr != nil {
  8013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8015. return
  8016. }
  8017. var respJSON map[string]interface{}
  8018. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8021. return
  8022. }
  8023. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8024. result, _ := json.Marshal(respJSON)
  8025. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8026. utils.ErrorLog("解析失败:%v", err)
  8027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8028. return
  8029. }
  8030. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8031. res.Output = resSeven10265.Output
  8032. res.ErrMsg = resSeven10265.ErrMsg
  8033. res.Cainfo = resSeven10265.Cainfo
  8034. res.WarnMsg = resSeven10265.WarnMsg
  8035. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8036. res.Infcode = infocode
  8037. }
  8038. }
  8039. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8040. var cert_no string
  8041. if his.IdCardType == 4 {
  8042. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8043. cert_no = psn_info.VerifyNumber
  8044. 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)
  8045. } else if his.IdCardType == 1 {
  8046. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8047. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8048. 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)
  8049. }
  8050. //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)
  8051. var dat map[string]interface{}
  8052. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8053. fmt.Println(dat)
  8054. } else {
  8055. fmt.Println(err)
  8056. }
  8057. saveLog(result2, src_resquest, "2207", "结算")
  8058. userJSONBytes, _ := json.Marshal(dat)
  8059. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8060. utils.ErrorLog("解析失败:%v", err)
  8061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8062. return
  8063. }
  8064. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8065. res.Output = resSeven10265.Output
  8066. res.ErrMsg = resSeven10265.ErrMsg
  8067. res.Cainfo = resSeven10265.Cainfo
  8068. res.WarnMsg = resSeven10265.WarnMsg
  8069. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8070. res.Infcode = infocode
  8071. } else {
  8072. if miConfig.Code == "H15049901371" {
  8073. //赤峰地区国家医保医疗类别
  8074. //职工透析:医疗类别选特殊情况门诊990502
  8075. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8076. var med_type string
  8077. if his.Insutype == "390" {
  8078. if reg_type == 14 {
  8079. med_type = "9933"
  8080. } else if reg_type == 11 {
  8081. med_type = "11"
  8082. }
  8083. } else if his.Insutype == "310" {
  8084. if reg_type == 14 {
  8085. med_type = "990502"
  8086. } else if reg_type == 11 {
  8087. med_type = "11"
  8088. }
  8089. }
  8090. 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, "")
  8091. } else {
  8092. if his.IdCardType == 4 {
  8093. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8094. var token string
  8095. token = psn_info.VerifyNumber
  8096. 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)
  8097. } else {
  8098. 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, "")
  8099. }
  8100. }
  8101. //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)
  8102. var dat map[string]interface{}
  8103. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8104. fmt.Println(dat)
  8105. } else {
  8106. fmt.Println(err)
  8107. }
  8108. saveLog(result2, src_resquest, "2207", "结算")
  8109. userJSONBytes, _ := json.Marshal(dat)
  8110. if miConfig.Code == "H15049901371" {
  8111. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8112. utils.ErrorLog("解析失败:%v", err)
  8113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8114. return
  8115. }
  8116. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8117. res.Output = resSeven10265.Output
  8118. res.ErrMsg = resSeven10265.ErrMsg
  8119. res.Cainfo = resSeven10265.Cainfo
  8120. res.WarnMsg = resSeven10265.WarnMsg
  8121. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8122. res.Infcode = infocode
  8123. } else {
  8124. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8125. utils.ErrorLog("解析失败:%v", err)
  8126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8127. return
  8128. }
  8129. }
  8130. }
  8131. if res.Infcode != 0 {
  8132. errlog := &models.HisOrderError{
  8133. UserOrgId: adminUser.CurrentOrgId,
  8134. Ctime: time.Now().Unix(),
  8135. Mtime: time.Now().Unix(),
  8136. Number: chrg_bchno,
  8137. ErrMsg: res.ErrMsg,
  8138. Status: 1,
  8139. PatientId: id,
  8140. RecordTime: recordDateTime,
  8141. Stage: 6,
  8142. }
  8143. service.CreateErrMsgLog(errlog)
  8144. c.ServeSuccessJSON(map[string]interface{}{
  8145. "failed_code": -10,
  8146. "msg": res.ErrMsg,
  8147. })
  8148. return
  8149. } else {
  8150. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8151. order.OrderStatus = 2
  8152. order.Status = 1
  8153. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8154. order.SetlId = res.Output.Setlinfo.SetlID
  8155. order.PsnNo = res.Output.Setlinfo.PsnNo
  8156. order.PsnName = res.Output.Setlinfo.PsnName
  8157. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8158. order.Certno = res.Output.Setlinfo.Certno
  8159. order.Gend = res.Output.Setlinfo.Gend
  8160. order.Naty = res.Output.Setlinfo.Naty
  8161. order.Age = res.Output.Setlinfo.Age
  8162. order.Insutype = res.Output.Setlinfo.Insutype
  8163. order.PsnType = res.Output.Setlinfo.PsnType
  8164. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8165. order.SetlTime = res.Output.Setlinfo.SetlTime
  8166. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8167. if res.Output.Setlinfo.MedType == "140101" {
  8168. order.MedType = "14"
  8169. } else {
  8170. order.MedType = res.Output.Setlinfo.MedType
  8171. }
  8172. if reg_type == 1112 {
  8173. order.MedType = "1112"
  8174. }
  8175. if reg_type == 1111 {
  8176. order.MedType = "1111"
  8177. }
  8178. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8179. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8180. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8181. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8182. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8183. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8184. order.HifpPay = res.Output.Setlinfo.HifpPay
  8185. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8186. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8187. order.HifesPay = res.Output.Setlinfo.HifesPay
  8188. order.HifobPay = res.Output.Setlinfo.HifobPay
  8189. order.MafPay = res.Output.Setlinfo.MafPay
  8190. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8191. order.OthPay = res.Output.Setlinfo.OthPay
  8192. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8193. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8194. order.AcctPay = res.Output.Setlinfo.AcctPay
  8195. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8196. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8197. order.Balc = res.Output.Setlinfo.Balc
  8198. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8199. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8200. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8201. order.ClrType = res.Output.Setlinfo.ClrType
  8202. order.ClrWay = res.Output.Setlinfo.ClrWay
  8203. order.Creator = order.Creator
  8204. order.Modify = roles.AdminUserId
  8205. order.RequestLog = src_resquest
  8206. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8207. detailStr := string(setlDetail)
  8208. order.SetlDetail = detailStr
  8209. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8210. err = service.UpDateOrder(order)
  8211. if err == nil {
  8212. //判断是否使用了押金
  8213. if dec_way == "true" {
  8214. tmpstring := strconv.FormatInt(order.ID, 10)
  8215. order.Decimal = decimal
  8216. service.UpDateOrder(order)
  8217. //扣押金
  8218. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8219. if errmsg != nil {
  8220. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8221. return
  8222. }
  8223. }
  8224. c.ServeSuccessJSON(map[string]interface{}{
  8225. "msg": "结算成功",
  8226. })
  8227. } else {
  8228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8229. return
  8230. }
  8231. }
  8232. } else {
  8233. adminUser := c.GetAdminUserInfo()
  8234. errlog := &models.HisOrderError{
  8235. UserOrgId: adminUser.CurrentOrgId,
  8236. Ctime: time.Now().Unix(),
  8237. Mtime: time.Now().Unix(),
  8238. ErrMsg: res.ErrMsg,
  8239. Status: 1,
  8240. PatientId: id,
  8241. RecordTime: recordDateTime,
  8242. Stage: 4,
  8243. }
  8244. service.CreateErrMsgLog(errlog)
  8245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8246. return
  8247. }
  8248. } else {
  8249. adminUser := c.GetAdminUserInfo()
  8250. errlog := &models.HisOrderError{
  8251. UserOrgId: adminUser.CurrentOrgId,
  8252. Ctime: time.Now().Unix(),
  8253. Mtime: time.Now().Unix(),
  8254. ErrMsg: res.ErrMsg,
  8255. Status: 1,
  8256. PatientId: id,
  8257. RecordTime: recordDateTime,
  8258. Stage: 4,
  8259. }
  8260. service.CreateErrMsgLog(errlog)
  8261. c.ServeSuccessJSON(map[string]interface{}{
  8262. "failed_code": -10,
  8263. "msg": res.ErrMsg,
  8264. })
  8265. return
  8266. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  8267. //return
  8268. }
  8269. }
  8270. }
  8271. } else if tempOrder.ID > 0 {
  8272. if tempOrder.IsPre == 1 {
  8273. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  8274. var rf []*ResultFive
  8275. json.Unmarshal([]byte(his.Iinfo), &rf)
  8276. chrg_bchno := tempOrder.Number
  8277. cert_no := his.Certno
  8278. var insutypes []string
  8279. var insutype string
  8280. var is390 int = 0
  8281. var is310 int = 0
  8282. for _, item := range rf {
  8283. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8284. insutypes = append(insutypes, item.Insutype)
  8285. }
  8286. }
  8287. if len(insutypes) == 1 {
  8288. insutype = insutypes[0]
  8289. } else {
  8290. for _, i := range insutypes {
  8291. if i == "390" {
  8292. is390 = 1
  8293. }
  8294. if i == "310" {
  8295. is310 = 1
  8296. }
  8297. }
  8298. }
  8299. if is390 == 1 {
  8300. insutype = "390"
  8301. }
  8302. if is310 == 1 {
  8303. insutype = "310"
  8304. }
  8305. if len(insutypes) == 0 {
  8306. insutype = "310"
  8307. }
  8308. if len(insutypes) == 2 {
  8309. insutype = strconv.FormatInt(his.SocialType, 64)
  8310. }
  8311. //insutype = "390"
  8312. if his.IdCardType == 1 {
  8313. // cert_no = his.MedicalInsuranceNumber
  8314. cert_no = his.Certno
  8315. } else {
  8316. cert_no = his.Certno
  8317. }
  8318. var res ResultSeven
  8319. var resSeven10265 ResultSeven10265
  8320. var src_resquest string
  8321. var result2 string
  8322. var acct_used_flag string
  8323. fmt.Println("pay_way")
  8324. fmt.Println(pay_way)
  8325. fmt.Println("pay_way")
  8326. if pay_way == 4 {
  8327. acct_used_flag = "1"
  8328. } else {
  8329. acct_used_flag = "0"
  8330. }
  8331. if miConfig.MdtrtareaAdmvs == "421300" {
  8332. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8333. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8334. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8335. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8336. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8337. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8338. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  8339. resp, requestErr := http.Get(api)
  8340. if requestErr != nil {
  8341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8342. return
  8343. }
  8344. body, ioErr := ioutil.ReadAll(resp.Body)
  8345. if ioErr != nil {
  8346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8348. return
  8349. }
  8350. var respJSON map[string]interface{}
  8351. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8354. return
  8355. }
  8356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8357. result, _ := json.Marshal(respJSON)
  8358. fmt.Println("log")
  8359. fmt.Println(string(result))
  8360. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8361. utils.ErrorLog("解析失败:%v", err)
  8362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8363. return
  8364. }
  8365. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8366. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  8367. if result3101.Infcode == "0" {
  8368. if len(result3101.Output.Result) > 0 {
  8369. var errMsgs []string
  8370. for _, item := range result3101.Output.Result {
  8371. errMsgs = append(errMsgs, item.VolaCont)
  8372. }
  8373. c.ServeSuccessJSON(map[string]interface{}{
  8374. "failed_code": -10,
  8375. "msg": errMsgs,
  8376. })
  8377. return
  8378. } else {
  8379. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8380. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8381. bas := strings.Split(psn_info.CardInfo, "|")
  8382. if his.IdCardType == 1 {
  8383. cert_no = bas[2]
  8384. } else if his.IdCardType == 3 {
  8385. cert_no = his.Certno
  8386. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  8387. } else if his.IdCardType == 4 {
  8388. cert_no = his.Certno
  8389. psn_info.VerifyNumber = psn_info.VerifyNumber
  8390. }
  8391. //江苏地区国家医保医疗类别
  8392. //职工透析:医疗类别选特殊情况门诊9933
  8393. //居民血透门慢: 医疗类别选门诊慢病1402
  8394. //var med_type string
  8395. //if his.Insutype == "310" {
  8396. // if reg_type == 14 {
  8397. // med_type = "9933"
  8398. // } else if reg_type == 11 {
  8399. // med_type = "11"
  8400. //
  8401. // }
  8402. //} else if his.Insutype == "390" {
  8403. // if reg_type == 14 {
  8404. // med_type = "1402"
  8405. // } else if reg_type == 11 {
  8406. // med_type = "11"
  8407. // }
  8408. //}
  8409. var api string
  8410. if miConfig.MdtrtareaAdmvs == "320921" {
  8411. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8412. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8413. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8414. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8415. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8416. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8417. "&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
  8418. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8419. } else {
  8420. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8421. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8422. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8423. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8424. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8425. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8426. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8427. "&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
  8428. }
  8429. resp, requestErr := http.Get(api)
  8430. if requestErr != nil {
  8431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8432. return
  8433. }
  8434. body, ioErr := ioutil.ReadAll(resp.Body)
  8435. if ioErr != nil {
  8436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8438. return
  8439. }
  8440. var respJSON map[string]interface{}
  8441. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8444. return
  8445. }
  8446. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8447. result, _ := json.Marshal(respJSON)
  8448. fmt.Println("log")
  8449. fmt.Println(string(result))
  8450. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8451. utils.ErrorLog("解析失败:%v", err)
  8452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8453. return
  8454. }
  8455. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8456. res.Output = resSeven10265.Output
  8457. res.ErrMsg = resSeven10265.ErrMsg
  8458. res.Cainfo = resSeven10265.Cainfo
  8459. res.WarnMsg = resSeven10265.WarnMsg
  8460. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8461. res.Infcode = infocode
  8462. }
  8463. }
  8464. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8465. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8466. var cert_no string
  8467. if his.IdCardType == 1 {
  8468. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8469. } else {
  8470. cert_no = psn_info.VerifyNumber
  8471. }
  8472. 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)
  8473. var dat map[string]interface{}
  8474. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8475. fmt.Println(dat)
  8476. } else {
  8477. fmt.Println(err)
  8478. }
  8479. saveLog(result2, src_resquest, "2207", "结算")
  8480. userJSONBytes, _ := json.Marshal(dat)
  8481. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8482. utils.ErrorLog("解析失败:%v", err)
  8483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8484. return
  8485. }
  8486. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8487. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8488. var cert_no string
  8489. if his.IdCardType == 1 {
  8490. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8491. } else if his.IdCardType == 2 {
  8492. cert_no = his.IdCardNo
  8493. } else {
  8494. cert_no = psn_info.VerifyNumber
  8495. }
  8496. 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, "")
  8497. var dat map[string]interface{}
  8498. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8499. fmt.Println(dat)
  8500. } else {
  8501. fmt.Println(err)
  8502. }
  8503. saveLog(result2, src_resquest, "2207", "结算")
  8504. userJSONBytes, _ := json.Marshal(dat)
  8505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8506. utils.ErrorLog("解析失败:%v", err)
  8507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8508. return
  8509. }
  8510. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8511. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8512. var cert_no string
  8513. if his.IdCardType == 1 {
  8514. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8515. } else if his.IdCardType == 2 {
  8516. cert_no = his.IdCardNo
  8517. } else {
  8518. cert_no = psn_info.VerifyNumber
  8519. }
  8520. 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, "")
  8521. var dat map[string]interface{}
  8522. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8523. fmt.Println(dat)
  8524. } else {
  8525. fmt.Println(err)
  8526. }
  8527. saveLog(result2, src_resquest, "2207", "结算")
  8528. userJSONBytes, _ := json.Marshal(dat)
  8529. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8530. utils.ErrorLog("解析失败:%v", err)
  8531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8532. return
  8533. }
  8534. } else {
  8535. var src_resquest string
  8536. if miConfig.Code == "H15049901371" {
  8537. //赤峰地区国家医保医疗类别
  8538. //职工透析:医疗类别选特殊情况门诊990502
  8539. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8540. var med_type string
  8541. if his.Insutype == "390" {
  8542. if reg_type == 14 {
  8543. med_type = "9933"
  8544. } else if reg_type == 11 {
  8545. med_type = "11"
  8546. }
  8547. } else if his.Insutype == "310" {
  8548. if reg_type == 14 {
  8549. med_type = "990502"
  8550. } else if reg_type == 11 {
  8551. med_type = "11"
  8552. }
  8553. }
  8554. 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, "")
  8555. } else {
  8556. if his.IdCardType == 4 {
  8557. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8558. token := psn_info.VerifyNumber
  8559. 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)
  8560. } else {
  8561. 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, "")
  8562. }
  8563. }
  8564. var dat map[string]interface{}
  8565. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8566. fmt.Println(dat)
  8567. } else {
  8568. fmt.Println(err)
  8569. }
  8570. saveLog(result2, src_resquest, "2207", "结算")
  8571. userJSONBytes, _ := json.Marshal(dat)
  8572. if miConfig.Code == "H15049901371" {
  8573. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8574. utils.ErrorLog("解析失败:%v", err)
  8575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8576. return
  8577. }
  8578. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8579. res.Output = resSeven10265.Output
  8580. res.ErrMsg = resSeven10265.ErrMsg
  8581. res.Cainfo = resSeven10265.Cainfo
  8582. res.WarnMsg = resSeven10265.WarnMsg
  8583. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8584. res.Infcode = infocode
  8585. } else {
  8586. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8587. utils.ErrorLog("解析失败:%v", err)
  8588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8589. return
  8590. }
  8591. }
  8592. }
  8593. if res.Infcode != 0 {
  8594. errlog := &models.HisOrderError{
  8595. UserOrgId: adminUser.CurrentOrgId,
  8596. Ctime: time.Now().Unix(),
  8597. Mtime: time.Now().Unix(),
  8598. Number: chrg_bchno,
  8599. ErrMsg: res.ErrMsg,
  8600. Status: 1,
  8601. PatientId: id,
  8602. RecordTime: recordDateTime,
  8603. Stage: 6,
  8604. }
  8605. service.CreateErrMsgLog(errlog)
  8606. c.ServeSuccessJSON(map[string]interface{}{
  8607. "failed_code": -10,
  8608. "msg": res.ErrMsg,
  8609. })
  8610. return
  8611. } else {
  8612. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8613. order.OrderStatus = 2
  8614. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8615. order.SetlId = res.Output.Setlinfo.SetlID
  8616. order.PsnNo = res.Output.Setlinfo.PsnNo
  8617. order.PsnName = res.Output.Setlinfo.PsnName
  8618. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8619. order.Certno = res.Output.Setlinfo.Certno
  8620. order.Gend = res.Output.Setlinfo.Gend
  8621. order.Naty = res.Output.Setlinfo.Naty
  8622. order.Age = res.Output.Setlinfo.Age
  8623. order.Insutype = res.Output.Setlinfo.Insutype
  8624. order.PsnType = res.Output.Setlinfo.PsnType
  8625. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8626. order.SetlTime = res.Output.Setlinfo.SetlTime
  8627. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8628. //order.MedType = res.Output.Setlinfo.MedType
  8629. if reg_type == 1112 {
  8630. order.MedType = "1112"
  8631. }
  8632. if reg_type == 1111 {
  8633. order.MedType = "1111"
  8634. }
  8635. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8636. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8637. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8638. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8639. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8640. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8641. order.HifpPay = res.Output.Setlinfo.HifpPay
  8642. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8643. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8644. order.HifesPay = res.Output.Setlinfo.HifesPay
  8645. order.HifobPay = res.Output.Setlinfo.HifobPay
  8646. order.MafPay = res.Output.Setlinfo.MafPay
  8647. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8648. order.OthPay = res.Output.Setlinfo.OthPay
  8649. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8650. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8651. order.AcctPay = res.Output.Setlinfo.AcctPay
  8652. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8653. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8654. order.Balc = res.Output.Setlinfo.Balc
  8655. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8656. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8657. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8658. order.ClrWay = res.Output.Setlinfo.ClrWay
  8659. order.Creator = order.Creator
  8660. order.Modify = roles.AdminUserId
  8661. order.RequestLog = src_resquest
  8662. order.Diagnosis = diagnosis_id
  8663. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8664. detailStr := string(setlDetail)
  8665. order.SetlDetail = detailStr
  8666. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8667. err = service.UpDateOrder(order)
  8668. if err == nil {
  8669. //判断是否使用了押金
  8670. if dec_way == "true" {
  8671. tmpstring := strconv.FormatInt(order.ID, 10)
  8672. //扣押金
  8673. order.Decimal = decimal
  8674. service.UpDateOrder(order)
  8675. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8676. if errmsg != nil {
  8677. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8678. return
  8679. }
  8680. }
  8681. c.ServeSuccessJSON(map[string]interface{}{
  8682. "msg": "结算成功",
  8683. })
  8684. } else {
  8685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8686. return
  8687. }
  8688. }
  8689. }
  8690. }
  8691. }
  8692. //func (c *HisApiController) GetPreUploadInfo() {
  8693. // id, _ := c.GetInt64("id")
  8694. // record_time := c.GetString("record_time")
  8695. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8696. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8697. //
  8698. // timeLayout := "2006-01-02"
  8699. // loc, _ := time.LoadLocation("Local")
  8700. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8701. // if err != nil {
  8702. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8703. // return
  8704. // }
  8705. // recordDateTime := theTime.Unix()
  8706. // adminUser := c.GetAdminUserInfo()
  8707. //
  8708. // var prescriptions []*models.HisPrescription
  8709. //
  8710. // var start_time int64
  8711. // var end_time int64
  8712. //
  8713. // data := make(map[string]interface{})
  8714. // if settle_accounts_type == 1 { //日结
  8715. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  8716. // data["pre"] = prescriptions
  8717. //
  8718. // } else { //月结
  8719. // start_time_str := c.GetString("start_time")
  8720. // end_time_str := c.GetString("end_time")
  8721. // timeLayout := "2006-01-02"
  8722. // loc, _ := time.LoadLocation("Local")
  8723. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  8724. // if err != nil {
  8725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8726. // return
  8727. // }
  8728. // recordStartTime := theStartTime.Unix()
  8729. // start_time = recordStartTime
  8730. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8731. // if err != nil {
  8732. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8733. // return
  8734. // }
  8735. // recordEndTime := theEndTime.Unix()
  8736. // end_time = recordEndTime
  8737. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  8738. // data["pre"] = prescriptions
  8739. //
  8740. // }
  8741. //
  8742. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8743. //
  8744. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8745. // timestamp := time.Now().Unix()
  8746. // tempTime := time.Unix(timestamp, 0)
  8747. // timeFormat := tempTime.Format("20060102150405")
  8748. // chrgBchno := rand.Intn(100000) + 10000
  8749. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8750. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8751. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8752. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8753. // strconv.FormatInt(his.PatientId, 10)
  8754. // client := &http.Client{}
  8755. // data["psn_no"] = his.PsnNo
  8756. // data["mdtrt_id"] = his.Number
  8757. // data["chrg_bchno"] = chrg_bchno
  8758. // data["org_name"] = miConfig.OrgName
  8759. // data["doctor"] = roles.UserName
  8760. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  8761. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  8762. // data["fixmedins_code"] = miConfig.Code
  8763. // data["dept_code"] = department.Number
  8764. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  8765. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8766. // data["secret_key"] = miConfig.SecretKey
  8767. // var ids []int64
  8768. //
  8769. // for _, item := range prescriptions {
  8770. // ids = append(ids, item.ID)
  8771. // }
  8772. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8773. // if config.IsOpen == 1 { //对接了医保,走医保流程
  8774. // bytesData, _ := json.Marshal(data)
  8775. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  8776. // resp, _ := client.Do(req)
  8777. // defer resp.Body.Close()
  8778. // body, ioErr := ioutil.ReadAll(resp.Body)
  8779. // if ioErr != nil {
  8780. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8781. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8782. // return
  8783. // }
  8784. // var respJSON map[string]interface{}
  8785. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8786. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8788. // return
  8789. // }
  8790. //
  8791. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8792. // userJSONBytes, _ := json.Marshal(respJSON)
  8793. // var res ResultFour
  8794. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8795. // utils.ErrorLog("解析失败:%v", err)
  8796. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8797. // return
  8798. // }
  8799. //
  8800. // if res.Infcode == 0 {
  8801. // order := &models.HisOrder{
  8802. // UserOrgId: adminUser.CurrentOrgId,
  8803. // HisPatientId: his.ID,
  8804. // PatientId: his.PatientId,
  8805. // SettleAccountsDate: recordDateTime,
  8806. // Ctime: time.Now().Unix(),
  8807. // Mtime: time.Now().Unix(),
  8808. // Status: 1,
  8809. // Number: chrg_bchno,
  8810. // Infcode: res.Infcode,
  8811. // WarnMsg: res.WarnMsg,
  8812. // Cainfo: res.Cainfo,
  8813. // ErrMsg: res.ErrMsg,
  8814. // RespondTime: res.RefmsgTime,
  8815. // InfRefmsgid: res.InfRefmsgid,
  8816. // OrderStatus: 1,
  8817. // IsMedicineInsurance: 1,
  8818. // SettleType: settle_accounts_type,
  8819. // SettleStartTime: start_time,
  8820. // SettleEndTime: end_time,
  8821. // Creator: roles.ID,
  8822. // Modify: roles.ID,
  8823. // PType: 2,
  8824. // }
  8825. // err = service.CreateOrder(order)
  8826. // if err != nil {
  8827. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8828. // return
  8829. // }
  8830. //
  8831. // for _, item := range res.Output.Result {
  8832. // temp := strings.Split(item.FeedetlSn, "-")
  8833. // var advice_id int64 = 0
  8834. // var project_id int64 = 0
  8835. // var types int64 = 0
  8836. //
  8837. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  8838. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  8839. //
  8840. // if temp[1] == "1" {
  8841. // advice_id = id
  8842. // project_id = 0
  8843. // } else if temp[1] == "2" {
  8844. // advice_id = 0
  8845. // project_id = id
  8846. // }
  8847. //
  8848. // info := &models.HisOrderInfo{
  8849. // OrderNumber: order.Number,
  8850. // FeedetlSn: item.FeedetlSn,
  8851. // UploadDate: time.Now().Unix(),
  8852. // AdviceId: advice_id,
  8853. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  8854. // Cnt: item.Cnt,
  8855. // Pric: float64(item.Pric),
  8856. // PatientId: his.PatientId,
  8857. // PricUplmtAmt: item.PricUplmtAmt,
  8858. // SelfpayProp: item.SelfpayProp,
  8859. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8860. // OverlmtAmt: item.OverlmtAmt,
  8861. // PreselfpayAmt: item.PreselfpayAmt,
  8862. // BasMednFlag: item.BasMednFlag,
  8863. // MedChrgitmType: item.MedChrgitmType,
  8864. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  8865. // Status: 1,
  8866. // Memo: item.Memo,
  8867. // Mtime: time.Now().Unix(),
  8868. // InscpScpAmt: item.InscpScpAmt,
  8869. // DrtReimFlag: item.DrtReimFlag,
  8870. // Ctime: time.Now().Unix(),
  8871. // ListSpItemFlag: item.ListSpItemFlag,
  8872. // ChldMedcFlag: item.ChldMedcFlag,
  8873. // LmtUsedFlag: item.LmtUsedFlag,
  8874. // ChrgitmLv: item.ChrgitmLv,
  8875. // UserOrgId: adminUser.CurrentOrgId,
  8876. // HisPatientId: his.ID,
  8877. // OrderId: order.ID,
  8878. // ProjectId: project_id,
  8879. // Type: types,
  8880. // }
  8881. // service.CreateOrderInfo(info)
  8882. //
  8883. // }
  8884. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8885. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  8886. //
  8887. // var total float64
  8888. // for _, item := range prescriptions {
  8889. // if item.Type == 1 { //药品
  8890. // for _, subItem := range item.HisDoctorAdviceInfo {
  8891. // total = total + (subItem.Price * subItem.PrescribingNumber)
  8892. // }
  8893. // }
  8894. // if item.Type == 2 { //项目
  8895. // for _, subItem := range item.HisPrescriptionProject {
  8896. // total = total + (subItem.Price * float64(subItem.Count))
  8897. // }
  8898. // }
  8899. // }
  8900. //
  8901. // for _, item := range prescriptions {
  8902. // for _, subItem := range item.HisAdditionalCharge {
  8903. // total = total + (subItem.Price * float64(subItem.Count))
  8904. // }
  8905. // }
  8906. //
  8907. // allTotal := fmt.Sprintf("%.2f", total)
  8908. // if res.Infcode == 0 {
  8909. // var rf []*ResultFive
  8910. // json.Unmarshal([]byte(his.Iinfo), &rf)
  8911. // psn_no := his.PsnNo
  8912. // mdtrt_id := his.Number
  8913. // chrg_bchno := chrg_bchno
  8914. // cert_no := his.Certno
  8915. // insutype := rf[0].Insutype
  8916. //
  8917. // if his.IdCardType == 1 {
  8918. // cert_no = his.MedicalInsuranceNumber
  8919. //
  8920. // } else {
  8921. //
  8922. // cert_no = his.Certno
  8923. //
  8924. // }
  8925. //
  8926. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  8927. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  8928. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  8929. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  8930. // resp, requestErr := http.Get(api)
  8931. // if requestErr != nil {
  8932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8933. // return
  8934. // }
  8935. // defer resp.Body.Close()
  8936. // body, ioErr := ioutil.ReadAll(resp.Body)
  8937. // if ioErr != nil {
  8938. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8939. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8940. // return
  8941. // }
  8942. // var respJSON map[string]interface{}
  8943. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8944. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8945. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8946. // return
  8947. // }
  8948. // fmt.Println(respJSON)
  8949. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8950. // userJSONBytes, _ := json.Marshal(respJSON)
  8951. // var res ResultSeven
  8952. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8953. // utils.ErrorLog("解析失败:%v", err)
  8954. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8955. // return
  8956. // }
  8957. // if res.Infcode != 0 {
  8958. // errlog := &models.HisOrderError{
  8959. // UserOrgId: adminUser.CurrentOrgId,
  8960. // Ctime: time.Now().Unix(),
  8961. // Mtime: time.Now().Unix(),
  8962. // Number: chrg_bchno,
  8963. // ErrMsg: res.ErrMsg,
  8964. // Status: 1,
  8965. // PatientId: id,
  8966. // RecordTime: recordDateTime,
  8967. // Stage: 7,
  8968. // }
  8969. // service.CreateErrMsgLog(errlog)
  8970. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8971. // return
  8972. // } else {
  8973. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8974. // order.OrderStatus = 1
  8975. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8976. // order.SetlId = res.Output.Setlinfo.SetlID
  8977. // order.PsnNo = res.Output.Setlinfo.PsnNo
  8978. // order.PsnName = res.Output.Setlinfo.PsnName
  8979. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8980. // order.Certno = res.Output.Setlinfo.Certno
  8981. // order.Gend = res.Output.Setlinfo.Gend
  8982. // order.Naty = res.Output.Setlinfo.Naty
  8983. // order.Age = res.Output.Setlinfo.Age
  8984. // order.Insutype = res.Output.Setlinfo.Insutype
  8985. // order.PsnType = res.Output.Setlinfo.PsnType
  8986. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8987. // order.SetlTime = res.Output.Setlinfo.SetlTime
  8988. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8989. // order.MedType = res.Output.Setlinfo.MedType
  8990. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8991. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8992. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8993. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8994. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8995. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8996. // order.HifpPay = res.Output.Setlinfo.HifpPay
  8997. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8998. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8999. // order.HifesPay = res.Output.Setlinfo.HifesPay
  9000. // order.HifobPay = res.Output.Setlinfo.HifobPay
  9001. // order.MafPay = res.Output.Setlinfo.MafPay
  9002. // order.OthPay = res.Output.Setlinfo.OthPay
  9003. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9004. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9005. // order.AcctPay = res.Output.Setlinfo.AcctPay
  9006. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9007. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9008. // order.Balc = res.Output.Setlinfo.Balc
  9009. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9010. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9011. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9012. // order.ClrWay = res.Output.Setlinfo.ClrWay
  9013. // order.Creator = order.Creator
  9014. // order.Modify = roles.ID
  9015. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9016. // detailStr := string(setlDetail)
  9017. // order.SetlDetail = detailStr
  9018. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9019. // err = service.UpDateOrder(order)
  9020. // if err == nil {
  9021. // c.ServeSuccessJSON(map[string]interface{}{
  9022. // "msg": "预结算成功",
  9023. // })
  9024. // } else {
  9025. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9026. // return
  9027. // }
  9028. // }
  9029. // } else {
  9030. // adminUser := c.GetAdminUserInfo()
  9031. // errlog := &models.HisOrderError{
  9032. // UserOrgId: adminUser.CurrentOrgId,
  9033. // Ctime: time.Now().Unix(),
  9034. // Mtime: time.Now().Unix(),
  9035. // ErrMsg: res.ErrMsg,
  9036. // Status: 1,
  9037. // PatientId: id,
  9038. // RecordTime: recordDateTime,
  9039. // Stage: 4,
  9040. // }
  9041. // service.CreateErrMsgLog(errlog)
  9042. //
  9043. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9044. // return
  9045. // }
  9046. // } else {
  9047. // adminUser := c.GetAdminUserInfo()
  9048. // errlog := &models.HisOrderError{
  9049. // UserOrgId: adminUser.CurrentOrgId,
  9050. // Ctime: time.Now().Unix(),
  9051. // Mtime: time.Now().Unix(),
  9052. // ErrMsg: res.ErrMsg,
  9053. // Status: 1,
  9054. // PatientId: id,
  9055. // RecordTime: recordDateTime,
  9056. // Stage: 4,
  9057. // }
  9058. // service.CreateErrMsgLog(errlog)
  9059. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  9060. // return
  9061. // }
  9062. //
  9063. // } else {
  9064. // var total float64
  9065. // for _, item := range prescriptions {
  9066. // if item.Type == 1 { //药品
  9067. // for _, subItem := range item.HisDoctorAdviceInfo {
  9068. // total = total + (subItem.Price * subItem.PrescribingNumber)
  9069. // }
  9070. // }
  9071. // if item.Type == 2 { //项目
  9072. // for _, subItem := range item.HisPrescriptionProject {
  9073. // total = total + (subItem.Price * float64(subItem.Count))
  9074. // }
  9075. // }
  9076. //
  9077. // for _, subItem := range item.HisAdditionalCharge {
  9078. // total = total + (subItem.Price * float64(subItem.Count))
  9079. // }
  9080. // }
  9081. //
  9082. // allTotal := fmt.Sprintf("%.2f", total)
  9083. // totals, _ := strconv.ParseFloat(allTotal, 64)
  9084. // order := &models.HisOrder{
  9085. // UserOrgId: adminUser.CurrentOrgId,
  9086. // HisPatientId: his.ID,
  9087. // PatientId: id,
  9088. // SettleAccountsDate: recordDateTime,
  9089. // Ctime: time.Now().Unix(),
  9090. // Mtime: time.Now().Unix(),
  9091. // Status: 1,
  9092. // OrderStatus: 2,
  9093. // Number: chrg_bchno,
  9094. // MedfeeSumamt: totals,
  9095. // }
  9096. // err = service.CreateOrder(order)
  9097. // if err != nil {
  9098. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9099. // return
  9100. // }
  9101. //
  9102. // var customs []*Custom
  9103. // for _, item := range prescriptions {
  9104. //
  9105. // if item.Type == 1 { //药品
  9106. // for _, subItem := range item.HisDoctorAdviceInfo {
  9107. // cus := &Custom{
  9108. // AdviceId: subItem.ID,
  9109. // ProjectId: 0,
  9110. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  9111. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  9112. // FeedetlSn: subItem.FeedetlSn,
  9113. // Price: fmt.Sprintf("%.2f", subItem.Price),
  9114. // MedListCodg: subItem.MedListCodg,
  9115. // Type: 1,
  9116. // }
  9117. // customs = append(customs, cus)
  9118. // }
  9119. // }
  9120. //
  9121. // if item.Type == 2 { //项目
  9122. // for _, subItem := range item.HisPrescriptionProject {
  9123. //
  9124. // cus := &Custom{
  9125. // AdviceId: 0,
  9126. // ProjectId: subItem.ID,
  9127. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  9128. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  9129. // FeedetlSn: subItem.FeedetlSn,
  9130. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  9131. // MedListCodg: subItem.MedListCodg,
  9132. // Type: 2,
  9133. // }
  9134. //
  9135. // customs = append(customs, cus)
  9136. // }
  9137. // }
  9138. //
  9139. // for _, item := range item.HisAdditionalCharge {
  9140. // cus := &Custom{
  9141. // ItemId: item.ID,
  9142. // AdviceId: 0,
  9143. // ProjectId: 0,
  9144. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  9145. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  9146. // FeedetlSn: item.FeedetlSn,
  9147. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  9148. // MedListCodg: item.XtHisAddtionConfig.Code,
  9149. // Type: 3,
  9150. // }
  9151. //
  9152. // customs = append(customs, cus)
  9153. // }
  9154. //
  9155. // }
  9156. //
  9157. // for _, item := range customs {
  9158. // var advice_id int64 = 0
  9159. // var project_id int64 = 0
  9160. // var item_id int64 = 0
  9161. //
  9162. // var types int64 = 0
  9163. //
  9164. // if item.Type == 1 {
  9165. // advice_id = item.AdviceId
  9166. // project_id = 0
  9167. // item_id = 0
  9168. // } else if item.Type == 2 {
  9169. // advice_id = 0
  9170. // item_id = 0
  9171. //
  9172. // project_id = item.ProjectId
  9173. // } else if item.Type == 3 {
  9174. // advice_id = 0
  9175. // item_id = item.ItemId
  9176. // project_id = 0
  9177. // }
  9178. //
  9179. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  9180. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  9181. // pric, _ := strconv.ParseFloat(item.Price, 32)
  9182. //
  9183. // info := &models.HisOrderInfo{
  9184. // OrderNumber: order.Number,
  9185. // UploadDate: time.Now().Unix(),
  9186. // AdviceId: advice_id,
  9187. // DetItemFeeSumamt: detItemFeeSumamt,
  9188. // Cnt: cut,
  9189. // Pric: pric,
  9190. // PatientId: id,
  9191. // Status: 1,
  9192. // Mtime: time.Now().Unix(),
  9193. // Ctime: time.Now().Unix(),
  9194. // UserOrgId: adminUser.CurrentOrgId,
  9195. // HisPatientId: his.ID,
  9196. // OrderId: order.ID,
  9197. // ProjectId: project_id,
  9198. // Type: types,
  9199. // ItemId: item_id,
  9200. // }
  9201. // service.CreateOrderInfo(info)
  9202. // }
  9203. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9204. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9205. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  9206. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9207. // if err == nil {
  9208. // c.ServeSuccessJSON(map[string]interface{}{
  9209. // "msg": "结算成功",
  9210. // })
  9211. // } else {
  9212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9213. // return
  9214. // }
  9215. // }
  9216. //}
  9217. //上传明细-预结算-
  9218. func (c *HisApiController) GetPreUploadInfo() {
  9219. id, _ := c.GetInt64("id")
  9220. record_time := c.GetString("record_time")
  9221. his_patient_id, _ := c.GetInt64("his_patient_id")
  9222. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9223. admin_user_id, _ := c.GetInt64("admin_user_id")
  9224. diagnosis_id := c.GetString("diagnosis")
  9225. sick_type, _ := c.GetInt64("sick_type")
  9226. reg_type, _ := c.GetInt64("p_type")
  9227. begin_time := c.GetString("begin_time")
  9228. id_str := c.GetString("ids")
  9229. ids_arr := strings.Split(id_str, ",")
  9230. timeLayout := "2006-01-02"
  9231. loc, _ := time.LoadLocation("Local")
  9232. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9233. if err != nil {
  9234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9235. return
  9236. }
  9237. recordDateTime := theTime.Unix()
  9238. adminUser := c.GetAdminUserInfo()
  9239. diagnosis_ids := strings.Split(diagnosis_id, ",")
  9240. var config []*models.HisXtDiagnoseConfig
  9241. for _, item := range diagnosis_ids {
  9242. id, _ := strconv.ParseInt(item, 10, 64)
  9243. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9244. config = append(config, &diagnosisConfig)
  9245. }
  9246. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9247. sickConfig, _ := service.FindSickById(sick_type)
  9248. var prescriptions []*models.HisPrescription
  9249. var start_time int64
  9250. var end_time int64
  9251. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9252. fmt.Println(his_patient_id)
  9253. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9254. timestamp := time.Now().Unix()
  9255. tempTime := time.Unix(timestamp, 0)
  9256. timeFormat := tempTime.Format("20060102150405")
  9257. chrgBchno := rand.Intn(100000) + 10000
  9258. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9259. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9260. var patientPrescription models.HisPrescriptionInfo
  9261. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9262. if patientPrescription.ID == 0 {
  9263. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9264. }
  9265. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9266. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9267. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9268. strconv.FormatInt(his.PatientId, 10)
  9269. var res2 ResultSix
  9270. var resSix10265 ResultSix10265
  9271. //var time_stamp string
  9272. if miConfig.MdtrtareaAdmvs == "421300" {
  9273. data := make(map[string]interface{})
  9274. client := &http.Client{}
  9275. data["psn_no"] = his.PsnNo
  9276. data["mdtrt_id"] = his.Number
  9277. data["department"] = department.Name
  9278. data["org_name"] = miConfig.OrgName
  9279. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9280. data["doctor_id"] = doctor_info.DoctorNumber
  9281. data["doctor_name"] = roles.UserName
  9282. data["fixmedins_code"] = miConfig.Code
  9283. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  9284. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9285. data["secret_key"] = miConfig.SecretKey
  9286. data["sick_code"] = sickConfig.CountryCode
  9287. data["sick_name"] = sickConfig.ClassName
  9288. data["begin_time"] = begin_time
  9289. data["dept"] = strconv.FormatInt(department.ID, 10)
  9290. data["config"] = config
  9291. data["opter"] = roles.UserName
  9292. fmt.Println(data)
  9293. bytesData, _ := json.Marshal(data)
  9294. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  9295. resp, _ := client.Do(req)
  9296. defer resp.Body.Close()
  9297. body, ioErr := ioutil.ReadAll(resp.Body)
  9298. if ioErr != nil {
  9299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9301. return
  9302. }
  9303. var respJSON map[string]interface{}
  9304. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9307. return
  9308. }
  9309. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9310. userJSONBytes, _ := json.Marshal(respJSON)
  9311. fmt.Println("log")
  9312. fmt.Println(string(userJSONBytes))
  9313. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9314. utils.ErrorLog("解析失败:%v", err)
  9315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9316. return
  9317. }
  9318. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9319. data := make(map[string]interface{})
  9320. client := &http.Client{}
  9321. data["psn_no"] = his.PsnNo
  9322. data["mdtrt_id"] = his.Number
  9323. data["doctor"] = roles.UserName
  9324. data["department"] = department.Name
  9325. data["org_name"] = miConfig.OrgName
  9326. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9327. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  9328. data["fixmedins_code"] = miConfig.Code
  9329. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9330. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9331. data["secret_key"] = miConfig.SecretKey
  9332. data["sick_code"] = sickConfig.CountryCode
  9333. data["sick_name"] = sickConfig.ClassName
  9334. data["begin_time"] = begin_time
  9335. data["dept"] = strconv.FormatInt(department.ID, 10)
  9336. data["config"] = config
  9337. data["url"] = miConfig.Url
  9338. data["ak"] = miConfig.AccessKey
  9339. data["cainfo"] = miConfig.Cainfo
  9340. bytesData, _ := json.Marshal(data)
  9341. var req *http.Request
  9342. if miConfig.MdtrtareaAdmvs == "320921" {
  9343. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9344. } else {
  9345. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9346. }
  9347. resp, _ := client.Do(req)
  9348. defer resp.Body.Close()
  9349. body, ioErr := ioutil.ReadAll(resp.Body)
  9350. if ioErr != nil {
  9351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9353. return
  9354. }
  9355. var respJSON map[string]interface{}
  9356. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9359. return
  9360. }
  9361. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  9362. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  9363. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  9364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9365. userJSONBytes, _ := json.Marshal(respJSON)
  9366. fmt.Println("log")
  9367. fmt.Println(string(userJSONBytes))
  9368. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  9369. utils.ErrorLog("解析失败:%v", err)
  9370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9371. return
  9372. }
  9373. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9374. res2.Output = resSix10265.Output
  9375. res2.ErrMsg = resSix10265.ErrMsg
  9376. res2.Cainfo = resSix10265.Cainfo
  9377. res2.WarnMsg = resSix10265.WarnMsg
  9378. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9379. res2.Infcode = infocode
  9380. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9381. 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)
  9382. saveLog(result, requestLog, "2203", "上传就诊信息")
  9383. var respJSON2 map[string]interface{}
  9384. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9387. return
  9388. }
  9389. userJSONBytes2, _ := json.Marshal(respJSON2)
  9390. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9391. utils.ErrorLog("解析失败:%v", err)
  9392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9393. return
  9394. }
  9395. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9396. var result string
  9397. var requestLog string
  9398. 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, "")
  9399. saveLog(result, requestLog, "2203", "上传就诊信息")
  9400. var respJSON2 map[string]interface{}
  9401. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9404. return
  9405. }
  9406. userJSONBytes2, _ := json.Marshal(respJSON2)
  9407. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9408. utils.ErrorLog("解析失败:%v", err)
  9409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9410. return
  9411. }
  9412. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9413. var result string
  9414. var requestLog string
  9415. 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, "")
  9416. saveLog(result, requestLog, "2203", "上传就诊信息")
  9417. var respJSON2 map[string]interface{}
  9418. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9421. return
  9422. }
  9423. userJSONBytes2, _ := json.Marshal(respJSON2)
  9424. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9425. utils.ErrorLog("解析失败:%v", err)
  9426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9427. return
  9428. }
  9429. } else {
  9430. var result string
  9431. var requestLog string
  9432. if miConfig.MdtrtareaAdmvs == "440781" { //
  9433. 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)
  9434. } else {
  9435. if miConfig.Code == "H15049901371" {
  9436. //赤峰地区国家医保医疗类别
  9437. //职工透析:医疗类别选特殊情况门诊990502
  9438. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9439. var med_type string
  9440. if his.Insutype == "390" {
  9441. if reg_type == 14 {
  9442. med_type = "9933"
  9443. } else if reg_type == 11 {
  9444. med_type = "11"
  9445. }
  9446. } else if his.Insutype == "310" {
  9447. if reg_type == 14 {
  9448. med_type = "990502"
  9449. } else if reg_type == 11 {
  9450. med_type = "11"
  9451. }
  9452. }
  9453. 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)
  9454. } else {
  9455. 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)
  9456. }
  9457. saveLog(result, requestLog, "2203", "上传就诊信息")
  9458. var respJSON2 map[string]interface{}
  9459. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9462. return
  9463. }
  9464. userJSONBytes2, _ := json.Marshal(respJSON2)
  9465. if miConfig.Code == "H15049901371" {
  9466. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  9467. utils.ErrorLog("解析失败:%v", err)
  9468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9469. return
  9470. }
  9471. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9472. res2.Output = resSix10265.Output
  9473. res2.ErrMsg = resSix10265.ErrMsg
  9474. res2.Cainfo = resSix10265.Cainfo
  9475. res2.WarnMsg = resSix10265.WarnMsg
  9476. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9477. res2.Infcode = infocode
  9478. } else {
  9479. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9480. utils.ErrorLog("解析失败:%v", err)
  9481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9482. return
  9483. }
  9484. }
  9485. }
  9486. }
  9487. if res2.Infcode != 0 {
  9488. adminUser := c.GetAdminUserInfo()
  9489. errlog := &models.HisOrderError{
  9490. UserOrgId: adminUser.CurrentOrgId,
  9491. Ctime: time.Now().Unix(),
  9492. Mtime: time.Now().Unix(),
  9493. ErrMsg: res2.ErrMsg,
  9494. Status: 1,
  9495. PatientId: id,
  9496. RecordTime: recordDateTime,
  9497. Stage: 3,
  9498. }
  9499. service.CreateErrMsgLog(errlog)
  9500. c.ServeSuccessJSON(map[string]interface{}{
  9501. "failed_code": -10,
  9502. "msg": res2.ErrMsg,
  9503. })
  9504. return
  9505. } else {
  9506. his.Diagnosis = diagnosis_id
  9507. his.SickType = sickConfig.ID
  9508. his.PType = fmt.Sprintf("%d", reg_type)
  9509. service.UpdateHisPatientThree(&his)
  9510. data := make(map[string]interface{})
  9511. if settle_accounts_type == 1 { //日结
  9512. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  9513. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  9514. } else {
  9515. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  9516. }
  9517. data["pre"] = prescriptions
  9518. } else { //月结
  9519. start_time_str := c.GetString("start_time")
  9520. end_time_str := c.GetString("end_time")
  9521. timeLayout := "2006-01-02"
  9522. loc, _ := time.LoadLocation("Local")
  9523. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9524. if err != nil {
  9525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9526. return
  9527. }
  9528. recordStartTime := theStartTime.Unix()
  9529. start_time = recordStartTime
  9530. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9531. if err != nil {
  9532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9533. return
  9534. }
  9535. recordEndTime := theEndTime.Unix()
  9536. end_time = recordEndTime
  9537. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  9538. data["pre"] = prescriptions
  9539. }
  9540. client := &http.Client{}
  9541. data["psn_no"] = his.PsnNo
  9542. data["mdtrt_id"] = his.Number
  9543. data["chrg_bchno"] = chrg_bchno
  9544. data["org_name"] = miConfig.OrgName
  9545. data["doctor"] = doctor_info.UserName
  9546. data["doctor_id"] = doctor_info.DoctorNumber
  9547. data["dept"] = department.Name
  9548. data["fixmedins_code"] = miConfig.Code
  9549. data["opter"] = roles.UserName
  9550. data["dept_code"] = department.Number
  9551. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9552. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9553. data["secret_key"] = miConfig.SecretKey
  9554. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  9555. data["url"] = miConfig.Url
  9556. data["ak"] = miConfig.AccessKey
  9557. data["new_doctor_name"] = patientPrescription.Doctor
  9558. data["diag_code"] = sickConfig.CountryCode
  9559. data["cainfo"] = miConfig.Cainfo
  9560. data["opter"] = roles.UserName
  9561. var ids []int64
  9562. for _, item := range prescriptions {
  9563. ids = append(ids, item.ID)
  9564. }
  9565. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9566. if config.IsOpen == 1 { //对接了医保,走医保流程
  9567. var res ResultFour
  9568. var resFour10265 ResultFour10265
  9569. if miConfig.MdtrtareaAdmvs == "421300" {
  9570. bytesData, _ := json.Marshal(data)
  9571. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  9572. resp, _ := client.Do(req)
  9573. defer resp.Body.Close()
  9574. body, ioErr := ioutil.ReadAll(resp.Body)
  9575. if ioErr != nil {
  9576. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9578. return
  9579. }
  9580. var respJSON map[string]interface{}
  9581. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9584. return
  9585. }
  9586. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9587. userJSONBytes, _ := json.Marshal(respJSON)
  9588. fmt.Println("log")
  9589. fmt.Println(string(userJSONBytes))
  9590. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9591. utils.ErrorLog("解析失败:%v", err)
  9592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9593. return
  9594. }
  9595. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9596. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  9597. if result3101.Infcode == "0" {
  9598. if len(result3101.Output.Result) > 0 {
  9599. var errMsgs []string
  9600. for _, item := range result3101.Output.Result {
  9601. errMsgs = append(errMsgs, item.VolaCont)
  9602. }
  9603. c.ServeSuccessJSON(map[string]interface{}{
  9604. "failed_code": -10,
  9605. "msg": errMsgs,
  9606. })
  9607. return
  9608. } else {
  9609. if miConfig.MdtrtareaAdmvs == "320921" {
  9610. data["doctor_id"] = "D320923012139"
  9611. } else {
  9612. data["doctor_id"] = "D371621008686"
  9613. }
  9614. bytesData, _ := json.Marshal(data)
  9615. var req *http.Request
  9616. if miConfig.MdtrtareaAdmvs == "320921" {
  9617. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9618. } else {
  9619. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9620. }
  9621. resp, _ := client.Do(req)
  9622. defer resp.Body.Close()
  9623. body, ioErr := ioutil.ReadAll(resp.Body)
  9624. if ioErr != nil {
  9625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9627. return
  9628. }
  9629. var respJSON map[string]interface{}
  9630. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9633. return
  9634. }
  9635. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9636. userJSONBytes, _ := json.Marshal(respJSON)
  9637. fmt.Println("log")
  9638. fmt.Println(string(userJSONBytes))
  9639. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9640. utils.ErrorLog("解析失败:%v", err)
  9641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9642. return
  9643. }
  9644. res.InfRefmsgid = resFour10265.InfRefmsgid
  9645. res.Output = resFour10265.Output
  9646. res.ErrMsg = resFour10265.ErrMsg
  9647. res.Cainfo = resFour10265.Cainfo
  9648. res.WarnMsg = resFour10265.WarnMsg
  9649. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9650. res.Infcode = infocode
  9651. }
  9652. }
  9653. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9654. 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)
  9655. var dat map[string]interface{}
  9656. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9657. fmt.Println(dat)
  9658. } else {
  9659. fmt.Println(err)
  9660. }
  9661. saveLog(result, request_log, "2204", "上传费用明细")
  9662. userJSONBytes, _ := json.Marshal(dat)
  9663. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9664. utils.ErrorLog("解析失败:%v", err)
  9665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9666. return
  9667. }
  9668. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9669. 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, "", "")
  9670. var dat map[string]interface{}
  9671. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9672. fmt.Println(dat)
  9673. } else {
  9674. fmt.Println(err)
  9675. }
  9676. saveLog(result, request_log, "2204", "上传费用明细")
  9677. userJSONBytes, _ := json.Marshal(dat)
  9678. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9679. utils.ErrorLog("解析失败:%v", err)
  9680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9681. return
  9682. }
  9683. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9684. 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, "", "")
  9685. var dat map[string]interface{}
  9686. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9687. fmt.Println(dat)
  9688. } else {
  9689. fmt.Println(err)
  9690. }
  9691. saveLog(result, request_log, "2204", "上传费用明细")
  9692. userJSONBytes, _ := json.Marshal(dat)
  9693. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9694. utils.ErrorLog("解析失败:%v", err)
  9695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9696. return
  9697. }
  9698. } else {
  9699. if miConfig.Code == "H15049901371" {
  9700. 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)
  9701. var dat map[string]interface{}
  9702. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9703. fmt.Println(dat)
  9704. } else {
  9705. fmt.Println(err)
  9706. }
  9707. saveLog(result, request_log, "2204", "上传费用明细")
  9708. userJSONBytes, _ := json.Marshal(dat)
  9709. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9710. utils.ErrorLog("解析失败:%v", err)
  9711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9712. return
  9713. }
  9714. res.InfRefmsgid = resFour10265.InfRefmsgid
  9715. res.Output = resFour10265.Output
  9716. res.ErrMsg = resFour10265.ErrMsg
  9717. res.Cainfo = resFour10265.Cainfo
  9718. res.WarnMsg = resFour10265.WarnMsg
  9719. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9720. res.Infcode = infocode
  9721. } else {
  9722. 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)
  9723. var dat map[string]interface{}
  9724. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9725. fmt.Println(dat)
  9726. } else {
  9727. fmt.Println(err)
  9728. }
  9729. saveLog(result, request_log, "2204", "上传费用明细")
  9730. userJSONBytes, _ := json.Marshal(dat)
  9731. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9732. utils.ErrorLog("解析失败:%v", err)
  9733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9734. return
  9735. }
  9736. }
  9737. }
  9738. if res.Infcode == 0 {
  9739. order := &models.HisOrder{
  9740. UserOrgId: adminUser.CurrentOrgId,
  9741. HisPatientId: his.ID,
  9742. PatientId: his.PatientId,
  9743. SettleAccountsDate: recordDateTime,
  9744. Ctime: time.Now().Unix(),
  9745. Mtime: time.Now().Unix(),
  9746. MdtrtId: his.Number,
  9747. PsnNo: his.PsnNo,
  9748. MedType: strconv.FormatInt(reg_type, 10),
  9749. Status: 1,
  9750. Number: chrg_bchno,
  9751. Infcode: res.Infcode,
  9752. WarnMsg: res.WarnMsg,
  9753. Cainfo: res.Cainfo,
  9754. ErrMsg: res.ErrMsg,
  9755. RespondTime: res.RefmsgTime,
  9756. InfRefmsgid: res.InfRefmsgid,
  9757. OrderStatus: 1,
  9758. IsMedicineInsurance: 1,
  9759. SettleType: settle_accounts_type,
  9760. SettleStartTime: start_time,
  9761. SettleEndTime: end_time,
  9762. Creator: roles.AdminUserId,
  9763. Modify: roles.AdminUserId,
  9764. PType: 2,
  9765. Diagnosis: diagnosis_id,
  9766. }
  9767. err = service.CreateOrder(order)
  9768. if err != nil {
  9769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9770. return
  9771. }
  9772. for _, item := range res.Output.Result {
  9773. temp := strings.Split(item.FeedetlSn, "-")
  9774. var advice_id int64 = 0
  9775. var project_id int64 = 0
  9776. var types int64 = 0
  9777. id, _ := strconv.ParseInt(temp[2], 10, 64)
  9778. types, _ = strconv.ParseInt(temp[1], 10, 64)
  9779. if temp[1] == "1" {
  9780. advice_id = id
  9781. project_id = 0
  9782. } else if temp[1] == "2" {
  9783. advice_id = 0
  9784. project_id = id
  9785. }
  9786. info := &models.HisOrderInfo{
  9787. OrderNumber: order.Number,
  9788. FeedetlSn: item.FeedetlSn,
  9789. UploadDate: time.Now().Unix(),
  9790. AdviceId: advice_id,
  9791. DetItemFeeSumamt: item.DetItemFeeSumamt,
  9792. Cnt: item.Cnt,
  9793. Pric: float64(item.Pric),
  9794. PatientId: his.PatientId,
  9795. PricUplmtAmt: item.PricUplmtAmt,
  9796. SelfpayProp: item.SelfpayProp,
  9797. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9798. OverlmtAmt: item.OverlmtAmt,
  9799. PreselfpayAmt: item.PreselfpayAmt,
  9800. BasMednFlag: item.BasMednFlag,
  9801. MedChrgitmType: item.MedChrgitmType,
  9802. HiNegoDrugFlag: item.HiNegoDrugFlag,
  9803. Status: 1,
  9804. Memo: item.Memo,
  9805. Mtime: time.Now().Unix(),
  9806. InscpScpAmt: item.InscpScpAmt,
  9807. DrtReimFlag: item.DrtReimFlag,
  9808. Ctime: time.Now().Unix(),
  9809. ListSpItemFlag: item.ListSpItemFlag,
  9810. ChldMedcFlag: item.ChldMedcFlag,
  9811. LmtUsedFlag: item.LmtUsedFlag,
  9812. ChrgitmLv: item.ChrgitmLv,
  9813. UserOrgId: adminUser.CurrentOrgId,
  9814. HisPatientId: his.ID,
  9815. OrderId: order.ID,
  9816. ProjectId: project_id,
  9817. Type: types,
  9818. }
  9819. service.CreateOrderInfo(info)
  9820. }
  9821. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9822. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  9823. var total float64
  9824. for _, item := range prescriptions {
  9825. if item.Type == 1 { //药品
  9826. for _, subItem := range item.HisDoctorAdviceInfo {
  9827. total = total + (subItem.Price * subItem.PrescribingNumber)
  9828. }
  9829. }
  9830. if item.Type == 2 { //项目
  9831. for _, subItem := range item.HisPrescriptionProject {
  9832. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9833. total = total + (subItem.Price * cnt)
  9834. }
  9835. }
  9836. }
  9837. for _, item := range prescriptions {
  9838. for _, subItem := range item.HisAdditionalCharge {
  9839. total = total + (subItem.Price * float64(subItem.Count))
  9840. }
  9841. }
  9842. allTotal := fmt.Sprintf("%.4f", total)
  9843. if res.Infcode == 0 {
  9844. var rf []*ResultFive
  9845. json.Unmarshal([]byte(his.Iinfo), &rf)
  9846. chrg_bchno := chrg_bchno
  9847. cert_no := his.Certno
  9848. var insutypes []string
  9849. var insutype string
  9850. var is390 int = 0
  9851. var is310 int = 0
  9852. for _, item := range rf {
  9853. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9854. insutypes = append(insutypes, item.Insutype)
  9855. }
  9856. }
  9857. if len(insutypes) == 1 {
  9858. insutype = insutypes[0]
  9859. } else {
  9860. for _, i := range insutypes {
  9861. if i == "390" {
  9862. is390 = 1
  9863. }
  9864. if i == "310" {
  9865. is310 = 1
  9866. }
  9867. }
  9868. }
  9869. if is390 == 1 {
  9870. insutype = "390"
  9871. }
  9872. if is310 == 1 {
  9873. insutype = "310"
  9874. }
  9875. if len(insutypes) == 0 {
  9876. insutype = "310"
  9877. }
  9878. if len(insutypes) == 2 {
  9879. insutype = strconv.FormatInt(his.SocialType, 64)
  9880. }
  9881. //insutype = "390"
  9882. if his.IdCardType == 1 {
  9883. cert_no = his.MedicalInsuranceNumber
  9884. } else {
  9885. cert_no = his.Certno
  9886. }
  9887. var res ResultSeven
  9888. var resSeven10265 ResultSeven10265
  9889. if miConfig.MdtrtareaAdmvs == "421300" {
  9890. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9891. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9892. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9893. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9894. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9895. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9896. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  9897. resp, requestErr := http.Get(api)
  9898. if requestErr != nil {
  9899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9900. return
  9901. }
  9902. body, ioErr := ioutil.ReadAll(resp.Body)
  9903. if ioErr != nil {
  9904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9906. return
  9907. }
  9908. var respJSON map[string]interface{}
  9909. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9912. return
  9913. }
  9914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9915. result, _ := json.Marshal(respJSON)
  9916. fmt.Println("log")
  9917. fmt.Println(string(result))
  9918. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9919. utils.ErrorLog("解析失败:%v", err)
  9920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9921. return
  9922. }
  9923. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9924. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  9925. if result3101.Infcode == "0" {
  9926. if len(result3101.Output.Result) > 0 {
  9927. var errMsgs []string
  9928. for _, item := range result3101.Output.Result {
  9929. errMsgs = append(errMsgs, item.VolaCont)
  9930. }
  9931. c.ServeSuccessJSON(map[string]interface{}{
  9932. "failed_code": -10,
  9933. "msg": errMsgs,
  9934. })
  9935. return
  9936. } else {
  9937. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9938. if his.IdCardType != 4 {
  9939. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9940. bas := strings.Split(psn_info.CardInfo, "|")
  9941. if his.IdCardType == 1 {
  9942. cert_no = bas[2]
  9943. } else {
  9944. cert_no = bas[1]
  9945. }
  9946. } else {
  9947. cert_no = his.Certno
  9948. }
  9949. //江苏地区国家医保医疗类别
  9950. //职工透析:医疗类别选特殊情况门诊9933
  9951. //居民血透门慢: 医疗类别选门诊慢病1402
  9952. //var med_type string
  9953. //if his.Insutype == "310" {
  9954. // if reg_type == 14 {
  9955. // med_type = "9933"
  9956. // } else if reg_type == 11 {
  9957. // med_type = "11"
  9958. //
  9959. // }
  9960. //} else if his.Insutype == "390" {
  9961. // if reg_type == 14 {
  9962. // med_type = "1402"
  9963. // } else if reg_type == 11 {
  9964. // med_type = "11"
  9965. // }
  9966. //}
  9967. var api string
  9968. if miConfig.MdtrtareaAdmvs == "320921" {
  9969. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9970. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9971. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9972. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9973. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9974. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9975. "&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
  9976. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9977. } else {
  9978. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9979. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9980. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9981. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9982. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9983. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9984. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9985. "&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
  9986. }
  9987. resp, requestErr := http.Get(api)
  9988. if requestErr != nil {
  9989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9990. return
  9991. }
  9992. body, ioErr := ioutil.ReadAll(resp.Body)
  9993. if ioErr != nil {
  9994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9996. return
  9997. }
  9998. var respJSON map[string]interface{}
  9999. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10002. return
  10003. }
  10004. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10005. result, _ := json.Marshal(respJSON)
  10006. fmt.Println("log")
  10007. fmt.Println(string(result))
  10008. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10009. utils.ErrorLog("解析失败:%v", err)
  10010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10011. return
  10012. }
  10013. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10014. res.Output = resSeven10265.Output
  10015. res.ErrMsg = resSeven10265.ErrMsg
  10016. res.Cainfo = resSeven10265.Cainfo
  10017. res.WarnMsg = resSeven10265.WarnMsg
  10018. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10019. res.Infcode = infocode
  10020. }
  10021. }
  10022. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10023. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId, recordDateTime)
  10024. var result string
  10025. var request_log string
  10026. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  10027. 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)
  10028. } else {
  10029. 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)
  10030. }
  10031. var dat map[string]interface{}
  10032. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10033. fmt.Println(dat)
  10034. } else {
  10035. fmt.Println(err)
  10036. }
  10037. saveLog(result, request_log, "2206", "预结算")
  10038. userJSONBytes, _ := json.Marshal(dat)
  10039. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10040. utils.ErrorLog("解析失败:%v", err)
  10041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10042. return
  10043. }
  10044. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10045. var result string
  10046. var request_log string
  10047. if his.IdCardType == 2 {
  10048. 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, "")
  10049. } else if his.IdCardType == 1 {
  10050. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10051. bas := strings.Split(psn_info.CardInfo, "|")
  10052. basNumber := bas[2]
  10053. card_sn := bas[3]
  10054. 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)
  10055. } else {
  10056. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10057. 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, "")
  10058. }
  10059. var dat map[string]interface{}
  10060. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10061. fmt.Println(dat)
  10062. } else {
  10063. fmt.Println(err)
  10064. }
  10065. saveLog(result, request_log, "2206", "预结算")
  10066. userJSONBytes, _ := json.Marshal(dat)
  10067. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10068. utils.ErrorLog("解析失败:%v", err)
  10069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10070. return
  10071. }
  10072. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10073. var result string
  10074. var request_log string
  10075. if his.IdCardType == 2 {
  10076. 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, "")
  10077. } else if his.IdCardType == 1 {
  10078. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10079. bas := strings.Split(psn_info.CardInfo, "|")
  10080. basNumber := bas[2]
  10081. card_sn := bas[3]
  10082. 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)
  10083. } else {
  10084. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10085. 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, "")
  10086. }
  10087. var dat map[string]interface{}
  10088. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10089. fmt.Println(dat)
  10090. } else {
  10091. fmt.Println(err)
  10092. }
  10093. saveLog(result, request_log, "2206", "预结算")
  10094. userJSONBytes, _ := json.Marshal(dat)
  10095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10096. utils.ErrorLog("解析失败:%v", err)
  10097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10098. return
  10099. }
  10100. } else {
  10101. var result string
  10102. var request_log string
  10103. if miConfig.Code == "H15049901371" {
  10104. //赤峰地区国家医保医疗类别
  10105. //职工透析:医疗类别选特殊情况门诊990502
  10106. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10107. var med_type string
  10108. if his.Insutype == "390" {
  10109. if reg_type == 14 {
  10110. med_type = "9933"
  10111. } else if reg_type == 11 {
  10112. med_type = "11"
  10113. }
  10114. } else if his.Insutype == "310" {
  10115. if reg_type == 14 {
  10116. med_type = "990502"
  10117. } else if reg_type == 11 {
  10118. med_type = "11"
  10119. }
  10120. }
  10121. 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)
  10122. } else {
  10123. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10124. if his.IdCardType == 4 {
  10125. 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)
  10126. } else {
  10127. 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)
  10128. }
  10129. }
  10130. var dat map[string]interface{}
  10131. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10132. fmt.Println(dat)
  10133. } else {
  10134. fmt.Println(err)
  10135. }
  10136. saveLog(result, request_log, "2206", "预结算")
  10137. //userJSONBytes, _ := json.Marshal(dat)
  10138. //
  10139. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10140. // utils.ErrorLog("解析失败:%v", err)
  10141. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10142. // return
  10143. //}
  10144. userJSONBytes, _ := json.Marshal(dat)
  10145. if miConfig.Code == "H15049901371" {
  10146. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10147. utils.ErrorLog("解析失败:%v", err)
  10148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10149. return
  10150. }
  10151. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10152. res.Output = resSeven10265.Output
  10153. res.ErrMsg = resSeven10265.ErrMsg
  10154. res.Cainfo = resSeven10265.Cainfo
  10155. res.WarnMsg = resSeven10265.WarnMsg
  10156. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10157. res.Infcode = infocode
  10158. } else {
  10159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10160. utils.ErrorLog("解析失败:%v", err)
  10161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10162. return
  10163. }
  10164. }
  10165. }
  10166. if res.Infcode != 0 {
  10167. errlog := &models.HisOrderError{
  10168. UserOrgId: adminUser.CurrentOrgId,
  10169. Ctime: time.Now().Unix(),
  10170. Mtime: time.Now().Unix(),
  10171. Number: chrg_bchno,
  10172. ErrMsg: res.ErrMsg,
  10173. Status: 1,
  10174. PatientId: id,
  10175. RecordTime: recordDateTime,
  10176. Stage: 20,
  10177. }
  10178. service.CreateErrMsgLog(errlog)
  10179. c.ServeSuccessJSON(map[string]interface{}{
  10180. "failed_code": -10,
  10181. "msg": res.ErrMsg,
  10182. })
  10183. return
  10184. } else {
  10185. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10186. order.OrderStatus = 1
  10187. order.IsPre = 1
  10188. order.Status = 1
  10189. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10190. order.SetlId = res.Output.Setlinfo.SetlID
  10191. order.PsnNo = res.Output.Setlinfo.PsnNo
  10192. order.PsnName = res.Output.Setlinfo.PsnName
  10193. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10194. order.Certno = res.Output.Setlinfo.Certno
  10195. order.Gend = res.Output.Setlinfo.Gend
  10196. order.Naty = res.Output.Setlinfo.Naty
  10197. order.Age = res.Output.Setlinfo.Age
  10198. order.Insutype = res.Output.Setlinfo.Insutype
  10199. order.PsnType = res.Output.Setlinfo.PsnType
  10200. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10201. order.SetlTime = res.Output.Setlinfo.SetlTime
  10202. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10203. if res.Output.Setlinfo.MedType == "140101" {
  10204. order.MedType = "14"
  10205. } else {
  10206. order.MedType = res.Output.Setlinfo.MedType
  10207. }
  10208. if reg_type == 1112 {
  10209. order.MedType = "1112"
  10210. }
  10211. if reg_type == 1111 {
  10212. order.MedType = "1111"
  10213. }
  10214. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10215. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10216. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10217. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10218. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10219. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10220. order.HifpPay = res.Output.Setlinfo.HifpPay
  10221. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10222. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10223. order.HifesPay = res.Output.Setlinfo.HifesPay
  10224. order.HifobPay = res.Output.Setlinfo.HifobPay
  10225. order.MafPay = res.Output.Setlinfo.MafPay
  10226. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10227. order.OthPay = res.Output.Setlinfo.OthPay
  10228. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10229. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10230. order.AcctPay = res.Output.Setlinfo.AcctPay
  10231. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10232. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10233. order.Balc = res.Output.Setlinfo.Balc
  10234. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10235. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10236. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10237. order.ClrWay = res.Output.Setlinfo.ClrWay
  10238. order.Creator = order.Creator
  10239. order.Modify = roles.AdminUserId
  10240. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10241. detailStr := string(setlDetail)
  10242. order.SetlDetail = detailStr
  10243. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10244. err = service.UpDateOrder(order)
  10245. if err == nil {
  10246. c.ServeSuccessJSON(map[string]interface{}{
  10247. "msg": "预结算成功",
  10248. })
  10249. } else {
  10250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10251. return
  10252. }
  10253. }
  10254. } else {
  10255. adminUser := c.GetAdminUserInfo()
  10256. errlog := &models.HisOrderError{
  10257. UserOrgId: adminUser.CurrentOrgId,
  10258. Ctime: time.Now().Unix(),
  10259. Mtime: time.Now().Unix(),
  10260. ErrMsg: res.ErrMsg,
  10261. Status: 1,
  10262. PatientId: id,
  10263. RecordTime: recordDateTime,
  10264. Stage: 4,
  10265. }
  10266. service.CreateErrMsgLog(errlog)
  10267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10268. return
  10269. }
  10270. } else {
  10271. adminUser := c.GetAdminUserInfo()
  10272. errlog := &models.HisOrderError{
  10273. UserOrgId: adminUser.CurrentOrgId,
  10274. Ctime: time.Now().Unix(),
  10275. Mtime: time.Now().Unix(),
  10276. ErrMsg: res.ErrMsg,
  10277. Status: 1,
  10278. PatientId: id,
  10279. RecordTime: recordDateTime,
  10280. Stage: 4,
  10281. }
  10282. service.CreateErrMsgLog(errlog)
  10283. c.ServeSuccessJSON(map[string]interface{}{
  10284. "failed_code": -10,
  10285. "msg": res.ErrMsg,
  10286. })
  10287. return
  10288. }
  10289. }
  10290. }
  10291. }
  10292. //退款
  10293. func (c *HisApiController) Refund() {
  10294. order_id, _ := c.GetInt64("order_id")
  10295. admin_user_id, _ := c.GetInt64("admin_user_id")
  10296. adminUser := c.GetAdminUserInfo()
  10297. var order models.HisOrder
  10298. order, _ = service.GetHisOrderByID(order_id)
  10299. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10300. if order.ID == 0 {
  10301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10302. return
  10303. }
  10304. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10305. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10306. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10307. if config.IsOpen == 1 { //对接了医保,走医保流程
  10308. var res ResultSixteen
  10309. var resSixteen10265 ResultSixteen10265
  10310. var src_resquest string
  10311. var result string
  10312. if miConfig.MdtrtareaAdmvs == "421300" {
  10313. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  10314. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10315. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10316. resp3, requestErr3 := http.Get(api3)
  10317. if requestErr3 != nil {
  10318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10319. return
  10320. }
  10321. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10322. if ioErr3 != nil {
  10323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10325. return
  10326. }
  10327. var respJSON3 map[string]interface{}
  10328. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10331. return
  10332. }
  10333. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10334. userJSONBytes3, _ := json.Marshal(respJSON3)
  10335. fmt.Println("log")
  10336. fmt.Println(string(userJSONBytes3))
  10337. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  10338. utils.ErrorLog("解析失败:%v", err)
  10339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10340. return
  10341. }
  10342. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10343. var api3 string
  10344. if miConfig.MdtrtareaAdmvs == "320921" {
  10345. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10346. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10347. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10348. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10349. } else {
  10350. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10351. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10352. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10353. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10354. }
  10355. resp3, requestErr3 := http.Get(api3)
  10356. if requestErr3 != nil {
  10357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10358. return
  10359. }
  10360. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10361. if ioErr3 != nil {
  10362. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10364. return
  10365. }
  10366. var respJSON3 map[string]interface{}
  10367. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10370. return
  10371. }
  10372. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10373. userJSONBytes3, _ := json.Marshal(respJSON3)
  10374. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  10375. utils.ErrorLog("解析失败:%v", err)
  10376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10377. return
  10378. }
  10379. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10380. res.Output = resSixteen10265.Output
  10381. res.ErrMsg = resSixteen10265.ErrMsg
  10382. res.Cainfo = resSixteen10265.Cainfo
  10383. res.WarnMsg = resSixteen10265.WarnMsg
  10384. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10385. res.Infcode = infocode
  10386. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10387. 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)
  10388. var dat map[string]interface{}
  10389. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10390. fmt.Println(dat)
  10391. } else {
  10392. fmt.Println(err)
  10393. }
  10394. saveLog(result, src_resquest, "2208", "退费")
  10395. userJSONBytes, _ := json.Marshal(dat)
  10396. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10397. utils.ErrorLog("解析失败:%v", err)
  10398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10399. return
  10400. }
  10401. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10402. 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, "")
  10403. var dat map[string]interface{}
  10404. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10405. fmt.Println(dat)
  10406. } else {
  10407. fmt.Println(err)
  10408. }
  10409. saveLog(result, src_resquest, "2208", "退费")
  10410. userJSONBytes, _ := json.Marshal(dat)
  10411. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10412. utils.ErrorLog("解析失败:%v", err)
  10413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10414. return
  10415. }
  10416. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10417. 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, "")
  10418. var dat map[string]interface{}
  10419. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10420. fmt.Println(dat)
  10421. } else {
  10422. fmt.Println(err)
  10423. }
  10424. saveLog(result, src_resquest, "2208", "退费")
  10425. userJSONBytes, _ := json.Marshal(dat)
  10426. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10427. utils.ErrorLog("解析失败:%v", err)
  10428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10429. return
  10430. }
  10431. } else {
  10432. if miConfig.Code == "H15049901371" {
  10433. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10434. var dat map[string]interface{}
  10435. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10436. fmt.Println(dat)
  10437. } else {
  10438. fmt.Println(err)
  10439. }
  10440. saveLog(result, src_resquest, "2208", "退费")
  10441. userJSONBytes, _ := json.Marshal(dat)
  10442. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  10443. utils.ErrorLog("解析失败:%v", err)
  10444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10445. return
  10446. }
  10447. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10448. res.Output = resSixteen10265.Output
  10449. res.ErrMsg = resSixteen10265.ErrMsg
  10450. res.Cainfo = resSixteen10265.Cainfo
  10451. res.WarnMsg = resSixteen10265.WarnMsg
  10452. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10453. res.Infcode = infocode
  10454. } else {
  10455. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10456. var dat map[string]interface{}
  10457. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10458. fmt.Println(dat)
  10459. } else {
  10460. fmt.Println(err)
  10461. }
  10462. saveLog(result, src_resquest, "2208", "退费")
  10463. userJSONBytes, _ := json.Marshal(dat)
  10464. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10465. utils.ErrorLog("解析失败:%v", err)
  10466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10467. return
  10468. }
  10469. }
  10470. }
  10471. if res.Infcode == 0 {
  10472. var res2 ResultSix
  10473. var resSix10265 ResultSix10265
  10474. if miConfig.MdtrtareaAdmvs == "421300" {
  10475. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10476. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10477. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10478. resp3, requestErr3 := http.Get(api3)
  10479. if requestErr3 != nil {
  10480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10481. return
  10482. }
  10483. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10484. if ioErr3 != nil {
  10485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10487. return
  10488. }
  10489. var respJSON3 map[string]interface{}
  10490. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10493. return
  10494. }
  10495. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10496. userJSONBytes3, _ := json.Marshal(respJSON3)
  10497. fmt.Println("log")
  10498. fmt.Println(string(userJSONBytes3))
  10499. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10500. utils.ErrorLog("解析失败:%v", err)
  10501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10502. return
  10503. }
  10504. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10505. var api3 string
  10506. if miConfig.MdtrtareaAdmvs == "320921" {
  10507. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10508. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10509. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10510. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10511. } else {
  10512. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10513. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10514. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10515. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10516. }
  10517. resp3, requestErr3 := http.Get(api3)
  10518. if requestErr3 != nil {
  10519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10520. return
  10521. }
  10522. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10523. if ioErr3 != nil {
  10524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10526. return
  10527. }
  10528. var respJSON3 map[string]interface{}
  10529. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10532. return
  10533. }
  10534. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10535. userJSONBytes3, _ := json.Marshal(respJSON3)
  10536. fmt.Println("log")
  10537. fmt.Println(string(userJSONBytes3))
  10538. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10539. utils.ErrorLog("解析失败:%v", err)
  10540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10541. return
  10542. }
  10543. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10544. res2.Output = resSix10265.Output
  10545. res2.ErrMsg = resSix10265.ErrMsg
  10546. res2.Cainfo = resSix10265.Cainfo
  10547. res2.WarnMsg = resSix10265.WarnMsg
  10548. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10549. res2.Infcode = infocode
  10550. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10551. 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)
  10552. var dat map[string]interface{}
  10553. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10554. fmt.Println(dat)
  10555. } else {
  10556. fmt.Println(err)
  10557. }
  10558. saveLog(result2, src_request, "2205", "撤销明细")
  10559. userJSONBytes, _ := json.Marshal(dat)
  10560. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10561. utils.ErrorLog("解析失败:%v", err)
  10562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10563. return
  10564. }
  10565. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10566. 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, "")
  10567. var dat map[string]interface{}
  10568. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10569. fmt.Println(dat)
  10570. } else {
  10571. fmt.Println(err)
  10572. }
  10573. saveLog(result2, src_request, "2205", "撤销明细")
  10574. userJSONBytes, _ := json.Marshal(dat)
  10575. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10576. utils.ErrorLog("解析失败:%v", err)
  10577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10578. return
  10579. }
  10580. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10581. 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, "")
  10582. var dat map[string]interface{}
  10583. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10584. fmt.Println(dat)
  10585. } else {
  10586. fmt.Println(err)
  10587. }
  10588. saveLog(result2, src_request, "2205", "撤销明细")
  10589. userJSONBytes, _ := json.Marshal(dat)
  10590. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10591. utils.ErrorLog("解析失败:%v", err)
  10592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10593. return
  10594. }
  10595. } else {
  10596. if miConfig.Code == "H15049901371" {
  10597. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10598. var dat map[string]interface{}
  10599. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10600. fmt.Println(dat)
  10601. } else {
  10602. fmt.Println(err)
  10603. }
  10604. saveLog(result2, src_request, "2205", "撤销明细")
  10605. userJSONBytes, _ := json.Marshal(dat)
  10606. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  10607. utils.ErrorLog("解析失败:%v", err)
  10608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10609. return
  10610. }
  10611. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10612. res2.Output = resSix10265.Output
  10613. res2.ErrMsg = resSix10265.ErrMsg
  10614. res2.Cainfo = resSix10265.Cainfo
  10615. res2.WarnMsg = resSix10265.WarnMsg
  10616. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10617. res2.Infcode = infocode
  10618. } else {
  10619. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10620. var dat map[string]interface{}
  10621. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10622. fmt.Println(dat)
  10623. } else {
  10624. fmt.Println(err)
  10625. }
  10626. saveLog(result2, src_request, "2205", "撤销明细")
  10627. userJSONBytes, _ := json.Marshal(dat)
  10628. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10629. utils.ErrorLog("解析失败:%v", err)
  10630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10631. return
  10632. }
  10633. }
  10634. }
  10635. if res2.Infcode == 0 {
  10636. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  10637. if err == nil {
  10638. //当押金不为零时产生退费记录
  10639. if order.Decimal != 0 {
  10640. tmp := strconv.FormatInt(order.ID, 10)
  10641. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  10642. if err != nil {
  10643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10644. return
  10645. }
  10646. }
  10647. c.ServeSuccessJSON(map[string]interface{}{
  10648. "msg": "退费成功",
  10649. })
  10650. } else {
  10651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10652. return
  10653. }
  10654. } else {
  10655. c.ServeSuccessJSON(map[string]interface{}{
  10656. "code": -10,
  10657. "msg": res2.ErrMsg,
  10658. })
  10659. }
  10660. } else {
  10661. c.ServeSuccessJSON(map[string]interface{}{
  10662. "code": -10,
  10663. "msg": res.ErrMsg,
  10664. })
  10665. }
  10666. }
  10667. }
  10668. func (c *HisApiController) RefundNumber() {
  10669. record_time := c.GetString("record_time")
  10670. //patient_id, _ := c.GetInt64("patient_id")
  10671. admin_user_id, _ := c.GetInt64("admin_user_id")
  10672. his_patient_id, _ := c.GetInt64("id")
  10673. timeLayout := "2006-01-02"
  10674. loc, _ := time.LoadLocation("Local")
  10675. adminUser := c.GetAdminUserInfo()
  10676. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10677. fmt.Println(err)
  10678. if err != nil {
  10679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10680. return
  10681. }
  10682. recordDateTime := theTime.Unix()
  10683. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10684. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  10685. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10686. //order, _ := service.GetHisOrderByID(order_id)
  10687. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10688. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10689. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10690. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  10691. if count > 0 {
  10692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  10693. return
  10694. }
  10695. if config.IsOpen == 1 { //对接了医保,走医保流程
  10696. var res2 ResultSix
  10697. var resSix10265 ResultSix10265
  10698. if miConfig.MdtrtareaAdmvs == "421300" {
  10699. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  10700. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10701. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10702. resp3, requestErr3 := http.Get(api3)
  10703. if requestErr3 != nil {
  10704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10705. return
  10706. }
  10707. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10708. if ioErr3 != nil {
  10709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10711. return
  10712. }
  10713. var respJSON3 map[string]interface{}
  10714. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10717. return
  10718. }
  10719. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10720. userJSONBytes3, _ := json.Marshal(respJSON3)
  10721. fmt.Println("log")
  10722. fmt.Println(string(userJSONBytes3))
  10723. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10724. utils.ErrorLog("解析失败:%v", err)
  10725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10726. return
  10727. }
  10728. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10729. var api3 string
  10730. if miConfig.MdtrtareaAdmvs == "320921" {
  10731. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10732. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10733. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10734. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10735. } else {
  10736. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10737. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10738. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10739. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10740. }
  10741. resp3, requestErr3 := http.Get(api3)
  10742. if requestErr3 != nil {
  10743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10744. return
  10745. }
  10746. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10747. if ioErr3 != nil {
  10748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10750. return
  10751. }
  10752. var respJSON3 map[string]interface{}
  10753. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10756. return
  10757. }
  10758. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10759. userJSONBytes3, _ := json.Marshal(respJSON3)
  10760. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10761. utils.ErrorLog("解析失败:%v", err)
  10762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10763. return
  10764. }
  10765. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10766. res2.Output = resSix10265.Output
  10767. res2.ErrMsg = resSix10265.ErrMsg
  10768. res2.Cainfo = resSix10265.Cainfo
  10769. res2.WarnMsg = resSix10265.WarnMsg
  10770. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10771. res2.Infcode = infocode
  10772. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10773. 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)
  10774. var dat map[string]interface{}
  10775. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10776. fmt.Println(dat)
  10777. } else {
  10778. fmt.Println(err)
  10779. }
  10780. saveLog(result, request, "2202", "退号")
  10781. userJSONBytes, _ := json.Marshal(dat)
  10782. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10783. utils.ErrorLog("解析失败:%v", err)
  10784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10785. return
  10786. }
  10787. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10788. 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, "")
  10789. var dat map[string]interface{}
  10790. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10791. fmt.Println(dat)
  10792. } else {
  10793. fmt.Println(err)
  10794. }
  10795. saveLog(result, request, "2202", "退号")
  10796. userJSONBytes, _ := json.Marshal(dat)
  10797. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10798. utils.ErrorLog("解析失败:%v", err)
  10799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10800. return
  10801. }
  10802. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10803. 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, "")
  10804. var dat map[string]interface{}
  10805. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10806. fmt.Println(dat)
  10807. } else {
  10808. fmt.Println(err)
  10809. }
  10810. saveLog(result, request, "2202", "退号")
  10811. userJSONBytes, _ := json.Marshal(dat)
  10812. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10813. utils.ErrorLog("解析失败:%v", err)
  10814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10815. return
  10816. }
  10817. } else {
  10818. var api3 string
  10819. if miConfig.Code == "H15049901371" {
  10820. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10821. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10822. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10823. } else {
  10824. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10825. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10826. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10827. }
  10828. resp3, requestErr3 := http.Get(api3)
  10829. if requestErr3 != nil {
  10830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10831. return
  10832. }
  10833. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10834. if ioErr3 != nil {
  10835. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10837. return
  10838. }
  10839. var respJSON3 map[string]interface{}
  10840. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10843. return
  10844. }
  10845. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10846. userJSONBytes3, _ := json.Marshal(respJSON3)
  10847. if miConfig.Code == "H15049901371" {
  10848. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10849. utils.ErrorLog("解析失败:%v", err)
  10850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10851. return
  10852. }
  10853. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10854. res2.Output = resSix10265.Output
  10855. res2.ErrMsg = resSix10265.ErrMsg
  10856. res2.Cainfo = resSix10265.Cainfo
  10857. res2.WarnMsg = resSix10265.WarnMsg
  10858. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10859. res2.Infcode = infocode
  10860. } else {
  10861. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10862. utils.ErrorLog("解析失败:%v", err)
  10863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10864. return
  10865. }
  10866. }
  10867. }
  10868. if res2.Infcode == 0 {
  10869. if err == nil {
  10870. c.ServeSuccessJSON(map[string]interface{}{
  10871. "msg": "退号成功",
  10872. })
  10873. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  10874. } else {
  10875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10876. return
  10877. }
  10878. } else {
  10879. c.ServeSuccessJSON(map[string]interface{}{
  10880. "code": -10,
  10881. "msg": res2.ErrMsg,
  10882. })
  10883. }
  10884. } else {
  10885. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  10886. //if err == nil {
  10887. // c.ServeSuccessJSON(map[string]interface{}{
  10888. // "msg": "退费成功",
  10889. // })
  10890. //} else {
  10891. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10892. // return
  10893. //}
  10894. }
  10895. }
  10896. func (c *HisApiController) RefundDetail() {
  10897. order_id, _ := c.GetInt64("order_id")
  10898. admin_user_id, _ := c.GetInt64("admin_user_id")
  10899. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10900. number := c.GetString("number")
  10901. record_time := c.GetString("record_time")
  10902. patient_id, _ := c.GetInt64("patient_id")
  10903. //med_type, _ := c.GetInt64("med_type")
  10904. timeLayout := "2006-01-02"
  10905. loc, _ := time.LoadLocation("Local")
  10906. adminUser := c.GetAdminUserInfo()
  10907. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10908. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10909. fmt.Println(err)
  10910. if err != nil {
  10911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10912. return
  10913. }
  10914. recordDateTime := theTime.Unix()
  10915. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10916. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10917. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10918. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10919. var order models.HisOrder
  10920. order, _ = service.GetHisOrderByID(order_id)
  10921. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10922. if config.IsOpen == 1 { //对接了医保,走医保流程
  10923. var res2 ResultSix
  10924. if miConfig.MdtrtareaAdmvs == "421300" {
  10925. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10926. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10927. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10928. resp3, requestErr3 := http.Get(api3)
  10929. if requestErr3 != nil {
  10930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10931. return
  10932. }
  10933. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10934. if ioErr3 != nil {
  10935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10937. return
  10938. }
  10939. var respJSON3 map[string]interface{}
  10940. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10943. return
  10944. }
  10945. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10946. userJSONBytes3, _ := json.Marshal(respJSON3)
  10947. fmt.Println("log")
  10948. fmt.Println(string(userJSONBytes3))
  10949. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10950. utils.ErrorLog("解析失败:%v", err)
  10951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10952. return
  10953. }
  10954. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10955. if err == nil {
  10956. c.ServeSuccessJSON(map[string]interface{}{
  10957. "msg": "撤销明细成功",
  10958. })
  10959. return
  10960. } else {
  10961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10962. return
  10963. }
  10964. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10965. var resSix10265 ResultSix10265
  10966. var api3 string
  10967. if miConfig.MdtrtareaAdmvs == "320921" {
  10968. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10969. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10970. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10971. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10972. } else {
  10973. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10974. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10975. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10976. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10977. }
  10978. resp3, requestErr3 := http.Get(api3)
  10979. if requestErr3 != nil {
  10980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10981. return
  10982. }
  10983. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10984. if ioErr3 != nil {
  10985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10987. return
  10988. }
  10989. var respJSON3 map[string]interface{}
  10990. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10993. return
  10994. }
  10995. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10996. userJSONBytes3, _ := json.Marshal(respJSON3)
  10997. fmt.Println("log")
  10998. fmt.Println(string(userJSONBytes3))
  10999. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11000. utils.ErrorLog("解析失败:%v", err)
  11001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11002. return
  11003. }
  11004. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11005. res2.Output = resSix10265.Output
  11006. res2.ErrMsg = resSix10265.ErrMsg
  11007. res2.Cainfo = resSix10265.Cainfo
  11008. res2.WarnMsg = resSix10265.WarnMsg
  11009. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11010. res2.Infcode = infocode
  11011. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11012. if err == nil {
  11013. c.ServeSuccessJSON(map[string]interface{}{
  11014. "msg": "撤销明细成功",
  11015. })
  11016. return
  11017. } else {
  11018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11019. return
  11020. }
  11021. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11022. 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)
  11023. var dat map[string]interface{}
  11024. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11025. fmt.Println(dat)
  11026. } else {
  11027. fmt.Println(err)
  11028. }
  11029. saveLog(result2, src_request, "2205", "撤销明细")
  11030. userJSONBytes, _ := json.Marshal(dat)
  11031. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11032. utils.ErrorLog("解析失败:%v", err)
  11033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11034. return
  11035. }
  11036. if res2.Infcode == 0 {
  11037. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11038. if err == nil {
  11039. c.ServeSuccessJSON(map[string]interface{}{
  11040. "msg": "撤销明细成功",
  11041. })
  11042. return
  11043. } else {
  11044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11045. return
  11046. }
  11047. } else {
  11048. c.ServeSuccessJSON(map[string]interface{}{
  11049. "code": -10,
  11050. "msg": res2.ErrMsg,
  11051. })
  11052. }
  11053. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11054. 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, "")
  11055. var dat map[string]interface{}
  11056. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11057. fmt.Println(dat)
  11058. } else {
  11059. fmt.Println(err)
  11060. }
  11061. saveLog(result2, src_request, "2205", "撤销明细")
  11062. userJSONBytes, _ := json.Marshal(dat)
  11063. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11064. utils.ErrorLog("解析失败:%v", err)
  11065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11066. return
  11067. }
  11068. if res2.Infcode == 0 {
  11069. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11070. if err == nil {
  11071. c.ServeSuccessJSON(map[string]interface{}{
  11072. "msg": "撤销明细成功",
  11073. })
  11074. return
  11075. } else {
  11076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11077. return
  11078. }
  11079. } else {
  11080. c.ServeSuccessJSON(map[string]interface{}{
  11081. "code": -10,
  11082. "msg": res2.ErrMsg,
  11083. })
  11084. }
  11085. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11086. 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, "")
  11087. var dat map[string]interface{}
  11088. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11089. fmt.Println(dat)
  11090. } else {
  11091. fmt.Println(err)
  11092. }
  11093. saveLog(result2, src_request, "2205", "撤销明细")
  11094. userJSONBytes, _ := json.Marshal(dat)
  11095. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11096. utils.ErrorLog("解析失败:%v", err)
  11097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11098. return
  11099. }
  11100. if res2.Infcode == 0 {
  11101. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11102. if err == nil {
  11103. c.ServeSuccessJSON(map[string]interface{}{
  11104. "msg": "撤销明细成功",
  11105. })
  11106. return
  11107. } else {
  11108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11109. return
  11110. }
  11111. } else {
  11112. c.ServeSuccessJSON(map[string]interface{}{
  11113. "code": -10,
  11114. "msg": res2.ErrMsg,
  11115. })
  11116. }
  11117. } else {
  11118. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  11119. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11120. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11121. resp2, requestErr2 := http.Get(api2)
  11122. if requestErr2 != nil {
  11123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11124. return
  11125. }
  11126. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  11127. if ioErr2 != nil {
  11128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  11129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11130. return
  11131. }
  11132. var respJSON2 map[string]interface{}
  11133. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  11134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11136. return
  11137. }
  11138. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11139. if err == nil {
  11140. c.ServeSuccessJSON(map[string]interface{}{
  11141. "msg": "撤销明细成功",
  11142. })
  11143. return
  11144. } else {
  11145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11146. return
  11147. }
  11148. }
  11149. } else {
  11150. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11151. if err == nil {
  11152. c.ServeSuccessJSON(map[string]interface{}{
  11153. "msg": "退费成功",
  11154. })
  11155. } else {
  11156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11157. return
  11158. }
  11159. }
  11160. }
  11161. //对账
  11162. func (c *HisApiController) GetCheckAccount() {
  11163. start_time := c.GetString("start_time")
  11164. end_time := c.GetString("end_time")
  11165. insutype := c.GetString("insutype")
  11166. clr_type := c.GetString("clr_type")
  11167. clr_org := c.GetString("clr_optins")
  11168. admin_user_id, _ := c.GetInt64("admin_user_id")
  11169. adminUser := c.GetAdminUserInfo()
  11170. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11171. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11172. if len(clr_org) == 0 {
  11173. clr_org = miConfig.MdtrtareaAdmvs
  11174. }
  11175. timeLayout := "2006-01-02"
  11176. loc, _ := time.LoadLocation("Local")
  11177. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11178. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11179. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  11180. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  11181. fixmedins_setl_cnt := int64(len(orders))
  11182. var medfee_sumamt float64
  11183. var acct_pay float64
  11184. var fund_pay_sumamt float64
  11185. for _, item := range orders {
  11186. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11187. acct_pay = acct_pay + item.AcctPay
  11188. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11189. }
  11190. var user_name string
  11191. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11192. if role.ID == 0 {
  11193. user_name = "xxx"
  11194. } else {
  11195. user_name = role.UserName
  11196. }
  11197. var res ResultEight
  11198. var res10188 ResultEightFor10188
  11199. if config.IsOpen == 1 {
  11200. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11201. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  11202. "insutype=" + insutype +
  11203. "&clr_type=" + clr_type +
  11204. "&setl_optins=" + clr_org +
  11205. "&stmt_begndate=" + start_time +
  11206. "&stm_enddate=" + end_time +
  11207. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11208. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11209. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11210. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11211. "&fixmedins_code=" + miConfig.Code +
  11212. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11213. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11214. "&secret_key=" + miConfig.SecretKey +
  11215. "&org_name=" + miConfig.OrgName +
  11216. "&doctor=" + user_name +
  11217. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11218. fmt.Println(api)
  11219. resp, requestErr := http.Get(api)
  11220. if requestErr != nil {
  11221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11222. return
  11223. }
  11224. body, ioErr := ioutil.ReadAll(resp.Body)
  11225. fmt.Println(body)
  11226. if ioErr != nil {
  11227. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11229. return
  11230. }
  11231. var respJSON map[string]interface{}
  11232. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11233. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11235. return
  11236. }
  11237. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11238. userJSONBytes, _ := json.Marshal(respJSON)
  11239. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11240. utils.ErrorLog("解析失败:%v", err)
  11241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11242. return
  11243. }
  11244. res.InfRefmsgid = res10188.InfRefmsgid
  11245. res.Output = res10188.Output
  11246. res.ErrMsg = res10188.ErrMsg
  11247. res.Cainfo = res10188.Cainfo
  11248. res.WarnMsg = res10188.WarnMsg
  11249. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11250. res.Infcode = infocode
  11251. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11252. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  11253. "insutype=" + insutype +
  11254. "&clr_type=" + "21" +
  11255. "&setl_optins=" + clr_org +
  11256. "&stmt_begndate=" + start_time +
  11257. "&stm_enddate=" + end_time +
  11258. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11259. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11260. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11261. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11262. "&fixmedins_code=" + miConfig.Code +
  11263. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11264. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11265. "&secret_key=" + miConfig.SecretKey +
  11266. "&org_name=" + miConfig.OrgName +
  11267. "&doctor=" + user_name
  11268. resp, requestErr := http.Get(api)
  11269. if requestErr != nil {
  11270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11271. return
  11272. }
  11273. body, ioErr := ioutil.ReadAll(resp.Body)
  11274. if ioErr != nil {
  11275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11277. return
  11278. }
  11279. var respJSON map[string]interface{}
  11280. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11281. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11283. return
  11284. }
  11285. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11286. result, _ := json.Marshal(respJSON)
  11287. fmt.Println("log")
  11288. fmt.Println(string(result))
  11289. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  11290. utils.ErrorLog("解析失败:%v", err)
  11291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11292. return
  11293. }
  11294. res.InfRefmsgid = res10188.InfRefmsgid
  11295. res.Output = res10188.Output
  11296. res.ErrMsg = res10188.ErrMsg
  11297. res.Cainfo = res10188.Cainfo
  11298. res.WarnMsg = res10188.WarnMsg
  11299. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11300. res.Infcode = infocode
  11301. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11302. var baseParams models.BaseParams
  11303. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11304. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11305. baseParams.SecretKey = miConfig.SecretKey
  11306. baseParams.OrgName = miConfig.OrgName
  11307. baseParams.FixmedinsCode = miConfig.Code
  11308. baseParams.EncKey = miConfig.EncKey
  11309. baseParams.AppSecret = miConfig.AppSecret
  11310. baseParams.SignKey = miConfig.SignKey
  11311. baseParams.AppID = miConfig.Code
  11312. baseParams.Doctor = role.UserName
  11313. baseParams.RequestUrl = miConfig.Url
  11314. businessParams := models.BusinessParams{
  11315. Insutype: insutype,
  11316. ClrType: clr_type,
  11317. SetlOptins: clr_org,
  11318. StmtBegndate: start_time,
  11319. StmtEnddate: end_time,
  11320. MedfeeSumamt: medfee_sumamt,
  11321. FundPaySumamt: fund_pay_sumamt,
  11322. AcctPay: acct_pay,
  11323. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11324. }
  11325. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11326. fmt.Println(requestLog)
  11327. fmt.Println(result)
  11328. fmt.Println(err_msg)
  11329. var dat map[string]interface{}
  11330. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11331. fmt.Println(dat)
  11332. } else {
  11333. fmt.Println(err)
  11334. }
  11335. userJSONBytes, _ := json.Marshal(dat)
  11336. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11337. utils.ErrorLog("解析失败:%v", err)
  11338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11339. return
  11340. }
  11341. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11342. var baseParams models.BaseParams
  11343. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11344. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11345. baseParams.SecretKey = miConfig.SecretKey
  11346. baseParams.OrgName = miConfig.OrgName
  11347. baseParams.FixmedinsCode = miConfig.Code
  11348. baseParams.EncKey = miConfig.EncKey
  11349. baseParams.AppSecret = miConfig.AppSecret
  11350. baseParams.SignKey = miConfig.SignKey
  11351. baseParams.AppID = miConfig.Code
  11352. baseParams.Doctor = role.UserName
  11353. baseParams.RequestUrl = miConfig.Url
  11354. baseParams.AccessKey = miConfig.AccessKey
  11355. businessParams := models.BusinessParams{
  11356. Insutype: insutype,
  11357. ClrType: clr_type,
  11358. SetlOptins: "430822",
  11359. StmtBegndate: start_time,
  11360. StmtEnddate: end_time,
  11361. MedfeeSumamt: medfee_sumamt,
  11362. FundPaySumamt: fund_pay_sumamt,
  11363. AcctPay: acct_pay,
  11364. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11365. }
  11366. 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)
  11367. fmt.Println(requestLog)
  11368. fmt.Println(result)
  11369. var dat map[string]interface{}
  11370. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11371. fmt.Println(dat)
  11372. } else {
  11373. fmt.Println(err)
  11374. }
  11375. userJSONBytes, _ := json.Marshal(dat)
  11376. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11377. utils.ErrorLog("解析失败:%v", err)
  11378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11379. return
  11380. }
  11381. } else if miConfig.MdtrtareaAdmvs == "" {
  11382. var baseParams models.BaseParams
  11383. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11384. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11385. baseParams.SecretKey = miConfig.SecretKey
  11386. baseParams.OrgName = miConfig.OrgName
  11387. baseParams.FixmedinsCode = miConfig.Code
  11388. baseParams.EncKey = miConfig.EncKey
  11389. baseParams.AppSecret = miConfig.AppSecret
  11390. baseParams.SignKey = miConfig.SignKey
  11391. baseParams.AppID = miConfig.Code
  11392. baseParams.Doctor = role.UserName
  11393. baseParams.RequestUrl = miConfig.Url
  11394. businessParams := models.BusinessParams{
  11395. Insutype: insutype,
  11396. ClrType: clr_type,
  11397. SetlOptins: clr_org,
  11398. StmtBegndate: start_time,
  11399. StmtEnddate: end_time,
  11400. MedfeeSumamt: medfee_sumamt,
  11401. FundPaySumamt: fund_pay_sumamt,
  11402. AcctPay: acct_pay,
  11403. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11404. }
  11405. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11406. fmt.Println(requestLog)
  11407. fmt.Println(result)
  11408. fmt.Println(err_msg)
  11409. var dat map[string]interface{}
  11410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11411. fmt.Println(dat)
  11412. } else {
  11413. fmt.Println(err)
  11414. }
  11415. userJSONBytes, _ := json.Marshal(dat)
  11416. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11417. utils.ErrorLog("解析失败:%v", err)
  11418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11419. return
  11420. }
  11421. } else {
  11422. if len(clr_type) == 0 {
  11423. clr_type = "11"
  11424. }
  11425. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11426. "insutype=" + insutype +
  11427. "&clr_type=" + clr_type +
  11428. "&setl_optins=" + clr_org +
  11429. "&stmt_begndate=" + start_time +
  11430. "&stm_enddate=" + end_time +
  11431. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11432. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11433. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11434. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11435. "&fixmedins_code=" + miConfig.Code +
  11436. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11437. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11438. "&secret_key=" + miConfig.SecretKey +
  11439. "&org_name=" + miConfig.OrgName +
  11440. "&doctor=" + user_name
  11441. fmt.Println(api)
  11442. resp, requestErr := http.Get(api)
  11443. if requestErr != nil {
  11444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11445. return
  11446. }
  11447. body, ioErr := ioutil.ReadAll(resp.Body)
  11448. fmt.Println(body)
  11449. if ioErr != nil {
  11450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11452. return
  11453. }
  11454. var respJSON map[string]interface{}
  11455. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11458. return
  11459. }
  11460. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11461. userJSONBytes, _ := json.Marshal(respJSON)
  11462. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11463. utils.ErrorLog("解析失败:%v", err)
  11464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11465. return
  11466. }
  11467. }
  11468. if res.Infcode == 0 {
  11469. if res.Output.Stmtinfo.StmtRslt == "0" {
  11470. micc := &models.MedicalInsuranceCostCompare{
  11471. StartTime: startime.Unix(),
  11472. EndTime: endtime.Unix(),
  11473. Insutype: insutype,
  11474. CheckType: 1,
  11475. Num: fixmedins_setl_cnt,
  11476. Mtime: time.Now().Unix(),
  11477. Status: 1,
  11478. UserOrgId: adminUser.CurrentOrgId,
  11479. CostTotal: medfee_sumamt,
  11480. FuncTotal: fund_pay_sumamt,
  11481. PsnPay: acct_pay,
  11482. Creator: admin_user_id,
  11483. Ctime: time.Now().Unix(),
  11484. ClrType: clr_type,
  11485. }
  11486. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  11487. if err == nil {
  11488. c.ServeSuccessJSON(map[string]interface{}{
  11489. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11490. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11491. })
  11492. } else {
  11493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11494. }
  11495. } else {
  11496. c.ServeSuccessJSON(map[string]interface{}{
  11497. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11498. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11499. })
  11500. }
  11501. } else {
  11502. c.ServeSuccessJSON(map[string]interface{}{
  11503. "code": -10,
  11504. "msg": res.ErrMsg,
  11505. })
  11506. }
  11507. }
  11508. }
  11509. func (c *HisApiController) Check310() {
  11510. adminUser := c.GetAdminUserInfo()
  11511. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11512. var user_name string
  11513. user_name = "高慧裕"
  11514. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11515. "insutype=" + "310" +
  11516. "&clr_type=" + "" +
  11517. "&setl_optins=" + "441202" +
  11518. "&stmt_begndate=" + "2022-03-01" +
  11519. "&stm_enddate=" + "2022-03-31" +
  11520. "&medfee_sumamt=" + "194930.12" +
  11521. "&fund_pay_sumamt=" + "188741.46" +
  11522. "&acct_pay=" + "0" +
  11523. "&fixmedins_setl_cnt=" + "452" +
  11524. "&fixmedins_code=" + miConfig.Code +
  11525. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11526. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11527. "&secret_key=" + miConfig.SecretKey +
  11528. "&org_name=" + miConfig.OrgName +
  11529. "&doctor=" + user_name
  11530. fmt.Println(api)
  11531. resp, requestErr := http.Get(api)
  11532. if requestErr != nil {
  11533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11534. return
  11535. }
  11536. body, ioErr := ioutil.ReadAll(resp.Body)
  11537. fmt.Println(body)
  11538. if ioErr != nil {
  11539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11541. return
  11542. }
  11543. var respJSON map[string]interface{}
  11544. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11547. return
  11548. }
  11549. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11550. userJSONBytes, _ := json.Marshal(respJSON)
  11551. var res ResultEight
  11552. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11553. utils.ErrorLog("解析失败:%v", err)
  11554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11555. return
  11556. }
  11557. }
  11558. func (c *HisApiController) Check390() {
  11559. adminUser := c.GetAdminUserInfo()
  11560. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11561. var user_name string
  11562. user_name = "高慧裕"
  11563. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11564. "insutype=" + "390" +
  11565. "&clr_type=" + "" +
  11566. "&setl_optins=" + "441202" +
  11567. "&stmt_begndate=" + "2022-03-01" +
  11568. "&stm_enddate=" + "2022-03-31" +
  11569. "&medfee_sumamt=" + "1068448.89" +
  11570. "&fund_pay_sumamt=" + "1014677.62" +
  11571. "&acct_pay=" + "0" +
  11572. "&fixmedins_setl_cnt=" + "1950" +
  11573. "&fixmedins_code=" + miConfig.Code +
  11574. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11575. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11576. "&secret_key=" + miConfig.SecretKey +
  11577. "&org_name=" + miConfig.OrgName +
  11578. "&doctor=" + user_name
  11579. fmt.Println(api)
  11580. resp, requestErr := http.Get(api)
  11581. if requestErr != nil {
  11582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11583. return
  11584. }
  11585. body, ioErr := ioutil.ReadAll(resp.Body)
  11586. fmt.Println(body)
  11587. if ioErr != nil {
  11588. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11590. return
  11591. }
  11592. var respJSON map[string]interface{}
  11593. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11596. return
  11597. }
  11598. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11599. userJSONBytes, _ := json.Marshal(respJSON)
  11600. var res ResultEight
  11601. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11602. utils.ErrorLog("解析失败:%v", err)
  11603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11604. return
  11605. }
  11606. }
  11607. //对账明细
  11608. func (c *HisApiController) GetCheckDetailAccount() {
  11609. start_time := c.GetString("start_time")
  11610. end_time := c.GetString("end_time")
  11611. admin_user_id, _ := c.GetInt64("admin_user_id")
  11612. adminUser := c.GetAdminUserInfo()
  11613. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11614. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11615. timeLayout := "2006-01-02"
  11616. loc, _ := time.LoadLocation("Local")
  11617. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11618. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11619. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  11620. rand.Seed(time.Now().UnixNano())
  11621. num := rand.Intn(30000)
  11622. Mkdir(miConfig.OrgName)
  11623. file := strconv.FormatInt(int64(num), 10)
  11624. file_name := file + ".txt"
  11625. zip_name := file + ".zip"
  11626. zip_path := miConfig.OrgName + "/" + zip_name
  11627. file_path := miConfig.OrgName + "/" + file_name
  11628. decimal.DivisionPrecision = 2
  11629. var medfee_sumamt float64
  11630. var psn_cash_pay float64
  11631. var fund_pay_sumamt float64
  11632. fixmedins_setl_cnt := int64(len(orders))
  11633. for _, item := range orders {
  11634. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11635. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  11636. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11637. }
  11638. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  11639. defer f.Close()
  11640. if err != nil {
  11641. fmt.Println(err.Error())
  11642. } else {
  11643. for _, item := range orders {
  11644. var refd_setl_flag string
  11645. if item.OrderStatus == 2 {
  11646. refd_setl_flag = "0"
  11647. var str string
  11648. str = item.SetlId + " " +
  11649. item.MdtrtId + " " +
  11650. item.PsnNo + " " +
  11651. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11652. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11653. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  11654. _, err = f.Write([]byte(str))
  11655. }
  11656. if item.OrderStatus == 3 {
  11657. var str string
  11658. str = item.SetlId + " " +
  11659. item.MdtrtId + " " +
  11660. item.PsnNo + " " +
  11661. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11662. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11663. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  11664. _, err = f.Write([]byte(str))
  11665. var str2 string
  11666. str2 = item.SetlId + " " +
  11667. item.MdtrtId + " " +
  11668. item.PsnNo + " " +
  11669. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  11670. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  11671. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  11672. _, err = f.Write([]byte(str2))
  11673. }
  11674. }
  11675. }
  11676. Zip(file_path, zip_path)
  11677. fmt.Println(ReadFile(zip_path))
  11678. fmt.Println(string(ReadFile(zip_path)))
  11679. if config.IsOpen == 1 {
  11680. var user_name string
  11681. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11682. if role.ID == 0 {
  11683. user_name = "管理员"
  11684. } else {
  11685. user_name = role.UserName
  11686. }
  11687. baseParams := models.BaseParams{
  11688. SecretKey: miConfig.SecretKey,
  11689. FixmedinsCode: miConfig.Code,
  11690. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11691. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11692. OrgName: miConfig.OrgName,
  11693. Doctor: user_name,
  11694. }
  11695. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  11696. var dat map[string]interface{}
  11697. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11698. fmt.Println(dat)
  11699. } else {
  11700. fmt.Println(err)
  11701. }
  11702. userJSONBytes, _ := json.Marshal(dat)
  11703. var res ResultNine
  11704. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11705. utils.ErrorLog("解析失败:%v", err)
  11706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11707. return
  11708. }
  11709. if res.Infcode == 0 {
  11710. fileNo := res.Output.FileQuryNo
  11711. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  11712. "file_qury_no=" + fileNo +
  11713. "&setl_optins=" + "定点医保中心" +
  11714. "&stmt_begndate=" + start_time +
  11715. "&stm_enddate=" + end_time +
  11716. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11717. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11718. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  11719. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11720. "&fixmedins_code=" + miConfig.Code +
  11721. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11722. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11723. "&secret_key=" + miConfig.SecretKey +
  11724. "&org_name=" + miConfig.OrgName +
  11725. "&doctor=" + user_name
  11726. resp, requestErr := http.Get(api)
  11727. if requestErr != nil {
  11728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11729. return
  11730. }
  11731. body, ioErr := ioutil.ReadAll(resp.Body)
  11732. if ioErr != nil {
  11733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11735. return
  11736. }
  11737. var respJSON map[string]interface{}
  11738. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11741. return
  11742. }
  11743. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11744. userJSONBytes, _ := json.Marshal(respJSON)
  11745. var res ResultTen
  11746. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11747. utils.ErrorLog("解析失败:%v", err)
  11748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11749. return
  11750. }
  11751. if res.Infcode == 0 {
  11752. service.Gdyb9102(baseParams, zip_name, fileNo)
  11753. micc := &models.MedicalInsuranceCostCompare{
  11754. StartTime: startime.Unix(),
  11755. EndTime: endtime.Unix(),
  11756. Insutype: "0",
  11757. CheckType: 2,
  11758. Num: fixmedins_setl_cnt,
  11759. Mtime: time.Now().Unix(),
  11760. Status: 1,
  11761. UserOrgId: adminUser.CurrentOrgId,
  11762. CostTotal: medfee_sumamt,
  11763. FuncTotal: fund_pay_sumamt,
  11764. PsnPay: psn_cash_pay,
  11765. Creator: admin_user_id,
  11766. Ctime: time.Now().Unix(),
  11767. }
  11768. service.CreateMedicalInsuranceCostCompareRecord(micc)
  11769. c.ServeSuccessJSON(map[string]interface{}{
  11770. "msg": "明细对账成功",
  11771. })
  11772. }
  11773. } else {
  11774. }
  11775. }
  11776. }
  11777. type CustomOrderInfo struct {
  11778. Name string
  11779. Spec string
  11780. Unit string
  11781. Count float64
  11782. Price float64
  11783. Total float64
  11784. }
  11785. func (c *HisApiController) GetSettleAccounts() {
  11786. //id, _ := c.GetInt64("id")
  11787. //record_time := c.GetString("record_time")
  11788. order_id, _ := c.GetInt64("order_id")
  11789. admin_user_id, _ := c.GetInt64("admin_user_id")
  11790. //timeLayout := "2006-01-02"
  11791. //loc, _ := time.LoadLocation("Local")
  11792. //
  11793. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11794. //if err != nil {
  11795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11796. // return
  11797. //}
  11798. //recordDateTime := theTime.Unix()
  11799. adminUser := c.GetAdminUserInfo()
  11800. order, _ := service.GetHisOrderByID(order_id)
  11801. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11802. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  11803. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  11804. orderInfos = append(orderInfos, orderInfos_two...)
  11805. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  11806. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  11807. var diagnosis_ids []string
  11808. if his.ID > 0 {
  11809. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  11810. } else {
  11811. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  11812. }
  11813. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  11814. var dia_config []*models.HisXtDiagnoseConfig
  11815. var name string
  11816. for _, item := range diagnosis_ids {
  11817. id, _ := strconv.ParseInt(item, 10, 64)
  11818. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11819. dia_config = append(dia_config, &diagnosisConfig)
  11820. if len(name) == 0 {
  11821. name = diagnosisConfig.ClassName
  11822. } else {
  11823. name = name + "," + diagnosisConfig.ClassName
  11824. }
  11825. }
  11826. var bedCostTotal float64 = 0 //床位总费
  11827. var bedCostSelfTotal float64 = 0 //床位自费
  11828. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11829. var operationCostTotal float64 = 0 //手术费
  11830. var operationCostSelfTotal float64 = 0 //手术费
  11831. var operationCostPartSelfTotal float64 = 0 //手术费
  11832. var otherCostTotal float64 = 0 //其他费用
  11833. var otherCostSelfTotal float64 = 0 //其他费用
  11834. var otherCostPartSelfTotal float64 = 0 //其他费用
  11835. var materialCostTotal float64 = 0 //材料费
  11836. var materialCostSelfTotal float64 = 0 //材料费
  11837. var materialCostPartSelfTotal float64 = 0 //材料费
  11838. var westernMedicineCostTotal float64 = 0 //西药费
  11839. var westernMedicineCostSelfTotal float64 = 0 //西药费
  11840. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11841. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11842. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11843. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11844. var checkCostTotal float64 = 0 //检查费
  11845. var checkCostSelfTotal float64 = 0 //检查费
  11846. var checkCostPartSelfTotal float64 = 0 //检查费
  11847. var laboratoryCostTotal float64 = 0 //化验费
  11848. var laboratoryCostSelfTotal float64 = 0 //化验费
  11849. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11850. var treatCostTotal float64 = 0 //治疗费用
  11851. var treatCostSelfTotal float64 = 0 //治疗费用
  11852. var treatCostPartSelfTotal float64 = 0 //治疗费用
  11853. decimal.DivisionPrecision = 2
  11854. for _, item := range orderInfos {
  11855. if item.MedChrgitmType == "01" { //床位费
  11856. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11857. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11858. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11859. }
  11860. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  11861. if item.MedChrgitmType == "03" { //检查费
  11862. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11863. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11864. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11865. }
  11866. } else {
  11867. if item.MedChrgitmType == "03" { //检查费
  11868. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11869. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11870. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11871. }
  11872. }
  11873. if item.MedChrgitmType == "04" { //化验费
  11874. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11875. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11876. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11877. }
  11878. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  11879. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11880. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11881. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11882. }
  11883. if item.MedChrgitmType == "06" { //手术费
  11884. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11885. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11886. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11887. }
  11888. if item.MedChrgitmType == "08" { //材料费
  11889. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11890. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11891. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11892. }
  11893. if item.MedChrgitmType == "09" { //西药费
  11894. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11895. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11896. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11897. }
  11898. if item.MedChrgitmType == "11" { //中成费
  11899. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11900. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11901. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11902. }
  11903. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  11904. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11905. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11906. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11907. }
  11908. }
  11909. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11910. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11911. var user_name string
  11912. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11913. if role.ID == 0 {
  11914. user_name = "管理员"
  11915. } else {
  11916. user_name = role.UserName
  11917. }
  11918. baseParams := models.BaseParams{
  11919. SecretKey: miConfig.SecretKey,
  11920. FixmedinsCode: miConfig.Code,
  11921. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11922. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11923. OrgName: miConfig.OrgName,
  11924. Doctor: user_name,
  11925. RequestUrl: miConfig.Url,
  11926. AccessKey: miConfig.AccessKey,
  11927. }
  11928. businessParams := models.BusinessParams{
  11929. PsnNo: order.PsnNo,
  11930. MdtrtId: order.MdtrtId,
  11931. SetlId: order.SetlId,
  11932. }
  11933. var res ResultEleven
  11934. var resEleven10265 ResultEleven10265
  11935. if config.IsOpen == 1 {
  11936. if miConfig.MdtrtareaAdmvs == "421300" {
  11937. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11938. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11939. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11940. resp, requestErr := http.Get(api)
  11941. if requestErr != nil {
  11942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11943. return
  11944. }
  11945. body, ioErr := ioutil.ReadAll(resp.Body)
  11946. if ioErr != nil {
  11947. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11949. return
  11950. }
  11951. var respJSON map[string]interface{}
  11952. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11953. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11955. return
  11956. }
  11957. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11958. result, _ := json.Marshal(respJSON)
  11959. fmt.Println("log")
  11960. fmt.Println(string(result))
  11961. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11962. utils.ErrorLog("解析失败:%v", err)
  11963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11964. return
  11965. }
  11966. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11967. var api string
  11968. if miConfig.MdtrtareaAdmvs == "320921" {
  11969. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11970. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11971. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11972. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11973. } else {
  11974. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11975. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11976. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11977. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11978. }
  11979. resp, requestErr := http.Get(api)
  11980. if requestErr != nil {
  11981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11982. return
  11983. }
  11984. body, ioErr := ioutil.ReadAll(resp.Body)
  11985. if ioErr != nil {
  11986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11988. return
  11989. }
  11990. var respJSON map[string]interface{}
  11991. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11994. return
  11995. }
  11996. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11997. result, _ := json.Marshal(respJSON)
  11998. fmt.Println("log")
  11999. fmt.Println(string(result))
  12000. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12001. utils.ErrorLog("解析失败:%v", err)
  12002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12003. return
  12004. }
  12005. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12006. res.Output = resEleven10265.Output
  12007. res.ErrMsg = resEleven10265.ErrMsg
  12008. res.Cainfo = resEleven10265.Cainfo
  12009. res.WarnMsg = resEleven10265.WarnMsg
  12010. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12011. res.Infcode = infocode
  12012. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12013. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  12014. saveLog(result, requestLog, "5203", "结算单")
  12015. var dat map[string]interface{}
  12016. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12017. fmt.Println(dat)
  12018. } else {
  12019. fmt.Println(err)
  12020. }
  12021. userJSONBytes, _ := json.Marshal(dat)
  12022. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12023. utils.ErrorLog("解析失败:%v", err)
  12024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12025. return
  12026. }
  12027. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12028. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  12029. saveLog(result, requestLog, "5203", "结算单")
  12030. var dat map[string]interface{}
  12031. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12032. fmt.Println(dat)
  12033. } else {
  12034. fmt.Println(err)
  12035. }
  12036. userJSONBytes, _ := json.Marshal(dat)
  12037. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12038. utils.ErrorLog("解析失败:%v", err)
  12039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12040. return
  12041. }
  12042. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12043. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  12044. saveLog(result, requestLog, "5203", "结算单")
  12045. var dat map[string]interface{}
  12046. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12047. fmt.Println(dat)
  12048. } else {
  12049. fmt.Println(err)
  12050. }
  12051. userJSONBytes, _ := json.Marshal(dat)
  12052. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12053. utils.ErrorLog("解析失败:%v", err)
  12054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12055. return
  12056. }
  12057. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12058. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12059. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12060. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12061. resp, requestErr := http.Get(api)
  12062. if requestErr != nil {
  12063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12064. return
  12065. }
  12066. body, ioErr := ioutil.ReadAll(resp.Body)
  12067. if ioErr != nil {
  12068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12070. return
  12071. }
  12072. var respJSON map[string]interface{}
  12073. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12076. return
  12077. }
  12078. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12079. result, _ := json.Marshal(respJSON)
  12080. fmt.Println("log")
  12081. fmt.Println(string(result))
  12082. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12083. utils.ErrorLog("解析失败:%v", err)
  12084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12085. return
  12086. }
  12087. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12088. res.Output = resEleven10265.Output
  12089. res.ErrMsg = resEleven10265.ErrMsg
  12090. res.Cainfo = resEleven10265.Cainfo
  12091. res.WarnMsg = resEleven10265.WarnMsg
  12092. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12093. res.Infcode = infocode
  12094. } else {
  12095. result := service.Gdyb5203(baseParams, businessParams)
  12096. //service.Gdyb5204(baseParams, businessParams)
  12097. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  12098. var dat map[string]interface{}
  12099. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12100. fmt.Println(dat)
  12101. } else {
  12102. fmt.Println(err)
  12103. }
  12104. userJSONBytes, _ := json.Marshal(dat)
  12105. if miConfig.Code == "H15049901371" {
  12106. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  12107. utils.ErrorLog("解析失败:%v", err)
  12108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12109. return
  12110. }
  12111. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12112. res.Output = resEleven10265.Output
  12113. res.ErrMsg = resEleven10265.ErrMsg
  12114. res.Cainfo = resEleven10265.Cainfo
  12115. res.WarnMsg = resEleven10265.WarnMsg
  12116. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12117. res.Infcode = infocode
  12118. } else {
  12119. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12120. utils.ErrorLog("解析失败:%v", err)
  12121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12122. return
  12123. }
  12124. }
  12125. }
  12126. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12127. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  12128. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  12129. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12130. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  12131. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12132. var doctor_name string
  12133. if roles.ID == 0 {
  12134. doctor_name = "管理员"
  12135. } else {
  12136. doctor_name = roles.UserName
  12137. }
  12138. yiliao_leibie := ""
  12139. switch order.MedType {
  12140. case "11":
  12141. yiliao_leibie = "普通门诊"
  12142. break
  12143. case "12":
  12144. yiliao_leibie = "门诊挂号"
  12145. break
  12146. case "13":
  12147. yiliao_leibie = "急诊"
  12148. break
  12149. case "14":
  12150. yiliao_leibie = "门诊特殊病"
  12151. break
  12152. case "15":
  12153. yiliao_leibie = "门诊统筹"
  12154. break
  12155. case "16":
  12156. yiliao_leibie = "门诊慢性病"
  12157. break
  12158. case "21":
  12159. yiliao_leibie = "普通住院"
  12160. break
  12161. }
  12162. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12163. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  12164. if res.Infcode == 0 {
  12165. c.ServeSuccessJSON(map[string]interface{}{
  12166. "diagnosis": name,
  12167. "order_infos": orderInfos,
  12168. "number": order.MdtrtId,
  12169. "date": order.SettleAccountsDate,
  12170. "charge_admin": charge_admin,
  12171. "printor_admin": printor_admin,
  12172. "info": res.Output.Setlinfo,
  12173. "order": order,
  12174. "bedCostTotal": bedCostTotal,
  12175. "bedCostSelfTotal": bedCostSelfTotal,
  12176. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  12177. "operationCostTotal": operationCostTotal,
  12178. "operationCostSelfTotal": operationCostSelfTotal,
  12179. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  12180. "otherCostTotal": otherCostTotal,
  12181. "otherCostSelfTotal": otherCostSelfTotal,
  12182. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  12183. "materialCostTotal": materialCostTotal,
  12184. "materialCostSelfTotal": materialCostSelfTotal,
  12185. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  12186. "westernMedicineCostTotal": westernMedicineCostTotal,
  12187. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  12188. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  12189. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  12190. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  12191. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  12192. "checkCostTotal": checkCostTotal,
  12193. "checkCostSelfTotal": checkCostSelfTotal,
  12194. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  12195. "laboratoryCostTotal": laboratoryCostTotal,
  12196. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  12197. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  12198. "treatCostTotal": treatCostTotal,
  12199. "treatCostSelfTotal": treatCostSelfTotal,
  12200. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  12201. "doctor_info": doctor_info,
  12202. "doctor_code": adminRole_two.DoctorCode,
  12203. "doctor_name": doctor_name,
  12204. "health_card_no": order.PsnNo,
  12205. "department": departments.Name,
  12206. "yiliao_leibie": yiliao_leibie,
  12207. "after_money": order.AccountPrice,
  12208. "patient": patient,
  12209. "org_name": miConfig.OrgName,
  12210. "org_code": miConfig.Code,
  12211. "order_number": order.Number,
  12212. "his_hospital": his_hospital,
  12213. "his": his,
  12214. "dia_config": dia_config,
  12215. //"check_order_info": cus_slice,
  12216. })
  12217. }
  12218. }
  12219. }
  12220. func (c *HisApiController) CheckTreatment() {
  12221. patient_id, _ := c.GetInt64("patient_id")
  12222. id_card_no := c.GetString("id_card_no")
  12223. insutype := c.GetString("insutype")
  12224. med_type := c.GetString("med_type")
  12225. admin_user_id, _ := c.GetInt64("admin_user_id")
  12226. adminUser := c.GetAdminUserInfo()
  12227. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12228. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12229. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12230. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12231. if miConfig.MdtrtareaAdmvs == "421300" {
  12232. var res ResultTwo
  12233. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12234. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12235. "&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)
  12236. resp, requestErr := http.Get(api)
  12237. if requestErr != nil {
  12238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12239. return
  12240. }
  12241. body, ioErr := ioutil.ReadAll(resp.Body)
  12242. if ioErr != nil {
  12243. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12245. return
  12246. }
  12247. var respJSON map[string]interface{}
  12248. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12251. return
  12252. }
  12253. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12254. result, _ := json.Marshal(respJSON)
  12255. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12256. utils.ErrorLog("解析失败:%v", err)
  12257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12258. return
  12259. }
  12260. if res.Infcode == 0 {
  12261. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  12262. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12263. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  12264. resp, requestErr := http.Get(api)
  12265. if requestErr != nil {
  12266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12267. return
  12268. }
  12269. body, ioErr := ioutil.ReadAll(resp.Body)
  12270. if ioErr != nil {
  12271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12273. return
  12274. }
  12275. var respJSON map[string]interface{}
  12276. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12279. return
  12280. }
  12281. var res Result2001
  12282. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12283. result2, _ := json.Marshal(respJSON)
  12284. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  12285. utils.ErrorLog("解析失败:%v", err)
  12286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12287. return
  12288. }
  12289. if res.Infcode == 0 {
  12290. c.ServeSuccessJSON(map[string]interface{}{
  12291. "msg": res.Output.Trtinfo,
  12292. })
  12293. }
  12294. } else {
  12295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12296. return
  12297. }
  12298. } else {
  12299. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12300. var dat map[string]interface{}
  12301. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12302. fmt.Println(dat)
  12303. } else {
  12304. fmt.Println(err)
  12305. }
  12306. userJSONBytes, _ := json.Marshal(dat)
  12307. var res ResultTwo
  12308. var res10265 ResultTwo10265
  12309. if miConfig.Code == "H15049901371" {
  12310. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12311. utils.ErrorLog("解析失败:%v", err)
  12312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12313. return
  12314. }
  12315. res.ErrMsg = res10265.ErrMsg
  12316. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12317. res.Infcode = infocode
  12318. res.Output = res10265.Output
  12319. res.InfRefmsgid = res10265.InfRefmsgid
  12320. } else {
  12321. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12322. utils.ErrorLog("解析失败:%v", err)
  12323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12324. return
  12325. }
  12326. }
  12327. var user_name string
  12328. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  12329. if role.ID == 0 {
  12330. user_name = "xxx"
  12331. } else {
  12332. user_name = role.UserName
  12333. }
  12334. baseParams := models.BaseParams{
  12335. SecretKey: miConfig.SecretKey,
  12336. FixmedinsCode: miConfig.Code,
  12337. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12338. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12339. OrgName: miConfig.OrgName,
  12340. Doctor: user_name,
  12341. }
  12342. if config.IsOpen == 1 {
  12343. if miConfig.Code == "H15049901371" {
  12344. if med_type == "14" {
  12345. if insutype == "390" {
  12346. med_type = "9933"
  12347. } else if insutype == "310" {
  12348. med_type = "990502"
  12349. }
  12350. } else if med_type == "11" {
  12351. med_type = "11"
  12352. }
  12353. }
  12354. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  12355. var dat map[string]interface{}
  12356. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12357. fmt.Println(dat)
  12358. } else {
  12359. fmt.Println(err)
  12360. }
  12361. var res Result2001
  12362. var res10265 Result2001Org10265
  12363. if miConfig.Code == "H15049901371" {
  12364. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12365. utils.ErrorLog("解析失败:%v", err)
  12366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12367. return
  12368. }
  12369. res.ErrMsg = res10265.ErrMsg
  12370. res.Output = res10265.Output
  12371. res.InfRefmsgid = res10265.InfRefmsgid
  12372. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12373. res.Infcode = infocode
  12374. } else {
  12375. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12376. utils.ErrorLog("解析失败:%v", err)
  12377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12378. return
  12379. }
  12380. }
  12381. if res.Infcode == 0 {
  12382. c.ServeSuccessJSON(map[string]interface{}{
  12383. "msg": res.Output.Trtinfo,
  12384. })
  12385. }
  12386. }
  12387. }
  12388. }
  12389. //func (c *HisApiController) PutRecord() {
  12390. // id, _ := c.GetInt64("id")
  12391. // record_time := c.GetString("record_time")
  12392. // timeLayout := "2006-01-02"
  12393. // loc, _ := time.LoadLocation("Local")
  12394. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12395. // if err != nil {
  12396. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12397. // return
  12398. // }
  12399. // recordDateTime := theTime.Unix()
  12400. //
  12401. // adminInfo := c.GetAdminUserInfo()
  12402. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  12403. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12404. //
  12405. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12406. //
  12407. // fmt.Println(miConfig.SecretKey)
  12408. //
  12409. // if patient == nil {
  12410. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12411. // return
  12412. // }
  12413. // if len(patient.IdCardNo) == 0 {
  12414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  12415. // return
  12416. // }
  12417. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  12418. // if config.IsOpen == 1 {
  12419. // 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
  12420. // resp, requestErr := http.Get(api)
  12421. // if requestErr != nil {
  12422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12423. // return
  12424. // }
  12425. // defer resp.Body.Close()
  12426. // body, ioErr := ioutil.ReadAll(resp.Body)
  12427. // if ioErr != nil {
  12428. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12429. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12430. // return
  12431. // }
  12432. // var respJSON map[string]interface{}
  12433. //
  12434. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12435. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12436. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12437. // return
  12438. // }
  12439. //
  12440. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12441. // userJSONBytes, _ := json.Marshal(userJSON)
  12442. // var res ResultTwo
  12443. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12444. // utils.ErrorLog("解析失败:%v", err)
  12445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12446. // return
  12447. // }
  12448. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12449. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12450. // infoStr := string(Iinfos)
  12451. // idetinfoStr := string(Idetinfos)
  12452. //
  12453. // if res.Infcode == 0 {
  12454. // his := models.VMHisPatient{
  12455. // Status: 1,
  12456. // Ctime: time.Now().Unix(),
  12457. // Mtime: time.Now().Unix(),
  12458. // PsnNo: res.Output.Baseinfo.PsnNo,
  12459. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  12460. // Certno: res.Output.Baseinfo.Certno,
  12461. // PsnName: res.Output.Baseinfo.PsnName,
  12462. // Gend: res.Output.Baseinfo.Gend,
  12463. // Naty: res.Output.Baseinfo.Naty,
  12464. // Brdy: res.Output.Baseinfo.Brdy,
  12465. // Age: res.Output.Baseinfo.Age,
  12466. // Iinfo: infoStr,
  12467. // Idetinfo: idetinfoStr,
  12468. // PatientId: patient.ID,
  12469. // RecordDate: theTime.Unix(),
  12470. // UserOrgId: adminInfo.CurrentOrgId,
  12471. // AdminUserId: adminInfo.AdminUser.Id,
  12472. // IsReturn: 1,
  12473. // }
  12474. //
  12475. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  12476. // //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")
  12477. // //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")
  12478. //
  12479. // //var dat map[string]interface{}
  12480. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12481. // // fmt.Println(dat)
  12482. // //} else {
  12483. // // fmt.Println(err)
  12484. // //}
  12485. //
  12486. // var dat2 map[string]interface{}
  12487. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  12488. // fmt.Println(dat2)
  12489. // } else {
  12490. // fmt.Println(err)
  12491. // }
  12492. //
  12493. // } else {
  12494. // adminUser := c.GetAdminUserInfo()
  12495. // errlog := &models.HisOrderError{
  12496. // UserOrgId: adminUser.CurrentOrgId,
  12497. // Ctime: time.Now().Unix(),
  12498. // Mtime: time.Now().Unix(),
  12499. // ErrMsg: res.ErrMsg,
  12500. // Status: 1,
  12501. // PatientId: id,
  12502. // RecordTime: recordDateTime,
  12503. // Stage: 1,
  12504. // }
  12505. // service.CreateErrMsgLog(errlog)
  12506. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  12507. // return
  12508. // }
  12509. // }
  12510. //
  12511. //}
  12512. //func (c *HisApiController) GetUploadDiag() {
  12513. // id, _ := c.GetInt64("id")
  12514. // record_time := c.GetString("record_time")
  12515. //
  12516. // diagnosis_id, _ := c.GetInt64("diagnosis")
  12517. // sick_type, _ := c.GetInt64("sick_type")
  12518. // reg_type, _ := c.GetInt64("reg_type")
  12519. //
  12520. // timeLayout := "2006-01-02"
  12521. // loc, _ := time.LoadLocation("Local")
  12522. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12523. // if err != nil {
  12524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12525. // return
  12526. // }
  12527. //
  12528. // var patientPrescription models.HisPrescriptionInfo
  12529. // recordDateTime := theTime.Unix()
  12530. // adminInfo := c.GetAdminUserInfo()
  12531. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12532. //
  12533. // if patientPrescription.ID == 0 {
  12534. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12535. // }
  12536. //
  12537. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12538. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  12539. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12540. // sickConfig, _ := service.FindSickById(sick_type)
  12541. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12542. //
  12543. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  12544. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  12545. // "&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 +
  12546. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  12547. // resp2, requestErr2 := http.Get(api2)
  12548. // if requestErr2 != nil {
  12549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12550. // return
  12551. // }
  12552. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  12553. // if ioErr2 != nil {
  12554. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  12555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12556. // return
  12557. // }
  12558. // var respJSON2 map[string]interface{}
  12559. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  12560. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12561. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12562. // return
  12563. // }
  12564. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12565. // userJSONBytes2, _ := json.Marshal(respJSON2)
  12566. //
  12567. // var res2 ResultSix
  12568. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12569. // utils.ErrorLog("解析失败:%v", err)
  12570. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12571. // return
  12572. // }
  12573. // if res2.Infcode != 0 {
  12574. // adminUser := c.GetAdminUserInfo()
  12575. // errlog := &models.HisOrderError{
  12576. // UserOrgId: adminUser.CurrentOrgId,
  12577. // Ctime: time.Now().Unix(),
  12578. // Mtime: time.Now().Unix(),
  12579. // ErrMsg: res2.ErrMsg,
  12580. // Status: 1,
  12581. // PatientId: id,
  12582. // RecordTime: recordDateTime,
  12583. // Stage: 3,
  12584. // }
  12585. // service.CreateErrMsgLog(errlog)
  12586. //
  12587. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  12588. // return
  12589. // }
  12590. //
  12591. // c.ServeSuccessJSON(map[string]interface{}{
  12592. // "msg": "上传成功",
  12593. // })
  12594. //
  12595. //}
  12596. type QueryResult struct {
  12597. ID int64
  12598. Name string
  12599. Code string
  12600. List_type_code string
  12601. }
  12602. func (c *HisApiController) GetCheckCode() {
  12603. ids_str := c.GetString("ids")
  12604. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12605. ids_arr := strings.Split(ids_str, ",")
  12606. var queryResult []QueryResult
  12607. ids := make([]int64, 0)
  12608. for _, item := range ids_arr {
  12609. id, _ := strconv.ParseInt(item, 10, 64)
  12610. ids = append(ids, id)
  12611. }
  12612. if record_type == 1 {
  12613. drugs, _ := service.GetBatchDrugList(ids)
  12614. for _, item := range drugs {
  12615. result := QueryResult{
  12616. ID: item.ID,
  12617. Name: item.DrugName,
  12618. Code: item.MedicalInsuranceNumber,
  12619. List_type_code: "101",
  12620. }
  12621. queryResult = append(queryResult, result)
  12622. }
  12623. } else if record_type == 2 {
  12624. goods, _ := service.GetBatchGoodInformationList(ids)
  12625. for _, item := range goods {
  12626. result := QueryResult{
  12627. ID: item.ID,
  12628. Name: item.GoodName,
  12629. Code: item.MedicalInsuranceNumber,
  12630. List_type_code: "301",
  12631. }
  12632. queryResult = append(queryResult, result)
  12633. }
  12634. } else if record_type == 3 {
  12635. projects, _ := service.GetBathchMyPorjecgList(ids)
  12636. for _, item := range projects {
  12637. result := QueryResult{
  12638. ID: item.ID,
  12639. Name: item.ProjectName,
  12640. Code: item.MedicalCode,
  12641. List_type_code: "201",
  12642. }
  12643. queryResult = append(queryResult, result)
  12644. }
  12645. }
  12646. admin_user_id, _ := c.GetInt64("admin_user_id")
  12647. adminUser := c.GetAdminUserInfo()
  12648. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12649. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12650. var user_name string
  12651. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12652. if role.ID == 0 {
  12653. user_name = "xxx"
  12654. } else {
  12655. user_name = role.UserName
  12656. }
  12657. baseParams := &models.BaseParams{
  12658. SecretKey: miConfig.SecretKey,
  12659. FixmedinsCode: miConfig.Code,
  12660. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12661. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12662. OrgName: miConfig.OrgName,
  12663. Doctor: user_name,
  12664. }
  12665. if config.IsOpen == 1 {
  12666. for _, item := range queryResult {
  12667. var result string
  12668. if record_type == 1 {
  12669. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12670. } else if record_type == 2 {
  12671. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12672. } else if record_type == 3 {
  12673. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12674. }
  12675. var dat map[string]interface{}
  12676. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12677. fmt.Println(dat)
  12678. } else {
  12679. fmt.Println(err)
  12680. }
  12681. userJSONBytes, _ := json.Marshal(dat)
  12682. var res ResultSix
  12683. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12684. utils.ErrorLog("解析失败:%v", err)
  12685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12686. return
  12687. }
  12688. if res.Infcode == 0 {
  12689. if record_type == 1 {
  12690. service.UpdateBaseDrugById(item.ID)
  12691. } else if record_type == 2 {
  12692. service.UpdateGoodInformaitonByDetail(item.ID)
  12693. } else if record_type == 3 {
  12694. service.UpdateProjectById(item.ID)
  12695. }
  12696. c.ServeSuccessJSON(map[string]interface{}{
  12697. "failed_code": 0,
  12698. "msg": "目录对照成功",
  12699. })
  12700. } else {
  12701. c.ServeSuccessJSON(map[string]interface{}{
  12702. "failed_code": -10,
  12703. "msg": res.ErrMsg,
  12704. })
  12705. }
  12706. }
  12707. }
  12708. }
  12709. func (c *HisApiController) UnCheckCode() {
  12710. ids_str := c.GetString("ids")
  12711. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12712. admin_user_id, _ := c.GetInt64("admin_user_id")
  12713. ids_arr := strings.Split(ids_str, ",")
  12714. var queryResult []QueryResult
  12715. ids := make([]int64, 0)
  12716. for _, item := range ids_arr {
  12717. id, _ := strconv.ParseInt(item, 10, 64)
  12718. ids = append(ids, id)
  12719. }
  12720. if record_type == 1 {
  12721. drugs, _ := service.GetBatchDrugList(ids)
  12722. for _, item := range drugs {
  12723. result := QueryResult{
  12724. ID: item.ID,
  12725. Name: item.DrugName,
  12726. Code: item.MedicalInsuranceNumber,
  12727. List_type_code: "101",
  12728. }
  12729. queryResult = append(queryResult, result)
  12730. }
  12731. } else if record_type == 2 {
  12732. goods, _ := service.GetBatchGoodInformationList(ids)
  12733. for _, item := range goods {
  12734. result := QueryResult{
  12735. ID: item.ID,
  12736. Name: item.GoodName,
  12737. Code: item.MedicalInsuranceNumber,
  12738. List_type_code: "301",
  12739. }
  12740. queryResult = append(queryResult, result)
  12741. }
  12742. } else if record_type == 3 {
  12743. projects, _ := service.GetBathchMyPorjecgList(ids)
  12744. for _, item := range projects {
  12745. result := QueryResult{
  12746. ID: item.ID,
  12747. Name: item.ProjectName,
  12748. Code: item.MedicalCode,
  12749. List_type_code: "201",
  12750. }
  12751. queryResult = append(queryResult, result)
  12752. }
  12753. }
  12754. adminUser := c.GetAdminUserInfo()
  12755. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12756. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12757. var user_name string
  12758. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12759. if role.ID == 0 {
  12760. user_name = "xxx"
  12761. } else {
  12762. user_name = role.UserName
  12763. }
  12764. baseParams := &models.BaseParams{
  12765. SecretKey: miConfig.SecretKey,
  12766. FixmedinsCode: miConfig.Code,
  12767. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12768. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12769. OrgName: miConfig.OrgName,
  12770. Doctor: user_name,
  12771. }
  12772. if config.IsOpen == 1 {
  12773. for _, item := range queryResult {
  12774. var result string
  12775. if record_type == 1 {
  12776. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12777. } else if record_type == 2 {
  12778. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12779. } else if record_type == 3 {
  12780. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12781. }
  12782. var dat2 map[string]interface{}
  12783. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  12784. fmt.Println(dat2)
  12785. } else {
  12786. fmt.Println(err)
  12787. }
  12788. userJSONBytes, _ := json.Marshal(dat2)
  12789. var res ResultSix
  12790. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12791. utils.ErrorLog("解析失败:%v", err)
  12792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12793. return
  12794. }
  12795. if res.Infcode == 0 {
  12796. if record_type == 1 {
  12797. service.UpdateDrugByIdDetail(item.ID)
  12798. } else if record_type == 2 {
  12799. service.UpdateGoodInfoById(item.ID)
  12800. } else if record_type == 3 {
  12801. service.UpdateMyProjectById(item.ID)
  12802. }
  12803. c.ServeSuccessJSON(map[string]interface{}{
  12804. "failed_code": 0,
  12805. "msg": "撤销目录对照成功",
  12806. })
  12807. } else {
  12808. c.ServeSuccessJSON(map[string]interface{}{
  12809. "failed_code": -10,
  12810. "msg": res.ErrMsg,
  12811. })
  12812. }
  12813. }
  12814. }
  12815. }
  12816. func (c *HisApiController) GetPatientInfo() {
  12817. id_card_no := c.GetString("id_card_no")
  12818. admin_user_id, _ := c.GetInt64("admin_user_id")
  12819. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12820. if patient.ID == 0 {
  12821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12822. return
  12823. }
  12824. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12825. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12826. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  12827. if config.IsOpen == 1 {
  12828. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12829. var dat map[string]interface{}
  12830. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12831. fmt.Println(dat)
  12832. } else {
  12833. fmt.Println(err)
  12834. }
  12835. userJSONBytes, _ := json.Marshal(dat)
  12836. var res ResultTwo
  12837. var res10265 ResultTwo10265
  12838. if miConfig.Code == "H15049901371" {
  12839. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12840. utils.ErrorLog("解析失败:%v", err)
  12841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12842. return
  12843. }
  12844. res.ErrMsg = res10265.ErrMsg
  12845. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12846. res.Infcode = infocode
  12847. res.Output = res10265.Output
  12848. res.InfRefmsgid = res10265.InfRefmsgid
  12849. } else {
  12850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12851. utils.ErrorLog("解析失败:%v", err)
  12852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12853. return
  12854. }
  12855. }
  12856. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12857. // utils.ErrorLog("解析失败:%v", err)
  12858. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12859. // return
  12860. //}
  12861. if res.Infcode != 0 {
  12862. c.ServeSuccessJSON(map[string]interface{}{
  12863. "failed_code": -10,
  12864. "msg": res.ErrMsg,
  12865. })
  12866. } else {
  12867. c.ServeSuccessJSON(map[string]interface{}{
  12868. "failed_code": 0,
  12869. "info": res,
  12870. })
  12871. }
  12872. }
  12873. }
  12874. func (c *HisApiController) PsnPutOnRecord() {
  12875. record_type, _ := c.GetInt64("type")
  12876. patient_id, _ := c.GetInt64("patient_id")
  12877. admin_user_id, _ := c.GetInt64("admin_user_id")
  12878. start_time := c.GetString("start_time")
  12879. end_time := c.GetString("end_time")
  12880. adminUser := c.GetAdminUserInfo()
  12881. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12882. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12883. var patients []*models.Patients
  12884. if record_type == 1 { //全部备案
  12885. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  12886. patients = append(patients, patient...)
  12887. } else { //单个备案
  12888. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12889. patients = append(patients, patient)
  12890. }
  12891. var user_name string
  12892. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12893. if role.ID == 0 {
  12894. user_name = "xxx"
  12895. } else {
  12896. user_name = role.UserName
  12897. }
  12898. if config.IsOpen == 1 {
  12899. for _, item := range patients {
  12900. 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
  12901. resp, requestErr := http.Get(api)
  12902. if requestErr != nil {
  12903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12904. return
  12905. }
  12906. defer resp.Body.Close()
  12907. body, ioErr := ioutil.ReadAll(resp.Body)
  12908. if ioErr != nil {
  12909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12911. return
  12912. }
  12913. var respJSON map[string]interface{}
  12914. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12917. return
  12918. }
  12919. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12920. userJSONBytes, _ := json.Marshal(userJSON)
  12921. var res ResultTwo
  12922. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12923. utils.ErrorLog("解析失败:%v", err)
  12924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12925. return
  12926. }
  12927. if res.Infcode == 0 {
  12928. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  12929. var dat map[string]interface{}
  12930. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12931. fmt.Println(dat)
  12932. } else {
  12933. fmt.Println(err)
  12934. }
  12935. userJSONBytes, _ := json.Marshal(dat)
  12936. var res2 ResultThirteen
  12937. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12938. utils.ErrorLog("解析失败:%v", err)
  12939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12940. return
  12941. }
  12942. if res2.Infcode == 0 {
  12943. psnResult := &models.GdybPsnRecord{
  12944. UserOrgId: adminUser.CurrentOrgId,
  12945. PatientId: item.ID,
  12946. PsnNo: res.Output.Baseinfo.PsnNo,
  12947. Ctime: time.Now().Unix(),
  12948. Mtime: time.Now().Unix(),
  12949. Status: 1,
  12950. IsCancel: 1,
  12951. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  12952. }
  12953. service.CreatePsnRecord(psnResult)
  12954. } else {
  12955. c.ServeSuccessJSON(map[string]interface{}{
  12956. "failed_code": -10,
  12957. "msg": res2.ErrMsg,
  12958. })
  12959. return
  12960. }
  12961. }
  12962. }
  12963. }
  12964. }
  12965. func (c *HisApiController) PsnUnPutOnRecord() {
  12966. id, _ := c.GetInt64("id")
  12967. //record_type, _ := c.GetInt64("type")
  12968. admin_user_id, _ := c.GetInt64("admin_user_id")
  12969. adminUser := c.GetAdminUserInfo()
  12970. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12971. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12972. var user_name string
  12973. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12974. if role.ID == 0 {
  12975. user_name = "xxx"
  12976. } else {
  12977. user_name = role.UserName
  12978. }
  12979. psn_record, _ := service.GetPsnRecordById(id)
  12980. if psn_record.ID == 0 {
  12981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12982. return
  12983. }
  12984. if config.IsOpen == 1 {
  12985. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  12986. var dat map[string]interface{}
  12987. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12988. fmt.Println(dat)
  12989. } else {
  12990. fmt.Println(err)
  12991. }
  12992. userJSONBytes, _ := json.Marshal(dat)
  12993. var res ResultFourteen
  12994. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12995. utils.ErrorLog("解析失败:%v", err)
  12996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12997. return
  12998. }
  12999. if res.Infcode == 0 {
  13000. psn_record.IsCancel = 2
  13001. service.CreatePsnRecord(&psn_record)
  13002. } else {
  13003. c.ServeSuccessJSON(map[string]interface{}{
  13004. "failed_code": -10,
  13005. "msg": res.ErrMsg,
  13006. })
  13007. return
  13008. }
  13009. }
  13010. }
  13011. func (c *HisApiController) PsnPutNCDSOnRecord() {
  13012. patient_id, _ := c.GetInt64("patient_id")
  13013. insutype_two := c.GetString("insutype")
  13014. psn_no := c.GetString("psn_no")
  13015. doctor_id, _ := c.GetInt64("doctor_id")
  13016. sick_id, _ := c.GetInt64("sick_id")
  13017. department_id, _ := c.GetInt64("department_id")
  13018. start_time := c.GetString("start_time")
  13019. end_time := c.GetString("end_time")
  13020. check_time := c.GetString("check_time")
  13021. adminUser := c.GetAdminUserInfo()
  13022. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13023. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13024. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13025. sick, _ := service.FindSickById(sick_id)
  13026. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13027. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13028. var res ResultTwo
  13029. var res10265 ResultTwo10265
  13030. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13031. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  13032. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  13033. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13034. "&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
  13035. resp, requestErr := http.Get(api)
  13036. if requestErr != nil {
  13037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13038. return
  13039. }
  13040. body, ioErr := ioutil.ReadAll(resp.Body)
  13041. if ioErr != nil {
  13042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13044. return
  13045. }
  13046. var respJSON map[string]interface{}
  13047. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13050. return
  13051. }
  13052. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13053. result, _ := json.Marshal(respJSON)
  13054. fmt.Println("log")
  13055. fmt.Println(string(result))
  13056. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13057. utils.ErrorLog("解析失败:%v", err)
  13058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13059. return
  13060. }
  13061. res.ErrMsg = res10265.ErrMsg
  13062. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13063. res.Infcode = infocode
  13064. res.Output = res10265.Output
  13065. res.InfRefmsgid = res10265.InfRefmsgid
  13066. } else {
  13067. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13068. if miConfig.Code == "H15049901371" {
  13069. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13070. utils.ErrorLog("解析失败:%v", err)
  13071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13072. return
  13073. }
  13074. res.ErrMsg = res10265.ErrMsg
  13075. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13076. res.Infcode = infocode
  13077. res.Output = res10265.Output
  13078. res.InfRefmsgid = res10265.InfRefmsgid
  13079. } else {
  13080. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13081. utils.ErrorLog("解析失败:%v", err)
  13082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13083. return
  13084. }
  13085. }
  13086. }
  13087. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13088. infoStr := string(Iinfos)
  13089. var rf []*ResultFive
  13090. json.Unmarshal([]byte(infoStr), &rf)
  13091. var insuplc_admdvs string
  13092. var insutype string
  13093. var is390 int = 0
  13094. var is310 int = 0
  13095. var insutypes []*ResultFive
  13096. for _, item := range rf {
  13097. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13098. insutypes = append(insutypes, item)
  13099. }
  13100. }
  13101. if len(insutypes) == 1 {
  13102. insutype = insutypes[0].Insutype
  13103. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13104. } else {
  13105. for _, i := range insutypes {
  13106. if i.Insutype == "390" {
  13107. is390 = 1
  13108. }
  13109. if i.Insutype == "310" {
  13110. is310 = 1
  13111. }
  13112. }
  13113. }
  13114. if is390 == 1 {
  13115. insutype = "390"
  13116. }
  13117. if is310 == 1 {
  13118. insutype = "310"
  13119. }
  13120. if len(insutypes) == 2 {
  13121. insutype = insutype_two
  13122. }
  13123. if len(insutypes) == 0 {
  13124. insutype = "310"
  13125. }
  13126. insutype = insutype_two
  13127. fmt.Println(insutype)
  13128. for _, item := range rf {
  13129. fmt.Println(item.Insutype)
  13130. fmt.Println(insutype)
  13131. if item.Insutype == insutype {
  13132. fmt.Println(item.Insutype)
  13133. fmt.Println(insutype)
  13134. insuplc_admdvs = item.InsuplcAdmdvs
  13135. }
  13136. }
  13137. fmt.Println(insuplc_admdvs)
  13138. var res2 ResultThirteen
  13139. var res10265_2 ResultThirteen10265
  13140. if config.IsOpen == 1 {
  13141. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13142. } else {
  13143. 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)
  13144. var dat map[string]interface{}
  13145. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13146. fmt.Println(dat)
  13147. } else {
  13148. fmt.Println(err)
  13149. }
  13150. userJSONBytes, _ := json.Marshal(dat)
  13151. if miConfig.Code == "H15049901371" {
  13152. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  13153. utils.ErrorLog("解析失败:%v", err)
  13154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13155. return
  13156. }
  13157. res2.ErrMsg = res10265_2.ErrMsg
  13158. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  13159. res2.Infcode = infocode
  13160. res2.Output = res10265_2.Output
  13161. res2.InfRefmsgid = res10265_2.InfRefmsgid
  13162. } else {
  13163. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13164. utils.ErrorLog("解析失败:%v", err)
  13165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13166. return
  13167. }
  13168. }
  13169. }
  13170. if res2.Infcode == 0 {
  13171. psnResult := &models.GdybPsnNcdsRecord{
  13172. UserOrgId: adminUser.CurrentOrgId,
  13173. PatientId: patient.ID,
  13174. PsnNo: psn_no,
  13175. DoctorId: doctor.AdminUserId,
  13176. DepartmentId: department_id,
  13177. SickType: sick_id,
  13178. Insutype: insutype,
  13179. Ctime: time.Now().Unix(),
  13180. Mtime: time.Now().Unix(),
  13181. Status: 1,
  13182. IsCancel: 1,
  13183. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  13184. }
  13185. service.CreatePsnNCDSRecord(psnResult)
  13186. c.ServeSuccessJSON(map[string]interface{}{
  13187. "failed_code": 0,
  13188. "msg": "备案成功",
  13189. "result": psnResult,
  13190. })
  13191. } else {
  13192. c.ServeSuccessJSON(map[string]interface{}{
  13193. "failed_code": -10,
  13194. "msg": res2.ErrMsg,
  13195. })
  13196. return
  13197. }
  13198. }
  13199. }
  13200. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  13201. id, _ := c.GetInt64("id")
  13202. admin_user_id, _ := c.GetInt64("admin_user_id")
  13203. adminUser := c.GetAdminUserInfo()
  13204. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13205. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13206. //config, _ := service.Ge(adminUser.CurrentOrgId)
  13207. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  13208. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13209. //var user_name string
  13210. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13211. //if role.ID == 0 {
  13212. // user_name = "xxx"
  13213. //} else {
  13214. // user_name = role.UserName
  13215. //}
  13216. psn_record, _ := service.GetPsnNCDSRecordById(id)
  13217. if psn_record.ID == 0 {
  13218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13219. return
  13220. }
  13221. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13222. var res ResultTwo
  13223. var res10265 ResultTwo10265
  13224. if miConfig.Code == "H15049901371" {
  13225. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13226. utils.ErrorLog("解析失败:%v", err)
  13227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13228. return
  13229. }
  13230. res.ErrMsg = res10265.ErrMsg
  13231. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13232. res.Infcode = infocode
  13233. res.Output = res10265.Output
  13234. res.InfRefmsgid = res10265.InfRefmsgid
  13235. } else {
  13236. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13237. utils.ErrorLog("解析失败:%v", err)
  13238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13239. return
  13240. }
  13241. }
  13242. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13243. infoStr := string(Iinfos)
  13244. var rf []*ResultFive
  13245. json.Unmarshal([]byte(infoStr), &rf)
  13246. var insuplc_admdvs string
  13247. var insutype string
  13248. var is390 int = 0
  13249. var is310 int = 0
  13250. var insutypes []*ResultFive
  13251. for _, item := range rf {
  13252. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13253. insutypes = append(insutypes, item)
  13254. }
  13255. }
  13256. if len(insutypes) == 1 {
  13257. insutype = insutypes[0].Insutype
  13258. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13259. } else {
  13260. for _, i := range insutypes {
  13261. if i.Insutype == "390" {
  13262. is390 = 1
  13263. }
  13264. if i.Insutype == "310" {
  13265. is310 = 1
  13266. }
  13267. }
  13268. }
  13269. if is390 == 1 {
  13270. insutype = "390"
  13271. }
  13272. if is310 == 1 {
  13273. insutype = "310"
  13274. }
  13275. if len(insutypes) == 0 {
  13276. insutype = "310"
  13277. }
  13278. insutype = psn_record.Insutype
  13279. for _, item := range rf {
  13280. if item.Insutype == insutype {
  13281. insuplc_admdvs = item.InsuplcAdmdvs
  13282. }
  13283. }
  13284. if config.IsOpen == 1 {
  13285. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  13286. var dat map[string]interface{}
  13287. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13288. fmt.Println(dat)
  13289. } else {
  13290. fmt.Println(err)
  13291. }
  13292. userJSONBytes, _ := json.Marshal(dat)
  13293. var res ResultFourteen
  13294. var res10265 ResultFourteen10265
  13295. if miConfig.Code == "H15049901371" {
  13296. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13297. utils.ErrorLog("解析失败:%v", err)
  13298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13299. return
  13300. }
  13301. res.ErrMsg = res10265.ErrMsg
  13302. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13303. res.Infcode = infocode
  13304. res.Output = res10265.Output
  13305. res.InfRefmsgid = res10265.InfRefmsgid
  13306. } else {
  13307. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13308. utils.ErrorLog("解析失败:%v", err)
  13309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13310. return
  13311. }
  13312. }
  13313. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13314. // utils.ErrorLog("解析失败:%v", err)
  13315. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13316. // return
  13317. //}
  13318. if res.Infcode == 0 {
  13319. psn_record.IsCancel = 2
  13320. service.CreatePsnNCDSRecord(&psn_record)
  13321. c.ServeSuccessJSON(map[string]interface{}{
  13322. "failed_code": 0,
  13323. "msg": "撤销备案成功",
  13324. })
  13325. } else {
  13326. c.ServeSuccessJSON(map[string]interface{}{
  13327. "failed_code": -10,
  13328. "msg": res.ErrMsg,
  13329. })
  13330. return
  13331. }
  13332. }
  13333. }
  13334. func (c *HisApiController) TestTest() {
  13335. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  13336. fmt.Println(patient.Iinfo)
  13337. }
  13338. type CustomData struct {
  13339. MsgId string
  13340. PsnNo string
  13341. Info string
  13342. }
  13343. func (c *HisApiController) ReversalData() {
  13344. var customData []*CustomData
  13345. custom := &CustomData{
  13346. MsgId: "H44022900158202103301714472004",
  13347. PsnNo: "44020000001101329945",
  13348. Info: "2207",
  13349. }
  13350. customData = append(customData, custom)
  13351. custom1 := &CustomData{
  13352. MsgId: "H4402290015820210330172057803",
  13353. PsnNo: "44020000001101161813",
  13354. Info: "2207",
  13355. }
  13356. customData = append(customData, custom1)
  13357. custom2 := &CustomData{
  13358. MsgId: "H44022900158202103301705198813",
  13359. PsnNo: "44190000133097375417",
  13360. Info: "2207",
  13361. }
  13362. customData = append(customData, custom2)
  13363. custom3 := &CustomData{
  13364. MsgId: "H44022900158202103301715524756",
  13365. PsnNo: "44020000001100187221",
  13366. Info: "2207",
  13367. }
  13368. customData = append(customData, custom3)
  13369. custom4 := &CustomData{
  13370. MsgId: "H44022900158202103301730376224",
  13371. PsnNo: "44020000001101959155",
  13372. Info: "2207",
  13373. }
  13374. customData = append(customData, custom4)
  13375. custom5 := &CustomData{
  13376. MsgId: "H44022900158202103301748008725",
  13377. PsnNo: "44020000001104246641",
  13378. Info: "2207",
  13379. }
  13380. customData = append(customData, custom5)
  13381. custom6 := &CustomData{
  13382. MsgId: "H44022900158202103301718096755",
  13383. PsnNo: "44020000001102211860",
  13384. Info: "2207",
  13385. }
  13386. customData = append(customData, custom6)
  13387. custom7 := &CustomData{
  13388. MsgId: "H44022900158202103301736551640",
  13389. PsnNo: "44020000001102687718",
  13390. Info: "2207",
  13391. }
  13392. customData = append(customData, custom7)
  13393. custom8 := &CustomData{
  13394. MsgId: "H44022900158202103301743097676",
  13395. PsnNo: "44020000001102127785",
  13396. Info: "2207",
  13397. }
  13398. customData = append(customData, custom8)
  13399. custom9 := &CustomData{
  13400. MsgId: "H44022900158202103301712304203",
  13401. PsnNo: "44020000001101518097",
  13402. Info: "2207",
  13403. }
  13404. customData = append(customData, custom9)
  13405. custom10 := &CustomData{
  13406. MsgId: "H44022900158202103301738448785",
  13407. PsnNo: "44020000001100500813",
  13408. Info: "2207",
  13409. }
  13410. customData = append(customData, custom10)
  13411. custom11 := &CustomData{
  13412. MsgId: "H44022900158202103301732455843",
  13413. PsnNo: "44020000001102690557",
  13414. Info: "2207",
  13415. }
  13416. customData = append(customData, custom11)
  13417. custom12 := &CustomData{
  13418. MsgId: "H44022900158202103301745421708",
  13419. PsnNo: "44020000001102211928",
  13420. Info: "2207",
  13421. }
  13422. customData = append(customData, custom12)
  13423. custom1212 := &CustomData{
  13424. MsgId: "H440229001582021033017351627",
  13425. PsnNo: "44020000001102481733",
  13426. Info: "2207",
  13427. }
  13428. customData = append(customData, custom1212)
  13429. custom13 := &CustomData{
  13430. MsgId: "H44022900158202103301740327951",
  13431. PsnNo: "44020000001103174866",
  13432. Info: "2207",
  13433. }
  13434. customData = append(customData, custom13)
  13435. custom14 := &CustomData{
  13436. MsgId: "H4402290015820210330174922668",
  13437. PsnNo: "44020000001102927272",
  13438. Info: "2207",
  13439. }
  13440. customData = append(customData, custom14)
  13441. custom15 := &CustomData{
  13442. MsgId: "H44022900158202103301752362273",
  13443. PsnNo: "44020000001102942890",
  13444. Info: "2207",
  13445. }
  13446. customData = append(customData, custom15)
  13447. custom16 := &CustomData{
  13448. MsgId: "H44022900158202103301751082917",
  13449. PsnNo: "44020000001101662162",
  13450. Info: "2207",
  13451. }
  13452. customData = append(customData, custom16)
  13453. custom17 := &CustomData{
  13454. MsgId: "H44022900158202103301754147728",
  13455. PsnNo: "44020000000229014511",
  13456. Info: "2207",
  13457. }
  13458. customData = append(customData, custom17)
  13459. adminUser := c.GetAdminUserInfo()
  13460. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13461. for _, item := range customData {
  13462. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13463. fmt.Println(result)
  13464. }
  13465. }
  13466. //func (c *HisApiController) GetAllopatry() {
  13467. // year := c.GetString("year")
  13468. // month := c.GetString("month")
  13469. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13470. // adminUser := c.GetAdminUserInfo()
  13471. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13472. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13473. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13474. //
  13475. // var dat map[string]interface{}
  13476. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13477. // fmt.Println(dat)
  13478. // } else {
  13479. // fmt.Println(err)
  13480. // }
  13481. // userJSONBytes, _ := json.Marshal(dat)
  13482. // var res models.Result9001
  13483. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13484. // utils.ErrorLog("解析失败:%v", err)
  13485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13486. // return
  13487. // }
  13488. //
  13489. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13490. // var dat2 map[string]interface{}
  13491. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13492. // fmt.Println(dat)
  13493. // } else {
  13494. // fmt.Println(err)
  13495. // }
  13496. // userJSONBytes2, _ := json.Marshal(dat2)
  13497. // var res2 models.Result3260
  13498. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13499. // utils.ErrorLog("解析失败:%v", err)
  13500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13501. // return
  13502. // }
  13503. // if res2.Infcode == 0 {
  13504. // c.ServeSuccessJSON(map[string]interface{}{
  13505. // "list": res2.Output.Data,
  13506. // })
  13507. // return
  13508. // } else {
  13509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13510. // return
  13511. // }
  13512. //
  13513. //}
  13514. //func (c *HisApiController) ComfirmAllopatry() {
  13515. // year := c.GetString("year")
  13516. // month := c.GetString("month")
  13517. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13518. // adminUser := c.GetAdminUserInfo()
  13519. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13520. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13521. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13522. // var dat map[string]interface{}
  13523. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13524. // fmt.Println(dat)
  13525. // } else {
  13526. // fmt.Println(err)
  13527. // }
  13528. // userJSONBytes, _ := json.Marshal(dat)
  13529. // var res models.Result9001
  13530. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13531. // utils.ErrorLog("解析失败:%v", err)
  13532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13533. // return
  13534. // }
  13535. //
  13536. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13537. // var dat2 map[string]interface{}
  13538. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13539. // fmt.Println(dat)
  13540. // } else {
  13541. // fmt.Println(err)
  13542. // }
  13543. // userJSONBytes2, _ := json.Marshal(dat2)
  13544. // var res2 models.Result3260
  13545. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13546. // utils.ErrorLog("解析失败:%v", err)
  13547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13548. // return
  13549. // }
  13550. //
  13551. // if res2.Infcode == 0 {
  13552. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  13553. // var dat map[string]interface{}
  13554. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13555. // fmt.Println(dat)
  13556. // } else {
  13557. // fmt.Println(err)
  13558. // }
  13559. // userJSONBytes, _ := json.Marshal(dat)
  13560. // var res3 models.Result3261
  13561. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  13562. // utils.ErrorLog("解析失败:%v", err)
  13563. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13564. // return
  13565. // }
  13566. //
  13567. // if res3.Infcode == 0 {
  13568. // record := &models.HisYidiClearRecord{
  13569. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13570. // Ctime: time.Now().Unix(),
  13571. // Mtime: time.Now().Unix(),
  13572. // Status: 1,
  13573. // MsgId: msgId,
  13574. // }
  13575. // service.SaveClearRecord(record)
  13576. // c.ServeSuccessJSON(map[string]interface{}{
  13577. // "msg": "提取成功",
  13578. // })
  13579. // }
  13580. // }
  13581. //}
  13582. func (c *HisApiController) RefundAllopatry() {
  13583. year := c.GetString("year")
  13584. month := c.GetString("month")
  13585. id, _ := c.GetInt64("id")
  13586. admin_user_id, _ := c.GetInt64("admin_user_id")
  13587. adminUser := c.GetAdminUserInfo()
  13588. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13589. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13590. record, _ := service.GetClearRecordById(id)
  13591. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  13592. var dat map[string]interface{}
  13593. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13594. fmt.Println(dat)
  13595. } else {
  13596. fmt.Println(err)
  13597. }
  13598. userJSONBytes, _ := json.Marshal(dat)
  13599. var empty ResultFourteen
  13600. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  13601. utils.ErrorLog("解析失败:%v", err)
  13602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13603. return
  13604. }
  13605. if empty.Infcode == 0 {
  13606. c.ServeSuccessJSON(map[string]interface{}{
  13607. "msg": "撤销成功",
  13608. })
  13609. return
  13610. }
  13611. }
  13612. func (c *HisApiController) ReversalOtherData() {
  13613. var customData []*CustomData
  13614. custom := &CustomData{
  13615. MsgId: "H44022900158202103301714472004",
  13616. PsnNo: "44020000001101329945",
  13617. Info: "2208",
  13618. }
  13619. customData = append(customData, custom)
  13620. custom1 := &CustomData{
  13621. MsgId: "H4402290015820210330172057803",
  13622. PsnNo: "44020000001101161813",
  13623. Info: "2208",
  13624. }
  13625. customData = append(customData, custom1)
  13626. custom2 := &CustomData{
  13627. MsgId: "H44022900158202103301705198813",
  13628. PsnNo: "44190000133097375417",
  13629. Info: "2208",
  13630. }
  13631. customData = append(customData, custom2)
  13632. custom3 := &CustomData{
  13633. MsgId: "H44022900158202103301715524756",
  13634. PsnNo: "44020000001100187221",
  13635. Info: "2208",
  13636. }
  13637. customData = append(customData, custom3)
  13638. custom4 := &CustomData{
  13639. MsgId: "H44022900158202103301730376224",
  13640. PsnNo: "44020000001101959155",
  13641. Info: "2208",
  13642. }
  13643. customData = append(customData, custom4)
  13644. custom5 := &CustomData{
  13645. MsgId: "H44022900158202103301748008725",
  13646. PsnNo: "44020000001104246641",
  13647. Info: "2208",
  13648. }
  13649. customData = append(customData, custom5)
  13650. custom6 := &CustomData{
  13651. MsgId: "H44022900158202103301718096755",
  13652. PsnNo: "44020000001102211860",
  13653. Info: "2208",
  13654. }
  13655. customData = append(customData, custom6)
  13656. custom7 := &CustomData{
  13657. MsgId: "H44022900158202103301736551640",
  13658. PsnNo: "44020000001102687718",
  13659. Info: "2208",
  13660. }
  13661. customData = append(customData, custom7)
  13662. custom8 := &CustomData{
  13663. MsgId: "H44022900158202103301743097676",
  13664. PsnNo: "44020000001102127785",
  13665. Info: "2208",
  13666. }
  13667. customData = append(customData, custom8)
  13668. custom9 := &CustomData{
  13669. MsgId: "H44022900158202103301712304203",
  13670. PsnNo: "44020000001101518097",
  13671. Info: "2208",
  13672. }
  13673. customData = append(customData, custom9)
  13674. custom10 := &CustomData{
  13675. MsgId: "H44022900158202103301738448785",
  13676. PsnNo: "44020000001100500813",
  13677. Info: "2208",
  13678. }
  13679. customData = append(customData, custom10)
  13680. custom11 := &CustomData{
  13681. MsgId: "H44022900158202103301732455843",
  13682. PsnNo: "44020000001102690557",
  13683. Info: "2208",
  13684. }
  13685. customData = append(customData, custom11)
  13686. custom12 := &CustomData{
  13687. MsgId: "H44022900158202103301745421708",
  13688. PsnNo: "44020000001102211928",
  13689. Info: "2208",
  13690. }
  13691. customData = append(customData, custom12)
  13692. custom1212 := &CustomData{
  13693. MsgId: "H440229001582021033017351627",
  13694. PsnNo: "44020000001102481733",
  13695. Info: "2208",
  13696. }
  13697. customData = append(customData, custom1212)
  13698. custom13 := &CustomData{
  13699. MsgId: "H44022900158202103301740327951",
  13700. PsnNo: "44020000001103174866",
  13701. Info: "2208",
  13702. }
  13703. customData = append(customData, custom13)
  13704. custom14 := &CustomData{
  13705. MsgId: "H4402290015820210330174922668",
  13706. PsnNo: "44020000001102927272",
  13707. Info: "2208",
  13708. }
  13709. customData = append(customData, custom14)
  13710. custom15 := &CustomData{
  13711. MsgId: "H44022900158202103301752362273",
  13712. PsnNo: "44020000001102942890",
  13713. Info: "2208",
  13714. }
  13715. customData = append(customData, custom15)
  13716. custom16 := &CustomData{
  13717. MsgId: "H44022900158202103301751082917",
  13718. PsnNo: "44020000001101662162",
  13719. Info: "2208",
  13720. }
  13721. customData = append(customData, custom16)
  13722. custom17 := &CustomData{
  13723. MsgId: "H44022900158202103301754147728",
  13724. PsnNo: "44020000000229014511",
  13725. Info: "2208",
  13726. }
  13727. customData = append(customData, custom17)
  13728. adminUser := c.GetAdminUserInfo()
  13729. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13730. for _, item := range customData {
  13731. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13732. fmt.Println(result)
  13733. }
  13734. }
  13735. func PathExists(path string) (bool, error) {
  13736. _, err := os.Stat(path)
  13737. if err == nil {
  13738. return true, nil
  13739. }
  13740. if os.IsNotExist(err) {
  13741. return false, nil
  13742. }
  13743. return false, err
  13744. }
  13745. //创建文件夹
  13746. func Mkdir(dir string) {
  13747. // 创建文件夹
  13748. exist, err := PathExists(dir)
  13749. if err != nil {
  13750. fmt.Println(err.Error())
  13751. } else {
  13752. if exist {
  13753. fmt.Println(dir + "文件夹已存在!")
  13754. } else {
  13755. // 文件夹名称,权限
  13756. err := os.Mkdir(dir, os.ModePerm)
  13757. if err != nil {
  13758. fmt.Println(dir+"文件夹创建失败:", err.Error())
  13759. } else {
  13760. fmt.Println(dir + "文件夹创建成功!")
  13761. }
  13762. }
  13763. }
  13764. }
  13765. //压缩文件
  13766. func Zip(srcFile string, destZip string) error {
  13767. zipfile, err := os.Create(destZip)
  13768. if err != nil {
  13769. return err
  13770. }
  13771. defer zipfile.Close()
  13772. archive := zip.NewWriter(zipfile)
  13773. defer archive.Close()
  13774. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  13775. if err != nil {
  13776. return err
  13777. }
  13778. header, err := zip.FileInfoHeader(info)
  13779. if err != nil {
  13780. return err
  13781. }
  13782. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  13783. // header.Name = path
  13784. if info.IsDir() {
  13785. header.Name += "/"
  13786. } else {
  13787. header.Method = zip.Deflate
  13788. }
  13789. writer, err := archive.CreateHeader(header)
  13790. if err != nil {
  13791. return err
  13792. }
  13793. if !info.IsDir() {
  13794. file, err := os.Open(path)
  13795. if err != nil {
  13796. return err
  13797. }
  13798. defer file.Close()
  13799. _, err = io.Copy(writer, file)
  13800. }
  13801. return err
  13802. })
  13803. return err
  13804. }
  13805. func ReadFile(filePath string) []byte {
  13806. f, err := os.Open(filePath)
  13807. if err != nil {
  13808. fmt.Println("read file fail", err)
  13809. return nil
  13810. }
  13811. defer f.Close()
  13812. fd, err := ioutil.ReadAll(f)
  13813. if err != nil {
  13814. fmt.Println("read to fd fail", err)
  13815. return nil
  13816. }
  13817. return fd
  13818. }
  13819. func saveLog(result string, request string, infno string, desc string) {
  13820. org_id, _ := beego.AppConfig.Int64("org_id")
  13821. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13822. dir := miConfig.OrgName + "日志"
  13823. utils.Mkdir(dir)
  13824. month := time.Unix(1557042972, 0).Format("1")
  13825. year := time.Now().Format("2006")
  13826. month = time.Now().Format("01")
  13827. day := time.Now().Format("02")
  13828. hour := time.Now().Format("15")
  13829. min := time.Now().Format("04")
  13830. sec := time.Now().Format("05")
  13831. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  13832. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  13833. file_name := file + ".txt"
  13834. file_path := miConfig.OrgName + "日志" + "/" + file_name
  13835. exist, _ := utils.PathExists(file_path)
  13836. if exist { //存在
  13837. fmt.Println("存在")
  13838. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  13839. if err != nil {
  13840. fmt.Println("read fail")
  13841. }
  13842. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  13843. n, _ := f.Seek(0, 2)
  13844. _, err = f.WriteAt([]byte(content), n)
  13845. } else { //不存在
  13846. fmt.Println("文件不存在,创建文件")
  13847. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  13848. defer f.Close()
  13849. if err != nil {
  13850. } else {
  13851. _, err = f.Write([]byte("记录日志"))
  13852. }
  13853. }
  13854. }
  13855. type Charset string
  13856. const (
  13857. UTF8 = Charset("UTF-8")
  13858. GB18030 = Charset("GB18030")
  13859. )
  13860. func ConvertToString(src string, srcCode string, tagCode string) string {
  13861. srcCoder := mahonia.NewDecoder(srcCode)
  13862. srcResult := srcCoder.ConvertString(src)
  13863. tagCoder := mahonia.NewDecoder(tagCode)
  13864. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  13865. result := string(cdata)
  13866. return result
  13867. }
  13868. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  13869. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  13870. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13871. var token string
  13872. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13873. var api string
  13874. if miConfig.MdtrtareaAdmvs == "320921" {
  13875. 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 +
  13876. "&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
  13877. fmt.Println(api)
  13878. } else {
  13879. 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 +
  13880. "&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
  13881. }
  13882. resp, requestErr := http.Get(api)
  13883. if requestErr != nil {
  13884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13885. return ""
  13886. }
  13887. body, ioErr := ioutil.ReadAll(resp.Body)
  13888. if ioErr != nil {
  13889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13891. return ""
  13892. }
  13893. var respJSON map[string]interface{}
  13894. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13897. return ""
  13898. }
  13899. var status string
  13900. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13901. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13902. var res ResultTwo //1101结果
  13903. var res10265 ResultTwo10265 //1101结果
  13904. if status == "0" { //读卡成功
  13905. var card_info string //卡信息
  13906. var busi_card_info string
  13907. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13908. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13909. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13910. fmt.Println(card_info)
  13911. fmt.Println(busi_card_info)
  13912. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13913. result, _ := json.Marshal(respJSON)
  13914. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13915. utils.ErrorLog("解析失败:%v", err)
  13916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13917. return ""
  13918. }
  13919. res.ErrMsg = res10265.ErrMsg
  13920. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13921. res.Infcode = infocode
  13922. res.Output = res10265.Output
  13923. res.InfRefmsgid = res10265.InfRefmsgid
  13924. if res.Infcode == 0 {
  13925. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13926. if err == gorm.ErrRecordNotFound {
  13927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13928. return ""
  13929. } else if err != nil {
  13930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13931. return ""
  13932. } else {
  13933. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13934. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13935. infoStr := string(Iinfos)
  13936. idetinfoStr := string(Idetinfos)
  13937. psn := &models.HisPsn{
  13938. PsnNo: res.Output.Baseinfo.PsnNo,
  13939. Age: res.Output.Baseinfo.Age,
  13940. PatientId: patient.ID,
  13941. Certno: res.Output.Baseinfo.Certno,
  13942. Brdy: res.Output.Baseinfo.Brdy,
  13943. Gend: res.Output.Baseinfo.Gend,
  13944. Naty: res.Output.Baseinfo.Naty,
  13945. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13946. PsnName: res.Output.Baseinfo.PsnName,
  13947. Idetinfo: idetinfoStr,
  13948. Insuinfo: infoStr,
  13949. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13950. CardInfo: card_info,
  13951. VerifyNumber: token,
  13952. }
  13953. service.CreateHisPsn(psn)
  13954. return token
  13955. }
  13956. }
  13957. } else {
  13958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13959. return ""
  13960. }
  13961. } else { //读卡失败
  13962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13963. return ""
  13964. }
  13965. return token
  13966. }
  13967. func DeleteExtraSpaceTwo(s string) string {
  13968. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  13969. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  13970. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  13971. reg, _ := regexp.Compile(regstr) //编译正则表达式
  13972. s2 := make([]byte, len(s1)) //定义字符数组切片
  13973. copy(s2, s1) //将字符串复制到切片
  13974. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  13975. for len(spc_index) > 0 { //找到适配项
  13976. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  13977. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  13978. }
  13979. return string(s2)
  13980. }
  13981. func Remove0000(s string) string {
  13982. str := make([]rune, 0, len(s))
  13983. for _, v := range []rune(s) {
  13984. if v == 0 {
  13985. continue
  13986. }
  13987. str = append(str, v)
  13988. }
  13989. return string(str)
  13990. }
  13991. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  13992. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  13993. readCard := DllDef.MustFindProc("EcQuery")
  13994. pCardInfo := make([]byte, 8192)
  13995. pBusiCardInfo := make([]byte, 8192)
  13996. data := make(map[string]interface{})
  13997. //pData := make(map[string]interface{})
  13998. inputData := make(map[string]interface{})
  13999. inputData["orgId"] = code
  14000. inputData["businessType"] = "01101"
  14001. inputData["operatorId"] = operator_id
  14002. inputData["operatorName"] = operator_name
  14003. inputData["officeId"] = "001"
  14004. inputData["officeName"] = "血透室"
  14005. //
  14006. data["data"] = inputData
  14007. data["transType"] = "ec.query"
  14008. data["orgId"] = code
  14009. bytesData, _ := json.Marshal(data)
  14010. pCardInfo = bytesData
  14011. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  14012. fmt.Println(ret2)
  14013. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  14014. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  14015. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  14016. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  14017. if ret2 != 0 {
  14018. return "", ""
  14019. }
  14020. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  14021. }
  14022. func DeleteExtraSpace(s string) string {
  14023. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  14024. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  14025. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  14026. reg, _ := regexp.Compile(regstr) //编译正则表达式
  14027. s2 := make([]byte, len(s1)) //定义字符数组切片
  14028. copy(s2, s1) //将字符串复制到切片
  14029. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  14030. for len(spc_index) > 0 { //找到适配项
  14031. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  14032. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  14033. }
  14034. return string(s2)
  14035. }
  14036. //对账
  14037. func (c *HisApiController) Post3202() {
  14038. start_time := c.GetString("start_time")
  14039. end_time := c.GetString("end_time")
  14040. //insutype := c.GetString("insutype")
  14041. clr_type := c.GetString("clr_type")
  14042. clr_org := c.GetString("clr_optins")
  14043. admin_user_id, _ := c.GetInt64("admin_user_id")
  14044. adminUser := c.GetAdminUserInfo()
  14045. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14046. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14047. if len(clr_org) == 0 {
  14048. clr_org = miConfig.MdtrtareaAdmvs
  14049. }
  14050. timeLayout := "2006-01-02"
  14051. loc, _ := time.LoadLocation("Local")
  14052. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  14053. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  14054. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  14055. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  14056. //fixmedins_setl_cnt := int64(len(orders))
  14057. var medfee_sumamt float64
  14058. var acct_pay float64
  14059. var fund_pay_sumamt float64
  14060. for _, item := range orders {
  14061. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  14062. acct_pay = acct_pay + item.AcctPay
  14063. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  14064. }
  14065. //var medfee_sumamt_two float64
  14066. //var acct_pay_two float64
  14067. //var fund_pay_sumamt_two float64
  14068. //for _, item := range orders_two {
  14069. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  14070. // acct_pay_two = acct_pay_two + item.AcctPay
  14071. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  14072. //}
  14073. //var user_name string
  14074. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14075. //if role.ID == 0 {
  14076. // user_name = "xxx"
  14077. //} else {
  14078. // user_name = role.UserName
  14079. //}
  14080. var res ResultSix
  14081. if config.IsOpen == 1 {
  14082. var bps []*models.BusinessParamsTwo
  14083. var bp models.BusinessParamsTwo
  14084. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  14085. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  14086. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  14087. bp.MedfeeSumamt = medfee_sumamt_str
  14088. bp.AcctPay = acct_pay_str
  14089. bp.FundPaySumamt = fund_pay_sumamt_str
  14090. bp.Insutype = "390"
  14091. bp.StmtBegndate = start_time
  14092. bp.ClrType = clr_type
  14093. bp.SetlOptins = clr_org
  14094. bp.StmtEnddate = end_time
  14095. bps = append(bps, &bp)
  14096. data := make(map[string]interface{})
  14097. data["bps"] = bps
  14098. data["org_name"] = miConfig.OrgName
  14099. data["doctor"] = role.UserName
  14100. data["fixmedins_code"] = miConfig.Code
  14101. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14102. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14103. if miConfig.MdtrtareaAdmvs == "421300" {
  14104. client := &http.Client{}
  14105. bytesData, _ := json.Marshal(data)
  14106. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  14107. resp, _ := client.Do(req)
  14108. defer resp.Body.Close()
  14109. body, ioErr := ioutil.ReadAll(resp.Body)
  14110. if ioErr != nil {
  14111. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14113. return
  14114. }
  14115. var respJSON map[string]interface{}
  14116. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14117. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14119. return
  14120. }
  14121. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14122. userJSONBytes, _ := json.Marshal(respJSON)
  14123. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14124. utils.ErrorLog("解析失败:%v", err)
  14125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14126. return
  14127. }
  14128. }
  14129. if res.Infcode == 0 {
  14130. c.ServeSuccessJSON(map[string]interface{}{
  14131. "msg": "发起成功",
  14132. })
  14133. } else {
  14134. c.ServeSuccessJSON(map[string]interface{}{
  14135. "code": -10,
  14136. "msg": res.ErrMsg,
  14137. })
  14138. }
  14139. }
  14140. }
  14141. func (c *HisApiController) Post3501() {
  14142. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14143. data := make(map[string]interface{})
  14144. var struct3501s []models.Struct3501
  14145. var struct3501 models.Struct3501
  14146. struct3501.OrgName = miConfig.OrgName
  14147. struct3501.AccessKey = miConfig.AccessKey
  14148. struct3501.RequestUrl = miConfig.Url
  14149. struct3501.SecretKey = miConfig.SecretKey
  14150. struct3501.ManuDate = "2022-08-17"
  14151. struct3501.FixmedinsBchno = ""
  14152. struct3501.ManuLotnum = ""
  14153. struct3501.RxFlag = "0"
  14154. struct3501.ExpyEnd = "2022-08-17"
  14155. struct3501.Invdate = "2022-08-17"
  14156. struct3501.InvCnt = "20.25"
  14157. struct3501.Memo = ""
  14158. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14159. struct3501.FixmedinsHilistId = miConfig.Code
  14160. struct3501.FixmedinsHilistName = miConfig.OrgName
  14161. struct3501s = append(struct3501s, struct3501)
  14162. data["struct_3501s"] = struct3501s
  14163. client := &http.Client{}
  14164. bytesData, _ := json.Marshal(data)
  14165. var req *http.Request
  14166. if miConfig.MdtrtareaAdmvs == "320921" {
  14167. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14168. } else {
  14169. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14170. }
  14171. resp, _ := client.Do(req)
  14172. defer resp.Body.Close()
  14173. body, ioErr := ioutil.ReadAll(resp.Body)
  14174. if ioErr != nil {
  14175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14177. return
  14178. }
  14179. var respJSON map[string]interface{}
  14180. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14183. return
  14184. }
  14185. var res ResultSix
  14186. var resSix10265 ResultSix10265 //1101结果
  14187. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14188. result, _ := json.Marshal(respJSON)
  14189. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14190. utils.ErrorLog("解析失败:%v", err)
  14191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14192. return
  14193. }
  14194. res.InfRefmsgid = resSix10265.InfRefmsgid
  14195. res.Output = resSix10265.Output
  14196. res.ErrMsg = resSix10265.ErrMsg
  14197. res.Cainfo = resSix10265.Cainfo
  14198. res.WarnMsg = resSix10265.WarnMsg
  14199. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14200. res.Infcode = infocode
  14201. if infocode == 0 {
  14202. c.ServeSuccessJSON(map[string]interface{}{
  14203. "msg": "上传成功",
  14204. })
  14205. return
  14206. } else {
  14207. c.ServeSuccessJSON(map[string]interface{}{
  14208. "failed_code": -10,
  14209. "msg": res.ErrMsg,
  14210. })
  14211. return
  14212. }
  14213. }
  14214. func (c *HisApiController) Post3502() {
  14215. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14216. data := make(map[string]interface{})
  14217. var struct3502s []models.Struct3502
  14218. var struct3502 models.Struct3502
  14219. struct3502.OrgName = miConfig.OrgName
  14220. struct3502.AccessKey = miConfig.AccessKey
  14221. struct3502.RequestUrl = miConfig.Url
  14222. struct3502.SecretKey = miConfig.SecretKey
  14223. struct3502.ManuDate = "2022-08-15"
  14224. struct3502.FixmedinsBchno = ""
  14225. struct3502.ManuLotnum = ""
  14226. struct3502.RxFlag = "0"
  14227. struct3502.ExpyEnd = "2022-08-15"
  14228. struct3502.Invdate = "2022-08-15"
  14229. struct3502.InvCnt = "20.25"
  14230. struct3502.Memo = ""
  14231. struct3502.MedListCodg = "XB01ABD056B002020200517"
  14232. struct3502.FixmedinsHilistId = miConfig.Code
  14233. struct3502.FixmedinsHilistName = miConfig.OrgName
  14234. struct3502s = append(struct3502s, struct3502)
  14235. data["struct_3502s"] = struct3502s
  14236. client := &http.Client{}
  14237. bytesData, _ := json.Marshal(data)
  14238. var req *http.Request
  14239. if miConfig.MdtrtareaAdmvs == "320921" {
  14240. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14241. } else {
  14242. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14243. }
  14244. resp, _ := client.Do(req)
  14245. defer resp.Body.Close()
  14246. body, ioErr := ioutil.ReadAll(resp.Body)
  14247. if ioErr != nil {
  14248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14250. return
  14251. }
  14252. var respJSON map[string]interface{}
  14253. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14256. return
  14257. }
  14258. var res ResultSix
  14259. var resSix10265 ResultSix10265 //1101结果
  14260. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14261. result, _ := json.Marshal(respJSON)
  14262. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14263. utils.ErrorLog("解析失败:%v", err)
  14264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14265. return
  14266. }
  14267. res.InfRefmsgid = resSix10265.InfRefmsgid
  14268. res.Output = resSix10265.Output
  14269. res.ErrMsg = resSix10265.ErrMsg
  14270. res.Cainfo = resSix10265.Cainfo
  14271. res.WarnMsg = resSix10265.WarnMsg
  14272. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14273. res.Infcode = infocode
  14274. if infocode == 0 {
  14275. c.ServeSuccessJSON(map[string]interface{}{
  14276. "msg": "上传成功",
  14277. })
  14278. return
  14279. } else {
  14280. c.ServeSuccessJSON(map[string]interface{}{
  14281. "failed_code": -10,
  14282. "msg": res.ErrMsg,
  14283. })
  14284. return
  14285. }
  14286. }
  14287. func (c *HisApiController) Post3503() {
  14288. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14289. data := make(map[string]interface{})
  14290. var struct3501s []models.Struct3501
  14291. var struct3501 models.Struct3501
  14292. struct3501.OrgName = miConfig.OrgName
  14293. struct3501.AccessKey = miConfig.AccessKey
  14294. struct3501.RequestUrl = miConfig.Url
  14295. struct3501.SecretKey = miConfig.SecretKey
  14296. struct3501.ManuDate = "2022-08-15"
  14297. struct3501.FixmedinsBchno = ""
  14298. struct3501.ManuLotnum = ""
  14299. struct3501.RxFlag = "0"
  14300. struct3501.ExpyEnd = "2022-08-15"
  14301. struct3501.Invdate = "2022-08-15"
  14302. struct3501.InvCnt = "20.25"
  14303. struct3501.Memo = ""
  14304. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14305. struct3501.FixmedinsHilistId = miConfig.Code
  14306. struct3501.FixmedinsHilistName = miConfig.OrgName
  14307. struct3501s = append(struct3501s, struct3501)
  14308. data["struct_3501s"] = struct3501s
  14309. client := &http.Client{}
  14310. bytesData, _ := json.Marshal(data)
  14311. var req *http.Request
  14312. if miConfig.MdtrtareaAdmvs == "320921" {
  14313. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14314. } else {
  14315. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14316. }
  14317. resp, _ := client.Do(req)
  14318. defer resp.Body.Close()
  14319. body, ioErr := ioutil.ReadAll(resp.Body)
  14320. if ioErr != nil {
  14321. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14323. return
  14324. }
  14325. var respJSON map[string]interface{}
  14326. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14329. return
  14330. }
  14331. var res ResultSix
  14332. var resSix10265 ResultSix10265 //1101结果
  14333. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14334. result, _ := json.Marshal(respJSON)
  14335. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14336. utils.ErrorLog("解析失败:%v", err)
  14337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14338. return
  14339. }
  14340. res.InfRefmsgid = resSix10265.InfRefmsgid
  14341. res.Output = resSix10265.Output
  14342. res.ErrMsg = resSix10265.ErrMsg
  14343. res.Cainfo = resSix10265.Cainfo
  14344. res.WarnMsg = resSix10265.WarnMsg
  14345. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14346. res.Infcode = infocode
  14347. if infocode == 0 {
  14348. c.ServeSuccessJSON(map[string]interface{}{
  14349. "msg": "上传成功",
  14350. })
  14351. return
  14352. } else {
  14353. c.ServeSuccessJSON(map[string]interface{}{
  14354. "failed_code": -10,
  14355. "msg": res.ErrMsg,
  14356. })
  14357. return
  14358. }
  14359. }
  14360. func (c *HisApiController) Post3504() {
  14361. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14362. data := make(map[string]interface{})
  14363. var struct3501s []models.Struct3501
  14364. var struct3501 models.Struct3501
  14365. struct3501.OrgName = miConfig.OrgName
  14366. struct3501.AccessKey = miConfig.AccessKey
  14367. struct3501.RequestUrl = miConfig.Url
  14368. struct3501.SecretKey = miConfig.SecretKey
  14369. struct3501.ManuDate = "2022-08-15"
  14370. struct3501.FixmedinsBchno = ""
  14371. struct3501.ManuLotnum = ""
  14372. struct3501.RxFlag = "0"
  14373. struct3501.ExpyEnd = "2022-08-15"
  14374. struct3501.Invdate = "2022-08-15"
  14375. struct3501.InvCnt = "20.25"
  14376. struct3501.Memo = ""
  14377. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14378. struct3501.FixmedinsHilistId = miConfig.Code
  14379. struct3501.FixmedinsHilistName = miConfig.OrgName
  14380. struct3501s = append(struct3501s, struct3501)
  14381. data["struct_3501s"] = struct3501s
  14382. client := &http.Client{}
  14383. bytesData, _ := json.Marshal(data)
  14384. var req *http.Request
  14385. if miConfig.MdtrtareaAdmvs == "320921" {
  14386. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14387. } else {
  14388. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14389. }
  14390. resp, _ := client.Do(req)
  14391. defer resp.Body.Close()
  14392. body, ioErr := ioutil.ReadAll(resp.Body)
  14393. if ioErr != nil {
  14394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14396. return
  14397. }
  14398. var respJSON map[string]interface{}
  14399. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14402. return
  14403. }
  14404. var res ResultSix
  14405. var resSix10265 ResultSix10265 //1101结果
  14406. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14407. result, _ := json.Marshal(respJSON)
  14408. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14409. utils.ErrorLog("解析失败:%v", err)
  14410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14411. return
  14412. }
  14413. res.InfRefmsgid = resSix10265.InfRefmsgid
  14414. res.Output = resSix10265.Output
  14415. res.ErrMsg = resSix10265.ErrMsg
  14416. res.Cainfo = resSix10265.Cainfo
  14417. res.WarnMsg = resSix10265.WarnMsg
  14418. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14419. res.Infcode = infocode
  14420. if infocode == 0 {
  14421. c.ServeSuccessJSON(map[string]interface{}{
  14422. "msg": "上传成功",
  14423. })
  14424. return
  14425. } else {
  14426. c.ServeSuccessJSON(map[string]interface{}{
  14427. "failed_code": -10,
  14428. "msg": res.ErrMsg,
  14429. })
  14430. return
  14431. }
  14432. }
  14433. func (c *HisApiController) Post3505() {
  14434. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14435. data := make(map[string]interface{})
  14436. var struct3501s []models.Struct3501
  14437. var struct3501 models.Struct3501
  14438. struct3501.OrgName = miConfig.OrgName
  14439. struct3501.AccessKey = miConfig.AccessKey
  14440. struct3501.RequestUrl = miConfig.Url
  14441. struct3501.SecretKey = miConfig.SecretKey
  14442. struct3501.ManuDate = "2022-08-15"
  14443. struct3501.FixmedinsBchno = ""
  14444. struct3501.ManuLotnum = ""
  14445. struct3501.RxFlag = "0"
  14446. struct3501.ExpyEnd = "2022-08-15"
  14447. struct3501.Invdate = "2022-08-15"
  14448. struct3501.InvCnt = "20.25"
  14449. struct3501.Memo = ""
  14450. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14451. struct3501.FixmedinsHilistId = miConfig.Code
  14452. struct3501.FixmedinsHilistName = miConfig.OrgName
  14453. struct3501s = append(struct3501s, struct3501)
  14454. data["struct_3501s"] = struct3501s
  14455. client := &http.Client{}
  14456. bytesData, _ := json.Marshal(data)
  14457. var req *http.Request
  14458. if miConfig.MdtrtareaAdmvs == "320921" {
  14459. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14460. } else {
  14461. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14462. }
  14463. resp, _ := client.Do(req)
  14464. defer resp.Body.Close()
  14465. body, ioErr := ioutil.ReadAll(resp.Body)
  14466. if ioErr != nil {
  14467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14469. return
  14470. }
  14471. var respJSON map[string]interface{}
  14472. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14475. return
  14476. }
  14477. var res ResultSix
  14478. var resSix10265 ResultSix10265 //1101结果
  14479. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14480. result, _ := json.Marshal(respJSON)
  14481. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14482. utils.ErrorLog("解析失败:%v", err)
  14483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14484. return
  14485. }
  14486. res.InfRefmsgid = resSix10265.InfRefmsgid
  14487. res.Output = resSix10265.Output
  14488. res.ErrMsg = resSix10265.ErrMsg
  14489. res.Cainfo = resSix10265.Cainfo
  14490. res.WarnMsg = resSix10265.WarnMsg
  14491. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14492. res.Infcode = infocode
  14493. if infocode == 0 {
  14494. c.ServeSuccessJSON(map[string]interface{}{
  14495. "msg": "上传成功",
  14496. })
  14497. return
  14498. } else {
  14499. c.ServeSuccessJSON(map[string]interface{}{
  14500. "failed_code": -10,
  14501. "msg": res.ErrMsg,
  14502. })
  14503. return
  14504. }
  14505. }
  14506. func (c *HisApiController) Post3506() {
  14507. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14508. data := make(map[string]interface{})
  14509. var struct3501s []models.Struct3501
  14510. var struct3501 models.Struct3501
  14511. struct3501.OrgName = miConfig.OrgName
  14512. struct3501.AccessKey = miConfig.AccessKey
  14513. struct3501.RequestUrl = miConfig.Url
  14514. struct3501.SecretKey = miConfig.SecretKey
  14515. struct3501.ManuDate = "2022-08-15"
  14516. struct3501.FixmedinsBchno = ""
  14517. struct3501.ManuLotnum = ""
  14518. struct3501.RxFlag = "0"
  14519. struct3501.ExpyEnd = "2022-08-15"
  14520. struct3501.Invdate = "2022-08-15"
  14521. struct3501.InvCnt = "20.25"
  14522. struct3501.Memo = ""
  14523. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14524. struct3501.FixmedinsHilistId = miConfig.Code
  14525. struct3501.FixmedinsHilistName = miConfig.OrgName
  14526. struct3501s = append(struct3501s, struct3501)
  14527. data["struct_3501s"] = struct3501s
  14528. client := &http.Client{}
  14529. bytesData, _ := json.Marshal(data)
  14530. var req *http.Request
  14531. if miConfig.MdtrtareaAdmvs == "320921" {
  14532. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14533. } else {
  14534. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14535. }
  14536. resp, _ := client.Do(req)
  14537. defer resp.Body.Close()
  14538. body, ioErr := ioutil.ReadAll(resp.Body)
  14539. if ioErr != nil {
  14540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14542. return
  14543. }
  14544. var respJSON map[string]interface{}
  14545. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14548. return
  14549. }
  14550. var res ResultSix
  14551. var resSix10265 ResultSix10265 //1101结果
  14552. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14553. result, _ := json.Marshal(respJSON)
  14554. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14555. utils.ErrorLog("解析失败:%v", err)
  14556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14557. return
  14558. }
  14559. res.InfRefmsgid = resSix10265.InfRefmsgid
  14560. res.Output = resSix10265.Output
  14561. res.ErrMsg = resSix10265.ErrMsg
  14562. res.Cainfo = resSix10265.Cainfo
  14563. res.WarnMsg = resSix10265.WarnMsg
  14564. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14565. res.Infcode = infocode
  14566. if infocode == 0 {
  14567. c.ServeSuccessJSON(map[string]interface{}{
  14568. "msg": "上传成功",
  14569. })
  14570. return
  14571. } else {
  14572. c.ServeSuccessJSON(map[string]interface{}{
  14573. "failed_code": -10,
  14574. "msg": res.ErrMsg,
  14575. })
  14576. return
  14577. }
  14578. }
  14579. func (c *HisApiController) Post3507() {
  14580. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14581. data := make(map[string]interface{})
  14582. var struct3501s []models.Struct3501
  14583. var struct3501 models.Struct3501
  14584. struct3501.OrgName = miConfig.OrgName
  14585. struct3501.AccessKey = miConfig.AccessKey
  14586. struct3501.RequestUrl = miConfig.Url
  14587. struct3501.SecretKey = miConfig.SecretKey
  14588. struct3501.ManuDate = "2022-08-15"
  14589. struct3501.FixmedinsBchno = ""
  14590. struct3501.ManuLotnum = ""
  14591. struct3501.RxFlag = "0"
  14592. struct3501.ExpyEnd = "2022-08-15"
  14593. struct3501.Invdate = "2022-08-15"
  14594. struct3501.InvCnt = "20.25"
  14595. struct3501.Memo = ""
  14596. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14597. struct3501.FixmedinsHilistId = miConfig.Code
  14598. struct3501.FixmedinsHilistName = miConfig.OrgName
  14599. struct3501s = append(struct3501s, struct3501)
  14600. data["struct_3501s"] = struct3501s
  14601. client := &http.Client{}
  14602. bytesData, _ := json.Marshal(data)
  14603. var req *http.Request
  14604. if miConfig.MdtrtareaAdmvs == "320921" {
  14605. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14606. } else {
  14607. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14608. }
  14609. resp, _ := client.Do(req)
  14610. defer resp.Body.Close()
  14611. body, ioErr := ioutil.ReadAll(resp.Body)
  14612. if ioErr != nil {
  14613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14615. return
  14616. }
  14617. var respJSON map[string]interface{}
  14618. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14621. return
  14622. }
  14623. var res ResultSix
  14624. var resSix10265 ResultSix10265 //1101结果
  14625. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14626. result, _ := json.Marshal(respJSON)
  14627. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14628. utils.ErrorLog("解析失败:%v", err)
  14629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14630. return
  14631. }
  14632. res.InfRefmsgid = resSix10265.InfRefmsgid
  14633. res.Output = resSix10265.Output
  14634. res.ErrMsg = resSix10265.ErrMsg
  14635. res.Cainfo = resSix10265.Cainfo
  14636. res.WarnMsg = resSix10265.WarnMsg
  14637. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14638. res.Infcode = infocode
  14639. if infocode == 0 {
  14640. c.ServeSuccessJSON(map[string]interface{}{
  14641. "msg": "上传成功",
  14642. })
  14643. return
  14644. } else {
  14645. c.ServeSuccessJSON(map[string]interface{}{
  14646. "failed_code": -10,
  14647. "msg": res.ErrMsg,
  14648. })
  14649. return
  14650. }
  14651. }