his_api_controller.go 738KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. //"crypto/x509/pkix"
  6. "encoding/json"
  7. "fmt"
  8. //"github.com/tjfoc/gmsm/sm2"
  9. //"github.com/tjfoc/gmsm/sm3"
  10. "gdyb/controllers"
  11. "gdyb/enums"
  12. "gdyb/models"
  13. "gdyb/service"
  14. "gdyb/utils"
  15. "github.com/astaxie/beego"
  16. "github.com/axgle/mahonia"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. )
  35. type HisApiController struct {
  36. controllers.BaseAuthAPIController
  37. }
  38. func HisManagerApiRegistRouters() {
  39. //挂号
  40. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  41. //上传就诊信息-上传明细-结算
  42. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  43. //查询
  44. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  45. //对总账
  46. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  47. //对明细
  48. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  49. //退费,退明细
  50. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  51. //退号
  52. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  53. //退明细
  54. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  55. //上传就诊信息-上传明细-预结算
  56. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  57. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  58. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  59. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  60. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  61. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  62. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  63. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  64. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  65. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  66. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  67. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  68. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  69. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  70. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  71. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  72. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  73. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  74. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  75. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  76. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  77. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  78. beego.Router("/api/check", &HisApiController{}, "get:Check")
  79. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  80. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  81. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  82. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  83. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  84. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  85. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  86. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  87. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  88. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  89. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  90. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  91. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  92. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  93. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  94. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  95. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  96. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  97. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  98. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  99. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  100. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  101. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  102. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  103. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  104. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  105. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  106. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  107. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  108. //beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  109. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  110. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  111. beego.Router("/jsyb/3260", &HisApiController{}, "get:Get3260")
  112. beego.Router("/jsyb/3261", &HisApiController{}, "get:Get3261")
  113. beego.Router("/jsyb/3262", &HisApiController{}, "get:Get3262")
  114. beego.Router("/jsyb/3263", &HisApiController{}, "get:Get3263")
  115. beego.Router("/jsyb/3264", &HisApiController{}, "get:Get3264")
  116. beego.Router("/jsyb/3265", &HisApiController{}, "get:Get3265")
  117. beego.Router("/jsyb/3266", &HisApiController{}, "get:Get3266")
  118. beego.Router("/jsyb/3267", &HisApiController{}, "get:Get3267")
  119. beego.Router("/jsyb/3268", &HisApiController{}, "get:Get3268")
  120. beego.Router("/jsyb/3269", &HisApiController{}, "get:Get3269")
  121. beego.Router("/jsyb/3270", &HisApiController{}, "get:Get3270")
  122. beego.Router("/jsyb/3271", &HisApiController{}, "get:Get3271")
  123. beego.Router("/jsyb/3272", &HisApiController{}, "get:Get3272")
  124. beego.Router("/jsyb/3273", &HisApiController{}, "get:Get3273")
  125. beego.Router("/jsyb/3274", &HisApiController{}, "get:Get3274")
  126. beego.Router("/jsyb/3275", &HisApiController{}, "get:Get3275")
  127. beego.Router("/jsyb/3276", &HisApiController{}, "get:Get3276")
  128. beego.Router("/jsyb/3277", &HisApiController{}, "get:Get3277")
  129. }
  130. // 对账权限查询
  131. func (c *HisApiController) Get3260() {
  132. admin_user_id, _ := c.GetInt64("admin_user_id")
  133. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  134. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  135. var api string
  136. var res models.JSResult3260
  137. if miConfig.MdtrtareaAdmvs == "320921" {
  138. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  139. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  140. } else {
  141. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  142. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  143. }
  144. resp, requestErr := http.Get(api)
  145. if requestErr != nil {
  146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  147. return
  148. }
  149. body, ioErr := ioutil.ReadAll(resp.Body)
  150. if ioErr != nil {
  151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  153. return
  154. }
  155. var respJSON map[string]interface{}
  156. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  159. return
  160. }
  161. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  162. result, _ := json.Marshal(respJSON)
  163. if err := json.Unmarshal([]byte(result), &res); err != nil {
  164. utils.ErrorLog("解析失败:%v", err)
  165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  166. return
  167. }
  168. if res.Infcode == 0 {
  169. c.ServeSuccessJSON(map[string]interface{}{
  170. "result": res.Output.Data,
  171. })
  172. } else {
  173. c.ServeSuccessJSON(map[string]interface{}{
  174. "failed_code": -10,
  175. "msg": res.ErrMsg,
  176. })
  177. return
  178. }
  179. }
  180. func (c *HisApiController) Get3261() {
  181. admin_user_id, _ := c.GetInt64("admin_user_id")
  182. //month := c.GetString("month")
  183. startTime := c.GetString("start_time")
  184. //endTime, _ := c.GetString("end_time")
  185. times := strings.Split(startTime, "-")
  186. stmt_mon := times[0] + times[1]
  187. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  188. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  189. var api string
  190. var res models.JSResult3261
  191. //var res10265 Result5301For10265
  192. if miConfig.MdtrtareaAdmvs == "320921" {
  193. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  194. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  195. } else {
  196. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  197. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  198. }
  199. resp, requestErr := http.Get(api)
  200. if requestErr != nil {
  201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  202. return
  203. }
  204. body, ioErr := ioutil.ReadAll(resp.Body)
  205. if ioErr != nil {
  206. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  208. return
  209. }
  210. var respJSON map[string]interface{}
  211. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  214. return
  215. }
  216. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  217. result, _ := json.Marshal(respJSON)
  218. if err := json.Unmarshal([]byte(result), &res); err != nil {
  219. utils.ErrorLog("解析失败:%v", err)
  220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  221. return
  222. }
  223. if res.Infcode == 0 {
  224. c.ServeSuccessJSON(map[string]interface{}{
  225. "result": res.Output,
  226. })
  227. } else {
  228. c.ServeSuccessJSON(map[string]interface{}{
  229. "failed_code": -10,
  230. "msg": res.ErrMsg,
  231. })
  232. return
  233. }
  234. }
  235. func (c *HisApiController) Get3262() {
  236. admin_user_id, _ := c.GetInt64("admin_user_id")
  237. startTime, _ := c.GetString("start_time")
  238. endTime, _ := c.GetString("end_time")
  239. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  240. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  241. timeLayout := "2006-01-02"
  242. loc, _ := time.LoadLocation("Local")
  243. var theStartTIme int64
  244. if len(startTime) > 0 {
  245. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  246. if err != nil {
  247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  248. return
  249. }
  250. theStartTIme = theTime.Unix()
  251. }
  252. var theEndtTIme int64
  253. if len(endTime) > 0 {
  254. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  255. if err != nil {
  256. utils.ErrorLog(err.Error())
  257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  258. return
  259. }
  260. theEndtTIme = theTime.Unix()
  261. }
  262. datas, _ := service.GetOrderByTimeTen(theStartTIme, theEndtTIme, c.GetAdminUserInfo().CurrentOrgId)
  263. //startTime := c.GetString("start_time")
  264. //endTime, _ := c.GetString("end_time")
  265. times := strings.Split(startTime, "-")
  266. stmt_mon := times[0] + times[1]
  267. var funs []models.FundDetail
  268. for _, item := range datas {
  269. fun, _ := service.GetOrderDetailByTimeTen(theStartTIme, theEndtTIme, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  270. funs = append(funs, fun...)
  271. }
  272. var funInfos []models.Fund
  273. for _, item := range funs {
  274. var rf []models.FundInfo
  275. json.Unmarshal([]byte(item.SetlDetail), &rf)
  276. for _, subitem := range rf {
  277. var fund models.Fund
  278. fund.FundCode = subitem.FundPayType
  279. fund.FundName = subitem.FundPayTypeName
  280. fund.FundAmt = subitem.FundPayAmt
  281. fund.FundKey = item.FundKey
  282. fund.InsuAdmdvs = "555555"
  283. fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  284. funInfos = append(funInfos, fund)
  285. }
  286. }
  287. var upld_btch string
  288. var empty models.JSResultEmpty
  289. data := make(map[string]interface{})
  290. data["org_name"] = miConfig.OrgName
  291. data["doctor"] = curRoles.UserName
  292. data["doctor_name"] = curRoles.UserName
  293. data["fixmedins_code"] = miConfig.Code
  294. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  295. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  296. data["secret_key"] = miConfig.SecretKey
  297. data["url"] = miConfig.Url
  298. data["ak"] = miConfig.AccessKey
  299. data["cainfo"] = miConfig.Cainfo
  300. data["data"] = datas
  301. data["fund"] = funInfos
  302. month := time.Unix(1557042972, 0).Format("1")
  303. year := time.Now().Format("2006")
  304. month = time.Now().Format("01")
  305. day := time.Now().Format("02")
  306. hour := time.Now().Format("15")
  307. min := time.Now().Format("04")
  308. sec := time.Now().Format("05")
  309. fix_fill_date := year + month + day + hour + min + sec
  310. data["fix_fill_dept"] = miConfig.OrgName
  311. data["fix_fill_psn_id"] = curRoles.AdminUserId
  312. data["fix_fill_psn"] = curRoles.UserName
  313. data["fix_fill_date"] = fix_fill_date
  314. data["stmt_loc"] = "2"
  315. data["setl_mon"] = stmt_mon
  316. data["upld_btch"] = upld_btch
  317. client := &http.Client{}
  318. bytesData, _ := json.Marshal(data)
  319. var req *http.Request
  320. if miConfig.MdtrtareaAdmvs == "320921" {
  321. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  322. } else {
  323. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  324. }
  325. resp, _ := client.Do(req)
  326. defer resp.Body.Close()
  327. body, ioErr := ioutil.ReadAll(resp.Body)
  328. if ioErr != nil {
  329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  331. }
  332. var respJSON map[string]interface{}
  333. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  336. }
  337. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  338. fmt.Println(respJSON)
  339. result, _ := json.Marshal(respJSON)
  340. fmt.Println(result)
  341. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  342. utils.ErrorLog("解析失败:%v", err)
  343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  344. }
  345. if empty.Infcode != 0 {
  346. c.ServeSuccessJSON(map[string]interface{}{
  347. "failed_code": -10,
  348. "msg": empty.ErrMsg,
  349. })
  350. return
  351. } else {
  352. c.ServeSuccessJSON(map[string]interface{}{
  353. "msg": "上传成功",
  354. })
  355. return
  356. }
  357. }
  358. func (c *HisApiController) Get3263() {
  359. admin_user_id, _ := c.GetInt64("admin_user_id")
  360. startTime := c.GetString("start_time")
  361. //endTime, _ := c.GetString("end_time")
  362. times := strings.Split(startTime, "-")
  363. setl_mon := times[0] + times[1]
  364. upld_btch := 0
  365. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  366. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  367. var result3263 models.JSResult3263
  368. data := make(map[string]interface{})
  369. data["org_name"] = miConfig.OrgName
  370. data["doctor"] = curRoles.UserName
  371. data["doctor_name"] = curRoles.UserName
  372. data["fixmedins_code"] = miConfig.Code
  373. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  374. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  375. data["secret_key"] = miConfig.SecretKey
  376. data["url"] = miConfig.Url
  377. data["ak"] = miConfig.AccessKey
  378. data["cainfo"] = miConfig.Cainfo
  379. data["setl_mon"] = setl_mon
  380. data["stmt_loc"] = "2"
  381. data["upld_btch"] = upld_btch
  382. client := &http.Client{}
  383. bytesData, _ := json.Marshal(data)
  384. var req *http.Request
  385. if miConfig.MdtrtareaAdmvs == "320921" {
  386. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  387. } else {
  388. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  389. }
  390. resp, _ := client.Do(req)
  391. defer resp.Body.Close()
  392. body, ioErr := ioutil.ReadAll(resp.Body)
  393. if ioErr != nil {
  394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  396. }
  397. var respJSON map[string]interface{}
  398. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  401. }
  402. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  403. fmt.Println(respJSON)
  404. result, _ := json.Marshal(respJSON)
  405. fmt.Println(result)
  406. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  407. utils.ErrorLog("解析失败:%v", err)
  408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  409. }
  410. if result3263.Infcode != 0 {
  411. c.ServeSuccessJSON(map[string]interface{}{
  412. "failed_code": -10,
  413. "msg": result3263.ErrMsg,
  414. })
  415. return
  416. } else {
  417. c.ServeSuccessJSON(map[string]interface{}{
  418. "list": result3263.Output.Data,
  419. })
  420. return
  421. }
  422. }
  423. func (c *HisApiController) Get3264() {
  424. admin_user_id, _ := c.GetInt64("admin_user_id")
  425. startTime := c.GetString("start_time")
  426. //endTime, _ := c.GetString("end_time")
  427. times := strings.Split(startTime, "-")
  428. setl_mon := times[0] + times[1]
  429. upld_btch := 0
  430. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  431. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  432. //solidify_id := []
  433. var empty models.JSResultEmpty
  434. data := make(map[string]interface{})
  435. data["org_name"] = miConfig.OrgName
  436. data["doctor"] = curRoles.UserName
  437. data["doctor_name"] = curRoles.UserName
  438. data["fixmedins_code"] = miConfig.Code
  439. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  440. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  441. data["secret_key"] = miConfig.SecretKey
  442. data["url"] = miConfig.Url
  443. data["ak"] = miConfig.AccessKey
  444. data["cainfo"] = miConfig.Cainfo
  445. data["setl_mon"] = setl_mon
  446. data["stmt_loc"] = "2"
  447. data["upld_btch"] = upld_btch
  448. //data["solidify_id"] = solidify_id
  449. client := &http.Client{}
  450. bytesData, _ := json.Marshal(data)
  451. var req *http.Request
  452. if miConfig.MdtrtareaAdmvs == "320921" {
  453. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData))
  454. } else {
  455. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData))
  456. }
  457. resp, _ := client.Do(req)
  458. defer resp.Body.Close()
  459. body, ioErr := ioutil.ReadAll(resp.Body)
  460. if ioErr != nil {
  461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  463. }
  464. var respJSON map[string]interface{}
  465. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  468. }
  469. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  470. fmt.Println(respJSON)
  471. result, _ := json.Marshal(respJSON)
  472. fmt.Println(result)
  473. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  474. utils.ErrorLog("解析失败:%v", err)
  475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  476. }
  477. if result3264.Infcode != 0 {
  478. c.ServeSuccessJSON(map[string]interface{}{
  479. "failed_code": -10,
  480. "msg": empty.ErrMsg,
  481. })
  482. return
  483. } else {
  484. c.ServeSuccessJSON(map[string]interface{}{
  485. "msg": "",
  486. })
  487. return
  488. }
  489. }
  490. func (c *HisApiController) Get3265() {
  491. admin_user_id, _ := c.GetInt64("admin_user_id")
  492. startTime, _ := c.GetString("start_time")
  493. //endTime, _ := c.GetString("end_time")
  494. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  495. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  496. times := strings.Split(startTime, "-")
  497. stmt_mon := times[0] + times[1]
  498. var upld_btch string
  499. //var empty models.JSResultEmpty
  500. var result3265 models.JSResult3264
  501. data := make(map[string]interface{})
  502. data["org_name"] = miConfig.OrgName
  503. data["doctor"] = curRoles.UserName
  504. data["doctor_name"] = curRoles.UserName
  505. data["fixmedins_code"] = miConfig.Code
  506. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  507. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  508. data["secret_key"] = miConfig.SecretKey
  509. data["url"] = miConfig.Url
  510. data["ak"] = miConfig.AccessKey
  511. data["cainfo"] = miConfig.Cainfo
  512. data["stmt_mon"] = stmt_mon
  513. month := time.Unix(1557042972, 0).Format("1")
  514. year := time.Now().Format("2006")
  515. month = time.Now().Format("01")
  516. day := time.Now().Format("02")
  517. hour := time.Now().Format("15")
  518. min := time.Now().Format("04")
  519. sec := time.Now().Format("05")
  520. fix_fill_date := year + month + day + hour + min + sec
  521. data["fix_fill_dept"] = miConfig.OrgName
  522. data["fix_fill_psn_id"] = curRoles.AdminUserId
  523. data["fix_fill_psn"] = curRoles.UserName
  524. data["fix_fill_date"] = fix_fill_date
  525. data["stmt_loc"] = "2"
  526. data["upld_btch"] = upld_btch
  527. client := &http.Client{}
  528. bytesData, _ := json.Marshal(data)
  529. var req *http.Request
  530. if miConfig.MdtrtareaAdmvs == "320921" {
  531. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  532. } else {
  533. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  534. }
  535. resp, _ := client.Do(req)
  536. defer resp.Body.Close()
  537. body, ioErr := ioutil.ReadAll(resp.Body)
  538. if ioErr != nil {
  539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  541. }
  542. var respJSON map[string]interface{}
  543. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  544. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  546. }
  547. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  548. fmt.Println(respJSON)
  549. result, _ := json.Marshal(respJSON)
  550. fmt.Println(result)
  551. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  552. utils.ErrorLog("解析失败:%v", err)
  553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  554. }
  555. if result3265.Infcode != 0 {
  556. c.ServeSuccessJSON(map[string]interface{}{
  557. "failed_code": -10,
  558. "msg": result3265.ErrMsg,
  559. })
  560. return
  561. } else {
  562. c.ServeSuccessJSON(map[string]interface{}{
  563. "info": result3265.Output.Data,
  564. })
  565. return
  566. }
  567. }
  568. func (c *HisApiController) Get3266() {
  569. admin_user_id, _ := c.GetInt64("admin_user_id")
  570. startTime, _ := c.GetString("start_time")
  571. //endTime, _ := c.GetString("end_time")
  572. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  573. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  574. times := strings.Split(startTime, "-")
  575. stmt_mon := times[0] + times[1]
  576. var upld_btch string
  577. //var empty models.JSResultEmpty
  578. var result3265 models.JSResult3264
  579. data := make(map[string]interface{})
  580. data["org_name"] = miConfig.OrgName
  581. data["doctor"] = curRoles.UserName
  582. data["doctor_name"] = curRoles.UserName
  583. data["fixmedins_code"] = miConfig.Code
  584. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  585. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  586. data["secret_key"] = miConfig.SecretKey
  587. data["url"] = miConfig.Url
  588. data["ak"] = miConfig.AccessKey
  589. data["cainfo"] = miConfig.Cainfo
  590. data["setl_mon"] = stmt_mon
  591. month := time.Unix(1557042972, 0).Format("1")
  592. year := time.Now().Format("2006")
  593. month = time.Now().Format("01")
  594. day := time.Now().Format("02")
  595. hour := time.Now().Format("15")
  596. min := time.Now().Format("04")
  597. sec := time.Now().Format("05")
  598. fix_fill_date := year + month + day + hour + min + sec
  599. data["fix_fill_dept"] = miConfig.OrgName
  600. data["fix_fill_psn_id"] = curRoles.AdminUserId
  601. data["fix_fill_psn"] = curRoles.UserName
  602. data["fix_fill_date"] = fix_fill_date
  603. data["stmt_loc"] = "2"
  604. data["upld_btch"] = upld_btch
  605. client := &http.Client{}
  606. bytesData, _ := json.Marshal(data)
  607. var req *http.Request
  608. if miConfig.MdtrtareaAdmvs == "320921" {
  609. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  610. } else {
  611. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  612. }
  613. resp, _ := client.Do(req)
  614. defer resp.Body.Close()
  615. body, ioErr := ioutil.ReadAll(resp.Body)
  616. if ioErr != nil {
  617. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  619. }
  620. var respJSON map[string]interface{}
  621. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  622. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  624. }
  625. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  626. fmt.Println(respJSON)
  627. result, _ := json.Marshal(respJSON)
  628. fmt.Println(result)
  629. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  630. utils.ErrorLog("解析失败:%v", err)
  631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  632. }
  633. if result3265.Infcode != 0 {
  634. c.ServeSuccessJSON(map[string]interface{}{
  635. "failed_code": -10,
  636. "msg": result3265.ErrMsg,
  637. })
  638. return
  639. } else {
  640. c.ServeSuccessJSON(map[string]interface{}{
  641. "info": result3265.Output.Data,
  642. })
  643. return
  644. }
  645. }
  646. func (c *HisApiController) Get3267() {
  647. admin_user_id, _ := c.GetInt64("admin_user_id")
  648. startTime, _ := c.GetString("start_time")
  649. //endTime, _ := c.GetString("end_time")
  650. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  651. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  652. times := strings.Split(startTime, "-")
  653. stmt_mon := times[0] + times[1]
  654. var upld_btch string
  655. //var empty models.JSResultEmpty
  656. var result3265 models.JSResult3264
  657. data := make(map[string]interface{})
  658. data["org_name"] = miConfig.OrgName
  659. data["doctor"] = curRoles.UserName
  660. data["doctor_name"] = curRoles.UserName
  661. data["fixmedins_code"] = miConfig.Code
  662. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  663. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  664. data["secret_key"] = miConfig.SecretKey
  665. data["url"] = miConfig.Url
  666. data["ak"] = miConfig.AccessKey
  667. data["cainfo"] = miConfig.Cainfo
  668. data["setl_mon"] = stmt_mon
  669. data["stmt_loc"] = "2"
  670. data["upld_btch"] = upld_btch
  671. client := &http.Client{}
  672. bytesData, _ := json.Marshal(data)
  673. var req *http.Request
  674. if miConfig.MdtrtareaAdmvs == "320921" {
  675. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  676. } else {
  677. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  678. }
  679. resp, _ := client.Do(req)
  680. defer resp.Body.Close()
  681. body, ioErr := ioutil.ReadAll(resp.Body)
  682. if ioErr != nil {
  683. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  685. }
  686. var respJSON map[string]interface{}
  687. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  690. }
  691. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  692. fmt.Println(respJSON)
  693. result, _ := json.Marshal(respJSON)
  694. fmt.Println(result)
  695. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  696. utils.ErrorLog("解析失败:%v", err)
  697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  698. }
  699. if result3265.Infcode != 0 {
  700. c.ServeSuccessJSON(map[string]interface{}{
  701. "failed_code": -10,
  702. "msg": result3265.ErrMsg,
  703. })
  704. return
  705. } else {
  706. c.ServeSuccessJSON(map[string]interface{}{
  707. "info": result3265.Output.Data,
  708. })
  709. return
  710. }
  711. }
  712. func (c *HisApiController) Get3268() {
  713. admin_user_id, _ := c.GetInt64("admin_user_id")
  714. startTime, _ := c.GetString("start_time")
  715. //endTime, _ := c.GetString("end_time")
  716. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  717. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  718. timeLayout := "2006-01-02"
  719. loc, _ := time.LoadLocation("Local")
  720. var theStartTIme int64
  721. if len(startTime) > 0 {
  722. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  723. if err != nil {
  724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  725. return
  726. }
  727. theStartTIme = theTime.Unix()
  728. }
  729. //var theEndtTIme int64
  730. //if len(endTime) > 0 {
  731. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  732. // if err != nil {
  733. // utils.ErrorLog(err.Error())
  734. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  735. // return
  736. // }
  737. // theEndtTIme = theTime.Unix()
  738. //}
  739. datas, _ := service.GetOrderByTimeTen(theStartTIme, theStartTIme, c.GetAdminUserInfo().CurrentOrgId)
  740. var funs []models.FundDetail
  741. for _, item := range datas {
  742. fun, _ := service.GetOrderDetailByTimeTen(theStartTIme, theStartTIme, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  743. funs = append(funs, fun...)
  744. }
  745. var funInfos []models.Fund
  746. for _, item := range funs {
  747. var rf []models.FundInfo
  748. json.Unmarshal([]byte(item.SetlDetail), &rf)
  749. for _, subitem := range rf {
  750. var fund models.Fund
  751. fund.FundCode = subitem.FundPayType
  752. fund.FundName = subitem.FundPayTypeName
  753. fund.FundAmt = subitem.FundPayAmt
  754. fund.FundKey = item.FundKey
  755. fund.InsuAdmdvs = "555555"
  756. fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  757. funInfos = append(funInfos, fund)
  758. }
  759. }
  760. var upld_btch string
  761. var empty models.JSResultEmpty
  762. data := make(map[string]interface{})
  763. data["org_name"] = miConfig.OrgName
  764. data["doctor"] = curRoles.UserName
  765. data["doctor_name"] = curRoles.UserName
  766. data["fixmedins_code"] = miConfig.Code
  767. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  768. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  769. data["secret_key"] = miConfig.SecretKey
  770. data["url"] = miConfig.Url
  771. data["ak"] = miConfig.AccessKey
  772. data["cainfo"] = miConfig.Cainfo
  773. data["data"] = datas
  774. data["fund"] = funInfos
  775. month := time.Unix(1557042972, 0).Format("1")
  776. year := time.Now().Format("2006")
  777. month = time.Now().Format("01")
  778. day := time.Now().Format("02")
  779. hour := time.Now().Format("15")
  780. min := time.Now().Format("04")
  781. sec := time.Now().Format("05")
  782. fix_fill_date := year + month + day + hour + min + sec
  783. data["fix_fill_dept"] = miConfig.OrgName
  784. data["fix_fill_psn_id"] = curRoles.AdminUserId
  785. data["fix_fill_psn"] = curRoles.UserName
  786. data["fix_fill_date"] = fix_fill_date
  787. data["stmt_loc"] = "2"
  788. data["upld_btch"] = upld_btch
  789. client := &http.Client{}
  790. bytesData, _ := json.Marshal(data)
  791. var req *http.Request
  792. if miConfig.MdtrtareaAdmvs == "320921" {
  793. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  794. } else {
  795. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  796. }
  797. resp, _ := client.Do(req)
  798. defer resp.Body.Close()
  799. body, ioErr := ioutil.ReadAll(resp.Body)
  800. if ioErr != nil {
  801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  803. }
  804. var respJSON map[string]interface{}
  805. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  808. }
  809. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  810. fmt.Println(respJSON)
  811. result, _ := json.Marshal(respJSON)
  812. fmt.Println(result)
  813. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  814. utils.ErrorLog("解析失败:%v", err)
  815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  816. }
  817. if empty.Infcode != 0 {
  818. c.ServeSuccessJSON(map[string]interface{}{
  819. "failed_code": -10,
  820. "msg": empty.ErrMsg,
  821. })
  822. return
  823. } else {
  824. c.ServeSuccessJSON(map[string]interface{}{
  825. "msg": "上传成功",
  826. })
  827. return
  828. }
  829. }
  830. func (c *HisApiController) Get3269() {
  831. admin_user_id, _ := c.GetInt64("admin_user_id")
  832. startTime := c.GetString("start_time")
  833. //endTime, _ := c.GetString("end_time")
  834. times := strings.Split(startTime, "-")
  835. setl_mon := times[0] + times[1]
  836. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  837. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  838. var result3263 models.JSResult3263
  839. data := make(map[string]interface{})
  840. data["org_name"] = miConfig.OrgName
  841. data["doctor"] = curRoles.UserName
  842. data["doctor_name"] = curRoles.UserName
  843. data["fixmedins_code"] = miConfig.Code
  844. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  845. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  846. data["secret_key"] = miConfig.SecretKey
  847. data["url"] = miConfig.Url
  848. data["ak"] = miConfig.AccessKey
  849. data["cainfo"] = miConfig.Cainfo
  850. data["setl_mon"] = setl_mon
  851. data["stmt_loc"] = "2"
  852. client := &http.Client{}
  853. bytesData, _ := json.Marshal(data)
  854. var req *http.Request
  855. if miConfig.MdtrtareaAdmvs == "320921" {
  856. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  857. } else {
  858. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  859. }
  860. resp, _ := client.Do(req)
  861. defer resp.Body.Close()
  862. body, ioErr := ioutil.ReadAll(resp.Body)
  863. if ioErr != nil {
  864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  866. }
  867. var respJSON map[string]interface{}
  868. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  871. }
  872. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  873. fmt.Println(respJSON)
  874. result, _ := json.Marshal(respJSON)
  875. fmt.Println(result)
  876. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  877. utils.ErrorLog("解析失败:%v", err)
  878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  879. }
  880. if result3263.Infcode != 0 {
  881. c.ServeSuccessJSON(map[string]interface{}{
  882. "failed_code": -10,
  883. "msg": result3263.ErrMsg,
  884. })
  885. return
  886. } else {
  887. c.ServeSuccessJSON(map[string]interface{}{
  888. "msg": "上传成功",
  889. })
  890. return
  891. }
  892. }
  893. func (c *HisApiController) Get3270() {
  894. admin_user_id, _ := c.GetInt64("admin_user_id")
  895. startTime := c.GetString("start_time")
  896. //endTime, _ := c.GetString("end_time")
  897. times := strings.Split(startTime, "-")
  898. setl_mon := times[0] + times[1]
  899. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  900. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  901. var result3264 models.JSResult3264
  902. data := make(map[string]interface{})
  903. data["org_name"] = miConfig.OrgName
  904. data["doctor"] = curRoles.UserName
  905. data["doctor_name"] = curRoles.UserName
  906. data["fixmedins_code"] = miConfig.Code
  907. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  908. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  909. data["secret_key"] = miConfig.SecretKey
  910. data["url"] = miConfig.Url
  911. data["ak"] = miConfig.AccessKey
  912. data["cainfo"] = miConfig.Cainfo
  913. data["setl_mon"] = setl_mon
  914. data["stmt_loc"] = "2"
  915. client := &http.Client{}
  916. bytesData, _ := json.Marshal(data)
  917. var req *http.Request
  918. if miConfig.MdtrtareaAdmvs == "320921" {
  919. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  920. } else {
  921. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  922. }
  923. resp, _ := client.Do(req)
  924. defer resp.Body.Close()
  925. body, ioErr := ioutil.ReadAll(resp.Body)
  926. if ioErr != nil {
  927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  929. }
  930. var respJSON map[string]interface{}
  931. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  934. }
  935. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  936. fmt.Println(respJSON)
  937. result, _ := json.Marshal(respJSON)
  938. fmt.Println(result)
  939. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  940. utils.ErrorLog("解析失败:%v", err)
  941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  942. }
  943. if result3264.Infcode != 0 {
  944. c.ServeSuccessJSON(map[string]interface{}{
  945. "failed_code": -10,
  946. "msg": result3264.ErrMsg,
  947. })
  948. return
  949. } else {
  950. c.ServeSuccessJSON(map[string]interface{}{
  951. "info": result3264.Output.Data,
  952. })
  953. return
  954. }
  955. }
  956. func (c *HisApiController) Get3271() {
  957. admin_user_id, _ := c.GetInt64("admin_user_id")
  958. startTime, _ := c.GetString("start_time")
  959. //endTime, _ := c.GetString("end_time")
  960. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  961. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  962. times := strings.Split(startTime, "-")
  963. stmt_mon := times[0] + times[1]
  964. //var empty models.JSResultEmpty
  965. var result3265 models.JSResult3264
  966. data := make(map[string]interface{})
  967. data["org_name"] = miConfig.OrgName
  968. data["doctor"] = curRoles.UserName
  969. data["doctor_name"] = curRoles.UserName
  970. data["fixmedins_code"] = miConfig.Code
  971. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  972. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  973. data["secret_key"] = miConfig.SecretKey
  974. data["url"] = miConfig.Url
  975. data["ak"] = miConfig.AccessKey
  976. data["cainfo"] = miConfig.Cainfo
  977. data["stmt_mon"] = stmt_mon
  978. month := time.Unix(1557042972, 0).Format("1")
  979. year := time.Now().Format("2006")
  980. month = time.Now().Format("01")
  981. day := time.Now().Format("02")
  982. hour := time.Now().Format("15")
  983. min := time.Now().Format("04")
  984. sec := time.Now().Format("05")
  985. fix_fill_date := year + month + day + hour + min + sec
  986. data["fix_fill_dept"] = miConfig.OrgName
  987. data["fix_fill_psn_id"] = curRoles.AdminUserId
  988. data["fix_fill_psn"] = curRoles.UserName
  989. data["fix_fill_date"] = fix_fill_date
  990. data["stmt_loc"] = "2"
  991. client := &http.Client{}
  992. bytesData, _ := json.Marshal(data)
  993. var req *http.Request
  994. if miConfig.MdtrtareaAdmvs == "320921" {
  995. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  996. } else {
  997. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  998. }
  999. resp, _ := client.Do(req)
  1000. defer resp.Body.Close()
  1001. body, ioErr := ioutil.ReadAll(resp.Body)
  1002. if ioErr != nil {
  1003. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1005. }
  1006. var respJSON map[string]interface{}
  1007. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1010. }
  1011. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1012. fmt.Println(respJSON)
  1013. result, _ := json.Marshal(respJSON)
  1014. fmt.Println(result)
  1015. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1016. utils.ErrorLog("解析失败:%v", err)
  1017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1018. }
  1019. if result3265.Infcode != 0 {
  1020. c.ServeSuccessJSON(map[string]interface{}{
  1021. "failed_code": -10,
  1022. "msg": result3265.ErrMsg,
  1023. })
  1024. return
  1025. } else {
  1026. c.ServeSuccessJSON(map[string]interface{}{
  1027. "info": result3265.Output.Data,
  1028. })
  1029. return
  1030. }
  1031. }
  1032. func (c *HisApiController) Get3272() {
  1033. admin_user_id, _ := c.GetInt64("admin_user_id")
  1034. startTime, _ := c.GetString("start_time")
  1035. //endTime, _ := c.GetString("end_time")
  1036. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1037. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1038. times := strings.Split(startTime, "-")
  1039. setl_mon := times[0] + times[1]
  1040. var upld_btch string
  1041. //var empty models.JSResultEmpty
  1042. var result3265 models.JSResult3264
  1043. data := make(map[string]interface{})
  1044. data["org_name"] = miConfig.OrgName
  1045. data["doctor"] = curRoles.UserName
  1046. data["doctor_name"] = curRoles.UserName
  1047. data["fixmedins_code"] = miConfig.Code
  1048. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1049. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1050. data["secret_key"] = miConfig.SecretKey
  1051. data["url"] = miConfig.Url
  1052. data["ak"] = miConfig.AccessKey
  1053. data["cainfo"] = miConfig.Cainfo
  1054. data["setl_mon"] = setl_mon
  1055. month := time.Unix(1557042972, 0).Format("1")
  1056. year := time.Now().Format("2006")
  1057. month = time.Now().Format("01")
  1058. day := time.Now().Format("02")
  1059. hour := time.Now().Format("15")
  1060. min := time.Now().Format("04")
  1061. sec := time.Now().Format("05")
  1062. fix_fill_date := year + month + day + hour + min + sec
  1063. data["fix_fill_dept"] = miConfig.OrgName
  1064. data["fix_fill_psn_id"] = curRoles.AdminUserId
  1065. data["fix_fill_psn"] = curRoles.UserName
  1066. data["fix_fill_date"] = fix_fill_date
  1067. data["stmt_loc"] = "2"
  1068. data["upld_btch"] = upld_btch
  1069. client := &http.Client{}
  1070. bytesData, _ := json.Marshal(data)
  1071. var req *http.Request
  1072. if miConfig.MdtrtareaAdmvs == "320921" {
  1073. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  1074. } else {
  1075. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  1076. }
  1077. resp, _ := client.Do(req)
  1078. defer resp.Body.Close()
  1079. body, ioErr := ioutil.ReadAll(resp.Body)
  1080. if ioErr != nil {
  1081. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1083. }
  1084. var respJSON map[string]interface{}
  1085. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1088. }
  1089. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1090. fmt.Println(respJSON)
  1091. result, _ := json.Marshal(respJSON)
  1092. fmt.Println(result)
  1093. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1094. utils.ErrorLog("解析失败:%v", err)
  1095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1096. }
  1097. if result3265.Infcode != 0 {
  1098. c.ServeSuccessJSON(map[string]interface{}{
  1099. "failed_code": -10,
  1100. "msg": result3265.ErrMsg,
  1101. })
  1102. return
  1103. } else {
  1104. c.ServeSuccessJSON(map[string]interface{}{
  1105. "info": result3265.Output.Data,
  1106. })
  1107. return
  1108. }
  1109. }
  1110. func (c *HisApiController) Get3273() {
  1111. admin_user_id, _ := c.GetInt64("admin_user_id")
  1112. startTime, _ := c.GetString("start_time")
  1113. //endTime, _ := c.GetString("end_time")
  1114. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1115. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1116. times := strings.Split(startTime, "-")
  1117. stmt_mon := times[0] + times[1]
  1118. var result3265 models.JSResult3264
  1119. data := make(map[string]interface{})
  1120. data["org_name"] = miConfig.OrgName
  1121. data["doctor"] = curRoles.UserName
  1122. data["doctor_name"] = curRoles.UserName
  1123. data["fixmedins_code"] = miConfig.Code
  1124. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1125. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1126. data["secret_key"] = miConfig.SecretKey
  1127. data["url"] = miConfig.Url
  1128. data["ak"] = miConfig.AccessKey
  1129. data["cainfo"] = miConfig.Cainfo
  1130. data["setl_mon"] = stmt_mon
  1131. data["stmt_loc"] = "2"
  1132. client := &http.Client{}
  1133. bytesData, _ := json.Marshal(data)
  1134. var req *http.Request
  1135. if miConfig.MdtrtareaAdmvs == "320921" {
  1136. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  1137. } else {
  1138. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  1139. }
  1140. resp, _ := client.Do(req)
  1141. defer resp.Body.Close()
  1142. body, ioErr := ioutil.ReadAll(resp.Body)
  1143. if ioErr != nil {
  1144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1146. }
  1147. var respJSON map[string]interface{}
  1148. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1151. }
  1152. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1153. fmt.Println(respJSON)
  1154. result, _ := json.Marshal(respJSON)
  1155. fmt.Println(result)
  1156. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1157. utils.ErrorLog("解析失败:%v", err)
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1159. }
  1160. if result3265.Infcode != 0 {
  1161. c.ServeSuccessJSON(map[string]interface{}{
  1162. "failed_code": -10,
  1163. "msg": result3265.ErrMsg,
  1164. })
  1165. return
  1166. } else {
  1167. c.ServeSuccessJSON(map[string]interface{}{
  1168. "info": result3265.Output.Data,
  1169. })
  1170. return
  1171. }
  1172. }
  1173. func (c *HisApiController) Get3274() {
  1174. if miConfig.MdtrtareaAdmvs == "320921" {
  1175. api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1176. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1177. "&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
  1178. } else {
  1179. api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1180. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1181. "&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
  1182. }
  1183. }
  1184. func (c *HisApiController) Get3275() {
  1185. if miConfig.MdtrtareaAdmvs == "320921" {
  1186. api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1187. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1188. "&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
  1189. } else {
  1190. api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1191. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1192. "&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
  1193. }
  1194. }
  1195. func (c *HisApiController) Get3276() {
  1196. admin_user_id, _ := c.GetInt64("admin_user_id")
  1197. month := c.GetString("month")
  1198. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1199. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1200. var api string
  1201. var res Result5301
  1202. if miConfig.MdtrtareaAdmvs == "320921" {
  1203. api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1204. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1205. } else {
  1206. api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1207. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1208. }
  1209. resp, requestErr := http.Get(api)
  1210. if requestErr != nil {
  1211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1212. return
  1213. }
  1214. body, ioErr := ioutil.ReadAll(resp.Body)
  1215. if ioErr != nil {
  1216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1218. return
  1219. }
  1220. var respJSON map[string]interface{}
  1221. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1224. return
  1225. }
  1226. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1227. result, _ := json.Marshal(respJSON)
  1228. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1229. utils.ErrorLog("解析失败:%v", err)
  1230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1231. return
  1232. }
  1233. }
  1234. func (c *HisApiController) Get3277() {
  1235. admin_user_id, _ := c.GetInt64("admin_user_id")
  1236. month := c.GetString("month")
  1237. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1238. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1239. var api string
  1240. var res Result5301
  1241. if miConfig.MdtrtareaAdmvs == "320921" {
  1242. api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1243. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1244. } else {
  1245. api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1246. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1247. }
  1248. resp, requestErr := http.Get(api)
  1249. if requestErr != nil {
  1250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1251. return
  1252. }
  1253. body, ioErr := ioutil.ReadAll(resp.Body)
  1254. if ioErr != nil {
  1255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1257. return
  1258. }
  1259. var respJSON map[string]interface{}
  1260. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1263. return
  1264. }
  1265. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1266. result, _ := json.Marshal(respJSON)
  1267. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1268. utils.ErrorLog("解析失败:%v", err)
  1269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1270. return
  1271. }
  1272. }
  1273. func (c *HisApiController) GetCFYLJG001() {
  1274. admin_user_id, _ := c.GetInt64("admin_user_id")
  1275. patient_id, _ := c.GetInt64("patient_id")
  1276. his_patient_id, _ := c.GetInt64("his_patient_id")
  1277. record_time := c.GetString("record_time")
  1278. admin_user_id = 3626
  1279. patient_id = 19424
  1280. his_patient_id = 238932
  1281. record_time = "2023-07-03"
  1282. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1283. psn, _ := service.GetPsnByPatientId(patient_id)
  1284. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  1285. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  1286. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1287. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1288. var cFYLJG001 models.CFYLJG001
  1289. timeLayout := "2006-01-02"
  1290. loc, _ := time.LoadLocation("Local")
  1291. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1292. if err != nil {
  1293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1294. return
  1295. }
  1296. recordDateTime := theTime.Unix()
  1297. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  1298. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  1299. for _, item := range prescriptions {
  1300. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  1301. if his.IdCardType == 1 {
  1302. bas := strings.Split(psn.CardInfo, "|")
  1303. basNumber := bas[1]
  1304. fmt.Println(basNumber)
  1305. card_sn := bas[3]
  1306. card_no := bas[2]
  1307. cFYLJG001.MdtrtCertType = "03"
  1308. cFYLJG001.CardSn = card_sn
  1309. cFYLJG001.MdtrtCertNo = card_no
  1310. cFYLJG001.EcToken = ""
  1311. cFYLJG001.AuthNo = ""
  1312. } else if his.IdCardType == 2 {
  1313. cFYLJG001.MdtrtCertType = "02"
  1314. cFYLJG001.CardSn = ""
  1315. cFYLJG001.MdtrtCertNo = his.IdCardNo
  1316. cFYLJG001.EcToken = ""
  1317. cFYLJG001.AuthNo = ""
  1318. } else if his.IdCardType == 4 {
  1319. cFYLJG001.MdtrtCertType = "01"
  1320. cFYLJG001.CardSn = ""
  1321. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  1322. cFYLJG001.EcToken = psn.VerifyNumber
  1323. cFYLJG001.AuthNo = ""
  1324. }
  1325. cFYLJG001.BizTypeCode = "01"
  1326. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  1327. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  1328. cFYLJG001.RxTypeCode = "1"
  1329. tempTime := time.Unix(item.PreTime, 0)
  1330. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1331. cFYLJG001.PrscTime = timeFormatOne
  1332. var count float64
  1333. if item.Type == 1 {
  1334. for _, sumItem := range item.HisDoctorAdviceInfo {
  1335. count = count + sumItem.PrescribingNumber
  1336. }
  1337. }
  1338. cFYLJG001.RxDrugCnt = count
  1339. cFYLJG001.ValiDays = "5"
  1340. ts := time.Unix(item.PreTime, 0)
  1341. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  1342. tempTime3 := time.Unix(record_time2, 0)
  1343. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  1344. cFYLJG001.ValiEndTime = timeFormat3
  1345. cFYLJG001.RxCotnFlag = "0"
  1346. for _, subItem := range item.HisDoctorAdviceInfo {
  1347. var drug models.RxDrug
  1348. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  1349. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  1350. drug.RxItemTypeCode = "11"
  1351. drug.DrugDosform = "乳膏剂" //TODO
  1352. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  1353. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  1354. }
  1355. drug.MedcWayDscr = subItem.DeliveryWay
  1356. tempTime2 := time.Unix(subItem.StartTime, 0)
  1357. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  1358. drug.MedcBegntime = timeFormatTwo
  1359. if subItem.Day > 0 {
  1360. ts := time.Unix(subItem.StartTime, 0)
  1361. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  1362. tempTime4 := time.Unix(record_time, 0)
  1363. timeFormat5 := tempTime4.Format("2006-01-02") + " 23:59:00"
  1364. drug.MedcEndtime = timeFormat5
  1365. } else {
  1366. tempTime2 := time.Unix(subItem.StartTime, 0)
  1367. timeFormatTwo := tempTime2.Format("2006-01-02") + " 23:59:00"
  1368. drug.MedcEndtime = timeFormatTwo
  1369. }
  1370. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  1371. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  1372. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  1373. drug.DrugCnt = subItem.PrescribingNumber
  1374. drug.DrugDosunt = subItem.PrescribingNumberUnit
  1375. drug.DrugGenname = subItem.AdviceName
  1376. drug.MedcWayCodg = subItem.DeliveryWay
  1377. //drug.DrugTotlcnt = subItem.PrescribingNumber
  1378. drug.SinDoscnt = subItem.SingleDose
  1379. drug.SinDosunt = subItem.SingleDoseUnit
  1380. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  1381. drug.UsedFrquName = subItem.ExecutionFrequency
  1382. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1383. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  1384. drug.HospApprFlag = "1"
  1385. cFYLJG001.List = append(cFYLJG001.List, drug)
  1386. }
  1387. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  1388. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  1389. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  1390. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  1391. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  1392. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  1393. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  1394. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  1395. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  1396. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  1397. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  1398. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  1399. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  1400. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  1401. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  1402. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  1403. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  1404. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  1405. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  1406. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  1407. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  1408. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  1409. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  1410. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  1411. tempTime2 := time.Now().Unix()
  1412. tempTime6 := time.Unix(tempTime2, 0)
  1413. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  1414. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  1415. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  1416. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  1417. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  1418. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  1419. memo := make(map[string]interface{})
  1420. memo["insutype"] = his.Insutype
  1421. bytesData, _ := json.Marshal(memo)
  1422. cFYLJG001.Mdtrtinfo.Extras = string(bytesData)
  1423. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  1424. var config []*models.HisXtDiagnoseConfig
  1425. for _, item := range diagnosis_ids {
  1426. id, _ := strconv.ParseInt(item, 10, 64)
  1427. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1428. config = append(config, &diagnosisConfig)
  1429. }
  1430. for index, subitem := range config {
  1431. if index == 0 {
  1432. var dia models.DiseInfo
  1433. dia.DiagType = "1"
  1434. dia.MaindiagFlag = "1"
  1435. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  1436. dia.DiagCode = subitem.CountryCode
  1437. dia.DiagName = subitem.ClassName
  1438. dia.DiagDept = "肾内科"
  1439. dia.DiagDrNo = doctor.DoctorNumber
  1440. dia.DiagDrName = doctor.UserName
  1441. tempTime3 := time.Unix(item.PreTime, 0)
  1442. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  1443. dia.DiagTime = timeFormatTwo
  1444. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  1445. } else {
  1446. var dia models.DiseInfo
  1447. dia.DiagType = "1"
  1448. dia.MaindiagFlag = "0"
  1449. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  1450. dia.DiagCode = subitem.CountryCode
  1451. dia.DiagName = subitem.ClassName
  1452. dia.DiagDept = "肾内科"
  1453. dia.DiagDrNo = doctor.DoctorNumber
  1454. dia.DiagDrName = doctor.UserName
  1455. tempTime3 := time.Unix(item.PreTime, 0)
  1456. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  1457. dia.DiagTime = timeFormatTwo
  1458. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  1459. }
  1460. }
  1461. fmt.Println(cFYLJG001)
  1462. service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001)
  1463. }
  1464. }
  1465. func (c *HisApiController) GetCFYLJG002() {
  1466. admin_user_id, _ := c.GetInt64("admin_user_id")
  1467. id, _ := c.GetInt64("id")
  1468. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1469. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1470. flow, _ := service.Getflow(id)
  1471. his, _ := service.GetHisPatientByNumber(flow.MID)
  1472. inputData := make(map[string]interface{})
  1473. inputData["rxtracecode"] = flow.RxTraceCode
  1474. inputData["hirxno"] = flow.HiRxno
  1475. inputData["mdtrtid"] = flow.MID
  1476. inputData["patnname"] = his.PsnName
  1477. inputData["psncerttype"] = his.PsnCertType
  1478. inputData["certno"] = his.Certno
  1479. inputData["fixmedinsname"] = miConfig.OrgName
  1480. inputData["fixmedinscode"] = miConfig.Code
  1481. inputData["drcode"] = ""
  1482. inputData["prscdrname"] = ""
  1483. inputData["phardeptname"] = ""
  1484. inputData["phardeptcode"] = ""
  1485. inputData["pharprofttlcodg"] = ""
  1486. inputData["pharprofttlname"] = ""
  1487. inputData["pharcode"] = ""
  1488. inputData["rxfrquname"] = ""
  1489. inputData["pharcerttype"] = ""
  1490. inputData["pharcertno"] = ""
  1491. inputData["pharname"] = ""
  1492. inputData["pharpraccertno"] = ""
  1493. inputData["pharchktime"] = ""
  1494. bytesData, _ := json.Marshal(inputData)
  1495. fmt.Println(bytesData)
  1496. //// 使用 SM3 计算 JSON 数据的哈希值
  1497. //hash := sm3.New()
  1498. //hash.Write(bytesData)
  1499. //hashValue := hash.Sum(nil)
  1500. //
  1501. //// 加载 SM2 私钥
  1502. //privateKeyBytes, err := ioutil.ReadFile("path/to/private_key.pem")
  1503. //if err != nil {
  1504. // fmt.Println("Failed to read private key file:", err)
  1505. // return
  1506. //}
  1507. //privateKey, err := sm2.ParsePKCS8PrivateKey(privateKeyBytes)
  1508. //if err != nil {
  1509. // fmt.Println("Failed to parse private key:", err)
  1510. // return
  1511. //}
  1512. //
  1513. //// 使用私钥对哈希值进行签名
  1514. //r, s, err := sm2.Sign(rand.Reader, privateKey.(*sm2.PrivateKey), hashValue, nil)
  1515. //if err != nil {
  1516. // fmt.Println("Failed to sign data:", err)
  1517. // return
  1518. //}
  1519. //signature, err := syntax.EncodeSM2Signature(r, s)
  1520. //if err != nil {
  1521. // fmt.Println("Failed to encode signature:", err)
  1522. // return
  1523. //}
  1524. //
  1525. //// 构建 CMS/PKCS#7 Detached 数据结构
  1526. //// 这里只包含签名值和原始数据
  1527. //signedData := &pkix.ContentInfo{
  1528. // ContentType: pkix.SignedDataOID,
  1529. // Content: &pkix.SignedData{
  1530. // Version: 3,
  1531. // DigestAlgorithms: []pkix.AlgorithmIdentifier{{Algorithm: sm3.OID}},
  1532. // EncapContentInfo: pkix.EncapContentInfo{
  1533. // EContentType: pkix.DataOID,
  1534. // EContent: jsonBytes,
  1535. // },
  1536. // Certificates: []pkix.Certificate{},
  1537. // CRLs: []pkix.CertificateList{},
  1538. // SignerInfos: []pkix.SignerInfo{},
  1539. // DigestEncryptionAlgorithm: pkix.AlgorithmIdentifier{
  1540. // Algorithm: sm2.SignAlgorithmSM2WithSM3,
  1541. // },
  1542. // EncryptedDigest: signature,
  1543. // },
  1544. //}
  1545. //
  1546. //// 使用 DER 编码进行序列化
  1547. //derBytes, err := syntax.Marshal(signedData)
  1548. //if err != nil {
  1549. // fmt.Println("Failed to marshal CMS/PKCS#7 data:", err)
  1550. // return
  1551. //}
  1552. service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "", "", "")
  1553. }
  1554. func (c *HisApiController) GetCFYLJG003() {
  1555. admin_user_id, _ := c.GetInt64("admin_user_id")
  1556. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1557. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1558. var cFYLJG003 models.CFYLJG003
  1559. service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  1560. }
  1561. func (c *HisApiController) GetCFYLJG004() {
  1562. admin_user_id, _ := c.GetInt64("admin_user_id")
  1563. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1564. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1565. var cFYLJG004 models.CFYLJG004
  1566. service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  1567. }
  1568. func (c *HisApiController) GetCFYLJG005() {
  1569. admin_user_id, _ := c.GetInt64("admin_user_id")
  1570. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1571. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1572. var cFYLJG005 models.CFYLJG005
  1573. service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  1574. }
  1575. func (c *HisApiController) GetCFYLJG006() {
  1576. admin_user_id, _ := c.GetInt64("admin_user_id")
  1577. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1578. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1579. var cFYLJG006 models.CFYLJG006
  1580. service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  1581. }
  1582. func (c *HisApiController) GetCFYLJG007() {
  1583. admin_user_id, _ := c.GetInt64("admin_user_id")
  1584. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1585. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1586. var cFYLJG007 models.CFYLJG007
  1587. service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  1588. }
  1589. func (c *HisApiController) GetBL4201A() {
  1590. order_id, _ := c.GetInt64("order_id")
  1591. admin_user_id, _ := c.GetInt64("admin_user_id")
  1592. order, _ := service.GetHisOrderByIDTwo(order_id)
  1593. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1594. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  1595. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  1596. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1597. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1598. department, _ := service.GetDepartMentDetail(his.Departments)
  1599. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  1600. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  1601. if order.ID == 0 {
  1602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1603. return
  1604. }
  1605. var struct4201A models.Struct4201A
  1606. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  1607. for _, items := range order_info {
  1608. memo := make(map[string]interface{})
  1609. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1610. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1611. fsiOPFLD.MedType = "14"
  1612. fsiOPFLD.BkkpSn = items.FeedetlSn
  1613. fsiOPFLD.FixmedinsCode = miConfig.Code
  1614. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1615. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1616. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1617. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1618. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1619. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1620. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1621. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1622. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1623. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1624. fsiOPFLD.BilgDeptName = department.Name
  1625. fsiOPFLD.BilgDeptCodg = department.Number
  1626. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1627. fsiOPFLD.BilgDrName = doctor.UserName
  1628. fsiOPFLD.MedChrgitmType = "09"
  1629. memo["hosp_appr_flag"] = "1"
  1630. memo["invoice_no"] = order.MdtrtId
  1631. memo["memo"] = "自费"
  1632. bytesData, _ := json.Marshal(memo)
  1633. fsiOPFLD.Memo = string(bytesData)
  1634. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1635. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1636. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1637. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1638. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1639. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1640. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1641. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1642. fsiOPFLD.BilgDeptName = department.Name
  1643. fsiOPFLD.BilgDeptCodg = department.Number
  1644. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1645. fsiOPFLD.BilgDrName = doctor.UserName
  1646. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1647. case 0:
  1648. break
  1649. case 1:
  1650. fsiOPFLD.MedChrgitmType = "14"
  1651. break
  1652. case 2:
  1653. fsiOPFLD.MedChrgitmType = "05"
  1654. break
  1655. case 3:
  1656. fsiOPFLD.MedChrgitmType = "03"
  1657. break
  1658. case 4:
  1659. fsiOPFLD.MedChrgitmType = "03"
  1660. break
  1661. case 5:
  1662. fsiOPFLD.MedChrgitmType = "08"
  1663. break
  1664. case 6:
  1665. fsiOPFLD.MedChrgitmType = "14"
  1666. break
  1667. case 7:
  1668. fsiOPFLD.MedChrgitmType = "14"
  1669. break
  1670. case 8:
  1671. fsiOPFLD.MedChrgitmType = "03"
  1672. break
  1673. case 9:
  1674. fsiOPFLD.MedChrgitmType = "14"
  1675. break
  1676. case 10:
  1677. fsiOPFLD.MedChrgitmType = "14"
  1678. break
  1679. case 11:
  1680. fsiOPFLD.MedChrgitmType = "06"
  1681. break
  1682. case 12:
  1683. fsiOPFLD.MedChrgitmType = "12"
  1684. break
  1685. case 13:
  1686. fsiOPFLD.MedChrgitmType = "01"
  1687. break
  1688. case 14:
  1689. fsiOPFLD.MedChrgitmType = "04"
  1690. break
  1691. case 15:
  1692. fsiOPFLD.MedChrgitmType = "14"
  1693. break
  1694. }
  1695. memo["hosp_appr_flag"] = "1"
  1696. memo["invoice_no"] = order.MdtrtId
  1697. memo["memo"] = "自费"
  1698. bytesData, _ := json.Marshal(memo)
  1699. fsiOPFLD.Memo = string(bytesData)
  1700. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1701. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  1702. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1703. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1704. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1705. fsiOPFLD.BilgDeptName = department.Name
  1706. fsiOPFLD.BilgDeptCodg = department.Number
  1707. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1708. fsiOPFLD.BilgDrName = doctor.UserName
  1709. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1710. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1711. fsiOPFLD.MedChrgitmType = "08"
  1712. memo["hosp_appr_flag"] = "1"
  1713. memo["invoice_no"] = order.MdtrtId
  1714. memo["memo"] = "自费"
  1715. bytesData, _ := json.Marshal(memo)
  1716. fsiOPFLD.Memo = string(bytesData)
  1717. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1718. }
  1719. }
  1720. }
  1721. for _, items := range order_info_two {
  1722. memo := make(map[string]interface{})
  1723. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1724. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1725. fsiOPFLD.MedType = "14"
  1726. fsiOPFLD.BkkpSn = items.FeedetlSn
  1727. fsiOPFLD.FixmedinsCode = miConfig.Code
  1728. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1729. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1730. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1731. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1732. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1733. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1734. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1735. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1736. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1737. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1738. fsiOPFLD.BilgDeptName = department.Name
  1739. fsiOPFLD.BilgDeptCodg = department.Number
  1740. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1741. fsiOPFLD.BilgDrName = doctor.UserName
  1742. fsiOPFLD.MedChrgitmType = "09"
  1743. memo["hosp_appr_flag"] = "1"
  1744. memo["invoice_no"] = order.MdtrtId
  1745. memo["memo"] = "自费"
  1746. bytesData, _ := json.Marshal(memo)
  1747. fsiOPFLD.Memo = string(bytesData)
  1748. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1749. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1750. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1751. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1752. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1753. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1754. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1755. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1756. fsiOPFLD.BilgDeptName = department.Name
  1757. fsiOPFLD.BilgDeptCodg = department.Number
  1758. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1759. fsiOPFLD.BilgDrName = doctor.UserName
  1760. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1761. case 0:
  1762. break
  1763. case 1:
  1764. fsiOPFLD.MedChrgitmType = "14"
  1765. break
  1766. case 2:
  1767. fsiOPFLD.MedChrgitmType = "05"
  1768. break
  1769. case 3:
  1770. fsiOPFLD.MedChrgitmType = "03"
  1771. break
  1772. case 4:
  1773. fsiOPFLD.MedChrgitmType = "03"
  1774. break
  1775. case 5:
  1776. fsiOPFLD.MedChrgitmType = "08"
  1777. break
  1778. case 6:
  1779. fsiOPFLD.MedChrgitmType = "14"
  1780. break
  1781. case 7:
  1782. fsiOPFLD.MedChrgitmType = "14"
  1783. break
  1784. case 8:
  1785. fsiOPFLD.MedChrgitmType = "03"
  1786. break
  1787. case 9:
  1788. fsiOPFLD.MedChrgitmType = "14"
  1789. break
  1790. case 10:
  1791. fsiOPFLD.MedChrgitmType = "14"
  1792. break
  1793. case 11:
  1794. fsiOPFLD.MedChrgitmType = "06"
  1795. break
  1796. case 12:
  1797. fsiOPFLD.MedChrgitmType = "12"
  1798. break
  1799. case 13:
  1800. fsiOPFLD.MedChrgitmType = "01"
  1801. break
  1802. case 14:
  1803. fsiOPFLD.MedChrgitmType = "04"
  1804. break
  1805. case 15:
  1806. fsiOPFLD.MedChrgitmType = "14"
  1807. break
  1808. }
  1809. memo["hosp_appr_flag"] = "1"
  1810. memo["invoice_no"] = order.MdtrtId
  1811. memo["memo"] = "自费"
  1812. bytesData, _ := json.Marshal(memo)
  1813. fsiOPFLD.Memo = string(bytesData)
  1814. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1815. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  1816. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1817. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1818. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1819. fsiOPFLD.BilgDeptName = department.Name
  1820. fsiOPFLD.BilgDeptCodg = department.Number
  1821. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1822. fsiOPFLD.BilgDrName = doctor.UserName
  1823. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1824. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1825. fsiOPFLD.MedChrgitmType = "08"
  1826. memo["hosp_appr_flag"] = "1"
  1827. memo["invoice_no"] = order.MdtrtId
  1828. memo["memo"] = "自费"
  1829. bytesData, _ := json.Marshal(memo)
  1830. fsiOPFLD.Memo = string(bytesData)
  1831. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1832. }
  1833. }
  1834. }
  1835. fmt.Println(fsiOPFLDs)
  1836. struct4201A.Fopfd = fsiOPFLDs
  1837. fmt.Println(struct4201A.Fopfd)
  1838. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  1839. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  1840. var res2 ResultSix
  1841. var respJSON2 map[string]interface{}
  1842. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1845. return
  1846. }
  1847. userJSONBytes2, _ := json.Marshal(respJSON2)
  1848. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1849. utils.ErrorLog("解析失败:%v", err)
  1850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1851. return
  1852. }
  1853. if res2.Infcode != 0 {
  1854. c.ServeSuccessJSON(map[string]interface{}{
  1855. "failed_code": -10,
  1856. "msg": res2.ErrMsg,
  1857. })
  1858. return
  1859. } else {
  1860. order.IsUploadOrderInfo = 1
  1861. service.UpdateOrder(order)
  1862. c.ServeSuccessJSON(map[string]interface{}{
  1863. "msg": "上传成功",
  1864. })
  1865. }
  1866. }
  1867. func (c *HisApiController) Get2505() {
  1868. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  1869. 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")
  1870. }
  1871. func (c *HisApiController) Get4201A() {
  1872. order_id, _ := c.GetInt64("order_id")
  1873. admin_user_id, _ := c.GetInt64("admin_user_id")
  1874. order, _ := service.GetHisOrderByIDTwo(order_id)
  1875. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1876. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  1877. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  1878. //order_info = append(order_info, order_info_two...)
  1879. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1880. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1881. department, _ := service.GetDepartMentDetail(his.Departments)
  1882. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  1883. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  1884. if order.ID == 0 {
  1885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1886. return
  1887. }
  1888. var struct4201A models.Struct4201A
  1889. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  1890. for _, items := range order_info {
  1891. memo := make(map[string]interface{})
  1892. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1893. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1894. fsiOPFLD.MedType = "14"
  1895. fsiOPFLD.BkkpSn = items.FeedetlSn
  1896. fsiOPFLD.FixmedinsCode = miConfig.Code
  1897. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1898. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1899. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1900. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1901. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1902. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1903. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1904. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1905. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1906. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1907. fsiOPFLD.BilgDeptName = department.Name
  1908. fsiOPFLD.BilgDeptCodg = department.Number
  1909. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1910. fsiOPFLD.BilgDrName = doctor.UserName
  1911. fsiOPFLD.MedChrgitmType = "09"
  1912. memo["hosp_appr_flag"] = "1"
  1913. memo["invoice_no"] = order.MdtrtId
  1914. memo["memo"] = "自费"
  1915. bytesData, _ := json.Marshal(memo)
  1916. fsiOPFLD.Memo = string(bytesData)
  1917. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1918. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1919. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1920. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1921. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1922. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1923. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1924. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1925. fsiOPFLD.BilgDeptName = department.Name
  1926. fsiOPFLD.BilgDeptCodg = department.Number
  1927. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1928. fsiOPFLD.BilgDrName = doctor.UserName
  1929. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1930. case 0:
  1931. break
  1932. case 1:
  1933. fsiOPFLD.MedChrgitmType = "14"
  1934. break
  1935. case 2:
  1936. fsiOPFLD.MedChrgitmType = "05"
  1937. break
  1938. case 3:
  1939. fsiOPFLD.MedChrgitmType = "03"
  1940. break
  1941. case 4:
  1942. fsiOPFLD.MedChrgitmType = "03"
  1943. break
  1944. case 5:
  1945. fsiOPFLD.MedChrgitmType = "08"
  1946. break
  1947. case 6:
  1948. fsiOPFLD.MedChrgitmType = "14"
  1949. break
  1950. case 7:
  1951. fsiOPFLD.MedChrgitmType = "14"
  1952. break
  1953. case 8:
  1954. fsiOPFLD.MedChrgitmType = "03"
  1955. break
  1956. case 9:
  1957. fsiOPFLD.MedChrgitmType = "14"
  1958. break
  1959. case 10:
  1960. fsiOPFLD.MedChrgitmType = "14"
  1961. break
  1962. case 11:
  1963. fsiOPFLD.MedChrgitmType = "06"
  1964. break
  1965. case 12:
  1966. fsiOPFLD.MedChrgitmType = "12"
  1967. break
  1968. case 13:
  1969. fsiOPFLD.MedChrgitmType = "01"
  1970. break
  1971. case 14:
  1972. fsiOPFLD.MedChrgitmType = "04"
  1973. break
  1974. case 15:
  1975. fsiOPFLD.MedChrgitmType = "14"
  1976. break
  1977. }
  1978. memo["hosp_appr_flag"] = "1"
  1979. memo["invoice_no"] = order.MdtrtId
  1980. memo["memo"] = "自费"
  1981. bytesData, _ := json.Marshal(memo)
  1982. fsiOPFLD.Memo = string(bytesData)
  1983. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1984. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  1985. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1986. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1987. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1988. fsiOPFLD.BilgDeptName = department.Name
  1989. fsiOPFLD.BilgDeptCodg = department.Number
  1990. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1991. fsiOPFLD.BilgDrName = doctor.UserName
  1992. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1993. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1994. fsiOPFLD.MedChrgitmType = "08"
  1995. memo["hosp_appr_flag"] = "1"
  1996. memo["invoice_no"] = order.MdtrtId
  1997. memo["memo"] = "自费"
  1998. bytesData, _ := json.Marshal(memo)
  1999. fsiOPFLD.Memo = string(bytesData)
  2000. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2001. }
  2002. }
  2003. }
  2004. for _, items := range order_info_two {
  2005. memo := make(map[string]interface{})
  2006. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2007. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2008. fsiOPFLD.MedType = "14"
  2009. fsiOPFLD.BkkpSn = items.FeedetlSn
  2010. fsiOPFLD.FixmedinsCode = miConfig.Code
  2011. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2012. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2013. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2014. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2015. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2016. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2017. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2018. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2019. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2020. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2021. fsiOPFLD.BilgDeptName = department.Name
  2022. fsiOPFLD.BilgDeptCodg = department.Number
  2023. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2024. fsiOPFLD.BilgDrName = doctor.UserName
  2025. fsiOPFLD.MedChrgitmType = "09"
  2026. memo["hosp_appr_flag"] = "1"
  2027. memo["invoice_no"] = order.MdtrtId
  2028. memo["memo"] = "自费"
  2029. bytesData, _ := json.Marshal(memo)
  2030. fsiOPFLD.Memo = string(bytesData)
  2031. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2032. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2033. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2034. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2035. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2036. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2037. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2038. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2039. fsiOPFLD.BilgDeptName = department.Name
  2040. fsiOPFLD.BilgDeptCodg = department.Number
  2041. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2042. fsiOPFLD.BilgDrName = doctor.UserName
  2043. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2044. case 0:
  2045. break
  2046. case 1:
  2047. fsiOPFLD.MedChrgitmType = "14"
  2048. break
  2049. case 2:
  2050. fsiOPFLD.MedChrgitmType = "05"
  2051. break
  2052. case 3:
  2053. fsiOPFLD.MedChrgitmType = "03"
  2054. break
  2055. case 4:
  2056. fsiOPFLD.MedChrgitmType = "03"
  2057. break
  2058. case 5:
  2059. fsiOPFLD.MedChrgitmType = "08"
  2060. break
  2061. case 6:
  2062. fsiOPFLD.MedChrgitmType = "14"
  2063. break
  2064. case 7:
  2065. fsiOPFLD.MedChrgitmType = "14"
  2066. break
  2067. case 8:
  2068. fsiOPFLD.MedChrgitmType = "03"
  2069. break
  2070. case 9:
  2071. fsiOPFLD.MedChrgitmType = "14"
  2072. break
  2073. case 10:
  2074. fsiOPFLD.MedChrgitmType = "14"
  2075. break
  2076. case 11:
  2077. fsiOPFLD.MedChrgitmType = "06"
  2078. break
  2079. case 12:
  2080. fsiOPFLD.MedChrgitmType = "12"
  2081. break
  2082. case 13:
  2083. fsiOPFLD.MedChrgitmType = "01"
  2084. break
  2085. case 14:
  2086. fsiOPFLD.MedChrgitmType = "04"
  2087. break
  2088. case 15:
  2089. fsiOPFLD.MedChrgitmType = "14"
  2090. break
  2091. }
  2092. memo["hosp_appr_flag"] = "1"
  2093. memo["invoice_no"] = order.MdtrtId
  2094. memo["memo"] = "自费"
  2095. bytesData, _ := json.Marshal(memo)
  2096. fsiOPFLD.Memo = string(bytesData)
  2097. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2098. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  2099. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2100. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2101. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2102. fsiOPFLD.BilgDeptName = department.Name
  2103. fsiOPFLD.BilgDeptCodg = department.Number
  2104. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2105. fsiOPFLD.BilgDrName = doctor.UserName
  2106. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2107. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2108. fsiOPFLD.MedChrgitmType = "08"
  2109. memo["hosp_appr_flag"] = "1"
  2110. memo["invoice_no"] = order.MdtrtId
  2111. memo["memo"] = "自费"
  2112. bytesData, _ := json.Marshal(memo)
  2113. fsiOPFLD.Memo = string(bytesData)
  2114. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2115. }
  2116. }
  2117. }
  2118. fmt.Println(fsiOPFLDs)
  2119. struct4201A.Fopfd = fsiOPFLDs
  2120. fmt.Println(struct4201A.Fopfd)
  2121. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  2122. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  2123. var res2 ResultSix
  2124. var respJSON2 map[string]interface{}
  2125. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2128. return
  2129. }
  2130. userJSONBytes2, _ := json.Marshal(respJSON2)
  2131. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2132. utils.ErrorLog("解析失败:%v", err)
  2133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2134. return
  2135. }
  2136. if res2.Infcode != 0 {
  2137. c.ServeSuccessJSON(map[string]interface{}{
  2138. "failed_code": -10,
  2139. "msg": res2.ErrMsg,
  2140. })
  2141. return
  2142. } else {
  2143. order.IsUploadOrderInfo = 1
  2144. service.UpdateOrder(order)
  2145. c.ServeSuccessJSON(map[string]interface{}{
  2146. "msg": "上传成功",
  2147. })
  2148. }
  2149. }
  2150. func (c *HisApiController) Get4202() {
  2151. order_id, _ := c.GetInt64("order_id")
  2152. admin_user_id, _ := c.GetInt64("admin_user_id")
  2153. order, _ := service.GetHisOrderByIDTwo(order_id)
  2154. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2155. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2156. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2157. if order.ID == 0 {
  2158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2159. return
  2160. }
  2161. var struct4202 models.Struct4202
  2162. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  2163. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  2164. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  2165. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  2166. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  2167. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  2168. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  2169. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  2170. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  2171. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2172. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2173. var config []*models.HisXtDiagnoseConfig
  2174. for _, item := range diagnosis_ids {
  2175. id, _ := strconv.ParseInt(item, 10, 64)
  2176. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2177. config = append(config, &diagnosisConfig)
  2178. }
  2179. var tempDiaginfos []models.OwnPayPatnDiagListD
  2180. for index, item := range config {
  2181. if index == 0 {
  2182. var tempDiaginfo models.OwnPayPatnDiagListD
  2183. tempDiaginfo.InoutDiagType = "1"
  2184. tempDiaginfo.DiagCode = item.CountryCode
  2185. tempDiaginfo.DiagName = item.CountryContentName
  2186. tempDiaginfo.DiagType = "1"
  2187. tempDiaginfo.DiagSrtNo = "1"
  2188. tempDiaginfo.MaindiagFlag = "1"
  2189. tempDiaginfo.ValiFlag = "1"
  2190. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2191. } else {
  2192. var tempDiaginfo models.OwnPayPatnDiagListD
  2193. tempDiaginfo.DiagCode = item.CountryCode
  2194. tempDiaginfo.DiagName = item.CountryContentName
  2195. tempDiaginfo.DiagType = "2"
  2196. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2197. tempDiaginfo.MaindiagFlag = "0"
  2198. tempDiaginfo.ValiFlag = "1"
  2199. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2200. }
  2201. }
  2202. struct4202.ODiagListD = tempDiaginfos
  2203. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  2204. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  2205. var res2 ResultSix
  2206. var respJSON2 map[string]interface{}
  2207. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2210. return
  2211. }
  2212. userJSONBytes2, _ := json.Marshal(respJSON2)
  2213. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2214. utils.ErrorLog("解析失败:%v", err)
  2215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2216. return
  2217. }
  2218. if res2.Infcode != 0 {
  2219. c.ServeSuccessJSON(map[string]interface{}{
  2220. "failed_code": -10,
  2221. "msg": res2.ErrMsg,
  2222. })
  2223. return
  2224. } else {
  2225. order.IsUploadDiagnose = 1
  2226. service.UpdateOrder(order)
  2227. c.ServeSuccessJSON(map[string]interface{}{
  2228. "msg": "上传成功",
  2229. })
  2230. }
  2231. }
  2232. func (c *HisApiController) Get4203() {
  2233. admin_user_id, _ := c.GetInt64("admin_user_id")
  2234. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2235. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2236. order_id, _ := c.GetInt64("order_id")
  2237. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  2238. number := ""
  2239. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2240. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2241. if his.ID == 0 {
  2242. number = hospital.Number
  2243. } else {
  2244. number = his.Number
  2245. }
  2246. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  2247. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  2248. var res2 ResultSix
  2249. var respJSON2 map[string]interface{}
  2250. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2253. return
  2254. }
  2255. userJSONBytes2, _ := json.Marshal(respJSON2)
  2256. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2257. utils.ErrorLog("解析失败:%v", err)
  2258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2259. return
  2260. }
  2261. if res2.Infcode != 0 {
  2262. c.ServeSuccessJSON(map[string]interface{}{
  2263. "failed_code": -10,
  2264. "msg": res2.ErrMsg,
  2265. })
  2266. return
  2267. } else {
  2268. order.IsUploadSuccess = 1
  2269. service.UpdateOrderTwo(order)
  2270. c.ServeSuccessJSON(map[string]interface{}{
  2271. "msg": "上传成功",
  2272. })
  2273. }
  2274. }
  2275. func (c *HisApiController) Get4205() {
  2276. order_id, _ := c.GetInt64("order_id")
  2277. admin_user_id, _ := c.GetInt64("admin_user_id")
  2278. fapiao_code := c.GetString("fapiao_code")
  2279. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  2280. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2281. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2282. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2283. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  2284. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  2285. //order_info = append(order_info, order_info_two...)
  2286. department, _ := service.GetDepartMentDetail(his.Departments)
  2287. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  2288. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  2289. if order.ID == 0 {
  2290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2291. return
  2292. }
  2293. var struct4201A models.Struct4201A
  2294. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  2295. for _, items := range order_info {
  2296. memo := make(map[string]interface{})
  2297. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2298. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2299. fsiOPFLD.MedType = pre.MedType
  2300. fsiOPFLD.FixmedinsCode = miConfig.Code
  2301. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2302. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2303. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2304. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2305. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2306. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2307. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2308. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  2309. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2310. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2311. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2312. fsiOPFLD.BilgDeptName = department.Name
  2313. fsiOPFLD.BilgDeptCodg = department.Number
  2314. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2315. fsiOPFLD.BilgDrName = doctor.UserName
  2316. fsiOPFLD.MedChrgitmType = "09"
  2317. memo["hosp_appr_flag"] = "1"
  2318. memo["invoice_no"] = fapiao_code
  2319. memo["memo"] = "自费"
  2320. bytesData, _ := json.Marshal(memo)
  2321. fsiOPFLD.Memo = string(bytesData)
  2322. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2323. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2324. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  2325. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2326. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2327. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2328. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2329. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2330. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2331. fsiOPFLD.BilgDeptName = department.Name
  2332. fsiOPFLD.BilgDeptCodg = department.Number
  2333. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2334. fsiOPFLD.BilgDrName = doctor.UserName
  2335. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2336. case 0:
  2337. break
  2338. case 1:
  2339. fsiOPFLD.MedChrgitmType = "14"
  2340. break
  2341. case 2:
  2342. fsiOPFLD.MedChrgitmType = "05"
  2343. break
  2344. case 3:
  2345. fsiOPFLD.MedChrgitmType = "03"
  2346. break
  2347. case 4:
  2348. fsiOPFLD.MedChrgitmType = "03"
  2349. break
  2350. case 5:
  2351. fsiOPFLD.MedChrgitmType = "08"
  2352. break
  2353. case 6:
  2354. fsiOPFLD.MedChrgitmType = "14"
  2355. break
  2356. case 7:
  2357. fsiOPFLD.MedChrgitmType = "14"
  2358. break
  2359. case 8:
  2360. fsiOPFLD.MedChrgitmType = "03"
  2361. break
  2362. case 9:
  2363. fsiOPFLD.MedChrgitmType = "14"
  2364. break
  2365. case 10:
  2366. fsiOPFLD.MedChrgitmType = "14"
  2367. break
  2368. case 11:
  2369. fsiOPFLD.MedChrgitmType = "06"
  2370. break
  2371. case 12:
  2372. fsiOPFLD.MedChrgitmType = "12"
  2373. break
  2374. case 13:
  2375. fsiOPFLD.MedChrgitmType = "01"
  2376. break
  2377. case 14:
  2378. fsiOPFLD.MedChrgitmType = "04"
  2379. break
  2380. case 15:
  2381. fsiOPFLD.MedChrgitmType = "14"
  2382. break
  2383. }
  2384. memo["hosp_appr_flag"] = "1"
  2385. memo["invoice_no"] = fapiao_code
  2386. memo["memo"] = "自费"
  2387. bytesData, _ := json.Marshal(memo)
  2388. fsiOPFLD.Memo = string(bytesData)
  2389. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2390. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  2391. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2392. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2393. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2394. fsiOPFLD.BilgDeptName = department.Name
  2395. fsiOPFLD.BilgDeptCodg = department.Number
  2396. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2397. fsiOPFLD.BilgDrName = doctor.UserName
  2398. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2399. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2400. fsiOPFLD.MedChrgitmType = "08"
  2401. memo["hosp_appr_flag"] = "1"
  2402. memo["invoice_no"] = fapiao_code
  2403. memo["memo"] = "自费"
  2404. bytesData, _ := json.Marshal(memo)
  2405. fsiOPFLD.Memo = string(bytesData)
  2406. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2407. }
  2408. }
  2409. }
  2410. for _, items := range order_info_two {
  2411. memo := make(map[string]interface{})
  2412. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2413. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2414. fsiOPFLD.MedType = pre.MedType
  2415. fsiOPFLD.BkkpSn = items.FeedetlSn
  2416. fsiOPFLD.FixmedinsCode = miConfig.Code
  2417. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2418. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2419. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2420. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2421. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2422. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2423. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2424. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2425. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2426. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2427. fsiOPFLD.BilgDeptName = department.Name
  2428. fsiOPFLD.BilgDeptCodg = department.Number
  2429. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2430. fsiOPFLD.BilgDrName = doctor.UserName
  2431. fsiOPFLD.MedChrgitmType = "09"
  2432. memo["hosp_appr_flag"] = "1"
  2433. memo["invoice_no"] = fapiao_code
  2434. memo["memo"] = "自费"
  2435. bytesData, _ := json.Marshal(memo)
  2436. fsiOPFLD.Memo = string(bytesData)
  2437. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2438. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2439. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  2440. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2441. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2442. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2443. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2444. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2445. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2446. fsiOPFLD.BilgDeptName = department.Name
  2447. fsiOPFLD.BilgDeptCodg = department.Number
  2448. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2449. fsiOPFLD.BilgDrName = doctor.UserName
  2450. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2451. case 0:
  2452. break
  2453. case 1:
  2454. fsiOPFLD.MedChrgitmType = "14"
  2455. break
  2456. case 2:
  2457. fsiOPFLD.MedChrgitmType = "05"
  2458. break
  2459. case 3:
  2460. fsiOPFLD.MedChrgitmType = "03"
  2461. break
  2462. case 4:
  2463. fsiOPFLD.MedChrgitmType = "03"
  2464. break
  2465. case 5:
  2466. fsiOPFLD.MedChrgitmType = "08"
  2467. break
  2468. case 6:
  2469. fsiOPFLD.MedChrgitmType = "14"
  2470. break
  2471. case 7:
  2472. fsiOPFLD.MedChrgitmType = "14"
  2473. break
  2474. case 8:
  2475. fsiOPFLD.MedChrgitmType = "03"
  2476. break
  2477. case 9:
  2478. fsiOPFLD.MedChrgitmType = "14"
  2479. break
  2480. case 10:
  2481. fsiOPFLD.MedChrgitmType = "14"
  2482. break
  2483. case 11:
  2484. fsiOPFLD.MedChrgitmType = "06"
  2485. break
  2486. case 12:
  2487. fsiOPFLD.MedChrgitmType = "12"
  2488. break
  2489. case 13:
  2490. fsiOPFLD.MedChrgitmType = "01"
  2491. break
  2492. case 14:
  2493. fsiOPFLD.MedChrgitmType = "04"
  2494. break
  2495. case 15:
  2496. fsiOPFLD.MedChrgitmType = "14"
  2497. break
  2498. }
  2499. memo["hosp_appr_flag"] = "1"
  2500. memo["invoice_no"] = fapiao_code
  2501. memo["memo"] = "自费"
  2502. bytesData, _ := json.Marshal(memo)
  2503. fsiOPFLD.Memo = string(bytesData)
  2504. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2505. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  2506. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2507. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2508. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2509. fsiOPFLD.BilgDeptName = department.Name
  2510. fsiOPFLD.BilgDeptCodg = department.Number
  2511. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2512. fsiOPFLD.BilgDrName = doctor.UserName
  2513. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2514. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2515. fsiOPFLD.MedChrgitmType = "08"
  2516. memo["hosp_appr_flag"] = "1"
  2517. memo["invoice_no"] = fapiao_code
  2518. memo["memo"] = "自费"
  2519. bytesData, _ := json.Marshal(memo)
  2520. fsiOPFLD.Memo = string(bytesData)
  2521. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2522. }
  2523. }
  2524. }
  2525. fmt.Println(fsiOPFLDs)
  2526. struct4201A.Fopfd = fsiOPFLDs
  2527. fmt.Println(struct4201A.Fopfd)
  2528. var struct4202 models.Struct4202
  2529. timeLayout := "2006-01-02 15:04:05"
  2530. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  2531. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  2532. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  2533. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  2534. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  2535. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  2536. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  2537. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  2538. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  2539. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  2540. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2541. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2542. var config []*models.HisXtDiagnoseConfig
  2543. for _, item := range diagnosis_ids {
  2544. id, _ := strconv.ParseInt(item, 10, 64)
  2545. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2546. config = append(config, &diagnosisConfig)
  2547. }
  2548. var tempDiaginfos []models.OwnPayPatnDiagListD
  2549. for index, item := range config {
  2550. if index == 0 {
  2551. var tempDiaginfo models.OwnPayPatnDiagListD
  2552. tempDiaginfo.InoutDiagType = "1"
  2553. tempDiaginfo.DiagCode = item.CountryCode
  2554. tempDiaginfo.DiagName = item.CountryContentName
  2555. tempDiaginfo.DiagType = "1"
  2556. tempDiaginfo.DiagSrtNo = "1"
  2557. tempDiaginfo.MaindiagFlag = "1"
  2558. tempDiaginfo.ValiFlag = "1"
  2559. tempDiaginfo.DiagDrName = doctor.UserName
  2560. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  2561. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  2562. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2563. } else {
  2564. var tempDiaginfo models.OwnPayPatnDiagListD
  2565. tempDiaginfo.DiagCode = item.CountryCode
  2566. tempDiaginfo.DiagName = item.CountryContentName
  2567. tempDiaginfo.DiagType = "2"
  2568. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2569. tempDiaginfo.MaindiagFlag = "0"
  2570. tempDiaginfo.ValiFlag = "1"
  2571. tempDiaginfo.DiagDrName = doctor.UserName
  2572. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  2573. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  2574. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2575. }
  2576. }
  2577. struct4202.ODiagListD = tempDiaginfos
  2578. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  2579. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  2580. var res2 ResultSix
  2581. var respJSON2 map[string]interface{}
  2582. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2585. return
  2586. }
  2587. userJSONBytes2, _ := json.Marshal(respJSON2)
  2588. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2589. utils.ErrorLog("解析失败:%v", err)
  2590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2591. return
  2592. }
  2593. if res2.Infcode != 0 {
  2594. c.ServeSuccessJSON(map[string]interface{}{
  2595. "failed_code": -10,
  2596. "msg": res2.ErrMsg,
  2597. })
  2598. return
  2599. } else {
  2600. order.IsUploadDiagnose = 1
  2601. order.IsUploadOrderInfo = 1
  2602. service.UpdateOrderTwo(order)
  2603. c.ServeSuccessJSON(map[string]interface{}{
  2604. "msg": "上传成功",
  2605. })
  2606. }
  2607. }
  2608. func (c *HisApiController) Get4207() {
  2609. admin_user_id, _ := c.GetInt64("admin_user_id")
  2610. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2611. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2612. order_id, _ := c.GetInt64("order_id")
  2613. order, _ := service.GetHisOrderByIDTwo(order_id)
  2614. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2615. var struct4207 models.Struct4207
  2616. struct4207.PageNum = "1"
  2617. struct4207.PageSize = "1000"
  2618. struct4207.FixmedinsCode = miConfig.Code
  2619. struct4207.FixmedinsMdtrtID = order.Number
  2620. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  2621. saveLog(result, requestLog, "4207", "查询")
  2622. var res2 ResultSix
  2623. var respJSON2 map[string]interface{}
  2624. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2627. return
  2628. }
  2629. userJSONBytes2, _ := json.Marshal(respJSON2)
  2630. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2631. utils.ErrorLog("解析失败:%v", err)
  2632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2633. return
  2634. }
  2635. if res2.Infcode != 0 {
  2636. c.ServeSuccessJSON(map[string]interface{}{
  2637. "failed_code": -10,
  2638. "msg": res2.ErrMsg,
  2639. })
  2640. return
  2641. } else {
  2642. c.ServeSuccessJSON(map[string]interface{}{
  2643. "msg": "查询成功",
  2644. })
  2645. }
  2646. }
  2647. func (c *HisApiController) Get4208() {
  2648. admin_user_id, _ := c.GetInt64("admin_user_id")
  2649. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2650. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2651. order_id, _ := c.GetInt64("order_id")
  2652. order, _ := service.GetHisOrderByIDTwo(order_id)
  2653. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2654. var struct4208 models.Struct4208
  2655. struct4208.PageNum = "1"
  2656. struct4208.PageSize = "1000"
  2657. struct4208.PsnCertType = "01"
  2658. struct4208.Certno = his.Certno
  2659. struct4208.MedType = order.MedType
  2660. struct4208.PsnName = his.Name
  2661. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  2662. saveLog(result, requestLog, "4208", "查询")
  2663. var res2 ResultSix
  2664. var respJSON2 map[string]interface{}
  2665. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2668. return
  2669. }
  2670. userJSONBytes2, _ := json.Marshal(respJSON2)
  2671. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2672. utils.ErrorLog("解析失败:%v", err)
  2673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2674. return
  2675. }
  2676. if res2.Infcode != 0 {
  2677. c.ServeSuccessJSON(map[string]interface{}{
  2678. "failed_code": -10,
  2679. "msg": res2.ErrMsg,
  2680. })
  2681. return
  2682. } else {
  2683. c.ServeSuccessJSON(map[string]interface{}{
  2684. "msg": "查询成功",
  2685. })
  2686. }
  2687. }
  2688. func (c *HisApiController) Get4209() {
  2689. admin_user_id, _ := c.GetInt64("admin_user_id")
  2690. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2691. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2692. order_id, _ := c.GetInt64("order_id")
  2693. order, _ := service.GetHisOrderByIDTwo(order_id)
  2694. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2695. var struct4209 models.Struct4209
  2696. struct4209.FixmedinsMdtrtID = order.Number
  2697. struct4209.FixmedinsCode = miConfig.Code
  2698. struct4209.PageSize = "1000"
  2699. struct4209.PageNum = "1"
  2700. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  2701. saveLog(result, requestLog, "4209", "查询")
  2702. var res2 ResultSix
  2703. var respJSON2 map[string]interface{}
  2704. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2707. return
  2708. }
  2709. userJSONBytes2, _ := json.Marshal(respJSON2)
  2710. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2711. utils.ErrorLog("解析失败:%v", err)
  2712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2713. return
  2714. }
  2715. if res2.Infcode != 0 {
  2716. c.ServeSuccessJSON(map[string]interface{}{
  2717. "failed_code": -10,
  2718. "msg": res2.ErrMsg,
  2719. })
  2720. return
  2721. } else {
  2722. c.ServeSuccessJSON(map[string]interface{}{
  2723. "msg": "查询成功",
  2724. })
  2725. }
  2726. }
  2727. type Result3101 struct {
  2728. Infcode string `json:"infcode"`
  2729. InfRefmsgid string `json:"inf_refmsgid"`
  2730. RefmsgTime string `json:"refmsg_time"`
  2731. RespondTime string `json:"respond_time"`
  2732. Enctype string `json:"enctype"`
  2733. Signtype string `json:"signtype"`
  2734. ErrMsg string `json:"err_msg"`
  2735. Output struct {
  2736. Result []struct {
  2737. JudgeResultDetailDtos []struct {
  2738. VolaItemType string `json:"vola_item_type"`
  2739. MdtrtID string `json:"mdtrt_id"`
  2740. JrdID string `json:"jrd_id"`
  2741. PatnID string `json:"patn_id"`
  2742. RxID string `json:"rx_id"`
  2743. VolaAmt interface{} `json:"vola_amt"`
  2744. } `json:"judge_result_detail_dtos"`
  2745. RuleID string `json:"rule_id"`
  2746. VolaEvid string `json:"vola_evid"`
  2747. MdtrtID string `json:"mdtrt_id"`
  2748. RuleName string `json:"rule_name"`
  2749. VolaAmtStas string `json:"vola_amt_stas"`
  2750. JrID string `json:"jr_id"`
  2751. PatnID string `json:"patn_id"`
  2752. SevDeg string `json:"sev_deg"`
  2753. VolaAmt float64 `json:"vola_amt"`
  2754. VolaBhvrType string `json:"vola_bhvr_type"`
  2755. VolaCont string `json:"vola_cont"`
  2756. } `json:"result"`
  2757. } `json:"output"`
  2758. }
  2759. func (c *HisApiController) ReadEleToken() {
  2760. admin_user_id, _ := c.GetInt64("admin_user_id")
  2761. his_patient_id, _ := c.GetInt64("his_patient_id")
  2762. adminUser := c.GetAdminUserInfo()
  2763. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2764. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2765. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2766. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2767. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  2768. if len(tokens) > 0 {
  2769. c.ServeSuccessJSON(map[string]interface{}{
  2770. "msg": "读取成功",
  2771. })
  2772. } else {
  2773. c.ServeSuccessJSON(map[string]interface{}{
  2774. "failed_code": -10,
  2775. "msg": "读取失败",
  2776. })
  2777. }
  2778. } else if miConfig.MdtrtareaAdmvs == "350500" {
  2779. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  2780. if len(errMsg) == 0 {
  2781. type ELeData struct {
  2782. Data struct {
  2783. IdNo string `json:"idNo"`
  2784. IdType string `json:"idType"`
  2785. UserName string `json:"userName"`
  2786. EcToken string `json:"ecToken"`
  2787. InsuOrg string `json:"insuOrg"`
  2788. Gender string `json:"gender"`
  2789. Birthday string `json:"birthday"`
  2790. Nationality string `json:"nationality"`
  2791. Email string `json:"email"`
  2792. Extra string `json:"extra"`
  2793. } `json:"data"`
  2794. Code int `json:"code"`
  2795. Message string `json:"message"`
  2796. }
  2797. var ele ELeData
  2798. err := json.Unmarshal([]byte(outPutInfo), &ele)
  2799. if err != nil {
  2800. utils.ErrorLog("解析失败:%v", err)
  2801. }
  2802. token := ele.Data.EcToken
  2803. if len(token) > 0 {
  2804. psn := &models.HisPsn{
  2805. PsnNo: his.PsnNo,
  2806. Age: 0,
  2807. PatientId: his.PatientId,
  2808. Certno: his.Certno,
  2809. Brdy: his.Brdy,
  2810. Gend: his.Gend,
  2811. Naty: his.Naty,
  2812. PsnCertType: his.PsnCertType,
  2813. PsnName: his.PsnName,
  2814. Idetinfo: his.Idetinfo,
  2815. Insuinfo: his.Iinfo,
  2816. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2817. CardInfo: outPutInfo,
  2818. VerifyNumber: token,
  2819. }
  2820. service.CreateHisPsn(psn)
  2821. }
  2822. if len(token) > 0 {
  2823. c.ServeSuccessJSON(map[string]interface{}{
  2824. "msg": "读取成功",
  2825. })
  2826. } else {
  2827. c.ServeSuccessJSON(map[string]interface{}{
  2828. "failed_code": -10,
  2829. "msg": "读取失败",
  2830. })
  2831. }
  2832. }
  2833. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2834. if initFlag == 0 {
  2835. c.TestGetJiangXiBasBaseInit()
  2836. }
  2837. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  2838. type ELeData struct {
  2839. Data struct {
  2840. IdNo string `json:"idNo"`
  2841. IdType string `json:"idType"`
  2842. UserName string `json:"userName"`
  2843. EcToken string `json:"ecToken"`
  2844. InsuOrg string `json:"insuOrg"`
  2845. Gender string `json:"gender"`
  2846. Birthday string `json:"birthday"`
  2847. Nationality string `json:"nationality"`
  2848. Email string `json:"email"`
  2849. Extra string `json:"extra"`
  2850. } `json:"data"`
  2851. Code int `json:"code"`
  2852. Message string `json:"message"`
  2853. }
  2854. var ele ELeData
  2855. err := json.Unmarshal([]byte(json_result), &ele)
  2856. if err != nil {
  2857. utils.ErrorLog("解析失败:%v", err)
  2858. }
  2859. token := ele.Data.EcToken
  2860. token = Remove0000(token)
  2861. fmt.Println(ele.Data.UserName)
  2862. 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)
  2863. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2864. var res ResultTwo
  2865. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2866. utils.ErrorLog("解析失败:%v", err)
  2867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2868. return
  2869. }
  2870. if res.Infcode == 0 {
  2871. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2872. if err == gorm.ErrRecordNotFound {
  2873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2874. return
  2875. } else if err != nil {
  2876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2877. return
  2878. } else {
  2879. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2880. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2881. infoStr := string(Iinfos)
  2882. idetinfoStr := string(Idetinfos)
  2883. psn := &models.HisPsn{
  2884. PsnNo: res.Output.Baseinfo.PsnNo,
  2885. Age: res.Output.Baseinfo.Age,
  2886. PatientId: patient.ID,
  2887. Certno: res.Output.Baseinfo.Certno,
  2888. Brdy: res.Output.Baseinfo.Brdy,
  2889. Gend: res.Output.Baseinfo.Gend,
  2890. Naty: res.Output.Baseinfo.Naty,
  2891. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2892. PsnName: res.Output.Baseinfo.PsnName,
  2893. Idetinfo: idetinfoStr,
  2894. Insuinfo: infoStr,
  2895. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2896. CardInfo: "",
  2897. VerifyNumber: token,
  2898. }
  2899. service.CreateHisPsn(psn)
  2900. c.ServeSuccessJSON(map[string]interface{}{
  2901. "patient": patient,
  2902. "number": token,
  2903. })
  2904. }
  2905. } else {
  2906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2907. return
  2908. }
  2909. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2910. idNo := c.GetString("idNo")
  2911. userName := c.GetString("userName")
  2912. ecToken := c.GetString("ecToken")
  2913. insuOrg := c.GetString("insuOrg")
  2914. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  2915. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2916. var res ResultTwo
  2917. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2918. utils.ErrorLog("解析失败:%v", err)
  2919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2920. return
  2921. }
  2922. if res.Infcode == 0 {
  2923. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2924. if err == gorm.ErrRecordNotFound {
  2925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2926. return
  2927. } else if err != nil {
  2928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2929. return
  2930. } else {
  2931. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2932. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2933. infoStr := string(Iinfos)
  2934. idetinfoStr := string(Idetinfos)
  2935. psn := &models.HisPsn{
  2936. PsnNo: res.Output.Baseinfo.PsnNo,
  2937. Age: res.Output.Baseinfo.Age,
  2938. PatientId: patient.ID,
  2939. Certno: res.Output.Baseinfo.Certno,
  2940. Brdy: res.Output.Baseinfo.Brdy,
  2941. Gend: res.Output.Baseinfo.Gend,
  2942. Naty: res.Output.Baseinfo.Naty,
  2943. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2944. PsnName: res.Output.Baseinfo.PsnName,
  2945. Idetinfo: idetinfoStr,
  2946. Insuinfo: infoStr,
  2947. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2948. CardInfo: "",
  2949. VerifyNumber: ecToken,
  2950. InsuplcAdmdvs: insuOrg,
  2951. }
  2952. service.CreateHisPsn(psn)
  2953. c.ServeSuccessJSON(map[string]interface{}{
  2954. "patient": patient,
  2955. "number": ecToken,
  2956. })
  2957. }
  2958. } else {
  2959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2960. return
  2961. }
  2962. } else {
  2963. //if initFlag == 0 {
  2964. // c.TestGetBasBaseInit()
  2965. //}
  2966. //token := c.GetEleBaseInfo()
  2967. //token = Remove0000(token)
  2968. type ELeData struct {
  2969. Code string `json:"code"`
  2970. Data struct {
  2971. Aac002 string `json:"aac002"`
  2972. Aaz500 string `json:"aaz500"`
  2973. ActCardNo string `json:"actCardNo"`
  2974. Bab520 string `json:"bab520"`
  2975. Bkz543 string `json:"bkz543"`
  2976. BusinessType string `json:"businessType"`
  2977. CertfCodg string `json:"certfCodg"`
  2978. EcIndexNo string `json:"ecIndexNo"`
  2979. EcToken string `json:"ecToken"`
  2980. ID0000 string `json:"id0000"`
  2981. IDNo string `json:"idNo"`
  2982. IDType string `json:"idType"`
  2983. Idcode string `json:"idcode"`
  2984. IdentityToken string `json:"identity_token"`
  2985. InsuOrg string `json:"insuOrg"`
  2986. OfficeID string `json:"officeId"`
  2987. OfficeName string `json:"officeName"`
  2988. OperatorID string `json:"operatorId"`
  2989. OperatorName string `json:"operatorName"`
  2990. OrgID string `json:"orgId"`
  2991. UserName string `json:"userName"`
  2992. } `json:"data"`
  2993. Infno interface{} `json:"infno"`
  2994. Message string `json:"message"`
  2995. OrgID string `json:"orgId"`
  2996. TransType string `json:"transType"`
  2997. }
  2998. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  2999. fmt.Println(result)
  3000. outPutInfo := Remove0000(result)
  3001. fmt.Println(outPutInfo)
  3002. var ele ELeData
  3003. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3004. if err != nil {
  3005. utils.ErrorLog("解析失败:%v", err)
  3006. }
  3007. token := ele.Data.EcToken
  3008. if len(token) > 0 {
  3009. result2, requestLog2 := service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  3010. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3011. var res ResultTwo
  3012. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3013. utils.ErrorLog("解析失败:%v", err)
  3014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3015. return
  3016. }
  3017. if res.Infcode == 0 {
  3018. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3019. if err == gorm.ErrRecordNotFound {
  3020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3021. return
  3022. } else if err != nil {
  3023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3024. return
  3025. } else {
  3026. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3027. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3028. infoStr := string(Iinfos)
  3029. idetinfoStr := string(Idetinfos)
  3030. psn := &models.HisPsn{
  3031. PsnNo: res.Output.Baseinfo.PsnNo,
  3032. Age: res.Output.Baseinfo.Age,
  3033. PatientId: patient.ID,
  3034. Certno: res.Output.Baseinfo.Certno,
  3035. Brdy: res.Output.Baseinfo.Brdy,
  3036. Gend: res.Output.Baseinfo.Gend,
  3037. Naty: res.Output.Baseinfo.Naty,
  3038. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3039. PsnName: res.Output.Baseinfo.PsnName,
  3040. Idetinfo: idetinfoStr,
  3041. Insuinfo: infoStr,
  3042. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3043. CardInfo: "",
  3044. VerifyNumber: token,
  3045. }
  3046. service.CreateHisPsn(psn)
  3047. c.ServeSuccessJSON(map[string]interface{}{
  3048. "msg": "读取成功",
  3049. })
  3050. }
  3051. } else {
  3052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3053. return
  3054. }
  3055. } else {
  3056. c.ServeSuccessJSON(map[string]interface{}{
  3057. "failed_code": -10,
  3058. "msg": "读取失败",
  3059. })
  3060. }
  3061. }
  3062. }
  3063. func (c *HisApiController) Get9001() {
  3064. adminUser := c.GetAdminUserInfo()
  3065. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3066. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  3067. if miConfig.MdtrtareaAdmvs == "350500" {
  3068. service.GetFjAuthorizationInfo(miConfig.Code)
  3069. } else if miConfig.MdtrtareaAdmvs == "131023" {
  3070. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  3071. var dat map[string]interface{}
  3072. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3073. fmt.Println(dat)
  3074. } else {
  3075. fmt.Println(err)
  3076. }
  3077. userJSONBytes, _ := json.Marshal(dat)
  3078. var res models.Result9001
  3079. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3080. utils.ErrorLog("解析失败:%v", err)
  3081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3082. return
  3083. }
  3084. } else {
  3085. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  3086. var dat map[string]interface{}
  3087. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3088. fmt.Println(dat)
  3089. } else {
  3090. fmt.Println(err)
  3091. }
  3092. userJSONBytes, _ := json.Marshal(dat)
  3093. var res models.Result9001
  3094. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3095. utils.ErrorLog("解析失败:%v", err)
  3096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3097. return
  3098. }
  3099. }
  3100. }
  3101. 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) {
  3102. var res Result3101
  3103. adminUser := c.GetAdminUserInfo()
  3104. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3105. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3106. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3107. //record_time := c.GetString("record_time")
  3108. //trig_scen := c.GetString("trig_scen")
  3109. timeLayout := "2006-01-02"
  3110. loc, _ := time.LoadLocation("Local")
  3111. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3112. if err != nil {
  3113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3114. return res
  3115. }
  3116. recordDateTime := theTime.Unix()
  3117. var patientPrescription models.HisPrescriptionInfo
  3118. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3119. //if patientPrescription.ID == 0 {
  3120. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3121. //}
  3122. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3123. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3124. //
  3125. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  3126. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3127. var pp models.PublicParams
  3128. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3129. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3130. pp.FixmedinsName = miConfig.OrgName
  3131. pp.FixmedinsCode = miConfig.Code
  3132. pp.RequestUrl = miConfig.Url
  3133. pp.Cainfo = miConfig.Cainfo
  3134. pp.SecretKey = miConfig.SecretKey
  3135. pp.AccessKey = miConfig.AccessKey
  3136. pp.OpterName = roles.UserName
  3137. var config []*models.HisXtDiagnoseConfig
  3138. for _, item := range diagnosis_ids {
  3139. id, _ := strconv.ParseInt(item, 10, 64)
  3140. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3141. config = append(config, &diagnosisConfig)
  3142. }
  3143. var pd models.PatientDtos
  3144. pd.PatnID = his.PsnNo
  3145. pd.PatnName = his.Name
  3146. pd.Gend = his.Gend
  3147. pd.Brdy = his.Brdy
  3148. pd.Poolarea = miConfig.MdtrtareaAdmvs
  3149. pd.CurrMdtrtID = his.Number
  3150. var fed models.FsiEncounterDtos
  3151. fed.MdtrtID = his.Number
  3152. fed.MedinsID = miConfig.Code
  3153. fed.MedinsName = miConfig.OrgName
  3154. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  3155. fed.MedMdtrtType = "1"
  3156. fed.MedinsType = "1"
  3157. fed.MedinsLv = "11"
  3158. tm := time.Unix(his.RecordDate, 0)
  3159. s_tm := tm.Format("2006-01-02 15:04:05")
  3160. fed.AdmDate = s_tm
  3161. fed.DscgDate = s_tm
  3162. fed.DscgMainDiseCodg = config[0].CountryCode
  3163. fed.DscgMainDiseName = config[0].CountryContentName
  3164. //诊断信息
  3165. var fdds []*models.FsiDiagnoseDtos
  3166. for index, item := range config {
  3167. if index == 0 {
  3168. var fdd models.FsiDiagnoseDtos
  3169. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3170. fdd.InoutDiseType = "1"
  3171. fdd.MaindiseFlag = "1"
  3172. fdd.DiseDate = s_tm
  3173. fdd.DiasSrtNo = "1"
  3174. fdd.DiseName = item.CountryContentName
  3175. fdd.DiseCodg = item.CountryCode
  3176. fdds = append(fdds, &fdd)
  3177. } else {
  3178. var fdd models.FsiDiagnoseDtos
  3179. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3180. fdd.InoutDiseType = "1"
  3181. fdd.MaindiseFlag = "1"
  3182. fdd.DiseDate = s_tm
  3183. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  3184. fdd.DiseName = item.CountryContentName
  3185. fdd.DiseCodg = item.CountryCode
  3186. fdds = append(fdds, &fdd)
  3187. }
  3188. }
  3189. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  3190. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  3191. fed.AdmDeptName = department.Name
  3192. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  3193. fed.DscgDeptName = department.Name
  3194. fed.MedMdtrtType = "1"
  3195. fed.MedType = "11"
  3196. //if his.Insutype == "390" {
  3197. // fed.MedType = "1402"
  3198. //} else {
  3199. // fed.MedType = "9933"
  3200. //}
  3201. var orders []*models.FsiOrderDtos
  3202. if trig_scen == "2" {
  3203. //处方医嘱信息
  3204. for _, item := range prescriptions {
  3205. for _, subItem := range item.HisDoctorAdviceInfo {
  3206. var order models.FsiOrderDtos
  3207. order.RxID = strconv.FormatInt(item.ID, 10)
  3208. order.Rxno = strconv.FormatInt(item.ID, 10)
  3209. order.LongDrordFlag = "0"
  3210. order.HilistType = "1"
  3211. order.ChrgType = "1"
  3212. order.DrordBhvr = "-"
  3213. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3214. order.HosplistName = subItem.BaseDrugLib.DrugName
  3215. order.HilistLv = "1"
  3216. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3217. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3218. order.HosplistName = subItem.BaseDrugLib.DrugName
  3219. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  3220. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3221. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  3222. order.OwnpayAmt = ""
  3223. order.SelfpayAmt = ""
  3224. order.Spec = ""
  3225. order.SpecUnt = ""
  3226. order.DrordBegnDate = s_tm
  3227. order.DrordStopDate = ""
  3228. order.DrordDrCodg = "1"
  3229. order.DrordDeptName = department.Name
  3230. order.DrordDrCodg = "1"
  3231. order.DrordDrName = doctor_info.UserName
  3232. order.DrordDrProfttl = ""
  3233. order.CurrDrordFlag = "1"
  3234. orders = append(orders, &order)
  3235. }
  3236. for _, subItem := range item.HisPrescriptionProject {
  3237. if subItem.Type == 2 {
  3238. var order models.FsiOrderDtos
  3239. order.RxID = strconv.FormatInt(item.ID, 10)
  3240. order.Rxno = strconv.FormatInt(item.ID, 10)
  3241. order.LongDrordFlag = "0"
  3242. order.HilistType = "1"
  3243. order.ChrgType = "1"
  3244. order.DrordBhvr = "-"
  3245. order.HilistCode = subItem.HisProject.MedicalCode
  3246. order.HosplistName = subItem.HisProject.ProjectName
  3247. order.HilistLv = "1"
  3248. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3249. order.HosplistCode = subItem.HisProject.MedicalCode
  3250. order.HosplistName = subItem.HisProject.ProjectName
  3251. order.Cnt = subItem.Count
  3252. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3253. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3254. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3255. order.OwnpayAmt = ""
  3256. order.SelfpayAmt = ""
  3257. order.Spec = ""
  3258. order.SpecUnt = ""
  3259. order.DrordBegnDate = s_tm
  3260. order.DrordStopDate = ""
  3261. order.DrordDrCodg = "1"
  3262. order.DrordDeptName = department.Name
  3263. order.DrordDrCodg = "1"
  3264. order.DrordDrName = doctor_info.UserName
  3265. order.DrordDrProfttl = ""
  3266. order.CurrDrordFlag = "1"
  3267. orders = append(orders, &order)
  3268. }
  3269. if subItem.Type == 3 {
  3270. var order models.FsiOrderDtos
  3271. order.RxID = strconv.FormatInt(item.ID, 10)
  3272. order.Rxno = strconv.FormatInt(item.ID, 10)
  3273. order.LongDrordFlag = "0"
  3274. order.HilistType = "1"
  3275. order.ChrgType = "1"
  3276. order.DrordBhvr = "-"
  3277. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3278. order.HosplistName = subItem.GoodInfo.GoodName
  3279. order.HilistLv = "1"
  3280. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3281. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3282. order.HosplistName = subItem.GoodInfo.GoodName
  3283. order.Cnt = subItem.Count
  3284. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3285. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3286. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3287. order.OwnpayAmt = ""
  3288. order.SelfpayAmt = ""
  3289. order.Spec = ""
  3290. order.SpecUnt = ""
  3291. order.DrordBegnDate = s_tm
  3292. order.DrordStopDate = ""
  3293. order.DrordDrCodg = "1"
  3294. order.DrordDeptName = department.Name
  3295. order.DrordDrCodg = "1"
  3296. order.DrordDrName = doctor_info.UserName
  3297. order.DrordDrProfttl = ""
  3298. order.CurrDrordFlag = "1"
  3299. orders = append(orders, &order)
  3300. }
  3301. }
  3302. }
  3303. //处方医嘱信息
  3304. }
  3305. fed.MatnStas = "0"
  3306. fed.MedfeeSumamt = "0"
  3307. fed.OwnpayAmt = "0"
  3308. fed.SelfpayAmt = "0"
  3309. fed.AcctPayamt = "0"
  3310. fed.MaAmt = "0"
  3311. fed.HifpPayamt = "0"
  3312. fed.SetlTotlnum = "1"
  3313. fed.Insutype = his.Insutype
  3314. fed.ReimFlag = "0"
  3315. fed.OutSetlFlag = "0"
  3316. var fopd []*models.FsiOperationDtosData
  3317. data := make(map[string]interface{})
  3318. data["fed"] = fed
  3319. data["fdd"] = fdds
  3320. data["fod"] = orders
  3321. data["pd"] = pd
  3322. data["pp"] = pp
  3323. data["fopd"] = fopd
  3324. data["trig_scen"] = trig_scen
  3325. fmt.Println(data)
  3326. fmt.Println(fed)
  3327. fmt.Println(fdds)
  3328. fmt.Println(orders)
  3329. fmt.Println(pd)
  3330. fmt.Println(pp)
  3331. fmt.Println(fopd)
  3332. client := &http.Client{}
  3333. bytesData, _ := json.Marshal(data)
  3334. var req *http.Request
  3335. if miConfig.MdtrtareaAdmvs == "320921" {
  3336. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  3337. } else {
  3338. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  3339. }
  3340. resp, _ := client.Do(req)
  3341. defer resp.Body.Close()
  3342. body, ioErr := ioutil.ReadAll(resp.Body)
  3343. if ioErr != nil {
  3344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3346. return res
  3347. }
  3348. var respJSON map[string]interface{}
  3349. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3352. return res
  3353. }
  3354. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3355. fmt.Println(respJSON)
  3356. result, _ := json.Marshal(respJSON)
  3357. fmt.Println(result)
  3358. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3359. utils.ErrorLog("解析失败:%v", err)
  3360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3361. return res
  3362. }
  3363. return res
  3364. }
  3365. 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) {
  3366. adminUser := c.GetAdminUserInfo()
  3367. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3368. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3369. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3370. //record_time := c.GetString("record_time")
  3371. //trig_scen := c.GetString("trig_scen")
  3372. timeLayout := "2006-01-02"
  3373. loc, _ := time.LoadLocation("Local")
  3374. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3375. if err != nil {
  3376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3377. return res
  3378. }
  3379. recordDateTime := theTime.Unix()
  3380. var patientPrescription models.HisPrescriptionInfo
  3381. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3382. if patientPrescription.ID == 0 {
  3383. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3384. }
  3385. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3386. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3387. //
  3388. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  3389. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3390. var pp models.PublicParams
  3391. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3392. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3393. pp.FixmedinsName = miConfig.OrgName
  3394. pp.FixmedinsCode = miConfig.Code
  3395. pp.RequestUrl = miConfig.Url
  3396. pp.Cainfo = miConfig.Cainfo
  3397. pp.SecretKey = miConfig.SecretKey
  3398. pp.AccessKey = miConfig.AccessKey
  3399. pp.OpterName = roles.UserName
  3400. var config []*models.HisXtDiagnoseConfig
  3401. for _, item := range diagnosis_ids {
  3402. id, _ := strconv.ParseInt(item, 10, 64)
  3403. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3404. config = append(config, &diagnosisConfig)
  3405. }
  3406. var pd models.PatientDtos
  3407. pd.PatnID = his.PsnNo
  3408. pd.PatnName = his.Name
  3409. pd.Gend = his.Gend
  3410. pd.Brdy = his.Brdy
  3411. pd.Poolarea = his.InsuplcAdmdvs
  3412. pd.CurrMdtrtID = his.Number
  3413. var fed models.FsiEncounterDtos
  3414. fed.MdtrtID = his.Number
  3415. fed.MedinsID = miConfig.Code
  3416. fed.MedinsName = miConfig.OrgName
  3417. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  3418. fed.MedMdtrtType = "1"
  3419. fed.MedinsType = "1"
  3420. fed.MedinsLv = "11"
  3421. tm := time.Unix(his.RecordDate, 0)
  3422. s_tm := tm.Format("2006-01-02 15:04:05")
  3423. fed.AdmDate = s_tm
  3424. fed.DscgDate = s_tm
  3425. fed.DscgMainDiseCodg = config[0].CountryCode
  3426. fed.DscgMainDiseName = config[0].CountryContentName
  3427. //诊断信息
  3428. var fdds []*models.FsiDiagnoseDtos
  3429. for index, item := range config {
  3430. if index == 0 {
  3431. var fdd models.FsiDiagnoseDtos
  3432. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3433. fdd.InoutDiseType = "1"
  3434. fdd.MaindiseFlag = "1"
  3435. fdd.DiseDate = s_tm
  3436. fdd.DiasSrtNo = "1"
  3437. fdd.DiseName = item.CountryContentName
  3438. fdd.DiseCodg = item.CountryCode
  3439. fdds = append(fdds, &fdd)
  3440. } else {
  3441. var fdd models.FsiDiagnoseDtos
  3442. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3443. fdd.InoutDiseType = "1"
  3444. fdd.MaindiseFlag = "1"
  3445. fdd.DiseDate = s_tm
  3446. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  3447. fdd.DiseName = item.CountryContentName
  3448. fdd.DiseCodg = item.CountryCode
  3449. fdds = append(fdds, &fdd)
  3450. }
  3451. }
  3452. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  3453. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  3454. fed.AdmDeptName = department.Name
  3455. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  3456. fed.DscgDeptName = department.Name
  3457. fed.MedMdtrtType = "1"
  3458. fed.MedType = "11"
  3459. //if his.Insutype == "390" {
  3460. // fed.MedType = "1402"
  3461. //} else {
  3462. // fed.MedType = "9933"
  3463. //}
  3464. var orders []*models.FsiOrderDtos
  3465. if trig_scen == "2" {
  3466. //处方医嘱信息
  3467. for _, item := range prescriptions {
  3468. for _, subItem := range item.HisDoctorAdviceInfo {
  3469. var order models.FsiOrderDtos
  3470. order.RxID = strconv.FormatInt(item.ID, 10)
  3471. order.Rxno = strconv.FormatInt(item.ID, 10)
  3472. order.LongDrordFlag = "0"
  3473. order.HilistType = "1"
  3474. order.ChrgType = "1"
  3475. order.DrordBhvr = "-"
  3476. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3477. order.HosplistName = subItem.BaseDrugLib.DrugName
  3478. order.HilistLv = "1"
  3479. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3480. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3481. order.HosplistName = subItem.BaseDrugLib.DrugName
  3482. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  3483. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3484. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  3485. order.OwnpayAmt = ""
  3486. order.SelfpayAmt = ""
  3487. order.Spec = ""
  3488. order.SpecUnt = ""
  3489. order.DrordBegnDate = s_tm
  3490. order.DrordStopDate = ""
  3491. order.DrordDrCodg = "1"
  3492. order.DrordDeptName = department.Name
  3493. order.DrordDrCodg = "1"
  3494. order.DrordDrName = doctor_info.UserName
  3495. order.DrordDrProfttl = ""
  3496. order.CurrDrordFlag = "1"
  3497. orders = append(orders, &order)
  3498. }
  3499. for _, subItem := range item.HisPrescriptionProject {
  3500. if subItem.Type == 2 {
  3501. var order models.FsiOrderDtos
  3502. order.RxID = strconv.FormatInt(item.ID, 10)
  3503. order.Rxno = strconv.FormatInt(item.ID, 10)
  3504. order.LongDrordFlag = "0"
  3505. order.HilistType = "1"
  3506. order.ChrgType = "1"
  3507. order.DrordBhvr = "-"
  3508. order.HilistCode = subItem.HisProject.MedicalCode
  3509. order.HosplistName = subItem.HisProject.ProjectName
  3510. order.HilistLv = "1"
  3511. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3512. order.HosplistCode = subItem.HisProject.MedicalCode
  3513. order.HosplistName = subItem.HisProject.ProjectName
  3514. order.Cnt = subItem.Count
  3515. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3516. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3517. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3518. order.OwnpayAmt = ""
  3519. order.SelfpayAmt = ""
  3520. order.Spec = ""
  3521. order.SpecUnt = ""
  3522. order.DrordBegnDate = s_tm
  3523. order.DrordStopDate = ""
  3524. order.DrordDrCodg = "1"
  3525. order.DrordDeptName = department.Name
  3526. order.DrordDrCodg = "1"
  3527. order.DrordDrName = doctor_info.UserName
  3528. order.DrordDrProfttl = ""
  3529. order.CurrDrordFlag = "1"
  3530. orders = append(orders, &order)
  3531. }
  3532. if subItem.Type == 3 {
  3533. var order models.FsiOrderDtos
  3534. order.RxID = strconv.FormatInt(item.ID, 10)
  3535. order.Rxno = strconv.FormatInt(item.ID, 10)
  3536. order.LongDrordFlag = "0"
  3537. order.HilistType = "1"
  3538. order.ChrgType = "1"
  3539. order.DrordBhvr = "-"
  3540. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3541. order.HosplistName = subItem.GoodInfo.GoodName
  3542. order.HilistLv = "1"
  3543. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3544. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3545. order.HosplistName = subItem.GoodInfo.GoodName
  3546. order.Cnt = subItem.Count
  3547. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3548. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3549. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3550. order.OwnpayAmt = ""
  3551. order.SelfpayAmt = ""
  3552. order.Spec = ""
  3553. order.SpecUnt = ""
  3554. order.DrordBegnDate = s_tm
  3555. order.DrordStopDate = ""
  3556. order.DrordDrCodg = "1"
  3557. order.DrordDeptName = department.Name
  3558. order.DrordDrCodg = "1"
  3559. order.DrordDrName = doctor_info.UserName
  3560. order.DrordDrProfttl = ""
  3561. order.CurrDrordFlag = "1"
  3562. orders = append(orders, &order)
  3563. }
  3564. }
  3565. }
  3566. //处方医嘱信息
  3567. }
  3568. fed.MatnStas = "0"
  3569. fed.MedfeeSumamt = "0"
  3570. fed.OwnpayAmt = "0"
  3571. fed.SelfpayAmt = "0"
  3572. fed.AcctPayamt = "0"
  3573. fed.MaAmt = "0"
  3574. fed.HifpPayamt = "0"
  3575. fed.SetlTotlnum = "1"
  3576. fed.Insutype = his.Insutype
  3577. fed.ReimFlag = "0"
  3578. fed.OutSetlFlag = "0"
  3579. var fopd []*models.FsiOperationDtosData
  3580. data := make(map[string]interface{})
  3581. data["fed"] = fed
  3582. data["fdd"] = fdds
  3583. data["fod"] = orders
  3584. data["pd"] = pd
  3585. data["pp"] = pp
  3586. data["fopd"] = fopd
  3587. data["trig_scen"] = trig_scen
  3588. fmt.Println(data)
  3589. fmt.Println(fed)
  3590. fmt.Println(fdds)
  3591. fmt.Println(orders)
  3592. fmt.Println(pd)
  3593. fmt.Println(pp)
  3594. fmt.Println(fopd)
  3595. client := &http.Client{}
  3596. bytesData, _ := json.Marshal(data)
  3597. var req *http.Request
  3598. if miConfig.MdtrtareaAdmvs == "320921" {
  3599. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  3600. } else {
  3601. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  3602. }
  3603. resp, _ := client.Do(req)
  3604. defer resp.Body.Close()
  3605. body, ioErr := ioutil.ReadAll(resp.Body)
  3606. if ioErr != nil {
  3607. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3609. return res
  3610. }
  3611. var respJSON map[string]interface{}
  3612. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3613. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3615. return res
  3616. }
  3617. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3618. result, _ := json.Marshal(respJSON)
  3619. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3620. utils.ErrorLog("解析失败:%v", err)
  3621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3622. return res
  3623. }
  3624. return res
  3625. }
  3626. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  3627. ////patient_id, _ := c.GetInt64("patient_id")
  3628. //order_id, _ := c.GetInt64("order_id")
  3629. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  3630. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  3631. //trig_scen := c.GetString("trig_scen")
  3632. adminUser := c.GetAdminUserInfo()
  3633. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3634. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3635. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3636. record_time := c.GetString("record_time")
  3637. order, _ := service.GetHisOrderByID(order_id)
  3638. timeLayout := "2006-01-02"
  3639. loc, _ := time.LoadLocation("Local")
  3640. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3641. if err != nil {
  3642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3643. return
  3644. }
  3645. recordDateTime := theTime.Unix()
  3646. var patientPrescription models.HisPrescriptionInfo
  3647. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3648. if patientPrescription.ID == 0 {
  3649. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3650. }
  3651. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3652. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3653. //
  3654. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3655. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3656. var pp models.PublicParams
  3657. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3658. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3659. pp.FixmedinsName = miConfig.OrgName
  3660. pp.FixmedinsCode = miConfig.Code
  3661. pp.RequestUrl = miConfig.Url
  3662. pp.Cainfo = miConfig.Cainfo
  3663. pp.SecretKey = miConfig.SecretKey
  3664. pp.AccessKey = miConfig.AccessKey
  3665. pp.OpterName = roles.UserName
  3666. var config []*models.HisXtDiagnoseConfig
  3667. for _, item := range diagnosis_ids {
  3668. id, _ := strconv.ParseInt(item, 10, 64)
  3669. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3670. config = append(config, &diagnosisConfig)
  3671. }
  3672. var pd models.PatientDtos
  3673. pd.PatnID = his.PsnNo
  3674. pd.PatnName = his.Name
  3675. pd.Gend = his.Gend
  3676. pd.Brdy = his.Brdy
  3677. pd.Poolarea = his.InsuplcAdmdvs
  3678. pd.CurrMdtrtID = his.Number
  3679. var fed models.FsiEncounterDtos
  3680. fed.MdtrtID = his.Number
  3681. fed.MedinsID = miConfig.Code
  3682. fed.MedinsName = miConfig.OrgName
  3683. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  3684. fed.MedMdtrtType = "1"
  3685. fed.MedinsType = "1"
  3686. fed.MedinsLv = "11"
  3687. tm := time.Unix(his.RecordDate, 0)
  3688. s_tm := tm.Format("2006-01-02 15:04:05")
  3689. fed.AdmDate = s_tm
  3690. fed.DscgDate = s_tm
  3691. fed.DscgMainDiseCodg = config[0].CountryCode
  3692. fed.DscgMainDiseName = config[0].CountryContentName
  3693. //诊断信息
  3694. var fdds []*models.FsiDiagnoseDtos
  3695. for index, item := range config {
  3696. if index == 0 {
  3697. var fdd models.FsiDiagnoseDtos
  3698. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3699. fdd.InoutDiseType = "1"
  3700. fdd.MaindiseFlag = "1"
  3701. fdd.DiseDate = s_tm
  3702. fdd.DiasSrtNo = "1"
  3703. fdd.DiseName = item.CountryContentName
  3704. fdd.DiseCodg = item.CountryCode
  3705. fdds = append(fdds, &fdd)
  3706. } else {
  3707. var fdd models.FsiDiagnoseDtos
  3708. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3709. fdd.InoutDiseType = "1"
  3710. fdd.MaindiseFlag = "1"
  3711. fdd.DiseDate = s_tm
  3712. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  3713. fdd.DiseName = item.CountryContentName
  3714. fdd.DiseCodg = item.CountryCode
  3715. fdds = append(fdds, &fdd)
  3716. }
  3717. }
  3718. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  3719. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  3720. fed.AdmDeptName = department.Name
  3721. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  3722. fed.DscgDeptName = department.Name
  3723. fed.MedType = order.MedType
  3724. //处方医嘱信息
  3725. var orders []*models.FsiOrderDtos
  3726. //for _, item := range prescriptions {
  3727. // for _, subItem := range item.HisDoctorAdviceInfo {
  3728. // var order models.FsiOrderDtos
  3729. // order.RxID = strconv.FormatInt(item.ID, 10)
  3730. // order.Rxno = strconv.FormatInt(item.ID, 10)
  3731. // order.LongDrordFlag = "0"
  3732. // order.HilistType = "1"
  3733. // order.ChrgType = "1"
  3734. // order.DrordBhvr = "-"
  3735. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3736. // order.HosplistName = subItem.BaseDrugLib.DrugName
  3737. // order.HilistLv = "1"
  3738. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  3739. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3740. // order.HosplistName = subItem.BaseDrugLib.DrugName
  3741. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  3742. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  3743. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  3744. // order.OwnpayAmt = ""
  3745. // order.SelfpayAmt = ""
  3746. // order.Spec = ""
  3747. // order.SpecUnt = ""
  3748. // order.DrordBegnDate = s_tm
  3749. // order.DrordStopDate = ""
  3750. // order.DrordDrCodg = "1"
  3751. // order.DrordDeptName = department.Name
  3752. // order.DrordDrCodg = "1"
  3753. // order.DrordDrName = doctor_info.UserName
  3754. // order.DrordDrProfttl = ""
  3755. // order.CurrDrordFlag = "1"
  3756. // orders = append(orders, &order)
  3757. // }
  3758. // for _, subItem := range item.HisPrescriptionProject {
  3759. // if subItem.Type == 2 {
  3760. // var order models.FsiOrderDtos
  3761. // order.RxID = strconv.FormatInt(item.ID, 10)
  3762. // order.Rxno = strconv.FormatInt(item.ID, 10)
  3763. // order.LongDrordFlag = "0"
  3764. // order.HilistType = "1"
  3765. // order.ChrgType = "1"
  3766. // order.DrordBhvr = "-"
  3767. // order.HilistCode = subItem.HisProject.MedicalCode
  3768. // order.HosplistName = subItem.HisProject.ProjectName
  3769. // order.HilistLv = "1"
  3770. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  3771. // order.HosplistCode = subItem.HisProject.MedicalCode
  3772. // order.HosplistName = subItem.HisProject.ProjectName
  3773. // order.Cnt = subItem.Count
  3774. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3775. //
  3776. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  3777. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  3778. // order.OwnpayAmt = ""
  3779. // order.SelfpayAmt = ""
  3780. // order.Spec = ""
  3781. // order.SpecUnt = ""
  3782. // order.DrordBegnDate = s_tm
  3783. // order.DrordStopDate = ""
  3784. // order.DrordDrCodg = "1"
  3785. // order.DrordDeptName = department.Name
  3786. // order.DrordDrCodg = "1"
  3787. // order.DrordDrName = doctor_info.UserName
  3788. // order.DrordDrProfttl = ""
  3789. // order.CurrDrordFlag = "1"
  3790. // orders = append(orders, &order)
  3791. //
  3792. // }
  3793. // if subItem.Type == 3 {
  3794. //
  3795. // var order models.FsiOrderDtos
  3796. // order.RxID = strconv.FormatInt(item.ID, 10)
  3797. // order.Rxno = strconv.FormatInt(item.ID, 10)
  3798. // order.LongDrordFlag = "0"
  3799. // order.HilistType = "1"
  3800. // order.ChrgType = "1"
  3801. // order.DrordBhvr = "-"
  3802. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3803. // order.HosplistName = subItem.GoodInfo.GoodName
  3804. // order.HilistLv = "1"
  3805. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  3806. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3807. // order.HosplistName = subItem.GoodInfo.GoodName
  3808. // order.Cnt = subItem.Count
  3809. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3810. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  3811. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  3812. // order.OwnpayAmt = ""
  3813. // order.SelfpayAmt = ""
  3814. // order.Spec = ""
  3815. // order.SpecUnt = ""
  3816. // order.DrordBegnDate = s_tm
  3817. // order.DrordStopDate = ""
  3818. // order.DrordDrCodg = "1"
  3819. // order.DrordDeptName = department.Name
  3820. // order.DrordDrCodg = "1"
  3821. // order.DrordDrName = doctor_info.UserName
  3822. // order.DrordDrProfttl = ""
  3823. // order.CurrDrordFlag = "1"
  3824. // orders = append(orders, &order)
  3825. //
  3826. // }
  3827. // }
  3828. //}
  3829. for _, item := range prescriptions {
  3830. for _, subItem := range item.HisDoctorAdviceInfo {
  3831. var order models.FsiOrderDtos
  3832. order.RxID = strconv.FormatInt(item.ID, 10)
  3833. order.Rxno = strconv.FormatInt(item.ID, 10)
  3834. order.LongDrordFlag = "0"
  3835. order.HilistType = "1"
  3836. order.ChrgType = "1"
  3837. order.DrordBhvr = "-"
  3838. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3839. order.HosplistName = subItem.BaseDrugLib.DrugName
  3840. order.HilistLv = "1"
  3841. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3842. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3843. order.HosplistName = subItem.BaseDrugLib.DrugName
  3844. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  3845. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3846. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  3847. order.OwnpayAmt = ""
  3848. order.SelfpayAmt = ""
  3849. order.Spec = ""
  3850. order.SpecUnt = ""
  3851. order.DrordBegnDate = s_tm
  3852. order.DrordStopDate = ""
  3853. order.DrordDrCodg = "1"
  3854. order.DrordDeptName = department.Name
  3855. order.DrordDrCodg = "1"
  3856. order.DrordDrName = doctor_info.UserName
  3857. order.DrordDrProfttl = ""
  3858. order.CurrDrordFlag = "1"
  3859. orders = append(orders, &order)
  3860. }
  3861. for _, subItem := range item.HisPrescriptionProject {
  3862. if subItem.Type == 2 {
  3863. var order models.FsiOrderDtos
  3864. order.RxID = strconv.FormatInt(item.ID, 10)
  3865. order.Rxno = strconv.FormatInt(item.ID, 10)
  3866. order.LongDrordFlag = "0"
  3867. order.HilistType = "1"
  3868. order.ChrgType = "1"
  3869. order.DrordBhvr = "-"
  3870. order.HilistCode = subItem.HisProject.MedicalCode
  3871. order.HosplistName = subItem.HisProject.ProjectName
  3872. order.HilistLv = "1"
  3873. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3874. order.HosplistCode = subItem.HisProject.MedicalCode
  3875. order.HosplistName = subItem.HisProject.ProjectName
  3876. order.Cnt = subItem.Count
  3877. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3878. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3879. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3880. order.OwnpayAmt = ""
  3881. order.SelfpayAmt = ""
  3882. order.Spec = ""
  3883. order.SpecUnt = ""
  3884. order.DrordBegnDate = s_tm
  3885. order.DrordStopDate = ""
  3886. order.DrordDrCodg = "1"
  3887. order.DrordDeptName = department.Name
  3888. order.DrordDrCodg = "1"
  3889. order.DrordDrName = doctor_info.UserName
  3890. order.DrordDrProfttl = ""
  3891. order.CurrDrordFlag = "1"
  3892. orders = append(orders, &order)
  3893. }
  3894. if subItem.Type == 3 {
  3895. var order models.FsiOrderDtos
  3896. order.RxID = strconv.FormatInt(item.ID, 10)
  3897. order.Rxno = strconv.FormatInt(item.ID, 10)
  3898. order.LongDrordFlag = "0"
  3899. order.HilistType = "1"
  3900. order.ChrgType = "1"
  3901. order.DrordBhvr = "-"
  3902. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3903. order.HosplistName = subItem.GoodInfo.GoodName
  3904. order.HilistLv = "1"
  3905. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3906. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3907. order.HosplistName = subItem.GoodInfo.GoodName
  3908. order.Cnt = subItem.Count
  3909. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3910. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3911. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3912. order.OwnpayAmt = ""
  3913. order.SelfpayAmt = ""
  3914. order.Spec = ""
  3915. order.SpecUnt = ""
  3916. order.DrordBegnDate = s_tm
  3917. order.DrordStopDate = ""
  3918. order.DrordDrCodg = "1"
  3919. order.DrordDeptName = department.Name
  3920. order.DrordDrCodg = "1"
  3921. order.DrordDrName = doctor_info.UserName
  3922. order.DrordDrProfttl = ""
  3923. order.CurrDrordFlag = "1"
  3924. orders = append(orders, &order)
  3925. }
  3926. }
  3927. }
  3928. //处方医嘱信息
  3929. fed.MatnStas = "0"
  3930. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3931. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  3932. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  3933. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  3934. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  3935. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  3936. fed.SetlTotlnum = "1"
  3937. fed.Insutype = his.Insutype
  3938. fed.ReimFlag = "0"
  3939. fed.OutSetlFlag = "0"
  3940. var fopd []*models.FsiOperationDtosData
  3941. data := make(map[string]interface{})
  3942. data["fed"] = fed
  3943. data["fdd"] = fdds
  3944. data["fod"] = orders
  3945. data["pd"] = pd
  3946. data["pp"] = pp
  3947. data["fopd"] = fopd
  3948. data["trig_scen"] = trig_scen
  3949. client := &http.Client{}
  3950. bytesData, _ := json.Marshal(data)
  3951. var req *http.Request
  3952. if miConfig.MdtrtareaAdmvs == "320921" {
  3953. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  3954. } else {
  3955. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  3956. }
  3957. resp, _ := client.Do(req)
  3958. defer resp.Body.Close()
  3959. body, ioErr := ioutil.ReadAll(resp.Body)
  3960. if ioErr != nil {
  3961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3963. return res
  3964. }
  3965. var respJSON map[string]interface{}
  3966. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3969. return res
  3970. }
  3971. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3972. result, _ := json.Marshal(respJSON)
  3973. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3974. utils.ErrorLog("解析失败:%v", err)
  3975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3976. return res
  3977. }
  3978. return res
  3979. //手术操作集合
  3980. //手术操作集合
  3981. }
  3982. func (c *HisApiController) Check() {
  3983. psn_no := c.GetString("psn_no")
  3984. in := c.GetString("in")
  3985. mt := c.GetString("mt")
  3986. baseParams := models.BaseParams{
  3987. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  3988. FixmedinsCode: "H15049901371",
  3989. InsuplcAdmdvs: "150499",
  3990. MdtrtareaAdmvs: "150499",
  3991. OrgName: "赤峰费森血液透析中心",
  3992. Doctor: "1111",
  3993. }
  3994. service.Gdyb2001(baseParams, psn_no, in, mt)
  3995. }
  3996. func (c *HisApiController) GetPsnNcdsInfo() {
  3997. admin_user_id, _ := c.GetInt64("admin_user_id")
  3998. patient_id, _ := c.GetInt64("patient_id")
  3999. id, _ := c.GetInt64("id")
  4000. adminUser := c.GetAdminUserInfo()
  4001. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4002. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4003. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  4004. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4005. psn_record, _ := service.GetPsnNCDSRecordById(id)
  4006. //
  4007. //if psn_record.ID == 0 {
  4008. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  4009. // return
  4010. //}
  4011. var res Result5301
  4012. var res10265 Result5301For10265
  4013. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4014. psn_info, _ := service.GetPsnByPatientId(patient_id)
  4015. var api string
  4016. if miConfig.MdtrtareaAdmvs == "320921" {
  4017. api = "http://192.168.2.3:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  4018. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  4019. } else {
  4020. 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 +
  4021. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  4022. }
  4023. resp, requestErr := http.Get(api)
  4024. if requestErr != nil {
  4025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4026. return
  4027. }
  4028. body, ioErr := ioutil.ReadAll(resp.Body)
  4029. if ioErr != nil {
  4030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4032. return
  4033. }
  4034. var respJSON map[string]interface{}
  4035. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4038. return
  4039. }
  4040. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4041. result, _ := json.Marshal(respJSON)
  4042. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4043. utils.ErrorLog("解析失败:%v", err)
  4044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4045. return
  4046. }
  4047. res.ErrMsg = res10265.ErrMsg
  4048. res.Output = res10265.Output
  4049. res.InfRefmsgid = res10265.InfRefmsgid
  4050. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4051. res.Infcode = infocode
  4052. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4053. p, _ := service.GetHisPatientById(patient_id)
  4054. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  4055. var dat map[string]interface{}
  4056. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4057. fmt.Println(dat)
  4058. } else {
  4059. fmt.Println(err)
  4060. }
  4061. userJSONBytes, _ := json.Marshal(dat)
  4062. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4063. utils.ErrorLog("解析失败:%v", err)
  4064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4065. return
  4066. }
  4067. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4068. p, _ := service.GetHisPatientById(patient_id)
  4069. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  4070. var dat map[string]interface{}
  4071. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4072. fmt.Println(dat)
  4073. } else {
  4074. fmt.Println(err)
  4075. }
  4076. userJSONBytes, _ := json.Marshal(dat)
  4077. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4078. utils.ErrorLog("解析失败:%v", err)
  4079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4080. return
  4081. }
  4082. } else {
  4083. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4084. var dat map[string]interface{}
  4085. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4086. fmt.Println(dat)
  4087. } else {
  4088. fmt.Println(err)
  4089. }
  4090. userJSONBytes, _ := json.Marshal(dat)
  4091. if miConfig.Code == "H15049901371" {
  4092. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  4093. utils.ErrorLog("解析失败:%v", err)
  4094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4095. return
  4096. }
  4097. res.InfRefmsgid = res10265.InfRefmsgid
  4098. res.Output = res10265.Output
  4099. res.ErrMsg = res10265.ErrMsg
  4100. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4101. res.Infcode = infocode
  4102. } else {
  4103. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4104. utils.ErrorLog("解析失败:%v", err)
  4105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4106. return
  4107. }
  4108. }
  4109. }
  4110. if res.Infcode == 0 {
  4111. c.ServeSuccessJSON(map[string]interface{}{
  4112. "result": res.Output.Result,
  4113. })
  4114. }
  4115. }
  4116. func (c *HisApiController) CheckInsutype() {
  4117. his_patient_id, _ := c.GetInt64("his_patient_id")
  4118. admin_user_id, _ := c.GetInt64("admin_user_id")
  4119. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4120. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4121. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4122. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4123. var dat map[string]interface{}
  4124. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4125. fmt.Println(dat)
  4126. } else {
  4127. fmt.Println(err)
  4128. }
  4129. userJSONBytes, _ := json.Marshal(dat)
  4130. var res Result90100
  4131. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4132. utils.ErrorLog("解析失败:%v", err)
  4133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4134. return
  4135. }
  4136. if res.Infcode != 0 {
  4137. c.ServeSuccessJSON(map[string]interface{}{
  4138. "failed_code": -10,
  4139. "msg": res.ErrMsg,
  4140. })
  4141. return
  4142. } else {
  4143. fmt.Println(res)
  4144. }
  4145. }
  4146. func (c *HisApiController) CheckCardPWD() {
  4147. card_pwd := c.GetString("card_pwd")
  4148. his_patient_id, _ := c.GetInt64("his_patient_id")
  4149. admin_user_id, _ := c.GetInt64("admin_user_id")
  4150. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4151. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4152. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4153. psn, _ := service.GetPsnByPatientId(his.PatientId)
  4154. bas := strings.Split(psn.CardInfo, "|")
  4155. basNumber := bas[2]
  4156. if psn.InsuplcAdmdvs[:4] == "4403" {
  4157. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  4158. var dat map[string]interface{}
  4159. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4160. fmt.Println(dat)
  4161. } else {
  4162. fmt.Println(err)
  4163. }
  4164. userJSONBytes, _ := json.Marshal(dat)
  4165. var res Result90991
  4166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4167. utils.ErrorLog("解析失败:%v", err)
  4168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4169. return
  4170. }
  4171. if res.Infcode != 0 {
  4172. c.ServeSuccessJSON(map[string]interface{}{
  4173. "failed_code": -10,
  4174. "msg": res.ErrMsg,
  4175. })
  4176. return
  4177. } else {
  4178. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  4179. var msg string
  4180. switch res.Output.Result.CardStat {
  4181. case "00":
  4182. msg = "未激活"
  4183. break
  4184. case "10":
  4185. msg = "激活"
  4186. break
  4187. case "20":
  4188. msg = "窗口挂失"
  4189. break
  4190. case "21":
  4191. msg = "电话挂失"
  4192. break
  4193. case "22":
  4194. msg = "单位网上申报挂失"
  4195. break
  4196. case "23":
  4197. msg = "保健办挂失"
  4198. break
  4199. case "24":
  4200. msg = "个人网上挂失"
  4201. break
  4202. case "25":
  4203. msg = "网上服务大厅挂失"
  4204. break
  4205. case "30":
  4206. msg = "注销"
  4207. break
  4208. case "40":
  4209. msg = "回收"
  4210. break
  4211. case "99":
  4212. msg = "制卡中(无效卡)"
  4213. break
  4214. }
  4215. c.ServeSuccessJSON(map[string]interface{}{
  4216. "failed_code": -10,
  4217. "msg": msg,
  4218. })
  4219. return
  4220. } else {
  4221. c.ServeSuccessJSON(map[string]interface{}{
  4222. "msg": "校验成功",
  4223. })
  4224. return
  4225. }
  4226. }
  4227. } else {
  4228. c.ServeSuccessJSON(map[string]interface{}{
  4229. "msg": "校验成功",
  4230. })
  4231. return
  4232. }
  4233. }
  4234. func (c *HisApiController) CheckCardPWDTwo() {
  4235. //card_pwd := c.GetString("card_pwd")
  4236. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4237. admin_user_id, _ := c.GetInt64("admin_user_id")
  4238. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4239. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4240. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  4241. var dat map[string]interface{}
  4242. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4243. fmt.Println(dat)
  4244. } else {
  4245. fmt.Println(err)
  4246. }
  4247. userJSONBytes, _ := json.Marshal(dat)
  4248. var res Result90991
  4249. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4250. utils.ErrorLog("解析失败:%v", err)
  4251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4252. return
  4253. }
  4254. if res.Infcode != 0 {
  4255. c.ServeSuccessJSON(map[string]interface{}{
  4256. "failed_code": -10,
  4257. "msg": res.ErrMsg,
  4258. })
  4259. return
  4260. } else {
  4261. if res.Output.Result.SscnoCheckStat == "0" {
  4262. var msg string
  4263. switch res.Output.Result.CardStat {
  4264. case "00":
  4265. msg = "未激活"
  4266. break
  4267. case "10":
  4268. msg = "激活"
  4269. break
  4270. case "20":
  4271. msg = "窗口挂失"
  4272. break
  4273. case "21":
  4274. msg = "电话挂失"
  4275. break
  4276. case "22":
  4277. msg = "单位网上申报挂失"
  4278. break
  4279. case "23":
  4280. msg = "保健办挂失"
  4281. break
  4282. case "24":
  4283. msg = "个人网上挂失"
  4284. break
  4285. case "25":
  4286. msg = "网上服务大厅挂失"
  4287. break
  4288. case "30":
  4289. msg = "注销"
  4290. break
  4291. case "40":
  4292. msg = "回收"
  4293. break
  4294. case "99":
  4295. msg = "制卡中(无效卡)"
  4296. break
  4297. }
  4298. c.ServeSuccessJSON(map[string]interface{}{
  4299. "failed_code": -10,
  4300. "msg": msg,
  4301. })
  4302. return
  4303. } else {
  4304. c.ServeSuccessJSON(map[string]interface{}{
  4305. "msg": "校验成功",
  4306. })
  4307. return
  4308. }
  4309. }
  4310. }
  4311. type ELeCertData struct {
  4312. Data struct {
  4313. Extra string `json:"extra"`
  4314. IDNo string `json:"idNo"`
  4315. IDType string `json:"idType"`
  4316. EcToken string `json:"ecToken"`
  4317. InsuOrg string `json:"insuOrg"`
  4318. UserName string `json:"userName"`
  4319. EcIndexNo string `json:"ecIndexNo"`
  4320. Gender string `json:"gender"`
  4321. Birthday string `json:"birthday"`
  4322. Nationality string `json:"nationality"`
  4323. Email string `json:"email"`
  4324. } `json:"OutData"`
  4325. }
  4326. func (c *HisApiController) ReadCard() {
  4327. id_card_type, _ := c.GetInt64("id_card_type")
  4328. admin_user_id, _ := c.GetInt64("admin_user_id")
  4329. certificates, _ := c.GetInt64("certificates")
  4330. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  4331. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4332. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4333. switch id_card_type {
  4334. case 1:
  4335. if miConfig.MdtrtareaAdmvs == "421300" {
  4336. var res ResultTwo
  4337. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  4338. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4339. "&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)
  4340. resp, requestErr := http.Get(api)
  4341. if requestErr != nil {
  4342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4343. return
  4344. }
  4345. body, ioErr := ioutil.ReadAll(resp.Body)
  4346. if ioErr != nil {
  4347. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4349. return
  4350. }
  4351. var respJSON map[string]interface{}
  4352. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4355. return
  4356. }
  4357. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4358. result, _ := json.Marshal(respJSON)
  4359. fmt.Println("log")
  4360. fmt.Println(string(result))
  4361. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4362. utils.ErrorLog("解析失败:%v", err)
  4363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4364. return
  4365. }
  4366. if res.Infcode == 0 {
  4367. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4368. if err == gorm.ErrRecordNotFound {
  4369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4370. return
  4371. } else if err != nil {
  4372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4373. return
  4374. } else {
  4375. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4376. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4377. infoStr := string(Iinfos)
  4378. idetinfoStr := string(Idetinfos)
  4379. psn := &models.HisPsn{
  4380. PsnNo: res.Output.Baseinfo.PsnNo,
  4381. Age: res.Output.Baseinfo.Age,
  4382. PatientId: patient.ID,
  4383. Certno: res.Output.Baseinfo.Certno,
  4384. Brdy: res.Output.Baseinfo.Brdy,
  4385. Gend: res.Output.Baseinfo.Gend,
  4386. Naty: res.Output.Baseinfo.Naty,
  4387. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4388. PsnName: res.Output.Baseinfo.PsnName,
  4389. Idetinfo: idetinfoStr,
  4390. Insuinfo: infoStr,
  4391. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4392. }
  4393. service.CreateHisPsn(psn)
  4394. c.ServeSuccessJSON(map[string]interface{}{
  4395. "patient": patient,
  4396. "number": res.Output.Baseinfo.Certno,
  4397. })
  4398. }
  4399. } else {
  4400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4401. return
  4402. }
  4403. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4404. var api string
  4405. if miConfig.MdtrtareaAdmvs == "320921" {
  4406. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  4407. "&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
  4408. fmt.Println(api)
  4409. } else {
  4410. 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 +
  4411. "&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)
  4412. }
  4413. resp, requestErr := http.Get(api)
  4414. if requestErr != nil {
  4415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4416. return
  4417. }
  4418. body, ioErr := ioutil.ReadAll(resp.Body)
  4419. if ioErr != nil {
  4420. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4422. return
  4423. }
  4424. var respJSON map[string]interface{}
  4425. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4426. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4428. return
  4429. }
  4430. var status string
  4431. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4432. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4433. //console.log()
  4434. fmt.Println("type===")
  4435. fmt.Println(card_type)
  4436. var token string
  4437. var res ResultTwo //1101结果
  4438. var res10265 ResultTwo10265 //1101结果
  4439. var card_info string //卡信息
  4440. var busi_card_info string
  4441. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4442. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4443. if status == "0" { //读卡成功
  4444. if card_type == "1" {
  4445. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4446. result, _ := json.Marshal(respJSON)
  4447. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4448. utils.ErrorLog("解析失败:%v", err)
  4449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4450. return
  4451. }
  4452. res.ErrMsg = res10265.ErrMsg
  4453. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4454. res.Infcode = infocode
  4455. res.Output = res10265.Output
  4456. res.InfRefmsgid = res10265.InfRefmsgid
  4457. } else {
  4458. //var card_info string //卡信息
  4459. //var busi_card_info string
  4460. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4461. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4462. //fmt.Println(card_info)
  4463. //fmt.Println(busi_card_info)
  4464. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4465. result, _ := json.Marshal(respJSON)
  4466. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4467. utils.ErrorLog("解析失败:%v", err)
  4468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4469. return
  4470. }
  4471. res.ErrMsg = res10265.ErrMsg
  4472. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4473. res.Infcode = infocode
  4474. res.Output = res10265.Output
  4475. res.InfRefmsgid = res10265.InfRefmsgid
  4476. }
  4477. if res.Infcode == 0 {
  4478. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4479. if err == gorm.ErrRecordNotFound {
  4480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4481. return
  4482. } else if err != nil {
  4483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4484. return
  4485. } else {
  4486. if card_type == "1" {
  4487. bas := strings.Split(card_info, "|")
  4488. basNumber := bas[2]
  4489. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4490. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4491. infoStr := string(Iinfos)
  4492. idetinfoStr := string(Idetinfos)
  4493. psn := &models.HisPsn{
  4494. PsnNo: res.Output.Baseinfo.PsnNo,
  4495. Age: res.Output.Baseinfo.Age,
  4496. PatientId: patient.ID,
  4497. Certno: res.Output.Baseinfo.Certno,
  4498. Brdy: res.Output.Baseinfo.Brdy,
  4499. Gend: res.Output.Baseinfo.Gend,
  4500. Naty: res.Output.Baseinfo.Naty,
  4501. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4502. PsnName: res.Output.Baseinfo.PsnName,
  4503. Idetinfo: idetinfoStr,
  4504. Insuinfo: infoStr,
  4505. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4506. CardInfo: card_info,
  4507. VerifyNumber: busi_card_info,
  4508. }
  4509. service.CreateHisPsn(psn)
  4510. var rf []*ResultFive
  4511. json.Unmarshal([]byte(infoStr), &rf)
  4512. var insutypes []*ResultFive
  4513. var insutype string
  4514. var is390 int = 0
  4515. var is310 int = 0
  4516. for _, item := range rf {
  4517. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4518. insutypes = append(insutypes, item)
  4519. }
  4520. }
  4521. if len(insutypes) == 1 {
  4522. insutype = insutypes[0].Insutype
  4523. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4524. } else {
  4525. for _, i := range insutypes {
  4526. if i.Insutype == "390" {
  4527. is390 = 1
  4528. }
  4529. if i.Insutype == "310" {
  4530. is310 = 1
  4531. }
  4532. }
  4533. }
  4534. if is390 == 1 {
  4535. insutype = "390"
  4536. }
  4537. if is310 == 1 {
  4538. insutype = "310"
  4539. }
  4540. if len(insutypes) == 0 {
  4541. insutype = "310"
  4542. }
  4543. c.ServeSuccessJSON(map[string]interface{}{
  4544. "patient": patient,
  4545. "number": basNumber,
  4546. "insutype": insutype,
  4547. })
  4548. } else {
  4549. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4550. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4551. infoStr := string(Iinfos)
  4552. idetinfoStr := string(Idetinfos)
  4553. psn := &models.HisPsn{
  4554. PsnNo: res.Output.Baseinfo.PsnNo,
  4555. Age: res.Output.Baseinfo.Age,
  4556. PatientId: patient.ID,
  4557. Certno: res.Output.Baseinfo.Certno,
  4558. Brdy: res.Output.Baseinfo.Brdy,
  4559. Gend: res.Output.Baseinfo.Gend,
  4560. Naty: res.Output.Baseinfo.Naty,
  4561. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4562. PsnName: res.Output.Baseinfo.PsnName,
  4563. Idetinfo: idetinfoStr,
  4564. Insuinfo: infoStr,
  4565. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4566. CardInfo: card_info,
  4567. VerifyNumber: token,
  4568. }
  4569. service.CreateHisPsn(psn)
  4570. c.ServeSuccessJSON(map[string]interface{}{
  4571. "patient": patient,
  4572. "number": token,
  4573. })
  4574. }
  4575. }
  4576. } else {
  4577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4578. return
  4579. }
  4580. } else { //读卡失败
  4581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4582. return
  4583. }
  4584. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4585. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  4586. cardnum = DeleteExtraSpaceTwo(cardnum)
  4587. cardCode = DeleteExtraSpaceTwo(cardCode)
  4588. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  4589. name = DeleteExtraSpaceTwo(name)
  4590. errmsg = DeleteExtraSpaceTwo(errmsg)
  4591. cardnum = Remove0000(cardnum)
  4592. cardCode = Remove0000(cardCode)
  4593. id_card_no = Remove0000(id_card_no)
  4594. name = Remove0000(name)
  4595. errmsg = Remove0000(errmsg)
  4596. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  4597. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  4598. //result2, requestLog2, errMsgLog2 := service.FJybidcomfirm(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name)
  4599. //fmt.Println(result2)
  4600. //fmt.Println(requestLog2)
  4601. //fmt.Println(errMsgLog2)
  4602. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, "", miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name, id_card_no)
  4603. saveLog(result, requestLog, "1101", "获取人员信息")
  4604. fmt.Println(errMsgLog)
  4605. if len(errMsgLog) > 0 {
  4606. } else {
  4607. var dat map[string]interface{}
  4608. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4609. fmt.Println(dat)
  4610. } else {
  4611. fmt.Println(err)
  4612. }
  4613. userJSONBytes, _ := json.Marshal(dat)
  4614. var res ResultTwo
  4615. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4616. utils.ErrorLog("解析失败:%v", err)
  4617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4618. return
  4619. }
  4620. res.ErrMsg = errMsgLog
  4621. if res.Infcode == 0 {
  4622. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  4623. if err == gorm.ErrRecordNotFound {
  4624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4625. return
  4626. } else if err != nil {
  4627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4628. return
  4629. } else {
  4630. fmt.Println(res)
  4631. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4632. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4633. infoStr := string(Iinfos)
  4634. idetinfoStr := string(Idetinfos)
  4635. var rf []*ResultFive
  4636. json.Unmarshal([]byte(infoStr), &rf)
  4637. var insutypes []*ResultFive
  4638. var insutype string
  4639. var is390 int = 0
  4640. var is310 int = 0
  4641. for _, item := range rf {
  4642. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4643. insutypes = append(insutypes, item)
  4644. }
  4645. }
  4646. if len(insutypes) == 1 {
  4647. insutype = insutypes[0].Insutype
  4648. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4649. } else {
  4650. for _, i := range insutypes {
  4651. if i.Insutype == "390" {
  4652. is390 = 1
  4653. }
  4654. if i.Insutype == "310" {
  4655. is310 = 1
  4656. }
  4657. }
  4658. }
  4659. if is390 == 1 {
  4660. insutype = "390"
  4661. }
  4662. if is310 == 1 {
  4663. insutype = "310"
  4664. }
  4665. if len(insutypes) == 0 {
  4666. insutype = "390"
  4667. }
  4668. var insuplc_admdvs string
  4669. for _, item := range rf {
  4670. if item.Insutype == insutype {
  4671. insuplc_admdvs = item.InsuplcAdmdvs
  4672. }
  4673. }
  4674. psn := &models.HisPsn{
  4675. PsnNo: res.Output.Baseinfo.PsnNo,
  4676. Age: res.Output.Baseinfo.Age,
  4677. PatientId: patient.ID,
  4678. Certno: res.Output.Baseinfo.Certno,
  4679. Brdy: res.Output.Baseinfo.Brdy,
  4680. Gend: res.Output.Baseinfo.Gend,
  4681. Naty: res.Output.Baseinfo.Naty,
  4682. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4683. PsnName: res.Output.Baseinfo.PsnName,
  4684. Idetinfo: idetinfoStr,
  4685. Insuinfo: infoStr,
  4686. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4687. CardInfo: basStr,
  4688. VerifyNumber: "",
  4689. InsuplcAdmdvs: insuplc_admdvs,
  4690. }
  4691. service.CreateHisPsn(psn)
  4692. c.ServeSuccessJSON(map[string]interface{}{
  4693. "patient": patient,
  4694. "number": cardnum,
  4695. "insutype": insutype,
  4696. })
  4697. }
  4698. } else {
  4699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4700. return
  4701. }
  4702. }
  4703. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4704. fmt.Println(initFlag)
  4705. fmt.Println("initFlag")
  4706. if initFlag == 0 {
  4707. c.TestGetJiangXiBasBaseInit()
  4708. }
  4709. basStr := c.GetBasBaseInfo()
  4710. if len(basStr) == 0 {
  4711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4712. return
  4713. }
  4714. fmt.Println(basStr)
  4715. bas := strings.Split(basStr, "|")
  4716. basNumber := bas[1]
  4717. fmt.Println(basNumber)
  4718. card_sn := bas[3]
  4719. fmt.Println(card_sn)
  4720. 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, "")
  4721. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  4722. var dat map[string]interface{}
  4723. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4724. fmt.Println(dat)
  4725. } else {
  4726. fmt.Println(err)
  4727. }
  4728. userJSONBytes, _ := json.Marshal(dat)
  4729. var res ResultTwo
  4730. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4731. utils.ErrorLog("解析失败:%v", err)
  4732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4733. return
  4734. }
  4735. if res.Infcode == 0 {
  4736. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  4737. if err == gorm.ErrRecordNotFound {
  4738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4739. return
  4740. } else if err != nil {
  4741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4742. return
  4743. } else {
  4744. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4745. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4746. infoStr := string(Iinfos)
  4747. idetinfoStr := string(Idetinfos)
  4748. psn := &models.HisPsn{
  4749. PsnNo: res.Output.Baseinfo.PsnNo,
  4750. Age: res.Output.Baseinfo.Age,
  4751. PatientId: patient.ID,
  4752. Certno: res.Output.Baseinfo.Certno,
  4753. Brdy: res.Output.Baseinfo.Brdy,
  4754. Gend: res.Output.Baseinfo.Gend,
  4755. Naty: res.Output.Baseinfo.Naty,
  4756. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4757. PsnName: res.Output.Baseinfo.PsnName,
  4758. Idetinfo: idetinfoStr,
  4759. Insuinfo: infoStr,
  4760. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4761. CardInfo: basStr,
  4762. VerifyNumber: "",
  4763. }
  4764. service.CreateHisPsn(psn)
  4765. var rf []*ResultFive
  4766. json.Unmarshal([]byte(infoStr), &rf)
  4767. var insutypes []*ResultFive
  4768. var insutype string
  4769. var is390 int = 0
  4770. var is310 int = 0
  4771. for _, item := range rf {
  4772. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4773. insutypes = append(insutypes, item)
  4774. }
  4775. }
  4776. if len(insutypes) == 1 {
  4777. insutype = insutypes[0].Insutype
  4778. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4779. } else {
  4780. for _, i := range insutypes {
  4781. if i.Insutype == "390" {
  4782. is390 = 1
  4783. }
  4784. if i.Insutype == "310" {
  4785. is310 = 1
  4786. }
  4787. }
  4788. }
  4789. if is390 == 1 {
  4790. insutype = "390"
  4791. }
  4792. if is310 == 1 {
  4793. insutype = "310"
  4794. }
  4795. if len(insutypes) == 0 {
  4796. insutype = "310"
  4797. }
  4798. c.ServeSuccessJSON(map[string]interface{}{
  4799. "patient": patient,
  4800. "number": basNumber,
  4801. "insutype": insutype,
  4802. })
  4803. }
  4804. } else {
  4805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4806. return
  4807. }
  4808. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4809. fmt.Println(initFlag)
  4810. fmt.Println("initFlag")
  4811. if initFlag == 0 {
  4812. c.TestGetHnBasBaseInit()
  4813. }
  4814. basStr := c.GetBasBaseInfo()
  4815. if len(basStr) == 0 {
  4816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4817. return
  4818. }
  4819. fmt.Println(basStr)
  4820. bas := strings.Split(basStr, "|")
  4821. basNumber := bas[1]
  4822. fmt.Println(basNumber)
  4823. card_sn := bas[3]
  4824. card_no := bas[2]
  4825. fmt.Println(card_sn)
  4826. name := bas[4]
  4827. name = ConvertToString(name, "gbk", "utf-8")
  4828. 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)
  4829. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  4830. var dat map[string]interface{}
  4831. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4832. fmt.Println(dat)
  4833. } else {
  4834. fmt.Println(err)
  4835. }
  4836. userJSONBytes, _ := json.Marshal(dat)
  4837. var res ResultTwo
  4838. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4839. utils.ErrorLog("解析失败:%v", err)
  4840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4841. return
  4842. }
  4843. if res.Infcode == 0 {
  4844. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  4845. if err == gorm.ErrRecordNotFound {
  4846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4847. return
  4848. } else if err != nil {
  4849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4850. return
  4851. } else {
  4852. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4853. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4854. infoStr := string(Iinfos)
  4855. idetinfoStr := string(Idetinfos)
  4856. psn := &models.HisPsn{
  4857. PsnNo: res.Output.Baseinfo.PsnNo,
  4858. Age: res.Output.Baseinfo.Age,
  4859. PatientId: patient.ID,
  4860. Certno: res.Output.Baseinfo.Certno,
  4861. Brdy: res.Output.Baseinfo.Brdy,
  4862. Gend: res.Output.Baseinfo.Gend,
  4863. Naty: res.Output.Baseinfo.Naty,
  4864. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4865. PsnName: res.Output.Baseinfo.PsnName,
  4866. Idetinfo: idetinfoStr,
  4867. Insuinfo: infoStr,
  4868. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4869. CardInfo: basStr,
  4870. VerifyNumber: "",
  4871. }
  4872. service.CreateHisPsn(psn)
  4873. var rf []*ResultFive
  4874. json.Unmarshal([]byte(infoStr), &rf)
  4875. var insutypes []*ResultFive
  4876. var insutype string
  4877. var is390 int = 0
  4878. var is310 int = 0
  4879. for _, item := range rf {
  4880. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4881. insutypes = append(insutypes, item)
  4882. }
  4883. }
  4884. if len(insutypes) == 1 {
  4885. insutype = insutypes[0].Insutype
  4886. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4887. } else {
  4888. for _, i := range insutypes {
  4889. if i.Insutype == "390" {
  4890. is390 = 1
  4891. }
  4892. if i.Insutype == "310" {
  4893. is310 = 1
  4894. }
  4895. }
  4896. }
  4897. if is390 == 1 {
  4898. insutype = "390"
  4899. }
  4900. if is310 == 1 {
  4901. insutype = "310"
  4902. }
  4903. if len(insutypes) == 0 {
  4904. insutype = "310"
  4905. }
  4906. c.ServeSuccessJSON(map[string]interface{}{
  4907. "patient": patient,
  4908. "number": basNumber,
  4909. "insutype": insutype,
  4910. })
  4911. }
  4912. } else {
  4913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4914. return
  4915. }
  4916. } else {
  4917. if initFlag == 0 {
  4918. c.TestGetBasBaseInit()
  4919. }
  4920. basStr := c.GetBasBaseInfo()
  4921. if len(basStr) == 0 {
  4922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4923. return
  4924. }
  4925. fmt.Println(basStr)
  4926. bas := strings.Split(basStr, "|")
  4927. basNumber := bas[1]
  4928. fmt.Println(basNumber)
  4929. card_sn := bas[3]
  4930. fmt.Println(card_sn)
  4931. cardNumber := bas[2]
  4932. fmt.Println(cardNumber)
  4933. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  4934. var result string
  4935. if bas[0][:2] == "44" {
  4936. result = service.Gdyb1101f(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, bas[0], miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, patient.Name, cardNumber)
  4937. } else {
  4938. result = service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, bas[0], miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, patient.Name, cardNumber)
  4939. }
  4940. var dat map[string]interface{}
  4941. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4942. fmt.Println(dat)
  4943. } else {
  4944. fmt.Println(err)
  4945. }
  4946. userJSONBytes, _ := json.Marshal(dat)
  4947. var res ResultTwo
  4948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4949. utils.ErrorLog("解析失败:%v", err)
  4950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4951. return
  4952. }
  4953. if res.Infcode == 0 {
  4954. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  4955. if err == gorm.ErrRecordNotFound {
  4956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4957. return
  4958. } else if err != nil {
  4959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4960. return
  4961. } else {
  4962. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4963. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4964. infoStr := string(Iinfos)
  4965. idetinfoStr := string(Idetinfos)
  4966. var rf []*ResultFive
  4967. json.Unmarshal([]byte(infoStr), &rf)
  4968. var insutypes []*ResultFive
  4969. var insutype string
  4970. var is390 int = 0
  4971. var is310 int = 0
  4972. var insuplc_admdvs string
  4973. for _, item := range rf {
  4974. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4975. insutypes = append(insutypes, item)
  4976. }
  4977. }
  4978. if len(insutypes) == 1 {
  4979. insutype = insutypes[0].Insutype
  4980. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4981. } else {
  4982. for _, i := range insutypes {
  4983. if i.Insutype == "390" {
  4984. is390 = 1
  4985. }
  4986. if i.Insutype == "310" {
  4987. is310 = 1
  4988. }
  4989. }
  4990. }
  4991. if is390 == 1 {
  4992. insutype = "390"
  4993. }
  4994. if is310 == 1 {
  4995. insutype = "310"
  4996. }
  4997. if len(insutypes) == 0 {
  4998. insutype = "310"
  4999. }
  5000. for _, item := range rf {
  5001. if item.Insutype == insutype {
  5002. insuplc_admdvs = item.InsuplcAdmdvs
  5003. }
  5004. }
  5005. psn := &models.HisPsn{
  5006. PsnNo: res.Output.Baseinfo.PsnNo,
  5007. Age: res.Output.Baseinfo.Age,
  5008. PatientId: patient.ID,
  5009. Certno: res.Output.Baseinfo.Certno,
  5010. Brdy: res.Output.Baseinfo.Brdy,
  5011. Gend: res.Output.Baseinfo.Gend,
  5012. Naty: res.Output.Baseinfo.Naty,
  5013. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5014. PsnName: res.Output.Baseinfo.PsnName,
  5015. Idetinfo: idetinfoStr,
  5016. Insuinfo: infoStr,
  5017. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5018. CardInfo: basStr,
  5019. VerifyNumber: "",
  5020. InsuplcAdmdvs: insuplc_admdvs,
  5021. }
  5022. service.CreateHisPsn(psn)
  5023. c.ServeSuccessJSON(map[string]interface{}{
  5024. "patient": patient,
  5025. "number": basNumber,
  5026. })
  5027. }
  5028. } else {
  5029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5030. return
  5031. }
  5032. break
  5033. }
  5034. case 2:
  5035. if miConfig.MdtrtareaAdmvs == "430800" {
  5036. if initFlag == 0 {
  5037. c.TestGetHnBasBaseInit()
  5038. }
  5039. SFZStr := c.GetSFZBaseInfo()
  5040. if len(SFZStr) == 0 {
  5041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5042. return
  5043. }
  5044. fmt.Println(SFZStr)
  5045. id_card_str := strings.Split(SFZStr, "^")
  5046. card_no := id_card_str[0]
  5047. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  5048. //name := id_card_str[1]
  5049. //name = ConvertToString(name, "gbk", "utf-8")
  5050. 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)
  5051. var dat map[string]interface{}
  5052. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5053. fmt.Println(dat)
  5054. } else {
  5055. fmt.Println(err)
  5056. }
  5057. userJSONBytes, _ := json.Marshal(dat)
  5058. var res ResultTwo
  5059. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5060. utils.ErrorLog("解析失败:%v", err)
  5061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5062. return
  5063. }
  5064. if res.Infcode == 0 {
  5065. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  5066. if err == gorm.ErrRecordNotFound {
  5067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5068. return
  5069. } else if err != nil {
  5070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5071. return
  5072. } else {
  5073. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5074. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5075. infoStr := string(Iinfos)
  5076. idetinfoStr := string(Idetinfos)
  5077. psn := &models.HisPsn{
  5078. PsnNo: res.Output.Baseinfo.PsnNo,
  5079. Age: res.Output.Baseinfo.Age,
  5080. PatientId: patient.ID,
  5081. Certno: res.Output.Baseinfo.Certno,
  5082. Brdy: res.Output.Baseinfo.Brdy,
  5083. Gend: res.Output.Baseinfo.Gend,
  5084. Naty: res.Output.Baseinfo.Naty,
  5085. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5086. PsnName: res.Output.Baseinfo.PsnName,
  5087. Idetinfo: idetinfoStr,
  5088. Insuinfo: infoStr,
  5089. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5090. CardInfo: SFZStr,
  5091. VerifyNumber: "",
  5092. }
  5093. service.CreateHisPsn(psn)
  5094. var rf []*ResultFive
  5095. json.Unmarshal([]byte(infoStr), &rf)
  5096. var insutypes []*ResultFive
  5097. var insutype string
  5098. var is390 int = 0
  5099. var is310 int = 0
  5100. for _, item := range rf {
  5101. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5102. insutypes = append(insutypes, item)
  5103. }
  5104. }
  5105. if len(insutypes) == 1 {
  5106. insutype = insutypes[0].Insutype
  5107. } else {
  5108. for _, i := range insutypes {
  5109. if i.Insutype == "390" {
  5110. is390 = 1
  5111. }
  5112. if i.Insutype == "310" {
  5113. is310 = 1
  5114. }
  5115. }
  5116. }
  5117. if is390 == 1 {
  5118. insutype = "390"
  5119. }
  5120. if is310 == 1 {
  5121. insutype = "310"
  5122. }
  5123. if len(insutypes) == 0 {
  5124. insutype = "310"
  5125. }
  5126. c.ServeSuccessJSON(map[string]interface{}{
  5127. "patient": patient,
  5128. "number": card_no,
  5129. "insutype": insutype,
  5130. })
  5131. }
  5132. } else {
  5133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5134. return
  5135. }
  5136. } else {
  5137. SFZStr := c.GetSFZBaseInfo()
  5138. id_card_str := strings.Split(SFZStr, "^")
  5139. id_card_number := id_card_str[0]
  5140. card_sn := ""
  5141. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "")
  5142. var dat map[string]interface{}
  5143. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5144. fmt.Println(dat)
  5145. } else {
  5146. fmt.Println(err)
  5147. }
  5148. userJSONBytes, _ := json.Marshal(dat)
  5149. var res ResultTwo
  5150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5151. utils.ErrorLog("解析失败:%v", err)
  5152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5153. return
  5154. }
  5155. if res.Infcode == 0 {
  5156. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  5157. if err == gorm.ErrRecordNotFound {
  5158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5159. return
  5160. } else if err != nil {
  5161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5162. return
  5163. } else {
  5164. c.ServeSuccessJSON(map[string]interface{}{
  5165. "patient": patient,
  5166. "number": id_card_number,
  5167. })
  5168. }
  5169. } else {
  5170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5171. return
  5172. }
  5173. }
  5174. break
  5175. case 3:
  5176. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5177. var api string
  5178. if miConfig.MdtrtareaAdmvs == "320921" {
  5179. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5180. "&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
  5181. fmt.Println(api)
  5182. } else {
  5183. 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 +
  5184. "&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)
  5185. }
  5186. resp, requestErr := http.Get(api)
  5187. if requestErr != nil {
  5188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5189. return
  5190. }
  5191. body, ioErr := ioutil.ReadAll(resp.Body)
  5192. if ioErr != nil {
  5193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5195. return
  5196. }
  5197. var respJSON map[string]interface{}
  5198. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5201. return
  5202. }
  5203. var status string
  5204. status = respJSON["data"].(map[string]interface{})["status"].(string)
  5205. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  5206. var token string
  5207. var res ResultTwo //1101结果
  5208. var res10265 ResultTwo10265 //1101结果
  5209. var card_info string //卡信息
  5210. var busi_card_info string
  5211. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  5212. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5213. if status == "0" { //读卡成功
  5214. if card_type == "1" {
  5215. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5216. result, _ := json.Marshal(respJSON)
  5217. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5218. utils.ErrorLog("解析失败:%v", err)
  5219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5220. return
  5221. }
  5222. res.ErrMsg = res10265.ErrMsg
  5223. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5224. res.Infcode = infocode
  5225. res.Output = res10265.Output
  5226. res.InfRefmsgid = res10265.InfRefmsgid
  5227. } else {
  5228. //var card_info string //卡信息
  5229. //var busi_card_info string
  5230. token = respJSON["data"].(map[string]interface{})["token"].(string)
  5231. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5232. //fmt.Println(card_info)
  5233. //fmt.Println(busi_card_info)
  5234. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5235. result, _ := json.Marshal(respJSON)
  5236. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5237. utils.ErrorLog("解析失败:%v", err)
  5238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5239. return
  5240. }
  5241. res.ErrMsg = res10265.ErrMsg
  5242. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5243. res.Infcode = infocode
  5244. res.Output = res10265.Output
  5245. res.InfRefmsgid = res10265.InfRefmsgid
  5246. }
  5247. if res.Infcode == 0 {
  5248. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5249. if err == gorm.ErrRecordNotFound {
  5250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5251. return
  5252. } else if err != nil {
  5253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5254. return
  5255. } else {
  5256. if card_type == "1" {
  5257. bas := strings.Split(card_info, "|")
  5258. basNumber := bas[2]
  5259. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5260. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5261. infoStr := string(Iinfos)
  5262. idetinfoStr := string(Idetinfos)
  5263. psn := &models.HisPsn{
  5264. PsnNo: res.Output.Baseinfo.PsnNo,
  5265. Age: res.Output.Baseinfo.Age,
  5266. PatientId: patient.ID,
  5267. Certno: res.Output.Baseinfo.Certno,
  5268. Brdy: res.Output.Baseinfo.Brdy,
  5269. Gend: res.Output.Baseinfo.Gend,
  5270. Naty: res.Output.Baseinfo.Naty,
  5271. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5272. PsnName: res.Output.Baseinfo.PsnName,
  5273. Idetinfo: idetinfoStr,
  5274. Insuinfo: infoStr,
  5275. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5276. CardInfo: card_info,
  5277. VerifyNumber: busi_card_info,
  5278. }
  5279. service.CreateHisPsn(psn)
  5280. c.ServeSuccessJSON(map[string]interface{}{
  5281. "patient": patient,
  5282. "number": basNumber,
  5283. })
  5284. } else {
  5285. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5286. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5287. infoStr := string(Iinfos)
  5288. idetinfoStr := string(Idetinfos)
  5289. psn := &models.HisPsn{
  5290. PsnNo: res.Output.Baseinfo.PsnNo,
  5291. Age: res.Output.Baseinfo.Age,
  5292. PatientId: patient.ID,
  5293. Certno: res.Output.Baseinfo.Certno,
  5294. Brdy: res.Output.Baseinfo.Brdy,
  5295. Gend: res.Output.Baseinfo.Gend,
  5296. Naty: res.Output.Baseinfo.Naty,
  5297. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5298. PsnName: res.Output.Baseinfo.PsnName,
  5299. Idetinfo: idetinfoStr,
  5300. Insuinfo: infoStr,
  5301. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5302. CardInfo: card_info,
  5303. VerifyNumber: token,
  5304. }
  5305. service.CreateHisPsn(psn)
  5306. var rf []*ResultFive
  5307. json.Unmarshal([]byte(infoStr), &rf)
  5308. var insutypes []*ResultFive
  5309. var insutype string
  5310. var is390 int = 0
  5311. var is310 int = 0
  5312. for _, item := range rf {
  5313. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5314. insutypes = append(insutypes, item)
  5315. }
  5316. }
  5317. if len(insutypes) == 1 {
  5318. insutype = insutypes[0].Insutype
  5319. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5320. } else {
  5321. for _, i := range insutypes {
  5322. if i.Insutype == "390" {
  5323. is390 = 1
  5324. }
  5325. if i.Insutype == "310" {
  5326. is310 = 1
  5327. }
  5328. }
  5329. }
  5330. if is390 == 1 {
  5331. insutype = "390"
  5332. }
  5333. if is310 == 1 {
  5334. insutype = "310"
  5335. }
  5336. if len(insutypes) == 0 {
  5337. insutype = "310"
  5338. }
  5339. c.ServeSuccessJSON(map[string]interface{}{
  5340. "patient": patient,
  5341. "number": token,
  5342. "insutype": insutype,
  5343. })
  5344. }
  5345. }
  5346. } else {
  5347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5348. return
  5349. }
  5350. } else { //读卡失败
  5351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5352. return
  5353. }
  5354. }
  5355. break
  5356. case 4:
  5357. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5358. var api string
  5359. if miConfig.MdtrtareaAdmvs == "320921" {
  5360. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5361. "&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
  5362. fmt.Println(api)
  5363. } else {
  5364. 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 +
  5365. "&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)
  5366. }
  5367. resp, requestErr := http.Get(api)
  5368. if requestErr != nil {
  5369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5370. return
  5371. }
  5372. body, ioErr := ioutil.ReadAll(resp.Body)
  5373. if ioErr != nil {
  5374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5376. return
  5377. }
  5378. var respJSON map[string]interface{}
  5379. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5382. return
  5383. }
  5384. var status string
  5385. status = respJSON["data"].(map[string]interface{})["status"].(string)
  5386. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  5387. var token string
  5388. var res ResultTwo //1101结果
  5389. var res10265 ResultTwo10265 //1101结果
  5390. if status == "0" { //读卡成功
  5391. var card_info string //卡信息
  5392. var busi_card_info string
  5393. token = respJSON["data"].(map[string]interface{})["token"].(string)
  5394. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5395. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  5396. fmt.Println(card_info)
  5397. fmt.Println(busi_card_info)
  5398. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5399. result, _ := json.Marshal(respJSON)
  5400. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5401. utils.ErrorLog("解析失败:%v", err)
  5402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5403. return
  5404. }
  5405. res.ErrMsg = res10265.ErrMsg
  5406. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5407. res.Infcode = infocode
  5408. res.Output = res10265.Output
  5409. res.InfRefmsgid = res10265.InfRefmsgid
  5410. if res.Infcode == 0 {
  5411. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5412. if err == gorm.ErrRecordNotFound {
  5413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5414. return
  5415. } else if err != nil {
  5416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5417. return
  5418. } else {
  5419. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5420. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5421. infoStr := string(Iinfos)
  5422. idetinfoStr := string(Idetinfos)
  5423. psn := &models.HisPsn{
  5424. PsnNo: res.Output.Baseinfo.PsnNo,
  5425. Age: res.Output.Baseinfo.Age,
  5426. PatientId: patient.ID,
  5427. Certno: res.Output.Baseinfo.Certno,
  5428. Brdy: res.Output.Baseinfo.Brdy,
  5429. Gend: res.Output.Baseinfo.Gend,
  5430. Naty: res.Output.Baseinfo.Naty,
  5431. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5432. PsnName: res.Output.Baseinfo.PsnName,
  5433. Idetinfo: idetinfoStr,
  5434. Insuinfo: infoStr,
  5435. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5436. CardInfo: card_info,
  5437. VerifyNumber: token,
  5438. }
  5439. var rf []*ResultFive
  5440. json.Unmarshal([]byte(infoStr), &rf)
  5441. var insutypes []*ResultFive
  5442. var insutype string
  5443. var is390 int = 0
  5444. var is310 int = 0
  5445. for _, item := range rf {
  5446. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5447. insutypes = append(insutypes, item)
  5448. }
  5449. }
  5450. if len(insutypes) == 1 {
  5451. insutype = insutypes[0].Insutype
  5452. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5453. } else {
  5454. for _, i := range insutypes {
  5455. if i.Insutype == "390" {
  5456. is390 = 1
  5457. }
  5458. if i.Insutype == "310" {
  5459. is310 = 1
  5460. }
  5461. }
  5462. }
  5463. if is390 == 1 {
  5464. insutype = "390"
  5465. }
  5466. if is310 == 1 {
  5467. insutype = "310"
  5468. }
  5469. if len(insutypes) == 0 {
  5470. insutype = "310"
  5471. }
  5472. service.CreateHisPsn(psn)
  5473. c.ServeSuccessJSON(map[string]interface{}{
  5474. "patient": patient,
  5475. "number": token,
  5476. "insutype": insutype,
  5477. })
  5478. }
  5479. } else {
  5480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5481. return
  5482. }
  5483. } else { //读卡失败
  5484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5485. return
  5486. }
  5487. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5488. idNo := c.GetString("idNo")
  5489. userName := c.GetString("userName")
  5490. ecToken := c.GetString("ecToken")
  5491. insuOrg := c.GetString("insuOrg")
  5492. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  5493. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5494. var res ResultTwo
  5495. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5496. utils.ErrorLog("解析失败:%v", err)
  5497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5498. return
  5499. }
  5500. if res.Infcode == 0 {
  5501. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5502. if err == gorm.ErrRecordNotFound {
  5503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5504. return
  5505. } else if err != nil {
  5506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5507. return
  5508. } else {
  5509. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5510. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5511. infoStr := string(Iinfos)
  5512. idetinfoStr := string(Idetinfos)
  5513. psn := &models.HisPsn{
  5514. PsnNo: res.Output.Baseinfo.PsnNo,
  5515. Age: res.Output.Baseinfo.Age,
  5516. PatientId: patient.ID,
  5517. Certno: res.Output.Baseinfo.Certno,
  5518. Brdy: res.Output.Baseinfo.Brdy,
  5519. Gend: res.Output.Baseinfo.Gend,
  5520. Naty: res.Output.Baseinfo.Naty,
  5521. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5522. PsnName: res.Output.Baseinfo.PsnName,
  5523. Idetinfo: idetinfoStr,
  5524. Insuinfo: infoStr,
  5525. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5526. CardInfo: "",
  5527. Stage: "1",
  5528. VerifyNumber: ecToken,
  5529. InsuplcAdmdvs: insuOrg,
  5530. }
  5531. service.CreateHisPsn(psn)
  5532. var rf []*ResultFive
  5533. json.Unmarshal([]byte(infoStr), &rf)
  5534. var insutypes []*ResultFive
  5535. var insutype string
  5536. var is390 int = 0
  5537. var is310 int = 0
  5538. for _, item := range rf {
  5539. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5540. insutypes = append(insutypes, item)
  5541. }
  5542. }
  5543. if len(insutypes) == 1 {
  5544. insutype = insutypes[0].Insutype
  5545. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5546. } else {
  5547. for _, i := range insutypes {
  5548. if i.Insutype == "390" {
  5549. is390 = 1
  5550. }
  5551. if i.Insutype == "310" {
  5552. is310 = 1
  5553. }
  5554. }
  5555. }
  5556. if is390 == 1 {
  5557. insutype = "390"
  5558. }
  5559. if is310 == 1 {
  5560. insutype = "310"
  5561. }
  5562. if len(insutypes) == 0 {
  5563. insutype = "310"
  5564. }
  5565. c.ServeSuccessJSON(map[string]interface{}{
  5566. "patient": patient,
  5567. "number": ecToken,
  5568. "insutype": insutype,
  5569. })
  5570. }
  5571. } else {
  5572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5573. return
  5574. }
  5575. } else if miConfig.MdtrtareaAdmvs == "360399" {
  5576. //if initFlag == 0 {
  5577. c.TestGetJiangXiBasBaseInit()
  5578. //}
  5579. //if initEleFlag == 0 {
  5580. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  5581. //}
  5582. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  5583. type ELeData struct {
  5584. Data struct {
  5585. IdNo string `json:"idNo"`
  5586. IdType string `json:"idType"`
  5587. UserName string `json:"userName"`
  5588. EcToken string `json:"ecToken"`
  5589. InsuOrg string `json:"insuOrg"`
  5590. Gender string `json:"gender"`
  5591. Birthday string `json:"birthday"`
  5592. Nationality string `json:"nationality"`
  5593. Email string `json:"email"`
  5594. Extra string `json:"extra"`
  5595. } `json:"data"`
  5596. Code int `json:"code"`
  5597. Message string `json:"message"`
  5598. }
  5599. var ele ELeData
  5600. err := json.Unmarshal([]byte(json_result), &ele)
  5601. if err != nil {
  5602. utils.ErrorLog("解析失败:%v", err)
  5603. }
  5604. token := ele.Data.EcToken
  5605. token = Remove0000(token)
  5606. 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)
  5607. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5608. var res ResultTwo
  5609. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5610. utils.ErrorLog("解析失败:%v", err)
  5611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5612. return
  5613. }
  5614. if res.Infcode == 0 {
  5615. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5616. if err == gorm.ErrRecordNotFound {
  5617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5618. return
  5619. } else if err != nil {
  5620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5621. return
  5622. } else {
  5623. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5624. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5625. infoStr := string(Iinfos)
  5626. idetinfoStr := string(Idetinfos)
  5627. psn := &models.HisPsn{
  5628. PsnNo: res.Output.Baseinfo.PsnNo,
  5629. Age: res.Output.Baseinfo.Age,
  5630. PatientId: patient.ID,
  5631. Certno: res.Output.Baseinfo.Certno,
  5632. Brdy: res.Output.Baseinfo.Brdy,
  5633. Gend: res.Output.Baseinfo.Gend,
  5634. Naty: res.Output.Baseinfo.Naty,
  5635. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5636. PsnName: res.Output.Baseinfo.PsnName,
  5637. Idetinfo: idetinfoStr,
  5638. Insuinfo: infoStr,
  5639. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5640. CardInfo: "",
  5641. //RecordDate:
  5642. VerifyNumber: token,
  5643. }
  5644. service.CreateHisPsn(psn)
  5645. var rf []*ResultFive
  5646. json.Unmarshal([]byte(infoStr), &rf)
  5647. var insutypes []*ResultFive
  5648. var insutype string
  5649. var is390 int = 0
  5650. var is310 int = 0
  5651. for _, item := range rf {
  5652. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5653. insutypes = append(insutypes, item)
  5654. }
  5655. }
  5656. if len(insutypes) == 1 {
  5657. insutype = insutypes[0].Insutype
  5658. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5659. } else {
  5660. for _, i := range insutypes {
  5661. if i.Insutype == "390" {
  5662. is390 = 1
  5663. }
  5664. if i.Insutype == "310" {
  5665. is310 = 1
  5666. }
  5667. }
  5668. }
  5669. if is390 == 1 {
  5670. insutype = "390"
  5671. }
  5672. if is310 == 1 {
  5673. insutype = "310"
  5674. }
  5675. if len(insutypes) == 0 {
  5676. insutype = "310"
  5677. }
  5678. c.ServeSuccessJSON(map[string]interface{}{
  5679. "patient": patient,
  5680. "number": token,
  5681. "insutype": insutype,
  5682. })
  5683. }
  5684. } else {
  5685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5686. return
  5687. }
  5688. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5689. //if initFlag == 0 {
  5690. c.TestGetJiangXiBasBaseInit()
  5691. //}
  5692. //if initEleFlag == 0 {
  5693. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  5694. //}
  5695. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  5696. type ELeData struct {
  5697. Data struct {
  5698. IdNo string `json:"idNo"`
  5699. IdType string `json:"idType"`
  5700. UserName string `json:"userName"`
  5701. EcToken string `json:"ecToken"`
  5702. InsuOrg string `json:"insuOrg"`
  5703. Gender string `json:"gender"`
  5704. Birthday string `json:"birthday"`
  5705. Nationality string `json:"nationality"`
  5706. Email string `json:"email"`
  5707. Extra string `json:"extra"`
  5708. } `json:"data"`
  5709. Code int `json:"code"`
  5710. Message string `json:"message"`
  5711. }
  5712. var ele ELeData
  5713. err := json.Unmarshal([]byte(json_result), &ele)
  5714. if err != nil {
  5715. utils.ErrorLog("解析失败:%v", err)
  5716. }
  5717. token := ele.Data.EcToken
  5718. token = Remove0000(token)
  5719. 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)
  5720. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5721. var res ResultTwo
  5722. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5723. utils.ErrorLog("解析失败:%v", err)
  5724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5725. return
  5726. }
  5727. if res.Infcode == 0 {
  5728. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5729. if err == gorm.ErrRecordNotFound {
  5730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5731. return
  5732. } else if err != nil {
  5733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5734. return
  5735. } else {
  5736. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5737. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5738. infoStr := string(Iinfos)
  5739. idetinfoStr := string(Idetinfos)
  5740. psn := &models.HisPsn{
  5741. PsnNo: res.Output.Baseinfo.PsnNo,
  5742. Age: res.Output.Baseinfo.Age,
  5743. PatientId: patient.ID,
  5744. Certno: res.Output.Baseinfo.Certno,
  5745. Brdy: res.Output.Baseinfo.Brdy,
  5746. Gend: res.Output.Baseinfo.Gend,
  5747. Naty: res.Output.Baseinfo.Naty,
  5748. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5749. PsnName: res.Output.Baseinfo.PsnName,
  5750. Idetinfo: idetinfoStr,
  5751. Insuinfo: infoStr,
  5752. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5753. CardInfo: "",
  5754. VerifyNumber: token,
  5755. }
  5756. service.CreateHisPsn(psn)
  5757. var rf []*ResultFive
  5758. json.Unmarshal([]byte(infoStr), &rf)
  5759. var insutypes []*ResultFive
  5760. var insutype string
  5761. var is390 int = 0
  5762. var is310 int = 0
  5763. for _, item := range rf {
  5764. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5765. insutypes = append(insutypes, item)
  5766. }
  5767. }
  5768. if len(insutypes) == 1 {
  5769. insutype = insutypes[0].Insutype
  5770. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5771. } else {
  5772. for _, i := range insutypes {
  5773. if i.Insutype == "390" {
  5774. is390 = 1
  5775. }
  5776. if i.Insutype == "310" {
  5777. is310 = 1
  5778. }
  5779. }
  5780. }
  5781. if is390 == 1 {
  5782. insutype = "390"
  5783. }
  5784. if is310 == 1 {
  5785. insutype = "310"
  5786. }
  5787. if len(insutypes) == 0 {
  5788. insutype = "310"
  5789. }
  5790. c.ServeSuccessJSON(map[string]interface{}{
  5791. "patient": patient,
  5792. "number": token,
  5793. "insutype": insutype,
  5794. })
  5795. }
  5796. } else {
  5797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5798. return
  5799. }
  5800. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5801. type ELeData struct {
  5802. Code string `json:"code"`
  5803. Data struct {
  5804. Aac002 string `json:"aac002"`
  5805. Aaz500 string `json:"aaz500"`
  5806. ActCardNo string `json:"actCardNo"`
  5807. Bab520 string `json:"bab520"`
  5808. Bkz543 string `json:"bkz543"`
  5809. BusinessType string `json:"businessType"`
  5810. CertfCodg string `json:"certfCodg"`
  5811. EcIndexNo string `json:"ecIndexNo"`
  5812. EcToken string `json:"ecToken"`
  5813. ID0000 string `json:"id0000"`
  5814. IDNo string `json:"idNo"`
  5815. IDType string `json:"idType"`
  5816. Idcode string `json:"idcode"`
  5817. IdentityToken string `json:"identity_token"`
  5818. InsuOrg string `json:"insuOrg"`
  5819. OfficeID string `json:"officeId"`
  5820. OfficeName string `json:"officeName"`
  5821. OperatorID string `json:"operatorId"`
  5822. OperatorName string `json:"operatorName"`
  5823. OrgID string `json:"orgId"`
  5824. UserName string `json:"userName"`
  5825. } `json:"data"`
  5826. Infno interface{} `json:"infno"`
  5827. Message string `json:"message"`
  5828. OrgID string `json:"orgId"`
  5829. TransType string `json:"transType"`
  5830. }
  5831. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  5832. outPutInfo = Remove0000(outPutInfo)
  5833. if len(outPutInfo) > 0 {
  5834. var ele ELeData
  5835. err := json.Unmarshal([]byte(outPutInfo), &ele)
  5836. if err != nil {
  5837. utils.ErrorLog("解析失败:%v", err)
  5838. }
  5839. token := ele.Data.EcToken
  5840. fmt.Println(inputInfo)
  5841. fmt.Println(outPutInfo)
  5842. result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IDNo, miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, id_card_type, "", 1, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token, ele.Data.UserName)
  5843. saveLog(result, requestLog, "1101", "获取人员信息")
  5844. var dat map[string]interface{}
  5845. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5846. fmt.Println(dat)
  5847. } else {
  5848. fmt.Println(err)
  5849. }
  5850. userJSONBytes, _ := json.Marshal(dat)
  5851. var res ResultTwo
  5852. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5853. utils.ErrorLog("解析失败:%v", err)
  5854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5855. return
  5856. }
  5857. res.ErrMsg = errMsgLog
  5858. if res.Infcode == 0 {
  5859. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  5860. if err == gorm.ErrRecordNotFound {
  5861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5862. return
  5863. } else if err != nil {
  5864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5865. return
  5866. } else {
  5867. fmt.Println(res)
  5868. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5869. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5870. infoStr := string(Iinfos)
  5871. idetinfoStr := string(Idetinfos)
  5872. psn := &models.HisPsn{
  5873. PsnNo: res.Output.Baseinfo.PsnNo,
  5874. Age: res.Output.Baseinfo.Age,
  5875. PatientId: patient.ID,
  5876. Certno: res.Output.Baseinfo.Certno,
  5877. Brdy: res.Output.Baseinfo.Brdy,
  5878. Gend: res.Output.Baseinfo.Gend,
  5879. Naty: res.Output.Baseinfo.Naty,
  5880. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5881. PsnName: res.Output.Baseinfo.PsnName,
  5882. Idetinfo: idetinfoStr,
  5883. Insuinfo: infoStr,
  5884. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5885. CardInfo: outPutInfo,
  5886. VerifyNumber: token,
  5887. InsuplcAdmdvs: ele.Data.InsuOrg,
  5888. }
  5889. service.CreateHisPsn(psn)
  5890. var rf []*ResultFive
  5891. json.Unmarshal([]byte(infoStr), &rf)
  5892. var insutypes []*ResultFive
  5893. var insutype string
  5894. var is390 int = 0
  5895. var is310 int = 0
  5896. for _, item := range rf {
  5897. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5898. insutypes = append(insutypes, item)
  5899. }
  5900. }
  5901. if len(insutypes) == 1 {
  5902. insutype = insutypes[0].Insutype
  5903. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5904. } else {
  5905. for _, i := range insutypes {
  5906. if i.Insutype == "390" {
  5907. is390 = 1
  5908. }
  5909. if i.Insutype == "310" {
  5910. is310 = 1
  5911. }
  5912. }
  5913. }
  5914. if is390 == 1 {
  5915. insutype = "390"
  5916. }
  5917. if is310 == 1 {
  5918. insutype = "310"
  5919. }
  5920. if len(insutypes) == 0 {
  5921. insutype = "310"
  5922. }
  5923. c.ServeSuccessJSON(map[string]interface{}{
  5924. "patient": patient,
  5925. "number": token,
  5926. "insutype": insutype,
  5927. })
  5928. }
  5929. } else {
  5930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5931. return
  5932. }
  5933. }
  5934. } else {
  5935. type ELeData struct {
  5936. Code string `json:"code"`
  5937. Data struct {
  5938. Aac002 string `json:"aac002"`
  5939. Aaz500 string `json:"aaz500"`
  5940. ActCardNo string `json:"actCardNo"`
  5941. Bab520 string `json:"bab520"`
  5942. Bkz543 string `json:"bkz543"`
  5943. BusinessType string `json:"businessType"`
  5944. CertfCodg string `json:"certfCodg"`
  5945. EcIndexNo string `json:"ecIndexNo"`
  5946. EcToken string `json:"ecToken"`
  5947. ID0000 string `json:"id0000"`
  5948. IDNo string `json:"idNo"`
  5949. IDType string `json:"idType"`
  5950. Idcode string `json:"idcode"`
  5951. IdentityToken string `json:"identity_token"`
  5952. InsuOrg string `json:"insuOrg"`
  5953. OfficeID string `json:"officeId"`
  5954. OfficeName string `json:"officeName"`
  5955. OperatorID string `json:"operatorId"`
  5956. OperatorName string `json:"operatorName"`
  5957. OrgID string `json:"orgId"`
  5958. UserName string `json:"userName"`
  5959. } `json:"data"`
  5960. Infno interface{} `json:"infno"`
  5961. Message string `json:"message"`
  5962. OrgID string `json:"orgId"`
  5963. TransType string `json:"transType"`
  5964. }
  5965. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName)
  5966. fmt.Println(result)
  5967. outPutInfo := Remove0000(result)
  5968. fmt.Println(outPutInfo)
  5969. if len(outPutInfo) > 0 {
  5970. var ele ELeData
  5971. err := json.Unmarshal([]byte(outPutInfo), &ele)
  5972. if err != nil {
  5973. utils.ErrorLog("解析失败:%v", err)
  5974. }
  5975. token := ele.Data.EcToken
  5976. fmt.Println(outPutInfo)
  5977. result, requestLog := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  5978. saveLog(result, requestLog, "1101", "获取人员信息")
  5979. var dat map[string]interface{}
  5980. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5981. fmt.Println(dat)
  5982. } else {
  5983. fmt.Println(err)
  5984. }
  5985. userJSONBytes, _ := json.Marshal(dat)
  5986. var res ResultTwo
  5987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5988. utils.ErrorLog("解析失败:%v", err)
  5989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5990. return
  5991. }
  5992. if res.Infcode == 0 {
  5993. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  5994. if err == gorm.ErrRecordNotFound {
  5995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5996. return
  5997. } else if err != nil {
  5998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5999. return
  6000. } else {
  6001. fmt.Println(res)
  6002. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6003. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6004. infoStr := string(Iinfos)
  6005. idetinfoStr := string(Idetinfos)
  6006. psn := &models.HisPsn{
  6007. PsnNo: res.Output.Baseinfo.PsnNo,
  6008. Age: res.Output.Baseinfo.Age,
  6009. PatientId: patient.ID,
  6010. Certno: res.Output.Baseinfo.Certno,
  6011. Brdy: res.Output.Baseinfo.Brdy,
  6012. Gend: res.Output.Baseinfo.Gend,
  6013. Naty: res.Output.Baseinfo.Naty,
  6014. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6015. PsnName: res.Output.Baseinfo.PsnName,
  6016. Idetinfo: idetinfoStr,
  6017. Insuinfo: infoStr,
  6018. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6019. CardInfo: outPutInfo,
  6020. VerifyNumber: token,
  6021. InsuplcAdmdvs: ele.Data.InsuOrg,
  6022. }
  6023. service.CreateHisPsn(psn)
  6024. var rf []*ResultFive
  6025. json.Unmarshal([]byte(infoStr), &rf)
  6026. var insutypes []*ResultFive
  6027. var insutype string
  6028. var is390 int = 0
  6029. var is310 int = 0
  6030. for _, item := range rf {
  6031. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6032. insutypes = append(insutypes, item)
  6033. }
  6034. }
  6035. if len(insutypes) == 1 {
  6036. insutype = insutypes[0].Insutype
  6037. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6038. } else {
  6039. for _, i := range insutypes {
  6040. if i.Insutype == "390" {
  6041. is390 = 1
  6042. }
  6043. if i.Insutype == "310" {
  6044. is310 = 1
  6045. }
  6046. }
  6047. }
  6048. if is390 == 1 {
  6049. insutype = "390"
  6050. }
  6051. if is310 == 1 {
  6052. insutype = "310"
  6053. }
  6054. if len(insutypes) == 0 {
  6055. insutype = "310"
  6056. }
  6057. c.ServeSuccessJSON(map[string]interface{}{
  6058. "patient": patient,
  6059. "number": token,
  6060. "insutype": insutype,
  6061. })
  6062. }
  6063. } else {
  6064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6065. return
  6066. }
  6067. }
  6068. //fmt.Println(result)
  6069. //
  6070. //if initFlag == 0 {
  6071. // c.TestGetBasBaseInit()
  6072. //}
  6073. //token := c.GetEleBaseInfo()
  6074. //
  6075. //token = Remove0000(token)
  6076. //
  6077. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  6078. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  6079. ////
  6080. //var res ResultTwo
  6081. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  6082. // utils.ErrorLog("解析失败:%v", err)
  6083. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6084. // return
  6085. //}
  6086. //
  6087. //if res.Infcode == 0 {
  6088. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6089. // if err == gorm.ErrRecordNotFound {
  6090. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6091. // return
  6092. // } else if err != nil {
  6093. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6094. // return
  6095. //
  6096. // } else {
  6097. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6098. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6099. // infoStr := string(Iinfos)
  6100. // idetinfoStr := string(Idetinfos)
  6101. //
  6102. //
  6103. //
  6104. //
  6105. // var rf []*ResultFive
  6106. // json.Unmarshal([]byte(infoStr), &rf)
  6107. //
  6108. // var insutypes []*ResultFive
  6109. // var insutype string
  6110. // var is390 int = 0
  6111. // var is310 int = 0
  6112. // var insuplc_admdvs string
  6113. //
  6114. // for _, item := range rf {
  6115. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6116. // insutypes = append(insutypes, item)
  6117. // }
  6118. // }
  6119. //
  6120. // if len(insutypes) == 1 {
  6121. // insutype = insutypes[0].Insutype
  6122. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6123. // } else {
  6124. // for _, i := range insutypes {
  6125. // if i.Insutype == "390" {
  6126. // is390 = 1
  6127. // }
  6128. //
  6129. // if i.Insutype == "310" {
  6130. // is310 = 1
  6131. // }
  6132. // }
  6133. // }
  6134. // if is390 == 1 {
  6135. // insutype = "390"
  6136. // }
  6137. //
  6138. // if is310 == 1 {
  6139. // insutype = "310"
  6140. // }
  6141. // if len(insutypes) == 0 {
  6142. // insutype = "310"
  6143. // }
  6144. // for _, item := range rf {
  6145. // if item.Insutype == insutype {
  6146. // insuplc_admdvs = item.InsuplcAdmdvs
  6147. // }
  6148. // }
  6149. // psn := &models.HisPsn{
  6150. // PsnNo: res.Output.Baseinfo.PsnNo,
  6151. // Age: res.Output.Baseinfo.Age,
  6152. // PatientId: patient.ID,
  6153. // Certno: res.Output.Baseinfo.Certno,
  6154. // Brdy: res.Output.Baseinfo.Brdy,
  6155. // Gend: res.Output.Baseinfo.Gend,
  6156. // Naty: res.Output.Baseinfo.Naty,
  6157. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  6158. // PsnName: res.Output.Baseinfo.PsnName,
  6159. // Idetinfo: idetinfoStr,
  6160. // Insuinfo: infoStr,
  6161. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6162. // CardInfo: "",
  6163. // VerifyNumber: token,
  6164. // InsuplcAdmdvs: insuplc_admdvs,
  6165. // }
  6166. // service.CreateHisPsn(psn)
  6167. //
  6168. // c.ServeSuccessJSON(map[string]interface{}{
  6169. // "patient": patient,
  6170. // "number": token,
  6171. // })
  6172. // }
  6173. //} else {
  6174. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6175. // return
  6176. //}
  6177. }
  6178. break
  6179. }
  6180. }
  6181. var initFlag int64 = 0
  6182. var initEleFlag int64 = 0
  6183. func (c *HisApiController) TestGetBasBaseInit() {
  6184. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6185. Iinit := DllDef.MustFindProc("Init")
  6186. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6187. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  6188. if ret != 0 {
  6189. fmt.Println("SSCard的报错原因:", err)
  6190. fmt.Println("SSCard的运算结果为:", ret)
  6191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  6192. return
  6193. }
  6194. result := int(ret)
  6195. fmt.Println("SSCard的运算结果为1:", result)
  6196. initFlag = 1
  6197. return
  6198. }
  6199. func (c *HisApiController) HandleJiangXiReadCard() {
  6200. fmt.Println("~~~~~~")
  6201. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6202. admin_user_id, _ := c.GetInt64("admin_user_id")
  6203. id_card_type, _ := c.GetInt64("id_card_type")
  6204. //certificates, _ := c.GetInt64("certificates")
  6205. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6206. if initFlag == 0 {
  6207. c.TestGetJiangXiBasBaseInit()
  6208. }
  6209. basStr := c.GetBasBaseInfo()
  6210. if len(basStr) == 0 {
  6211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  6212. return
  6213. }
  6214. fmt.Println(basStr)
  6215. bas := strings.Split(basStr, "|")
  6216. basNumber := bas[1]
  6217. fmt.Println(basNumber)
  6218. card_sn := bas[3]
  6219. fmt.Println(card_sn)
  6220. 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, "")
  6221. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  6222. var dat map[string]interface{}
  6223. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6224. fmt.Println(dat)
  6225. } else {
  6226. fmt.Println(err)
  6227. }
  6228. userJSONBytes, _ := json.Marshal(dat)
  6229. var res ResultTwo
  6230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6231. utils.ErrorLog("解析失败:%v", err)
  6232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6233. return
  6234. }
  6235. if res.Infcode == 0 {
  6236. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  6237. if err == gorm.ErrRecordNotFound {
  6238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6239. return
  6240. } else if err != nil {
  6241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6242. return
  6243. } else {
  6244. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6245. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6246. infoStr := string(Iinfos)
  6247. idetinfoStr := string(Idetinfos)
  6248. psn := &models.HisPsn{
  6249. PsnNo: res.Output.Baseinfo.PsnNo,
  6250. Age: res.Output.Baseinfo.Age,
  6251. PatientId: patient.ID,
  6252. Certno: res.Output.Baseinfo.Certno,
  6253. Brdy: res.Output.Baseinfo.Brdy,
  6254. Gend: res.Output.Baseinfo.Gend,
  6255. Naty: res.Output.Baseinfo.Naty,
  6256. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6257. PsnName: res.Output.Baseinfo.PsnName,
  6258. Idetinfo: idetinfoStr,
  6259. Insuinfo: infoStr,
  6260. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6261. CardInfo: basStr,
  6262. VerifyNumber: "",
  6263. }
  6264. service.CreateHisPsn(psn)
  6265. c.ServeSuccessJSON(map[string]interface{}{
  6266. "patient": patient,
  6267. "number": basNumber,
  6268. })
  6269. }
  6270. } else {
  6271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6272. return
  6273. }
  6274. }
  6275. func (c *HisApiController) TestGetHnBasBaseInit() {
  6276. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6277. Iinit := DllDef.MustFindProc("Init")
  6278. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6279. //http://10.77.211.236/CSB/hsa-fsi-1303
  6280. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  6281. if ret != 0 {
  6282. fmt.Println("SSCard的报错原因:", err)
  6283. fmt.Println("SSCard的运算结果为:", ret)
  6284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  6285. return
  6286. }
  6287. result := int(ret)
  6288. fmt.Println("SSCard的运算结果为1:", result)
  6289. initFlag = 1
  6290. return
  6291. }
  6292. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  6293. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6294. Iinit := DllDef.MustFindProc("Init")
  6295. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6296. //http://10.77.211.236/CSB/hsa-fsi-1303
  6297. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  6298. if ret != 0 {
  6299. fmt.Println("SSCard的报错原因:", err)
  6300. fmt.Println("SSCard的运算结果为:", ret)
  6301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  6302. return
  6303. }
  6304. result := int(ret)
  6305. fmt.Println("SSCard的运算结果为1:", result)
  6306. initFlag = 1
  6307. return
  6308. }
  6309. func (c *HisApiController) GetSFZBaseInfo() string {
  6310. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6311. readCard := DllDef.MustFindProc("ReadSFZ")
  6312. if readCard == nil {
  6313. fmt.Println("readcard is nil")
  6314. readCard = DllDef.MustFindProc("ReadSFZ")
  6315. }
  6316. str := make([]byte, 8096)
  6317. str1 := make([]byte, 8096)
  6318. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  6319. fmt.Println(r)
  6320. return Remove0000(string(str))
  6321. }
  6322. func (c *HisApiController) GetEleBaseInfo() string {
  6323. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6324. readCard := DllDef.MustFindProc("GetQRBase")
  6325. fmt.Println(readCard)
  6326. if readCard == nil {
  6327. fmt.Println("readcard is nil")
  6328. readCard = DllDef.MustFindProc("GetQRBase")
  6329. }
  6330. str := make([]byte, 1024)
  6331. str1 := make([]byte, 1024)
  6332. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  6333. fmt.Println(ret2)
  6334. fmt.Println(string(str1))
  6335. fmt.Println(string(str))
  6336. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  6337. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  6338. if ret2 != 0 {
  6339. return ""
  6340. }
  6341. return string(str)
  6342. }
  6343. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  6344. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  6345. readCard := DllDef.MustFindProc("NationEcTrans")
  6346. fmt.Println(readCard)
  6347. fmt.Println("!!!!!")
  6348. pBusiCardInfo := make([]byte, 2048)
  6349. input := make(map[string]interface{})
  6350. inputData := make(map[string]interface{})
  6351. inputData["orgId"] = code
  6352. inputData["businessType"] = "01101"
  6353. inputData["operatorId"] = "1"
  6354. inputData["operatorName"] = "admin"
  6355. inputData["officeId"] = "001"
  6356. inputData["officeName"] = "血透室"
  6357. inputData["deviceType"] = ""
  6358. input["data"] = inputData
  6359. input["orgId"] = code
  6360. input["transType"] = "ec.query"
  6361. bytesData, _ := json.Marshal(input)
  6362. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  6363. fmt.Println(ret2)
  6364. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  6365. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  6366. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  6367. }
  6368. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  6369. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  6370. readCard := DllDef.MustFindProc("NationEcTrans")
  6371. fmt.Println(readCard)
  6372. fmt.Println("!!!!!")
  6373. pBusiCardInfo := make([]byte, 2048)
  6374. input := make(map[string]interface{})
  6375. inputData := make(map[string]interface{})
  6376. inputData["orgId"] = code
  6377. inputData["businessType"] = "01101"
  6378. inputData["operatorId"] = "9"
  6379. inputData["operatorName"] = "admin"
  6380. inputData["officeId"] = "001"
  6381. inputData["officeName"] = "血透室"
  6382. inputData["deviceType"] = ""
  6383. input["data"] = inputData
  6384. input["orgId"] = code
  6385. input["transType"] = "ec.query"
  6386. bytesData, _ := json.Marshal(input)
  6387. ret2, _, _ := readCard.Call(StrPtr("http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  6388. fmt.Println(ret2)
  6389. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  6390. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  6391. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  6392. }
  6393. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  6394. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  6395. readCard := DllDef.MustFindProc("NationEcTrans")
  6396. fmt.Println(readCard)
  6397. fmt.Println("!!!!!")
  6398. pBusiCardInfo := make([]byte, 2048)
  6399. input := make(map[string]interface{})
  6400. inputData := make(map[string]interface{})
  6401. inputData["orgId"] = code
  6402. inputData["businessType"] = "01301"
  6403. inputData["operatorId"] = "9"
  6404. inputData["operatorName"] = "admin"
  6405. inputData["officeId"] = "001"
  6406. inputData["officeName"] = "血透室"
  6407. inputData["deviceType"] = ""
  6408. input["data"] = inputData
  6409. input["orgId"] = code
  6410. input["transType"] = "ec.query"
  6411. bytesData, _ := json.Marshal(input)
  6412. ret2, _, _ := readCard.Call(StrPtr("http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  6413. fmt.Println(ret2)
  6414. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  6415. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  6416. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  6417. }
  6418. func GetJxEleBaseInfo(org_id int64) string {
  6419. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6420. readCard := DllDef.MustFindProc("NationEcTrans")
  6421. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  6422. if readCard == nil {
  6423. fmt.Println("readcard is nil")
  6424. readCard = DllDef.MustFindProc("NationEcTrans")
  6425. }
  6426. str1 := make([]byte, 1024)
  6427. data := make(map[string]interface{})
  6428. inputData := make(map[string]interface{})
  6429. inputData["orgId"] = miConfig.Code
  6430. inputData["businessType"] = "01101"
  6431. inputData["operatorId"] = "test001"
  6432. inputData["operatorName"] = "cn"
  6433. inputData["officeId"] = "32760"
  6434. inputData["officeName"] = "waike"
  6435. inputData["deviceType"] = ""
  6436. data["data"] = inputData
  6437. data["transType"] = "ec.query"
  6438. data["extra "] = ""
  6439. data["orgId"] = miConfig.Code
  6440. bytesData, _ := json.Marshal(data)
  6441. //bytesData, _ := json.Marshal(data)
  6442. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  6443. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  6444. fmt.Println(ret2)
  6445. fmt.Println(string(str1))
  6446. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  6447. if ret2 != 0 {
  6448. return ""
  6449. }
  6450. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  6451. }
  6452. func GetJxEleBaseInitInfo(org_id int64) string {
  6453. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6454. readCard := DllDef.MustFindProc("NationEcTrans")
  6455. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  6456. if readCard == nil {
  6457. fmt.Println("readcard is nil")
  6458. readCard = DllDef.MustFindProc("NationEcTrans")
  6459. }
  6460. str1 := make([]byte, 2048)
  6461. data := make(map[string]interface{})
  6462. inputData := make(map[string]interface{})
  6463. inputData["orgId"] = miConfig.Code
  6464. inputData["businessType"] = "01101"
  6465. inputData["operatorId"] = "1"
  6466. inputData["operatorName"] = "huangchuang"
  6467. inputData["officeId"] = "101"
  6468. inputData["officeName"] = "xuetou"
  6469. inputData["deviceType"] = ""
  6470. data["data"] = inputData
  6471. data["transType"] = "ec.query"
  6472. data["orgId"] = miConfig.Code
  6473. bytesData, _ := json.Marshal(data)
  6474. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  6475. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  6476. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  6477. fmt.Println(ret2)
  6478. fmt.Println(string(str1))
  6479. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  6480. if ret2 != 0 {
  6481. return ""
  6482. }
  6483. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  6484. initEleFlag = 1
  6485. }
  6486. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  6487. }
  6488. func (c *HisApiController) GetBasBaseInfo() string {
  6489. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6490. readCard := DllDef.MustFindProc("ReadCardBas")
  6491. if readCard == nil {
  6492. fmt.Println("readcard is nil")
  6493. readCard = DllDef.MustFindProc("ReadCardBas")
  6494. }
  6495. str := make([]byte, 1024)
  6496. str1 := make([]byte, 1024)
  6497. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  6498. fmt.Println(string(str1))
  6499. fmt.Println(string(str))
  6500. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  6501. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  6502. if ret2 != 0 {
  6503. return ""
  6504. }
  6505. return string(str)
  6506. }
  6507. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  6508. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  6509. readCard := DllDef.MustFindProc("read_cardinfo")
  6510. if readCard == nil {
  6511. fmt.Println("readcard is nil")
  6512. readCard = DllDef.MustFindProc("read_cardinfo")
  6513. }
  6514. str := make([]byte, 1024) //卡号
  6515. str1 := make([]byte, 1024) //卡识别码
  6516. str2 := make([]byte, 1024) //身份证号
  6517. str3 := make([]byte, 1024) //姓名
  6518. str4 := make([]byte, 1024) //错误信息
  6519. 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])))
  6520. fmt.Println(string(str1))
  6521. fmt.Println(string(str))
  6522. fmt.Println(string(str2))
  6523. fmt.Println(string(str3))
  6524. fmt.Println(string(str4))
  6525. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  6526. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  6527. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  6528. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  6529. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  6530. if ret2 != 0 {
  6531. return "", "", "", "", ""
  6532. }
  6533. return string(str), string(str1), string(str2), string(str3), string(str4)
  6534. }
  6535. type CustomFundPay struct {
  6536. FundPayType string `json:"fund_pay_type"`
  6537. FundPayamt float64 `json:"fund_payamt"`
  6538. }
  6539. func (c *HisApiController) GetSettleList() {
  6540. order_id, _ := c.GetInt64("order_id")
  6541. admin_user_id, _ := c.GetInt64("admin_user_id")
  6542. order, _ := service.GetHisOrderByIDTwo(order_id)
  6543. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  6544. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6545. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  6546. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6547. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  6548. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6549. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  6550. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  6551. if order.ID == 0 {
  6552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  6553. return
  6554. }
  6555. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  6556. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  6557. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  6558. //fmt.Println(count)
  6559. //var zero string
  6560. //number := count + 1
  6561. //if number >= 1000 {
  6562. // zero = "0000" + strconv.FormatInt(number, 10)
  6563. //} else if number >= 10000 {
  6564. // zero = "000" + strconv.FormatInt(number, 10)
  6565. //} else if number >= 100000 {
  6566. // zero = "00" + strconv.FormatInt(number, 10)
  6567. //} else if number >= 1000000 {
  6568. // zero = "0" + strconv.FormatInt(number, 10)
  6569. //} else {
  6570. // zero = strconv.FormatInt(number, 10)
  6571. //}
  6572. //fmt.Println(zero)
  6573. struct4101 := service.Struct4101{
  6574. PsnNo: order.PsnNo,
  6575. MdtrtId: order.MdtrtId,
  6576. SetlId: order.SetlId,
  6577. PsnName: order.PsnName,
  6578. Gend: order.Gend,
  6579. Brdy: his.Brdy,
  6580. Age: his.Age,
  6581. Naty: order.Naty,
  6582. PatnCertType: "01",
  6583. Certno: order.Certno,
  6584. Prfs: "90",
  6585. ConerName: roles[0].UserName,
  6586. PatnRlts: "99",
  6587. ConerAddr: miConfig.OrgName,
  6588. ConerTel: admin.Mobile,
  6589. HiType: order.Insutype,
  6590. Insuplc: miConfig.InsuplcAdmdvs,
  6591. MaindiagFlag: "1",
  6592. BillCode: order.SetlId,
  6593. BillNo: order.SetlId,
  6594. BizSn: order.Number,
  6595. PsnSelfPay: order.PsnPartAmt,
  6596. PsnOwnPay: order.PsnPartAmt,
  6597. AcctPay: order.AcctPay,
  6598. PsnCashpay: order.PsnCashPay,
  6599. HiPaymtd: "1",
  6600. Hsorg: miConfig.InsuplcAdmdvs,
  6601. HsorgOpter: miConfig.InsuplcAdmdvs,
  6602. MedinsFillPsn: curRoles.UserName,
  6603. MedinsFillDept: depart.Name,
  6604. IptMedType: "2",
  6605. }
  6606. struct4101.SetlBegnDate = order.SetlTime
  6607. struct4101.SetlEndDate = order.SetlTime
  6608. time_arr := strings.Split(order.SetlTime, " ")
  6609. struct4101.AdmTime = time_arr[0]
  6610. struct4101.AdmEndTime = time_arr[0]
  6611. var rf []CustomFundPay
  6612. json.Unmarshal([]byte(order.SetlDetail), &rf)
  6613. var tempFunPays []service.CustomStruct
  6614. for _, item := range rf {
  6615. var tempFunPay service.CustomStruct
  6616. tempFunPay.FundPayamt = item.FundPayamt
  6617. tempFunPay.FundPayType = item.FundPayType
  6618. tempFunPays = append(tempFunPays, tempFunPay)
  6619. }
  6620. struct4101.CustomStruct = tempFunPays
  6621. var tempDiaginfos []service.DiaginfoStructTwo
  6622. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  6623. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  6624. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6625. var config []*models.HisXtDiagnoseConfig
  6626. for _, item := range diagnosis_ids {
  6627. id, _ := strconv.ParseInt(item, 10, 64)
  6628. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6629. config = append(config, &diagnosisConfig)
  6630. }
  6631. for index, item := range config {
  6632. if index == 0 {
  6633. var tempDiaginfo service.DiaginfoStructTwo
  6634. tempDiaginfo.DiagCode = item.CountryCode
  6635. tempDiaginfo.DiagName = item.CountryContentName
  6636. tempDiaginfo.DiagType = "1"
  6637. tempDiaginfo.MaindiagFlag = "1"
  6638. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6639. } else {
  6640. var tempDiaginfo service.DiaginfoStructTwo
  6641. tempDiaginfo.DiagCode = item.CountryCode
  6642. tempDiaginfo.DiagName = item.CountryContentName
  6643. tempDiaginfo.DiagType = "2"
  6644. tempDiaginfo.MaindiagFlag = "0"
  6645. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6646. }
  6647. }
  6648. struct4101.Diseinfo = tempDiaginfos
  6649. sickConfigTwo, _ := service.FindSickById(his.SickType)
  6650. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  6651. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  6652. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  6653. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  6654. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  6655. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  6656. var iteminfo service.IteminfoStruct
  6657. var bedCostTotal float64 = 0 //床位总费
  6658. var bedCostSelfTotal float64 = 0 //床位自费
  6659. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6660. var operationCostTotal float64 = 0 //手术费
  6661. var operationCostSelfTotal float64 = 0 //手术费
  6662. var operationCostPartSelfTotal float64 = 0 //手术费
  6663. var otherCostTotal float64 = 0 //其他费用
  6664. var otherCostSelfTotal float64 = 0 //其他费用
  6665. var otherCostPartSelfTotal float64 = 0 //其他费用
  6666. var materialCostTotal float64 = 0 //材料费
  6667. var materialCostSelfTotal float64 = 0 //材料费
  6668. var materialCostPartSelfTotal float64 = 0 //材料费
  6669. var westernMedicineCostTotal float64 = 0 //西药费
  6670. var westernMedicineCostSelfTotal float64 = 0 //西药费
  6671. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6672. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6673. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6674. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6675. var checkCostTotal float64 = 0 //检查费
  6676. var checkCostSelfTotal float64 = 0 //检查费
  6677. var checkCostPartSelfTotal float64 = 0 //检查费
  6678. var laboratoryCostTotal float64 = 0 //化验费
  6679. var laboratoryCostSelfTotal float64 = 0 //化验费
  6680. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6681. var treatCostTotal float64 = 0 //治疗费用
  6682. var treatCostSelfTotal float64 = 0 //治疗费用
  6683. var treatCostPartSelfTotal float64 = 0 //治疗费用
  6684. decimal.DivisionPrecision = 2
  6685. var bed_fulamt_ownpay_amt float64 = 0
  6686. var operation_fulamt_ownpay_amt float64 = 0
  6687. var other_fulamt_ownpay_amt float64 = 0
  6688. var westernMedicine_fulamt_ownpay_amt float64 = 0
  6689. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  6690. var check_fulamt_ownpay_amt float64 = 0
  6691. var material_fulamt_ownpay_amt float64 = 0
  6692. var laboratory_fulamt_ownpay_amt float64 = 0
  6693. var treat_fulamt_ownpay_amt float64 = 0
  6694. var bed_claa_sunmfee float64 = 0
  6695. var bed_clab_amt float64 = 0
  6696. var bed_other_amt float64 = 0
  6697. var operation_claa_sunmfee float64 = 0
  6698. var operation_clab_amt float64 = 0
  6699. var operation_other_amt float64 = 0
  6700. var other_claa_sunmfee float64 = 0
  6701. var other_clab_amt float64 = 0
  6702. var other_other_amt float64 = 0
  6703. var westernMedicine_claa_sunmfee float64 = 0
  6704. var westernMedicine_clab_amt float64 = 0
  6705. var westernMedicine_other_amt float64 = 0
  6706. var chineseTraditional_claa_sunmfee float64 = 0
  6707. var chineseTraditional_clab_amt float64 = 0
  6708. var chineseTraditional_other_amt float64 = 0
  6709. var check_claa_sunmfee float64 = 0
  6710. var check_clab_amt float64 = 0
  6711. var check_other_amt float64 = 0
  6712. var material_claa_sunmfee float64 = 0
  6713. var material_clab_amt float64 = 0
  6714. var material_other_amt float64 = 0
  6715. var laboratory_claa_sunmfee float64 = 0
  6716. var laboratory_clab_amt float64 = 0
  6717. var laboratory_other_amt float64 = 0
  6718. var treat_claa_sunmfee float64 = 0
  6719. var treat_clab_amt float64 = 0
  6720. var treat_other_amt float64 = 0
  6721. for _, item := range order.HisOrderInfo {
  6722. if item.MedChrgitmType == "01" { //床位费
  6723. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6724. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6725. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6726. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6727. if item.ChrgitmLv == "1" {
  6728. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6729. }
  6730. if item.ChrgitmLv == "2" {
  6731. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6732. }
  6733. if item.ChrgitmLv == "3" {
  6734. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6735. }
  6736. }
  6737. if item.MedChrgitmType == "03" { //检查费
  6738. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6739. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6740. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6741. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6742. if item.ChrgitmLv == "1" {
  6743. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6744. }
  6745. if item.ChrgitmLv == "2" {
  6746. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6747. }
  6748. if item.ChrgitmLv == "3" {
  6749. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6750. }
  6751. }
  6752. if item.MedChrgitmType == "04" { //化验费
  6753. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6754. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6755. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6756. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6757. if item.ChrgitmLv == "1" {
  6758. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6759. }
  6760. if item.ChrgitmLv == "2" {
  6761. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6762. }
  6763. if item.ChrgitmLv == "3" {
  6764. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6765. }
  6766. }
  6767. if item.MedChrgitmType == "05" { //治疗费
  6768. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6769. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6770. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6771. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6772. if item.ChrgitmLv == "1" {
  6773. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6774. }
  6775. if item.ChrgitmLv == "2" {
  6776. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6777. }
  6778. if item.ChrgitmLv == "3" {
  6779. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6780. }
  6781. }
  6782. if item.MedChrgitmType == "06" { //手术费
  6783. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6784. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6785. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6786. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6787. if item.ChrgitmLv == "1" {
  6788. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6789. }
  6790. if item.ChrgitmLv == "2" {
  6791. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6792. }
  6793. if item.ChrgitmLv == "3" {
  6794. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6795. }
  6796. }
  6797. if item.MedChrgitmType == "08" { //材料费
  6798. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6799. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6800. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6801. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6802. if item.ChrgitmLv == "1" {
  6803. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6804. }
  6805. if item.ChrgitmLv == "2" {
  6806. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6807. }
  6808. if item.ChrgitmLv == "3" {
  6809. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6810. }
  6811. }
  6812. if item.MedChrgitmType == "09" { //西药费
  6813. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6814. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6815. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6816. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6817. if item.ChrgitmLv == "1" {
  6818. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6819. }
  6820. if item.ChrgitmLv == "2" {
  6821. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6822. }
  6823. if item.ChrgitmLv == "3" {
  6824. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6825. }
  6826. }
  6827. if item.MedChrgitmType == "11" { //中成费
  6828. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6829. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6830. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6831. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6832. if item.ChrgitmLv == "1" {
  6833. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6834. }
  6835. if item.ChrgitmLv == "2" {
  6836. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6837. }
  6838. if item.ChrgitmLv == "3" {
  6839. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6840. }
  6841. }
  6842. if item.MedChrgitmType == "14" { //其他费
  6843. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6844. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6845. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6846. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6847. if item.ChrgitmLv == "1" {
  6848. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6849. }
  6850. if item.ChrgitmLv == "2" {
  6851. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6852. }
  6853. if item.ChrgitmLv == "3" {
  6854. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6855. }
  6856. }
  6857. }
  6858. var iteminfoStructs []service.IteminfoStruct
  6859. if bedCostTotal != 0 {
  6860. iteminfo.MedChrgitm = "01"
  6861. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6862. iteminfo.Amt = bedCostTotal
  6863. iteminfo.ClaaSumfee = bed_claa_sunmfee
  6864. iteminfo.ClabAmt = bed_clab_amt
  6865. iteminfo.OthAmt = bed_other_amt
  6866. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6867. }
  6868. if checkCostTotal != 0 {
  6869. iteminfo.MedChrgitm = "03"
  6870. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  6871. iteminfo.Amt = checkCostTotal
  6872. iteminfo.ClaaSumfee = check_claa_sunmfee
  6873. iteminfo.ClabAmt = check_clab_amt
  6874. iteminfo.OthAmt = check_other_amt
  6875. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6876. }
  6877. if laboratoryCostTotal != 0 {
  6878. iteminfo.MedChrgitm = "04"
  6879. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  6880. iteminfo.Amt = laboratoryCostTotal
  6881. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  6882. iteminfo.ClabAmt = laboratory_clab_amt
  6883. iteminfo.OthAmt = laboratory_other_amt
  6884. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6885. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6886. }
  6887. if treatCostTotal != 0 {
  6888. iteminfo.MedChrgitm = "05"
  6889. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  6890. iteminfo.Amt = treatCostTotal
  6891. iteminfo.ClaaSumfee = treat_claa_sunmfee
  6892. iteminfo.ClabAmt = treat_clab_amt
  6893. iteminfo.OthAmt = treat_other_amt
  6894. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6895. //(struct4101.IteminfoStruct, iteminfo)
  6896. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6897. }
  6898. if operationCostTotal != 0 {
  6899. iteminfo.MedChrgitm = "06"
  6900. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6901. iteminfo.Amt = operationCostTotal
  6902. iteminfo.ClaaSumfee = operation_claa_sunmfee
  6903. iteminfo.ClabAmt = operation_clab_amt
  6904. iteminfo.OthAmt = operation_other_amt
  6905. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6906. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6907. }
  6908. if materialCostTotal != 0 {
  6909. iteminfo.MedChrgitm = "08"
  6910. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  6911. iteminfo.Amt = materialCostTotal
  6912. iteminfo.ClaaSumfee = material_claa_sunmfee
  6913. iteminfo.ClabAmt = material_clab_amt
  6914. iteminfo.OthAmt = material_other_amt
  6915. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6916. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6917. }
  6918. if westernMedicineCostTotal != 0 {
  6919. iteminfo.MedChrgitm = "09"
  6920. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6921. iteminfo.Amt = westernMedicineCostTotal
  6922. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6923. iteminfo.ClabAmt = westernMedicine_clab_amt
  6924. iteminfo.OthAmt = westernMedicine_other_amt
  6925. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6926. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6927. }
  6928. if chineseTraditionalMedicineCostTotal != 0 {
  6929. iteminfo.MedChrgitm = "11"
  6930. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6931. iteminfo.Amt = westernMedicineCostTotal
  6932. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6933. iteminfo.ClabAmt = westernMedicine_clab_amt
  6934. iteminfo.OthAmt = westernMedicine_other_amt
  6935. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6936. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6937. }
  6938. if otherCostTotal != 0 {
  6939. iteminfo.MedChrgitm = "14"
  6940. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  6941. iteminfo.Amt = otherCostTotal
  6942. iteminfo.ClaaSumfee = other_claa_sunmfee
  6943. iteminfo.ClabAmt = other_clab_amt
  6944. iteminfo.OthAmt = other_other_amt
  6945. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6946. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6947. }
  6948. struct4101.IteminfoStruct = iteminfoStructs
  6949. struct4101.Ntly = "中国"
  6950. struct4101.AdmCaty = "A03.06"
  6951. struct4101.DoctorName = doctor.UserName
  6952. struct4101.DoctorCode = doctor.DoctorNumber
  6953. var res ResultSeventeen
  6954. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6955. struct4101.BillCode = order.Number
  6956. struct4101.BillNo = order.SetlId
  6957. var resOther ResultSeventeenOther
  6958. var pp models.PublicParams
  6959. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6960. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6961. pp.FixmedinsName = miConfig.OrgName
  6962. pp.FixmedinsCode = miConfig.Code
  6963. pp.RequestUrl = miConfig.Url
  6964. pp.Cainfo = miConfig.Cainfo
  6965. pp.SecretKey = miConfig.SecretKey
  6966. pp.AccessKey = miConfig.AccessKey
  6967. pp.OpterName = curRoles.UserName
  6968. client := &http.Client{}
  6969. var req *http.Request
  6970. data := make(map[string]interface{})
  6971. data["struct4101"] = struct4101
  6972. data["pp"] = pp
  6973. bytesData, _ := json.Marshal(data)
  6974. if miConfig.MdtrtareaAdmvs == "320921" {
  6975. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  6976. } else {
  6977. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  6978. }
  6979. resp, _ := client.Do(req)
  6980. defer resp.Body.Close()
  6981. body, ioErr := ioutil.ReadAll(resp.Body)
  6982. if ioErr != nil {
  6983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6985. return
  6986. }
  6987. var respJSON map[string]interface{}
  6988. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6991. return
  6992. }
  6993. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6994. userJSONBytes, _ := json.Marshal(respJSON)
  6995. fmt.Println("log")
  6996. fmt.Println(string(userJSONBytes))
  6997. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  6998. utils.ErrorLog("解析失败:%v", err)
  6999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7000. return
  7001. }
  7002. res.InfRefmsgid = resOther.InfRefmsgid
  7003. res.Output = resOther.Output
  7004. res.ErrMsg = resOther.ErrMsg
  7005. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  7006. res.Infcode = infocode
  7007. } else if miConfig.MdtrtareaAdmvs == "360399" {
  7008. var pp models.PublicParams
  7009. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7010. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7011. pp.FixmedinsName = miConfig.OrgName
  7012. pp.FixmedinsCode = miConfig.Code
  7013. pp.RequestUrl = miConfig.Url
  7014. pp.Cainfo = miConfig.Cainfo
  7015. pp.SecretKey = miConfig.SecretKey
  7016. pp.AccessKey = miConfig.AccessKey
  7017. pp.OpterName = curRoles.UserName
  7018. result, _ := service.Jxyb4101(struct4101, pp)
  7019. var dat map[string]interface{}
  7020. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7021. fmt.Println(dat)
  7022. } else {
  7023. fmt.Println(err)
  7024. }
  7025. userJSONBytes, _ := json.Marshal(dat)
  7026. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7027. utils.ErrorLog("解析失败:%v", err)
  7028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7029. return
  7030. }
  7031. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7032. var pp models.PublicParams
  7033. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7034. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7035. pp.FixmedinsName = miConfig.OrgName
  7036. pp.FixmedinsCode = miConfig.Code
  7037. pp.RequestUrl = miConfig.Url
  7038. pp.Cainfo = miConfig.Cainfo
  7039. pp.SecretKey = miConfig.SecretKey
  7040. pp.AccessKey = miConfig.AccessKey
  7041. pp.OpterName = curRoles.UserName
  7042. result, _ := service.Hnyb4101(struct4101, pp)
  7043. var dat map[string]interface{}
  7044. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7045. fmt.Println(dat)
  7046. } else {
  7047. fmt.Println(err)
  7048. }
  7049. userJSONBytes, _ := json.Marshal(dat)
  7050. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7051. utils.ErrorLog("解析失败:%v", err)
  7052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7053. return
  7054. }
  7055. } else {
  7056. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  7057. var dat map[string]interface{}
  7058. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7059. fmt.Println(dat)
  7060. } else {
  7061. fmt.Println(err)
  7062. }
  7063. userJSONBytes, _ := json.Marshal(dat)
  7064. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7065. utils.ErrorLog("解析失败:%v", err)
  7066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7067. return
  7068. }
  7069. }
  7070. if res.Infcode != 0 {
  7071. c.ServeSuccessJSON(map[string]interface{}{
  7072. "failed_code": -10,
  7073. "msg": res.ErrMsg,
  7074. })
  7075. return
  7076. } else {
  7077. //order.FaPiaoNumber = zero
  7078. //order.FaPiaoCode = last_order.FaPiaoCode
  7079. //service.UpdateOrder(order)
  7080. hisFundSettleListResult := &models.HisFundSettleListResult{
  7081. Number: res.Output.SetlListId,
  7082. Status: 1,
  7083. Ctime: time.Now().Unix(),
  7084. Mtime: time.Now().Unix(),
  7085. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7086. IsUpload: 1,
  7087. OrderId: order_id,
  7088. }
  7089. service.CreateUploadRecord(hisFundSettleListResult)
  7090. c.ServeSuccessJSON(map[string]interface{}{
  7091. "msg": "上传成功",
  7092. "result": hisFundSettleListResult,
  7093. })
  7094. return
  7095. }
  7096. }
  7097. func (c *HisApiController) GetSettleListHospital() {
  7098. order_id, _ := c.GetInt64("order_id")
  7099. admin_user_id, _ := c.GetInt64("admin_user_id")
  7100. order, _ := service.GetHisOrderByIDTwo(order_id)
  7101. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  7102. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7103. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  7104. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7105. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  7106. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7107. if order.ID == 0 {
  7108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7109. return
  7110. }
  7111. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  7112. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  7113. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  7114. fmt.Println(count)
  7115. var zero string
  7116. number := count + 1
  7117. if number >= 1000 {
  7118. zero = "0000" + strconv.FormatInt(number, 10)
  7119. } else if number >= 10000 {
  7120. zero = "000" + strconv.FormatInt(number, 10)
  7121. } else if number >= 100000 {
  7122. zero = "00" + strconv.FormatInt(number, 10)
  7123. } else if number >= 1000000 {
  7124. zero = "0" + strconv.FormatInt(number, 10)
  7125. } else {
  7126. zero = strconv.FormatInt(number, 10)
  7127. }
  7128. fmt.Println(zero)
  7129. struct4101 := service.Struct4101{
  7130. PsnNo: order.PsnNo,
  7131. MdtrtId: order.MdtrtId,
  7132. SetlId: order.SetlId,
  7133. PsnName: order.PsnName,
  7134. Gend: order.Gend,
  7135. Brdy: his.Brdy,
  7136. Age: int64(order.Age),
  7137. Naty: order.Naty,
  7138. PatnCertType: "01",
  7139. Certno: order.Certno,
  7140. Prfs: "90",
  7141. ConerName: roles[0].UserName,
  7142. PatnRlts: "99",
  7143. ConerAddr: miConfig.OrgName,
  7144. ConerTel: admin.Mobile,
  7145. HiType: order.Insutype,
  7146. Insuplc: miConfig.InsuplcAdmdvs,
  7147. MaindiagFlag: "1",
  7148. BillCode: order.SetlId,
  7149. BillNo: order.SetlId,
  7150. BizSn: order.Number,
  7151. PsnSelfPay: order.PsnPartAmt,
  7152. PsnOwnPay: order.PsnPartAmt,
  7153. AcctPay: order.AcctPay,
  7154. PsnCashpay: order.PsnCashPay,
  7155. HiPaymtd: "1",
  7156. Hsorg: miConfig.InsuplcAdmdvs,
  7157. HsorgOpter: miConfig.InsuplcAdmdvs,
  7158. MedinsFillPsn: curRoles.UserName,
  7159. MedinsFillDept: depart.Name,
  7160. IptMedType: "2",
  7161. AdmTime: his.InHosptialTime,
  7162. AdmEndTime: his.OutHosptialTime,
  7163. }
  7164. struct4101.SetlBegnDate = order.SetlTime
  7165. struct4101.SetlEndDate = order.SetlTime
  7166. var rf []CustomFundPay
  7167. json.Unmarshal([]byte(order.SetlDetail), &rf)
  7168. var tempFunPays []service.CustomStruct
  7169. for _, item := range rf {
  7170. var tempFunPay service.CustomStruct
  7171. tempFunPay.FundPayamt = item.FundPayamt
  7172. tempFunPay.FundPayType = item.FundPayType
  7173. tempFunPays = append(tempFunPays, tempFunPay)
  7174. }
  7175. struct4101.CustomStruct = tempFunPays
  7176. var tempDiaginfos []service.DiaginfoStructTwo
  7177. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  7178. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  7179. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7180. var config []*models.HisXtDiagnoseConfig
  7181. for _, item := range diagnosis_ids {
  7182. id, _ := strconv.ParseInt(item, 10, 64)
  7183. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7184. config = append(config, &diagnosisConfig)
  7185. }
  7186. for index, item := range config {
  7187. if index == 0 {
  7188. var tempDiaginfo service.DiaginfoStructTwo
  7189. tempDiaginfo.DiagCode = item.CountryCode
  7190. tempDiaginfo.DiagName = item.CountryContentName
  7191. tempDiaginfo.DiagType = "1"
  7192. tempDiaginfo.MaindiagFlag = "1"
  7193. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7194. } else {
  7195. var tempDiaginfo service.DiaginfoStructTwo
  7196. tempDiaginfo.DiagCode = item.CountryCode
  7197. tempDiaginfo.DiagName = item.CountryContentName
  7198. tempDiaginfo.DiagType = "2"
  7199. tempDiaginfo.MaindiagFlag = "0"
  7200. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7201. }
  7202. }
  7203. struct4101.Diseinfo = tempDiaginfos
  7204. sickConfigTwo, _ := service.FindSickById(his.SickType)
  7205. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  7206. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  7207. tempOpspdiseinfo2.OprnOprtCode = ""
  7208. tempOpspdiseinfo2.OprnOprtName = ""
  7209. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  7210. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  7211. var iteminfo service.IteminfoStruct
  7212. var bedCostTotal float64 = 0 //床位总费
  7213. var bedCostSelfTotal float64 = 0 //床位自费
  7214. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7215. var operationCostTotal float64 = 0 //手术费
  7216. var operationCostSelfTotal float64 = 0 //手术费
  7217. var operationCostPartSelfTotal float64 = 0 //手术费
  7218. var otherCostTotal float64 = 0 //其他费用
  7219. var otherCostSelfTotal float64 = 0 //其他费用
  7220. var otherCostPartSelfTotal float64 = 0 //其他费用
  7221. var materialCostTotal float64 = 0 //材料费
  7222. var materialCostSelfTotal float64 = 0 //材料费
  7223. var materialCostPartSelfTotal float64 = 0 //材料费
  7224. var westernMedicineCostTotal float64 = 0 //西药费
  7225. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7226. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7227. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7228. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7229. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7230. var checkCostTotal float64 = 0 //检查费
  7231. var checkCostSelfTotal float64 = 0 //检查费
  7232. var checkCostPartSelfTotal float64 = 0 //检查费
  7233. var laboratoryCostTotal float64 = 0 //化验费
  7234. var laboratoryCostSelfTotal float64 = 0 //化验费
  7235. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7236. var treatCostTotal float64 = 0 //治疗费用
  7237. var treatCostSelfTotal float64 = 0 //治疗费用
  7238. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7239. decimal.DivisionPrecision = 2
  7240. var bed_fulamt_ownpay_amt float64 = 0
  7241. var operation_fulamt_ownpay_amt float64 = 0
  7242. var other_fulamt_ownpay_amt float64 = 0
  7243. var westernMedicine_fulamt_ownpay_amt float64 = 0
  7244. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  7245. var check_fulamt_ownpay_amt float64 = 0
  7246. var material_fulamt_ownpay_amt float64 = 0
  7247. var laboratory_fulamt_ownpay_amt float64 = 0
  7248. var treat_fulamt_ownpay_amt float64 = 0
  7249. var bed_claa_sunmfee float64 = 0
  7250. var bed_clab_amt float64 = 0
  7251. var bed_other_amt float64 = 0
  7252. var operation_claa_sunmfee float64 = 0
  7253. var operation_clab_amt float64 = 0
  7254. var operation_other_amt float64 = 0
  7255. var other_claa_sunmfee float64 = 0
  7256. var other_clab_amt float64 = 0
  7257. var other_other_amt float64 = 0
  7258. var westernMedicine_claa_sunmfee float64 = 0
  7259. var westernMedicine_clab_amt float64 = 0
  7260. var westernMedicine_other_amt float64 = 0
  7261. var chineseTraditional_claa_sunmfee float64 = 0
  7262. var chineseTraditional_clab_amt float64 = 0
  7263. var chineseTraditional_other_amt float64 = 0
  7264. var check_claa_sunmfee float64 = 0
  7265. var check_clab_amt float64 = 0
  7266. var check_other_amt float64 = 0
  7267. var material_claa_sunmfee float64 = 0
  7268. var material_clab_amt float64 = 0
  7269. var material_other_amt float64 = 0
  7270. var laboratory_claa_sunmfee float64 = 0
  7271. var laboratory_clab_amt float64 = 0
  7272. var laboratory_other_amt float64 = 0
  7273. var treat_claa_sunmfee float64 = 0
  7274. var treat_clab_amt float64 = 0
  7275. var treat_other_amt float64 = 0
  7276. for _, item := range order.HisOrderInfo {
  7277. if item.MedChrgitmType == "01" { //床位费
  7278. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7279. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7280. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7281. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7282. if item.ChrgitmLv == "1" {
  7283. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7284. }
  7285. if item.ChrgitmLv == "2" {
  7286. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7287. }
  7288. if item.ChrgitmLv == "3" {
  7289. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7290. }
  7291. }
  7292. if item.MedChrgitmType == "03" { //检查费
  7293. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7294. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7295. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7296. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7297. if item.ChrgitmLv == "1" {
  7298. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7299. }
  7300. if item.ChrgitmLv == "2" {
  7301. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7302. }
  7303. if item.ChrgitmLv == "3" {
  7304. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7305. }
  7306. }
  7307. if item.MedChrgitmType == "04" { //化验费
  7308. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7309. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7310. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7311. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7312. if item.ChrgitmLv == "1" {
  7313. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7314. }
  7315. if item.ChrgitmLv == "2" {
  7316. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7317. }
  7318. if item.ChrgitmLv == "3" {
  7319. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7320. }
  7321. }
  7322. if item.MedChrgitmType == "05" { //治疗费
  7323. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7324. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7325. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7326. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7327. if item.ChrgitmLv == "1" {
  7328. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7329. }
  7330. if item.ChrgitmLv == "2" {
  7331. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7332. }
  7333. if item.ChrgitmLv == "3" {
  7334. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7335. }
  7336. }
  7337. if item.MedChrgitmType == "06" { //手术费
  7338. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7339. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7340. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7341. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7342. if item.ChrgitmLv == "1" {
  7343. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7344. }
  7345. if item.ChrgitmLv == "2" {
  7346. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7347. }
  7348. if item.ChrgitmLv == "3" {
  7349. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7350. }
  7351. }
  7352. if item.MedChrgitmType == "08" { //材料费
  7353. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7354. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7355. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7356. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7357. if item.ChrgitmLv == "1" {
  7358. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7359. }
  7360. if item.ChrgitmLv == "2" {
  7361. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7362. }
  7363. if item.ChrgitmLv == "3" {
  7364. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7365. }
  7366. }
  7367. if item.MedChrgitmType == "09" { //西药费
  7368. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7369. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7370. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7371. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7372. if item.ChrgitmLv == "1" {
  7373. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7374. }
  7375. if item.ChrgitmLv == "2" {
  7376. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7377. }
  7378. if item.ChrgitmLv == "3" {
  7379. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7380. }
  7381. }
  7382. if item.MedChrgitmType == "11" { //中成费
  7383. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7384. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7385. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7386. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7387. if item.ChrgitmLv == "1" {
  7388. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7389. }
  7390. if item.ChrgitmLv == "2" {
  7391. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7392. }
  7393. if item.ChrgitmLv == "3" {
  7394. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7395. }
  7396. }
  7397. if item.MedChrgitmType == "14" { //其他费
  7398. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7399. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7400. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7401. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7402. if item.ChrgitmLv == "1" {
  7403. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7404. }
  7405. if item.ChrgitmLv == "2" {
  7406. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7407. }
  7408. if item.ChrgitmLv == "3" {
  7409. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7410. }
  7411. }
  7412. }
  7413. var iteminfoStructs []service.IteminfoStruct
  7414. if bedCostTotal != 0 {
  7415. iteminfo.MedChrgitm = "01"
  7416. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  7417. iteminfo.Amt = bedCostTotal
  7418. iteminfo.ClaaSumfee = bed_claa_sunmfee
  7419. iteminfo.ClabAmt = bed_clab_amt
  7420. iteminfo.OthAmt = bed_other_amt
  7421. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7422. }
  7423. if checkCostTotal != 0 {
  7424. iteminfo.MedChrgitm = "03"
  7425. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  7426. iteminfo.Amt = checkCostTotal
  7427. iteminfo.ClaaSumfee = check_claa_sunmfee
  7428. iteminfo.ClabAmt = check_clab_amt
  7429. iteminfo.OthAmt = check_other_amt
  7430. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7431. }
  7432. if laboratoryCostTotal != 0 {
  7433. iteminfo.MedChrgitm = "04"
  7434. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  7435. iteminfo.Amt = laboratoryCostTotal
  7436. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  7437. iteminfo.ClabAmt = laboratory_clab_amt
  7438. iteminfo.OthAmt = laboratory_other_amt
  7439. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7440. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7441. }
  7442. if treatCostTotal != 0 {
  7443. iteminfo.MedChrgitm = "05"
  7444. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  7445. iteminfo.Amt = treatCostTotal
  7446. iteminfo.ClaaSumfee = treat_claa_sunmfee
  7447. iteminfo.ClabAmt = treat_clab_amt
  7448. iteminfo.OthAmt = treat_other_amt
  7449. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7450. //(struct4101.IteminfoStruct, iteminfo)
  7451. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7452. }
  7453. if operationCostTotal != 0 {
  7454. iteminfo.MedChrgitm = "06"
  7455. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  7456. iteminfo.Amt = operationCostTotal
  7457. iteminfo.ClaaSumfee = operation_claa_sunmfee
  7458. iteminfo.ClabAmt = operation_clab_amt
  7459. iteminfo.OthAmt = operation_other_amt
  7460. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7461. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7462. }
  7463. if materialCostTotal != 0 {
  7464. iteminfo.MedChrgitm = "08"
  7465. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  7466. iteminfo.Amt = materialCostTotal
  7467. iteminfo.ClaaSumfee = material_claa_sunmfee
  7468. iteminfo.ClabAmt = material_clab_amt
  7469. iteminfo.OthAmt = material_other_amt
  7470. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7471. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7472. }
  7473. if westernMedicineCostTotal != 0 {
  7474. iteminfo.MedChrgitm = "09"
  7475. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  7476. iteminfo.Amt = westernMedicineCostTotal
  7477. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  7478. iteminfo.ClabAmt = westernMedicine_clab_amt
  7479. iteminfo.OthAmt = westernMedicine_other_amt
  7480. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7481. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7482. }
  7483. if chineseTraditionalMedicineCostTotal != 0 {
  7484. iteminfo.MedChrgitm = "11"
  7485. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  7486. iteminfo.Amt = westernMedicineCostTotal
  7487. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  7488. iteminfo.ClabAmt = westernMedicine_clab_amt
  7489. iteminfo.OthAmt = westernMedicine_other_amt
  7490. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7491. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7492. }
  7493. if otherCostTotal != 0 {
  7494. iteminfo.MedChrgitm = "14"
  7495. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  7496. iteminfo.Amt = otherCostTotal
  7497. iteminfo.ClaaSumfee = other_claa_sunmfee
  7498. iteminfo.ClabAmt = other_clab_amt
  7499. iteminfo.OthAmt = other_other_amt
  7500. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7501. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7502. }
  7503. struct4101.IteminfoStruct = iteminfoStructs
  7504. struct4101.Ntly = "中国"
  7505. struct4101.AdmCaty = "A03.06"
  7506. var resOther ResultSeventeenOther
  7507. var res ResultSeventeen
  7508. if miConfig.MdtrtareaAdmvs == "150499" {
  7509. var pp models.PublicParams
  7510. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7511. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7512. pp.FixmedinsName = miConfig.OrgName
  7513. pp.FixmedinsCode = miConfig.Code
  7514. pp.RequestUrl = miConfig.Url
  7515. pp.Cainfo = miConfig.Cainfo
  7516. pp.SecretKey = miConfig.SecretKey
  7517. pp.AccessKey = miConfig.AccessKey
  7518. pp.OpterName = curRoles.UserName
  7519. client := &http.Client{}
  7520. var req *http.Request
  7521. data := make(map[string]interface{})
  7522. data["struct4101"] = struct4101
  7523. data["pp"] = pp
  7524. bytesData, _ := json.Marshal(data)
  7525. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  7526. resp, _ := client.Do(req)
  7527. defer resp.Body.Close()
  7528. body, ioErr := ioutil.ReadAll(resp.Body)
  7529. if ioErr != nil {
  7530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7532. return
  7533. }
  7534. var respJSON map[string]interface{}
  7535. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7538. return
  7539. }
  7540. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7541. userJSONBytes, _ := json.Marshal(respJSON)
  7542. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  7543. utils.ErrorLog("解析失败:%v", err)
  7544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7545. return
  7546. }
  7547. res.InfRefmsgid = resOther.InfRefmsgid
  7548. res.Output = resOther.Output
  7549. res.ErrMsg = resOther.ErrMsg
  7550. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  7551. res.Infcode = infocode
  7552. } else {
  7553. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  7554. var dat map[string]interface{}
  7555. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7556. fmt.Println(dat)
  7557. } else {
  7558. fmt.Println(err)
  7559. }
  7560. userJSONBytes, _ := json.Marshal(dat)
  7561. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7562. utils.ErrorLog("解析失败:%v", err)
  7563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7564. return
  7565. }
  7566. }
  7567. if res.Infcode != 0 {
  7568. c.ServeSuccessJSON(map[string]interface{}{
  7569. "failed_code": -10,
  7570. "msg": res.ErrMsg,
  7571. })
  7572. return
  7573. } else {
  7574. if miConfig.MdtrtareaAdmvs != "150499" {
  7575. order.FaPiaoNumber = zero
  7576. order.FaPiaoCode = last_order.FaPiaoCode
  7577. service.UpdateOrder(order)
  7578. }
  7579. hisFundSettleListResult := &models.HisFundSettleListResult{
  7580. Number: res.Output.SetlListId,
  7581. Status: 1,
  7582. Ctime: time.Now().Unix(),
  7583. Mtime: time.Now().Unix(),
  7584. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7585. IsUpload: 1,
  7586. OrderId: order_id,
  7587. }
  7588. service.CreateUploadRecord(hisFundSettleListResult)
  7589. c.ServeSuccessJSON(map[string]interface{}{
  7590. "msg": "上传成功",
  7591. "result": hisFundSettleListResult,
  7592. })
  7593. return
  7594. }
  7595. }
  7596. //func (c *HisApiController) GetBatchSettleList() {
  7597. // orders, _ := service.GetAllHisOrder(10106)
  7598. // for _, item := range orders {
  7599. // order_id := item.ID
  7600. // order, _ := service.GetHisOrderByIDTwo(order_id)
  7601. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  7602. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7603. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  7604. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  7605. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  7606. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7607. //
  7608. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7609. //
  7610. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7611. //
  7612. // if order.ID == 0 {
  7613. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7614. // return
  7615. // }
  7616. // if his.BalanceAccountsType == 2 {
  7617. // continue
  7618. // }
  7619. // struct4101 := service.Struct4101{
  7620. // PsnNo: order.PsnNo,
  7621. // MdtrtId: order.MdtrtId,
  7622. // SetlId: order.SetlId,
  7623. // PsnName: order.PsnName,
  7624. // Gend: order.Gend,
  7625. // Brdy: his.Brdy,
  7626. // Age: his.Age,
  7627. // Naty: order.Naty,
  7628. // PatnCertType: "01",
  7629. // Certno: order.Certno,
  7630. // Prfs: "90",
  7631. // ConerName: roles[0].UserName,
  7632. // PatnRlts: "99",
  7633. // ConerAddr: miConfig.OrgName,
  7634. // ConerTel: admin.Mobile,
  7635. // HiType: order.Insutype,
  7636. // Insuplc: his.InsuplcAdmdvs,
  7637. // MaindiagFlag: "1",
  7638. // BillCode: order.SetlId,
  7639. // BillNo: order.SetlId,
  7640. // BizSn: order.Number,
  7641. // PsnSelfPay: order.PsnPartAmt,
  7642. // PsnOwnPay: order.PsnPartAmt,
  7643. // AcctPay: order.AcctPay,
  7644. // PsnCashpay: order.PsnCashPay,
  7645. // HiPaymtd: "1",
  7646. // Hsorg: his.InsuplcAdmdvs,
  7647. // HsorgOpter: his.InsuplcAdmdvs,
  7648. // MedinsFillPsn: curRoles.UserName,
  7649. // MedinsFillDept: depart.Name,
  7650. // IptMedType: "2",
  7651. // }
  7652. // struct4101.SetlBegnDate = order.SetlTime
  7653. // struct4101.SetlEndDate = order.SetlTime
  7654. // //if order.SettleType == 1 {
  7655. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  7656. // // dateStr := t.Format("2006-01-02")
  7657. // // struct4101.SetlBegnDate = dateStr
  7658. // // struct4101.SetlEndDate = dateStr
  7659. // //} else {
  7660. // // t := time.Unix(int64(order.SettleStartTime), 0)
  7661. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  7662. // // dateStartStr := t.Format("2006-01-02")
  7663. // // dateEndStr := t2.Format("2006-01-02")
  7664. // // struct4101.SetlBegnDate = dateStartStr
  7665. // // struct4101.SetlEndDate = dateEndStr
  7666. // //}
  7667. //
  7668. // var rf []CustomFundPay
  7669. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  7670. //
  7671. // var tempFunPays []service.CustomStruct
  7672. // var tempFunPay610100 service.CustomStruct
  7673. //
  7674. // for _, item := range rf {
  7675. // if item.FundPayType == "610100" {
  7676. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  7677. // tempFunPay610100.FundPayType = item.FundPayType
  7678. // } else {
  7679. // var tempFunPay service.CustomStruct
  7680. // tempFunPay.FundPayamt = item.FundPayamt
  7681. // tempFunPay.FundPayType = item.FundPayType
  7682. // tempFunPays = append(tempFunPays, tempFunPay)
  7683. // }
  7684. // }
  7685. // tempFunPays = append(tempFunPays, tempFunPay610100)
  7686. // struct4101.CustomStruct = tempFunPays
  7687. //
  7688. // var tempDiaginfos []service.DiaginfoStructTwo
  7689. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  7690. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  7691. //
  7692. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7693. // var config []*models.HisXtDiagnoseConfig
  7694. // for _, item := range diagnosis_ids {
  7695. // id, _ := strconv.ParseInt(item, 10, 64)
  7696. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  7697. // config = append(config, &diagnosisConfig)
  7698. // }
  7699. //
  7700. // for index, item := range config {
  7701. // if index == 0 {
  7702. // var tempDiaginfo service.DiaginfoStructTwo
  7703. // tempDiaginfo.DiagCode = item.CountryCode
  7704. // tempDiaginfo.DiagName = item.CountryContentName
  7705. // tempDiaginfo.DiagType = "1"
  7706. // tempDiaginfo.MaindiagFlag = "1"
  7707. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7708. // } else {
  7709. //
  7710. // var tempDiaginfo service.DiaginfoStructTwo
  7711. // tempDiaginfo.DiagCode = item.CountryCode
  7712. // tempDiaginfo.DiagName = item.CountryContentName
  7713. // tempDiaginfo.DiagType = "2"
  7714. // tempDiaginfo.MaindiagFlag = "0"
  7715. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7716. // }
  7717. // }
  7718. // struct4101.Diseinfo = tempDiaginfos
  7719. //
  7720. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  7721. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  7722. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  7723. // tempOpspdiseinfo2.OprnOprtCode = ""
  7724. // tempOpspdiseinfo2.OprnOprtName = ""
  7725. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  7726. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  7727. //
  7728. // var iteminfo service.IteminfoStruct
  7729. //
  7730. // var bedCostTotal float64 = 0 //床位总费
  7731. // var bedCostSelfTotal float64 = 0 //床位自费
  7732. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7733. //
  7734. // var examineCostTotal float64 = 0 //诊查总费
  7735. // var examineCostSelfTotal float64 = 0 //诊查自费
  7736. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  7737. //
  7738. // var nursingCostTotal float64 = 0 //护理总费
  7739. // var nursingCostSelfTotal float64 = 0 //护理自费
  7740. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  7741. //
  7742. // var chineseMedicineCostTotal float64 = 0 //中成药
  7743. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  7744. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  7745. //
  7746. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  7747. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  7748. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  7749. //
  7750. // var registerCostTotal float64 = 0 //一般诊疗费
  7751. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  7752. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  7753. //
  7754. // var operationCostTotal float64 = 0 //手术费
  7755. // var operationCostSelfTotal float64 = 0 //手术费
  7756. // var operationCostPartSelfTotal float64 = 0 //手术费
  7757. //
  7758. // var otherCostTotal float64 = 0 //其他费用
  7759. // var otherCostSelfTotal float64 = 0 //其他费用
  7760. // var otherCostPartSelfTotal float64 = 0 //其他费用
  7761. //
  7762. // var materialCostTotal float64 = 0 //材料费
  7763. // var materialCostSelfTotal float64 = 0 //材料费
  7764. // var materialCostPartSelfTotal float64 = 0 //材料费
  7765. //
  7766. // var westernMedicineCostTotal float64 = 0 //西药费
  7767. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  7768. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7769. //
  7770. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7771. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7772. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7773. //
  7774. // var checkCostTotal float64 = 0 //检查费
  7775. // var checkCostSelfTotal float64 = 0 //检查费
  7776. // var checkCostPartSelfTotal float64 = 0 //检查费
  7777. //
  7778. // var laboratoryCostTotal float64 = 0 //化验费
  7779. // var laboratoryCostSelfTotal float64 = 0 //化验费
  7780. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7781. //
  7782. // var treatCostTotal float64 = 0 //治疗费用
  7783. // var treatCostSelfTotal float64 = 0 //治疗费用
  7784. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  7785. //
  7786. // decimal.DivisionPrecision = 2
  7787. //
  7788. // var bed_fulamt_ownpay_amt float64 = 0
  7789. //
  7790. // var examine_fulamt_ownpay_amt float64 = 0
  7791. //
  7792. // var nursing_fulamt_ownpay_amt float64 = 0
  7793. //
  7794. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  7795. //
  7796. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  7797. //
  7798. // var register_fulamt_ownpay_amt float64 = 0
  7799. //
  7800. // var operation_fulamt_ownpay_amt float64 = 0
  7801. // var other_fulamt_ownpay_amt float64 = 0
  7802. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  7803. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  7804. // var check_fulamt_ownpay_amt float64 = 0
  7805. // var material_fulamt_ownpay_amt float64 = 0
  7806. // var laboratory_fulamt_ownpay_amt float64 = 0
  7807. // var treat_fulamt_ownpay_amt float64 = 0
  7808. //
  7809. // var bed_claa_sunmfee float64 = 0
  7810. // var bed_clab_amt float64 = 0
  7811. // var bed_other_amt float64 = 0
  7812. //
  7813. // var examine_claa_sunmfee float64 = 0
  7814. // var examine_clab_amt float64 = 0
  7815. // var examine_other_amt float64 = 0
  7816. //
  7817. // var nursing_claa_sunmfee float64 = 0
  7818. // var nursing_clab_amt float64 = 0
  7819. // var nursing_other_amt float64 = 0
  7820. //
  7821. // var chinese_medicine_claa_sunmfee float64 = 0
  7822. // var chinese_medicine_clab_amt float64 = 0
  7823. // var chinese_medicine_other_amt float64 = 0
  7824. //
  7825. // var commonly_treatment_claa_sunmfee float64 = 0
  7826. // var commonly_treatment_clab_amt float64 = 0
  7827. // var commonly_treatment_other_amt float64 = 0
  7828. //
  7829. // var operation_claa_sunmfee float64 = 0
  7830. // var operation_clab_amt float64 = 0
  7831. // var operation_other_amt float64 = 0
  7832. //
  7833. // var other_claa_sunmfee float64 = 0
  7834. // var other_clab_amt float64 = 0
  7835. // var other_other_amt float64 = 0
  7836. //
  7837. // var westernMedicine_claa_sunmfee float64 = 0
  7838. // var westernMedicine_clab_amt float64 = 0
  7839. // var westernMedicine_other_amt float64 = 0
  7840. //
  7841. // var chineseTraditional_claa_sunmfee float64 = 0
  7842. // var chineseTraditional_clab_amt float64 = 0
  7843. // var chineseTraditional_other_amt float64 = 0
  7844. //
  7845. // var check_claa_sunmfee float64 = 0
  7846. // var check_clab_amt float64 = 0
  7847. // var check_other_amt float64 = 0
  7848. //
  7849. // var material_claa_sunmfee float64 = 0
  7850. // var material_clab_amt float64 = 0
  7851. // var material_other_amt float64 = 0
  7852. //
  7853. // var laboratory_claa_sunmfee float64 = 0
  7854. // var laboratory_clab_amt float64 = 0
  7855. // var laboratory_other_amt float64 = 0
  7856. //
  7857. // var treat_claa_sunmfee float64 = 0
  7858. // var treat_clab_amt float64 = 0
  7859. // var treat_other_amt float64 = 0
  7860. //
  7861. // var register_claa_sunmfee float64 = 0
  7862. // var register_clab_amt float64 = 0
  7863. // var register_other_amt float64 = 0
  7864. //
  7865. // for _, item := range order.HisOrderInfo {
  7866. // if item.MedChrgitmType == "01" { //床位费
  7867. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7868. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7869. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7870. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7871. // if item.ChrgitmLv == "1" {
  7872. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7873. // }
  7874. // if item.ChrgitmLv == "2" {
  7875. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7876. //
  7877. // }
  7878. // if item.ChrgitmLv == "3" {
  7879. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7880. // }
  7881. //
  7882. // }
  7883. //
  7884. // if item.MedChrgitmType == "02" { //诊查
  7885. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7886. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7887. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7888. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7889. // if item.ChrgitmLv == "1" {
  7890. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7891. // }
  7892. // if item.ChrgitmLv == "2" {
  7893. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7894. //
  7895. // }
  7896. // if item.ChrgitmLv == "3" {
  7897. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7898. // }
  7899. //
  7900. // }
  7901. //
  7902. // if item.MedChrgitmType == "03" { //检查费
  7903. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7904. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7905. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7906. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7907. // if item.ChrgitmLv == "1" {
  7908. //
  7909. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7910. //
  7911. // }
  7912. // if item.ChrgitmLv == "2" {
  7913. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7914. //
  7915. // }
  7916. // if item.ChrgitmLv == "3" {
  7917. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7918. // }
  7919. // }
  7920. //
  7921. // if item.MedChrgitmType == "04" { //化验费
  7922. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7923. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7924. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7925. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7926. // if item.ChrgitmLv == "1" {
  7927. //
  7928. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7929. //
  7930. // }
  7931. // if item.ChrgitmLv == "2" {
  7932. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7933. //
  7934. // }
  7935. // if item.ChrgitmLv == "3" {
  7936. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7937. // }
  7938. // }
  7939. //
  7940. // if item.MedChrgitmType == "05" { //治疗费
  7941. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7942. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7943. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7944. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7945. // if item.ChrgitmLv == "1" {
  7946. //
  7947. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7948. //
  7949. // }
  7950. // if item.ChrgitmLv == "2" {
  7951. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7952. //
  7953. // }
  7954. // if item.ChrgitmLv == "3" {
  7955. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7956. // }
  7957. // }
  7958. //
  7959. // if item.MedChrgitmType == "06" { //手术费
  7960. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7961. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7962. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7963. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7964. //
  7965. // if item.ChrgitmLv == "1" {
  7966. //
  7967. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7968. //
  7969. // }
  7970. // if item.ChrgitmLv == "2" {
  7971. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7972. //
  7973. // }
  7974. // if item.ChrgitmLv == "3" {
  7975. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7976. // }
  7977. // }
  7978. //
  7979. // if item.MedChrgitmType == "07" { //手术费
  7980. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7981. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7982. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7983. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7984. //
  7985. // if item.ChrgitmLv == "1" {
  7986. //
  7987. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7988. //
  7989. // }
  7990. // if item.ChrgitmLv == "2" {
  7991. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7992. //
  7993. // }
  7994. // if item.ChrgitmLv == "3" {
  7995. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7996. // }
  7997. // }
  7998. //
  7999. // if item.MedChrgitmType == "08" { //材料费
  8000. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8001. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8002. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8003. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8004. // if item.ChrgitmLv == "1" {
  8005. //
  8006. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8007. //
  8008. // }
  8009. // if item.ChrgitmLv == "2" {
  8010. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8011. //
  8012. // }
  8013. // if item.ChrgitmLv == "3" {
  8014. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8015. // }
  8016. // }
  8017. // if item.MedChrgitmType == "09" { //西药费
  8018. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8019. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8020. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8021. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8022. // if item.ChrgitmLv == "1" {
  8023. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8024. // }
  8025. // if item.ChrgitmLv == "2" {
  8026. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8027. // }
  8028. // if item.ChrgitmLv == "3" {
  8029. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8030. // }
  8031. // }
  8032. // if item.MedChrgitmType == "10" { //中药饮片
  8033. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8034. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8035. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8036. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8037. // if item.ChrgitmLv == "1" {
  8038. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8039. // }
  8040. // if item.ChrgitmLv == "2" {
  8041. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8042. // }
  8043. // if item.ChrgitmLv == "3" {
  8044. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8045. // }
  8046. // }
  8047. //
  8048. // if item.MedChrgitmType == "11" { //中成费
  8049. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8050. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8051. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8052. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8053. // if item.ChrgitmLv == "1" {
  8054. //
  8055. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8056. //
  8057. // }
  8058. // if item.ChrgitmLv == "2" {
  8059. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8060. //
  8061. // }
  8062. // if item.ChrgitmLv == "3" {
  8063. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8064. // }
  8065. // }
  8066. //
  8067. // if item.MedChrgitmType == "12" { //中成费
  8068. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8069. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8070. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8071. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8072. // if item.ChrgitmLv == "1" {
  8073. //
  8074. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8075. //
  8076. // }
  8077. // if item.ChrgitmLv == "2" {
  8078. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8079. //
  8080. // }
  8081. // if item.ChrgitmLv == "3" {
  8082. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8083. // }
  8084. // }
  8085. //
  8086. // if item.MedChrgitmType == "13" { //中成费
  8087. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8088. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8089. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8090. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8091. // if item.ChrgitmLv == "1" {
  8092. //
  8093. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8094. //
  8095. // }
  8096. // if item.ChrgitmLv == "2" {
  8097. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8098. //
  8099. // }
  8100. // if item.ChrgitmLv == "3" {
  8101. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8102. // }
  8103. // }
  8104. //
  8105. // if item.MedChrgitmType == "14" { //其他费
  8106. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8107. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8108. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8109. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8110. // if item.ChrgitmLv == "1" {
  8111. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8112. //
  8113. // }
  8114. // if item.ChrgitmLv == "2" {
  8115. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8116. //
  8117. // }
  8118. // if item.ChrgitmLv == "3" {
  8119. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8120. // }
  8121. // }
  8122. //
  8123. // }
  8124. //
  8125. // var iteminfoStructs []service.IteminfoStruct
  8126. //
  8127. // if bedCostTotal != 0 {
  8128. // iteminfo.MedChrgitm = "01"
  8129. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  8130. // iteminfo.Amt = bedCostTotal
  8131. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  8132. // iteminfo.ClabAmt = bed_clab_amt
  8133. // iteminfo.OthAmt = bed_other_amt
  8134. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8135. // }
  8136. //
  8137. // if examineCostTotal != 0 {
  8138. // iteminfo.MedChrgitm = "02"
  8139. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  8140. // iteminfo.Amt = examineCostTotal
  8141. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  8142. // iteminfo.ClabAmt = examine_clab_amt
  8143. // iteminfo.OthAmt = examine_other_amt
  8144. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8145. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8146. // }
  8147. //
  8148. // if checkCostTotal != 0 {
  8149. // iteminfo.MedChrgitm = "03"
  8150. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  8151. // iteminfo.Amt = checkCostTotal
  8152. // iteminfo.ClaaSumfee = check_claa_sunmfee
  8153. // iteminfo.ClabAmt = check_clab_amt
  8154. // iteminfo.OthAmt = check_other_amt
  8155. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8156. //
  8157. // }
  8158. //
  8159. // if laboratoryCostTotal != 0 {
  8160. // iteminfo.MedChrgitm = "04"
  8161. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  8162. // iteminfo.Amt = laboratoryCostTotal
  8163. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  8164. // iteminfo.ClabAmt = laboratory_clab_amt
  8165. // iteminfo.OthAmt = laboratory_other_amt
  8166. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8167. //
  8168. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8169. //
  8170. // }
  8171. //
  8172. // if treatCostTotal != 0 {
  8173. // iteminfo.MedChrgitm = "05"
  8174. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  8175. // iteminfo.Amt = treatCostTotal
  8176. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  8177. // iteminfo.ClabAmt = treat_clab_amt
  8178. // iteminfo.OthAmt = treat_other_amt
  8179. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8180. // //(struct4101.IteminfoStruct, iteminfo)
  8181. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8182. // }
  8183. //
  8184. // if operationCostTotal != 0 {
  8185. // iteminfo.MedChrgitm = "06"
  8186. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  8187. // iteminfo.Amt = operationCostTotal
  8188. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  8189. // iteminfo.ClabAmt = operation_clab_amt
  8190. // iteminfo.OthAmt = operation_other_amt
  8191. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8192. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8193. // }
  8194. //
  8195. // if nursingCostTotal != 0 {
  8196. // iteminfo.MedChrgitm = "07"
  8197. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  8198. // iteminfo.Amt = nursingCostTotal
  8199. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  8200. // iteminfo.ClabAmt = nursing_clab_amt
  8201. // iteminfo.OthAmt = nursing_other_amt
  8202. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8203. // }
  8204. //
  8205. // if materialCostTotal != 0 {
  8206. // iteminfo.MedChrgitm = "08"
  8207. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  8208. // iteminfo.Amt = materialCostTotal
  8209. // iteminfo.ClaaSumfee = material_claa_sunmfee
  8210. // iteminfo.ClabAmt = material_clab_amt
  8211. // iteminfo.OthAmt = material_other_amt
  8212. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8213. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8214. // }
  8215. //
  8216. // if westernMedicineCostTotal != 0 {
  8217. // iteminfo.MedChrgitm = "09"
  8218. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  8219. // iteminfo.Amt = westernMedicineCostTotal
  8220. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  8221. // iteminfo.ClabAmt = westernMedicine_clab_amt
  8222. // iteminfo.OthAmt = westernMedicine_other_amt
  8223. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8224. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8225. //
  8226. // }
  8227. //
  8228. // if chineseMedicineCostTotal != 0 {
  8229. // iteminfo.MedChrgitm = "10"
  8230. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  8231. // iteminfo.Amt = chineseMedicineCostTotal
  8232. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  8233. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  8234. // iteminfo.OthAmt = chinese_medicine_other_amt
  8235. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8236. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8237. //
  8238. // }
  8239. //
  8240. // if chineseTraditionalMedicineCostTotal != 0 {
  8241. // iteminfo.MedChrgitm = "11"
  8242. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  8243. // iteminfo.Amt = westernMedicineCostTotal
  8244. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  8245. // iteminfo.ClabAmt = westernMedicine_clab_amt
  8246. // iteminfo.OthAmt = westernMedicine_other_amt
  8247. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8248. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8249. //
  8250. // }
  8251. //
  8252. // if commonlyTreatmentCostTotal != 0 {
  8253. // iteminfo.MedChrgitm = "12"
  8254. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  8255. // iteminfo.Amt = commonlyTreatmentCostTotal
  8256. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  8257. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  8258. // iteminfo.OthAmt = commonly_treatment_other_amt
  8259. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8260. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8261. //
  8262. // }
  8263. //
  8264. // if registerCostTotal != 0 {
  8265. // iteminfo.MedChrgitm = "13"
  8266. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  8267. // iteminfo.Amt = registerCostTotal
  8268. // iteminfo.ClaaSumfee = register_claa_sunmfee
  8269. // iteminfo.ClabAmt = register_clab_amt
  8270. // iteminfo.OthAmt = register_other_amt
  8271. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8272. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8273. //
  8274. // }
  8275. //
  8276. // if otherCostTotal != 0 {
  8277. // iteminfo.MedChrgitm = "14"
  8278. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  8279. // iteminfo.Amt = otherCostTotal
  8280. // iteminfo.ClaaSumfee = other_claa_sunmfee
  8281. // iteminfo.ClabAmt = other_clab_amt
  8282. // iteminfo.OthAmt = other_other_amt
  8283. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8284. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  8285. //
  8286. // }
  8287. // struct4101.IteminfoStruct = iteminfoStructs
  8288. // time_arr := strings.Split(order.SetlTime, " ")
  8289. // struct4101.AdmTime = time_arr[0]
  8290. // struct4101.AdmEndTime = time_arr[0]
  8291. //
  8292. // struct4101.DoctorName = doctor.UserName
  8293. // struct4101.DoctorCode = doctor.DoctorNumber
  8294. //
  8295. // struct4101.Ntly = "中国"
  8296. // struct4101.AdmCaty = "A03.06"
  8297. // var res ResultSeventeen
  8298. // if miConfig.MdtrtareaAdmvs == "421300" {
  8299. // data := make(map[string]interface{})
  8300. // data["struct4101"] = struct4101
  8301. // data["secret_key"] = miConfig.SecretKey
  8302. // data["org_name"] = miConfig.OrgName
  8303. // data["opera"] = curRoles.UserName
  8304. // data["code"] = miConfig.Code
  8305. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  8306. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8307. //
  8308. // client := &http.Client{}
  8309. // bytesData, _ := json.Marshal(data)
  8310. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  8311. // resp, _ := client.Do(req)
  8312. // defer resp.Body.Close()
  8313. // body, ioErr := ioutil.ReadAll(resp.Body)
  8314. // if ioErr != nil {
  8315. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8316. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8317. // return
  8318. // }
  8319. // var respJSON map[string]interface{}
  8320. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8321. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8322. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8323. // return
  8324. // }
  8325. //
  8326. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8327. // userJSONBytes, _ := json.Marshal(respJSON)
  8328. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8329. // utils.ErrorLog("解析失败:%v", err)
  8330. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8331. // adminUser := c.GetAdminUserInfo()
  8332. // errlog := &models.HisOrderError{
  8333. // UserOrgId: adminUser.CurrentOrgId,
  8334. // Ctime: time.Now().Unix(),
  8335. // Mtime: time.Now().Unix(),
  8336. // ErrMsg: res.ErrMsg + "解析失败",
  8337. // Status: 1,
  8338. // PatientId: order_id,
  8339. // Stage: 10088,
  8340. // }
  8341. // service.CreateErrMsgLog(errlog)
  8342. // continue
  8343. // }
  8344. //
  8345. // } else {
  8346. // result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  8347. // fmt.Println(result)
  8348. //
  8349. // var dat map[string]interface{}
  8350. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8351. // fmt.Println(dat)
  8352. // } else {
  8353. // fmt.Println(err)
  8354. // }
  8355. // userJSONBytes, _ := json.Marshal(dat)
  8356. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8357. // utils.ErrorLog("解析失败:%v", err)
  8358. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8359. // adminUser := c.GetAdminUserInfo()
  8360. // errlog := &models.HisOrderError{
  8361. // UserOrgId: adminUser.CurrentOrgId,
  8362. // Ctime: time.Now().Unix(),
  8363. // Mtime: time.Now().Unix(),
  8364. // ErrMsg: res.ErrMsg + "解析失败",
  8365. // Status: 1,
  8366. // PatientId: order_id,
  8367. // Stage: 10106,
  8368. // }
  8369. // service.CreateErrMsgLog(errlog)
  8370. // continue
  8371. // }
  8372. // }
  8373. //
  8374. // if res.Infcode != 0 {
  8375. // adminUser := c.GetAdminUserInfo()
  8376. // errlog := &models.HisOrderError{
  8377. // UserOrgId: adminUser.CurrentOrgId,
  8378. // Ctime: time.Now().Unix(),
  8379. // Mtime: time.Now().Unix(),
  8380. // ErrMsg: res.ErrMsg,
  8381. // Status: 1,
  8382. // PatientId: order_id,
  8383. // Stage: 10106,
  8384. // }
  8385. // service.CreateErrMsgLog(errlog)
  8386. // continue
  8387. // } else {
  8388. // hisFundSettleListResult := &models.HisFundSettleListResult{
  8389. // Number: res.Output.SetlListId,
  8390. // Status: 1,
  8391. // Ctime: time.Now().Unix(),
  8392. // Mtime: time.Now().Unix(),
  8393. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8394. // IsUpload: 1,
  8395. // OrderId: order_id,
  8396. // }
  8397. // service.CreateUploadRecord(hisFundSettleListResult)
  8398. // continue
  8399. // }
  8400. // }
  8401. //}
  8402. func (c *HisApiController) GetOrgInfo() {
  8403. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  8404. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  8405. }
  8406. func (c *HisApiController) GetHisPatientInfo() {
  8407. medical_insurance_card := c.GetString("medical_insurance_card")
  8408. id_card_type, _ := c.GetInt64("id_card_type")
  8409. id_card := c.GetString("id_card")
  8410. adminInfo := c.GetAdminUserInfo()
  8411. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8412. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8413. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  8414. IdCardNo := ""
  8415. if id_card_type == 1 {
  8416. IdCardNo = medical_insurance_card
  8417. } else if id_card_type == 2 {
  8418. IdCardNo = id_card
  8419. }
  8420. if config.IsOpen == 1 {
  8421. 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
  8422. resp, requestErr := http.Get(api)
  8423. if requestErr != nil {
  8424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8425. return
  8426. }
  8427. defer resp.Body.Close()
  8428. body, ioErr := ioutil.ReadAll(resp.Body)
  8429. if ioErr != nil {
  8430. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8432. return
  8433. }
  8434. var respJSON map[string]interface{}
  8435. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8438. return
  8439. }
  8440. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8441. userJSONBytes, _ := json.Marshal(userJSON)
  8442. var res ResultTwo
  8443. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8444. utils.ErrorLog("解析失败:%v", err)
  8445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8446. return
  8447. }
  8448. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8449. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8450. infoStr := string(Iinfos)
  8451. idetinfoStr := string(Idetinfos)
  8452. if res.Infcode == 0 {
  8453. his := models.VMHisPatient{
  8454. Status: 1,
  8455. Ctime: time.Now().Unix(),
  8456. Mtime: time.Now().Unix(),
  8457. PsnNo: res.Output.Baseinfo.PsnNo,
  8458. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8459. Certno: res.Output.Baseinfo.Certno,
  8460. PsnName: res.Output.Baseinfo.PsnName,
  8461. Gend: res.Output.Baseinfo.Gend,
  8462. Naty: res.Output.Baseinfo.Naty,
  8463. Brdy: res.Output.Baseinfo.Brdy,
  8464. Age: res.Output.Baseinfo.Age,
  8465. Iinfo: infoStr,
  8466. Idetinfo: idetinfoStr,
  8467. UserOrgId: adminInfo.CurrentOrgId,
  8468. IsReturn: 1,
  8469. IdCardType: id_card_type,
  8470. }
  8471. c.ServeSuccessJSON(map[string]interface{}{
  8472. "info": his,
  8473. })
  8474. } else {
  8475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8476. return
  8477. }
  8478. }
  8479. }
  8480. //func GetBasBaseInfo() (jsonStr string, err error) {
  8481. //
  8482. // handle := syscall.NewLazyDLL("SSCard.dll")
  8483. // add := handle.NewProc("ReadCardBas")
  8484. // str := make([]byte, 1024)
  8485. // str1 := make([]byte, 1024)
  8486. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  8487. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  8488. //
  8489. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  8490. //
  8491. // fmt.Println("> Add(4,5)的结果为:", ret)
  8492. // handle.Release()
  8493. //
  8494. // return "", nil
  8495. //
  8496. //}
  8497. //func GetQRBaseInfo() (jsonStr string, err error) {
  8498. // handle := syscall.LoadDLL("SSCard.dll")
  8499. // ReadCardBas := handle.FindProc("GetQRBase")
  8500. //
  8501. // str := make([]byte, 256)
  8502. // str1 := make([]byte, 256)
  8503. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  8504. //
  8505. // fmt.Println(string(str))
  8506. // fmt.Println(r)
  8507. // return string(str), nil
  8508. //}
  8509. //func CardInit() int {
  8510. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  8511. // add := DllTestDef.MustFindProc("Init")
  8512. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  8513. // if err != nil {
  8514. // fmt.Println("SSCard的运算结果为:", ret)
  8515. // }
  8516. // result := int(ret)
  8517. // return result
  8518. //}
  8519. //func CardInit() int {
  8520. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  8521. // if err != nil {
  8522. // fmt.Println("SSCard的运算结果为:", ret)
  8523. // }
  8524. // fmt.Println(err)
  8525. // result := int(ret)
  8526. // return result
  8527. //}
  8528. func IntPtr(n int) uintptr {
  8529. return uintptr(n)
  8530. }
  8531. func StrPtr(s string) uintptr {
  8532. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  8533. }
  8534. type Result2001 struct {
  8535. Cainfo interface{} `json:"cainfo"`
  8536. ErrMsg string `json:"err_msg"`
  8537. InfRefmsgid string `json:"inf_refmsgid"`
  8538. Infcode int64 `json:"infcode"`
  8539. Output struct {
  8540. Trtinfo struct {
  8541. PsnNo string `json:"psn_no"`
  8542. TrtChkType string `json:"trt_chk_type"`
  8543. FundPayType string `json:"fund_pay_type"`
  8544. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  8545. Begndate string `json:"begndate"`
  8546. Enddate string `json:"enddate"`
  8547. TrtChkRslt string `json:"trt_chk_rslt"`
  8548. } `json:"trtinfo"`
  8549. } `json:"output"`
  8550. RefmsgTime string `json:"refmsg_time"`
  8551. RespondTime string `json:"respond_time"`
  8552. Signtype interface{} `json:"signtype"`
  8553. WarnMsg interface{} `json:"warn_msg"`
  8554. }
  8555. type Result2001Org10265 struct {
  8556. Cainfo interface{} `json:"cainfo"`
  8557. ErrMsg string `json:"err_msg"`
  8558. InfRefmsgid string `json:"inf_refmsgid"`
  8559. Infcode string `json:"infcode"`
  8560. Output struct {
  8561. Trtinfo struct {
  8562. PsnNo string `json:"psn_no"`
  8563. TrtChkType string `json:"trt_chk_type"`
  8564. FundPayType string `json:"fund_pay_type"`
  8565. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  8566. Begndate string `json:"begndate"`
  8567. Enddate string `json:"enddate"`
  8568. TrtChkRslt string `json:"trt_chk_rslt"`
  8569. } `json:"trtinfo"`
  8570. } `json:"output"`
  8571. RefmsgTime string `json:"refmsg_time"`
  8572. RespondTime string `json:"respond_time"`
  8573. Signtype interface{} `json:"signtype"`
  8574. WarnMsg interface{} `json:"warn_msg"`
  8575. }
  8576. type ResultTwo struct {
  8577. ErrMsg string `json:"err_msg"`
  8578. InfRefmsgid string `json:"inf_refmsgid"`
  8579. Infcode int64 `json:"infcode"`
  8580. Output struct {
  8581. Baseinfo struct {
  8582. Age float64 `json:"age"`
  8583. Brdy string `json:"brdy"`
  8584. Certno string `json:"certno"`
  8585. Gend string `json:"gend"`
  8586. Naty string `json:"naty"`
  8587. PsnCertType string `json:"psn_cert_type"`
  8588. PsnName string `json:"psn_name"`
  8589. PsnNo string `json:"psn_no"`
  8590. } `json:"baseinfo"`
  8591. Idetinfo []interface{} `json:"idetinfo"`
  8592. Iinfo []struct {
  8593. Balc float64 `json:"balc"`
  8594. CvlservFlag string `json:"cvlserv_flag"`
  8595. EmpName string `json:"emp_name"`
  8596. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  8597. Insutype string `json:"insutype"`
  8598. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  8599. PausInsuDate string `json:"paus_insu_date"`
  8600. PsnInsuDate string `json:"psn_insu_date"`
  8601. PsnInsuStas string `json:"psn_insu_stas"`
  8602. PsnType string `json:"psn_type"`
  8603. } `json:"insuinfo"`
  8604. } `json:"output"`
  8605. RefmsgTime string `json:"refmsg_time"`
  8606. RespondTime string `json:"respond_time"`
  8607. Signtype interface{} `json:"signtype"`
  8608. WarnInfo interface{} `json:"warn_info"`
  8609. }
  8610. type ResultTwo10265 struct {
  8611. ErrMsg string `json:"err_msg"`
  8612. InfRefmsgid string `json:"inf_refmsgid"`
  8613. Infcode string `json:"infcode"`
  8614. Output struct {
  8615. Baseinfo struct {
  8616. Age float64 `json:"age"`
  8617. Brdy string `json:"brdy"`
  8618. Certno string `json:"certno"`
  8619. Gend string `json:"gend"`
  8620. Naty string `json:"naty"`
  8621. PsnCertType string `json:"psn_cert_type"`
  8622. PsnName string `json:"psn_name"`
  8623. PsnNo string `json:"psn_no"`
  8624. } `json:"baseinfo"`
  8625. Idetinfo []interface{} `json:"idetinfo"`
  8626. Iinfo []struct {
  8627. Balc float64 `json:"balc"`
  8628. CvlservFlag string `json:"cvlserv_flag"`
  8629. EmpName string `json:"emp_name"`
  8630. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  8631. Insutype string `json:"insutype"`
  8632. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  8633. PausInsuDate string `json:"paus_insu_date"`
  8634. PsnInsuDate string `json:"psn_insu_date"`
  8635. PsnInsuStas string `json:"psn_insu_stas"`
  8636. PsnType string `json:"psn_type"`
  8637. } `json:"insuinfo"`
  8638. } `json:"output"`
  8639. RefmsgTime string `json:"refmsg_time"`
  8640. RespondTime string `json:"respond_time"`
  8641. Signtype interface{} `json:"signtype"`
  8642. WarnInfo interface{} `json:"warn_info"`
  8643. }
  8644. type ResultThree struct {
  8645. Cainfo interface{} `json:"cainfo"`
  8646. ErrMsg string `json:"err_msg"`
  8647. InfRefmsgid string `json:"inf_refmsgid"`
  8648. Infcode int64 `json:"infcode"`
  8649. Output struct {
  8650. Data struct {
  8651. IptOtpNo string `json:"ipt_otp_no"`
  8652. MdtrtID string `json:"mdtrt_id"`
  8653. PsnNo string `json:"psn_no"`
  8654. } `json:"data"`
  8655. } `json:"output"`
  8656. RefmsgTime string `json:"refmsg_time"`
  8657. RespondTime string `json:"respond_time"`
  8658. Signtype interface{} `json:"signtype"`
  8659. WarnMsg interface{} `json:"warn_msg"`
  8660. }
  8661. type ResultThree10265 struct {
  8662. Cainfo interface{} `json:"cainfo"`
  8663. ErrMsg string `json:"err_msg"`
  8664. InfRefmsgid string `json:"inf_refmsgid"`
  8665. Infcode string `json:"infcode"`
  8666. Output struct {
  8667. Data struct {
  8668. IptOtpNo string `json:"ipt_otp_no"`
  8669. MdtrtID string `json:"mdtrt_id"`
  8670. PsnNo string `json:"psn_no"`
  8671. } `json:"data"`
  8672. } `json:"output"`
  8673. RefmsgTime string `json:"refmsg_time"`
  8674. RespondTime string `json:"respond_time"`
  8675. Signtype interface{} `json:"signtype"`
  8676. WarnMsg interface{} `json:"warn_msg"`
  8677. }
  8678. type ResultFour struct {
  8679. Cainfo string `json:"cainfo"`
  8680. ErrMsg string `json:"err_msg"`
  8681. InfRefmsgid string `json:"inf_refmsgid"`
  8682. Infcode int64 `json:"infcode"`
  8683. Output struct {
  8684. Result []struct {
  8685. BasMednFlag string `json:"bas_medn_flag"`
  8686. ChldMedcFlag string `json:"chld_medc_flag"`
  8687. ChrgitmLv string `json:"chrgitm_lv"`
  8688. Cnt float64 `json:"cnt"`
  8689. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  8690. DrtReimFlag string `json:"drt_reim_flag"`
  8691. FeedetlSn string `json:"feedetl_sn"`
  8692. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8693. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  8694. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8695. ListSpItemFlag string `json:"list_sp_item_flag"`
  8696. LmtUsedFlag string `json:"lmt_used_flag"`
  8697. MedChrgitmType string `json:"med_chrgitm_type"`
  8698. Memo string `json:"memo"`
  8699. OverlmtAmt float64 `json:"overlmt_amt"`
  8700. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8701. Pric float64 `json:"pric"`
  8702. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  8703. SelfpayProp float64 `json:"selfpay_prop"`
  8704. } `json:"result"`
  8705. } `json:"output"`
  8706. RefmsgTime string `json:"refmsg_time"`
  8707. RespondTime string `json:"respond_time"`
  8708. Signtype string `json:"signtype"`
  8709. WarnMsg string `json:"warn_msg"`
  8710. }
  8711. type ResultFour10265 struct {
  8712. Cainfo string `json:"cainfo"`
  8713. ErrMsg string `json:"err_msg"`
  8714. InfRefmsgid string `json:"inf_refmsgid"`
  8715. Infcode string `json:"infcode"`
  8716. Output struct {
  8717. Result []struct {
  8718. BasMednFlag string `json:"bas_medn_flag"`
  8719. ChldMedcFlag string `json:"chld_medc_flag"`
  8720. ChrgitmLv string `json:"chrgitm_lv"`
  8721. Cnt float64 `json:"cnt"`
  8722. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  8723. DrtReimFlag string `json:"drt_reim_flag"`
  8724. FeedetlSn string `json:"feedetl_sn"`
  8725. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8726. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  8727. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8728. ListSpItemFlag string `json:"list_sp_item_flag"`
  8729. LmtUsedFlag string `json:"lmt_used_flag"`
  8730. MedChrgitmType string `json:"med_chrgitm_type"`
  8731. Memo string `json:"memo"`
  8732. OverlmtAmt float64 `json:"overlmt_amt"`
  8733. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8734. Pric float64 `json:"pric"`
  8735. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  8736. SelfpayProp float64 `json:"selfpay_prop"`
  8737. } `json:"result"`
  8738. } `json:"output"`
  8739. RefmsgTime string `json:"refmsg_time"`
  8740. RespondTime string `json:"respond_time"`
  8741. Signtype string `json:"signtype"`
  8742. WarnMsg string `json:"warn_msg"`
  8743. }
  8744. type ResultMemo struct {
  8745. InsuAdmdvs string `json:"insuAdmdvs"`
  8746. }
  8747. // [{"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}]
  8748. type ResultIDInfo struct {
  8749. Begntime string `json:"begntime"`
  8750. Endtime string `json:"endtime"`
  8751. Memo string `json:"memo"`
  8752. }
  8753. type ResultFive struct {
  8754. Balc float64 `json:"balc"`
  8755. CvlservFlag string `json:"cvlserv_flag"`
  8756. EmpName string `json:"emp_name"`
  8757. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  8758. Insutype string `json:"insutype"`
  8759. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  8760. PausInsuDate string `json:"paus_insu_date"`
  8761. PsnInsuDate string `json:"psn_insu_date"`
  8762. PsnInsuStas string `json:"psn_insu_stas"`
  8763. PsnType string `json:"psn_type"`
  8764. }
  8765. type ResultSix struct {
  8766. Cainfo interface{} `json:"cainfo"`
  8767. ErrMsg string `json:"err_msg"`
  8768. InfRefmsgid string `json:"inf_refmsgid"`
  8769. Infcode int64 `json:"infcode"`
  8770. Output struct {
  8771. } `json:"output"`
  8772. RefmsgTime string `json:"refmsg_time"`
  8773. RespondTime string `json:"respond_time"`
  8774. Signtype interface{} `json:"signtype"`
  8775. WarnMsg interface{} `json:"warn_msg"`
  8776. }
  8777. type ResultSix10265 struct {
  8778. Cainfo interface{} `json:"cainfo"`
  8779. ErrMsg string `json:"err_msg"`
  8780. InfRefmsgid string `json:"inf_refmsgid"`
  8781. Infcode string `json:"infcode"`
  8782. Output struct {
  8783. } `json:"output"`
  8784. RefmsgTime string `json:"refmsg_time"`
  8785. RespondTime string `json:"respond_time"`
  8786. Signtype interface{} `json:"signtype"`
  8787. WarnMsg interface{} `json:"warn_msg"`
  8788. }
  8789. type ResultSeven struct {
  8790. Cainfo string `json:"cainfo"`
  8791. ErrMsg string `json:"err_msg"`
  8792. InfRefmsgid string `json:"inf_refmsgid"`
  8793. Infcode int64 `json:"infcode"`
  8794. Output struct {
  8795. Setldetail []interface{} `json:"setldetail"`
  8796. Setlinfo struct {
  8797. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  8798. AcctPay float64 `json:"acct_pay"`
  8799. ActPayDedc float64 `json:"act_pay_dedc"`
  8800. Age float64 `json:"age"`
  8801. Balc float64 `json:"balc"`
  8802. Brdy string `json:"brdy"`
  8803. Certno string `json:"certno"`
  8804. ClrOptins string `json:"clr_optins"`
  8805. ClrType string `json:"clr_type"`
  8806. ClrWay string `json:"clr_way"`
  8807. CvlservFlag string `json:"cvlserv_flag"`
  8808. CvlservPay float64 `json:"cvlserv_pay"`
  8809. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8810. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8811. Gend string `json:"gend"`
  8812. HifesPay float64 `json:"hifes_pay"`
  8813. HifmiPay float64 `json:"hifmi_pay"`
  8814. HifpPay float64 `json:"hifp_pay"`
  8815. HospPartAmt float64 `json:"hosp_part_amt"`
  8816. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8817. Insutype string `json:"insutype"`
  8818. MafPay float64 `json:"maf_pay"`
  8819. MdtrtCertType string `json:"mdtrt_cert_type"`
  8820. HifobPay float64 `json:"hifob_pay"`
  8821. MdtrtID string `json:"mdtrt_id"`
  8822. MedType string `json:"med_type"`
  8823. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8824. MedinsSetlID string `json:"medins_setl_id"`
  8825. Naty string `json:"naty"`
  8826. OthPay float64 `json:"oth_pay"`
  8827. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8828. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  8829. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8830. PsnCashPay float64 `json:"psn_cash_pay"`
  8831. PsnCertType string `json:"psn_cert_type"`
  8832. PsnName string `json:"psn_name"`
  8833. PsnNo string `json:"psn_no"`
  8834. PsnPartAmt float64 `json:"psn_part_amt"`
  8835. PsnType string `json:"psn_type"`
  8836. SetlID string `json:"setl_id"`
  8837. SetlTime string `json:"setl_time"`
  8838. } `json:"setlinfo"`
  8839. } `json:"output"`
  8840. RefmsgTime string `json:"refmsg_time"`
  8841. RespondTime string `json:"respond_time"`
  8842. Signtype interface{} `json:"signtype"`
  8843. WarnMsg interface{} `json:"warn_msg"`
  8844. }
  8845. type ResultSeven10265 struct {
  8846. Cainfo string `json:"cainfo"`
  8847. ErrMsg string `json:"err_msg"`
  8848. InfRefmsgid string `json:"inf_refmsgid"`
  8849. Infcode string `json:"infcode"`
  8850. Output struct {
  8851. Setldetail []interface{} `json:"setldetail"`
  8852. Setlinfo struct {
  8853. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  8854. AcctPay float64 `json:"acct_pay"`
  8855. ActPayDedc float64 `json:"act_pay_dedc"`
  8856. Age float64 `json:"age"`
  8857. Balc float64 `json:"balc"`
  8858. Brdy string `json:"brdy"`
  8859. Certno string `json:"certno"`
  8860. ClrOptins string `json:"clr_optins"`
  8861. ClrType string `json:"clr_type"`
  8862. ClrWay string `json:"clr_way"`
  8863. CvlservFlag string `json:"cvlserv_flag"`
  8864. CvlservPay float64 `json:"cvlserv_pay"`
  8865. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8866. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8867. Gend string `json:"gend"`
  8868. HifesPay float64 `json:"hifes_pay"`
  8869. HifmiPay float64 `json:"hifmi_pay"`
  8870. HifpPay float64 `json:"hifp_pay"`
  8871. HospPartAmt float64 `json:"hosp_part_amt"`
  8872. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8873. Insutype string `json:"insutype"`
  8874. MafPay float64 `json:"maf_pay"`
  8875. MdtrtCertType string `json:"mdtrt_cert_type"`
  8876. HifobPay float64 `json:"hifob_pay"`
  8877. MdtrtID string `json:"mdtrt_id"`
  8878. MedType string `json:"med_type"`
  8879. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8880. MedinsSetlID string `json:"medins_setl_id"`
  8881. Naty string `json:"naty"`
  8882. OthPay float64 `json:"oth_pay"`
  8883. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8884. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  8885. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8886. PsnCashPay float64 `json:"psn_cash_pay"`
  8887. PsnCertType string `json:"psn_cert_type"`
  8888. PsnName string `json:"psn_name"`
  8889. PsnNo string `json:"psn_no"`
  8890. PsnPartAmt float64 `json:"psn_part_amt"`
  8891. PsnType string `json:"psn_type"`
  8892. SetlID string `json:"setl_id"`
  8893. SetlTime string `json:"setl_time"`
  8894. } `json:"setlinfo"`
  8895. } `json:"output"`
  8896. RefmsgTime string `json:"refmsg_time"`
  8897. RespondTime string `json:"respond_time"`
  8898. Signtype interface{} `json:"signtype"`
  8899. WarnMsg interface{} `json:"warn_msg"`
  8900. }
  8901. type ResultEight struct {
  8902. Cainfo string `json:"cainfo"`
  8903. ErrMsg string `json:"err_msg"`
  8904. InfRefmsgid string `json:"inf_refmsgid"`
  8905. Infcode int64 `json:"infcode"`
  8906. Output struct {
  8907. Stmtinfo struct {
  8908. SetlOptins string `json:"setl_optins"`
  8909. StmtRslt string `json:"stmt_rslt"`
  8910. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  8911. } `json:"stmtinfo"`
  8912. } `json:"output"`
  8913. RefmsgTime string `json:"refmsg_time"`
  8914. RespondTime string `json:"respond_time"`
  8915. Signtype interface{} `json:"signtype"`
  8916. WarnMsg interface{} `json:"warn_msg"`
  8917. }
  8918. type ResultEightFor10188 struct {
  8919. Cainfo string `json:"cainfo"`
  8920. ErrMsg string `json:"err_msg"`
  8921. InfRefmsgid string `json:"inf_refmsgid"`
  8922. Infcode string `json:"infcode"`
  8923. Output struct {
  8924. Stmtinfo struct {
  8925. SetlOptins string `json:"setl_optins"`
  8926. StmtRslt string `json:"stmt_rslt"`
  8927. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  8928. } `json:"stmtinfo"`
  8929. } `json:"output"`
  8930. RefmsgTime string `json:"refmsg_time"`
  8931. RespondTime string `json:"respond_time"`
  8932. Signtype interface{} `json:"signtype"`
  8933. WarnMsg interface{} `json:"warn_msg"`
  8934. }
  8935. type ResultNine struct {
  8936. Cainfo string `json:"cainfo"`
  8937. ErrMsg string `json:"err_msg"`
  8938. InfRefmsgid string `json:"inf_refmsgid"`
  8939. Infcode int64 `json:"infcode"`
  8940. Output struct {
  8941. FileQuryNo string `json:"file_qury_no"`
  8942. } `json:"output"`
  8943. RefmsgTime string `json:"refmsg_time"`
  8944. RespondTime string `json:"respond_time"`
  8945. Signtype interface{} `json:"signtype"`
  8946. WarnMsg interface{} `json:"warn_msg"`
  8947. }
  8948. type ResultTen struct {
  8949. Cainfo string `json:"cainfo"`
  8950. ErrMsg string `json:"err_msg"`
  8951. InfRefmsgid string `json:"inf_refmsgid"`
  8952. Infcode int64 `json:"infcode"`
  8953. Output struct {
  8954. DldEndtime string `json:"dld_endtime"`
  8955. FileQuryNo string `json:"file_qury_no"`
  8956. Filename string `json:"filename"`
  8957. } `json:"output"`
  8958. RefmsgTime string `json:"refmsg_time"`
  8959. RespondTime string `json:"respond_time"`
  8960. Signtype interface{} `json:"signtype"`
  8961. WarnMsg interface{} `json:"warn_msg"`
  8962. }
  8963. //type Autogenerated struct {
  8964. // Output struct {
  8965. // Setlinfo struct {
  8966. // SetlTime string `json:"setl_time"`
  8967. // CvlservPay float64 `json:"cvlserv_pay"`
  8968. // Year string `json:"year"`
  8969. // MedType string `json:"med_type"`
  8970. // PsnPay float64 `json:"psn_pay"`
  8971. // OpterID string `json:"opter_id"`
  8972. // Begndate string `json:"begndate"`
  8973. // FlxempeFlag string `json:"flxempe_flag"`
  8974. // HifmiPay float64 `json:"hifmi_pay"`
  8975. // PsnNo string `json:"psn_no"`
  8976. // ActPayDedc float64 `json:"act_pay_dedc"`
  8977. // MedinsSetlID interface{} `json:"medins_setl_id"`
  8978. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  8979. // ClrWay string `json:"clr_way"`
  8980. // OthPay float64 `json:"oth_pay"`
  8981. // Gend string `json:"gend"`
  8982. // MdtrtID string `json:"mdtrt_id"`
  8983. // AcctPay float64 `json:"acct_pay"`
  8984. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  8985. // Insutype string `json:"insutype"`
  8986. // Invono interface{} `json:"invono"`
  8987. // Enddate string `json:"enddate"`
  8988. // CashPayamt float64 `json:"cash_payamt"`
  8989. // PsnType string `json:"psn_type"`
  8990. // FixmedinsName string `json:"fixmedins_name"`
  8991. // HifpPay float64 `json:"hifp_pay"`
  8992. // NewFlag interface{} `json:"new_flag"`
  8993. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8994. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  8995. // PayLoc string `json:"pay_loc"`
  8996. // ClrType string `json:"clr_type"`
  8997. // RefdSetlFlag string `json:"refd_setl_flag"`
  8998. // CvlservFlag string `json:"cvlserv_flag"`
  8999. // EmpName string `json:"emp_name"`
  9000. // Brdy string `json:"brdy"`
  9001. // Naty string `json:"naty"`
  9002. // Certno string `json:"certno"`
  9003. // DiseCode string `json:"dise_code"`
  9004. // FixmedinsCode string `json:"fixmedins_code"`
  9005. // DedcHospLv string `json:"dedc_hosp_lv"`
  9006. // OpterName string `json:"opter_name"`
  9007. // Balc float64 `json:"balc"`
  9008. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  9009. // PsnCertType string `json:"psn_cert_type"`
  9010. // HifobPay float64 `json:"hifob_pay"`
  9011. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  9012. // HifesPay float64 `json:"hifes_pay"`
  9013. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9014. // OptTime string `json:"opt_time"`
  9015. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9016. // SetlID string `json:"setl_id"`
  9017. // MafPay float64 `json:"maf_pay"`
  9018. // PsnName string `json:"psn_name"`
  9019. // InsuOptins interface{} `json:"insu_optins"`
  9020. // PrefFundPay interface{} `json:"pref_fund_pay"`
  9021. // ClrOptins string `json:"clr_optins"`
  9022. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  9023. // DiseName string `json:"dise_name"`
  9024. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  9025. // Age float64 `json:"age"`
  9026. // DtrtCertType string `json:"dtrt_cert_type"`
  9027. // HospLv string `json:"hosp_lv"`
  9028. // } `json:"setlinfo"`
  9029. // Setldetail []struct {
  9030. // FundPayType string `json:"fund_pay_type"`
  9031. // FundPayamt float64 `json:"fund_payamt"`
  9032. // SetlProcInfo interface{} `json:"setl_proc_info"`
  9033. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  9034. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  9035. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  9036. // PrefFundPay interface{} `json:"pref_fund_pay"`
  9037. // } `json:"setldetail"`
  9038. // } `json:"output"`
  9039. // Infcode int `json:"infcode"`
  9040. // WarnMsg interface{} `json:"warn_msg"`
  9041. // Cainfo interface{} `json:"cainfo"`
  9042. // ErrMsg interface{} `json:"err_msg"`
  9043. // RefmsgTime string `json:"refmsg_time"`
  9044. // Signtype interface{} `json:"signtype"`
  9045. // RespondTime string `json:"respond_time"`
  9046. // InfRefmsgid string `json:"inf_refmsgid"`
  9047. //}
  9048. type ResultEleven struct {
  9049. Cainfo string `json:"cainfo"`
  9050. ErrMsg string `json:"err_msg"`
  9051. InfRefmsgid string `json:"inf_refmsgid"`
  9052. Infcode int64 `json:"infcode"`
  9053. Output struct {
  9054. Setlinfo struct {
  9055. SetlTime string `json:"setl_time"`
  9056. CvlservPay float64 `json:"cvlserv_pay"`
  9057. Year string `json:"year"`
  9058. MedType string `json:"med_type"`
  9059. PsnPay float64 `json:"psn_pay"`
  9060. OpterID string `json:"opter_id"`
  9061. Begndate string `json:"begndate"`
  9062. FlxempeFlag string `json:"flxempe_flag"`
  9063. HifmiPay float64 `json:"hifmi_pay"`
  9064. PsnNo string `json:"psn_no"`
  9065. ActPayDedc float64 `json:"act_pay_dedc"`
  9066. MedinsSetlID interface{} `json:"medins_setl_id"`
  9067. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  9068. ClrWay string `json:"clr_way"`
  9069. OthPay float64 `json:"oth_pay"`
  9070. Gend string `json:"gend"`
  9071. MdtrtID string `json:"mdtrt_id"`
  9072. AcctPay float64 `json:"acct_pay"`
  9073. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9074. Insutype string `json:"insutype"`
  9075. Invono interface{} `json:"invono"`
  9076. Enddate string `json:"enddate"`
  9077. CashPayamt float64 `json:"cash_payamt"`
  9078. PsnType string `json:"psn_type"`
  9079. FixmedinsName string `json:"fixmedins_name"`
  9080. HifpPay float64 `json:"hifp_pay"`
  9081. NewFlag interface{} `json:"new_flag"`
  9082. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9083. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9084. PayLoc string `json:"pay_loc"`
  9085. ClrType string `json:"clr_type"`
  9086. RefdSetlFlag string `json:"refd_setl_flag"`
  9087. CvlservFlag string `json:"cvlserv_flag"`
  9088. EmpName string `json:"emp_name"`
  9089. Brdy string `json:"brdy"`
  9090. Naty string `json:"naty"`
  9091. Certno string `json:"certno"`
  9092. DiseCode string `json:"dise_code"`
  9093. FixmedinsCode string `json:"fixmedins_code"`
  9094. DedcHospLv string `json:"dedc_hosp_lv"`
  9095. OpterName string `json:"opter_name"`
  9096. Balc float64 `json:"balc"`
  9097. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  9098. PsnCertType string `json:"psn_cert_type"`
  9099. HifobPay float64 `json:"hifob_pay"`
  9100. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9101. HifesPay float64 `json:"hifes_pay"`
  9102. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9103. OptTime string `json:"opt_time"`
  9104. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9105. SetlID string `json:"setl_id"`
  9106. MafPay float64 `json:"maf_pay"`
  9107. PsnName string `json:"psn_name"`
  9108. InsuOptins interface{} `json:"insu_optins"`
  9109. PrefFundPay interface{} `json:"pref_fund_pay"`
  9110. ClrOptins string `json:"clr_optins"`
  9111. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  9112. DiseName string `json:"dise_name"`
  9113. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  9114. Age float64 `json:"age"`
  9115. DtrtCertType string `json:"dtrt_cert_type"`
  9116. HospLv string `json:"hosp_lv"`
  9117. PsnCashPay float64
  9118. } `json:"setlinfo"`
  9119. } `json:"output"`
  9120. RefmsgTime string `json:"refmsg_time"`
  9121. RespondTime string `json:"respond_time"`
  9122. Signtype interface{} `json:"signtype"`
  9123. WarnMsg interface{} `json:"warn_msg"`
  9124. }
  9125. type ResultEleven10265 struct {
  9126. Cainfo string `json:"cainfo"`
  9127. ErrMsg string `json:"err_msg"`
  9128. InfRefmsgid string `json:"inf_refmsgid"`
  9129. Infcode string `json:"infcode"`
  9130. Output struct {
  9131. Setlinfo struct {
  9132. SetlTime string `json:"setl_time"`
  9133. CvlservPay float64 `json:"cvlserv_pay"`
  9134. Year string `json:"year"`
  9135. MedType string `json:"med_type"`
  9136. PsnPay float64 `json:"psn_pay"`
  9137. OpterID string `json:"opter_id"`
  9138. Begndate string `json:"begndate"`
  9139. FlxempeFlag string `json:"flxempe_flag"`
  9140. HifmiPay float64 `json:"hifmi_pay"`
  9141. PsnNo string `json:"psn_no"`
  9142. ActPayDedc float64 `json:"act_pay_dedc"`
  9143. MedinsSetlID interface{} `json:"medins_setl_id"`
  9144. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  9145. ClrWay string `json:"clr_way"`
  9146. OthPay float64 `json:"oth_pay"`
  9147. Gend string `json:"gend"`
  9148. MdtrtID string `json:"mdtrt_id"`
  9149. AcctPay float64 `json:"acct_pay"`
  9150. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9151. Insutype string `json:"insutype"`
  9152. Invono interface{} `json:"invono"`
  9153. Enddate string `json:"enddate"`
  9154. CashPayamt float64 `json:"cash_payamt"`
  9155. PsnType string `json:"psn_type"`
  9156. FixmedinsName string `json:"fixmedins_name"`
  9157. HifpPay float64 `json:"hifp_pay"`
  9158. NewFlag interface{} `json:"new_flag"`
  9159. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9160. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9161. PayLoc string `json:"pay_loc"`
  9162. ClrType string `json:"clr_type"`
  9163. RefdSetlFlag string `json:"refd_setl_flag"`
  9164. CvlservFlag string `json:"cvlserv_flag"`
  9165. EmpName string `json:"emp_name"`
  9166. Brdy string `json:"brdy"`
  9167. Naty string `json:"naty"`
  9168. Certno string `json:"certno"`
  9169. DiseCode string `json:"dise_code"`
  9170. FixmedinsCode string `json:"fixmedins_code"`
  9171. DedcHospLv string `json:"dedc_hosp_lv"`
  9172. OpterName string `json:"opter_name"`
  9173. Balc float64 `json:"balc"`
  9174. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  9175. PsnCertType string `json:"psn_cert_type"`
  9176. HifobPay float64 `json:"hifob_pay"`
  9177. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9178. HifesPay float64 `json:"hifes_pay"`
  9179. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9180. OptTime string `json:"opt_time"`
  9181. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9182. SetlID string `json:"setl_id"`
  9183. MafPay float64 `json:"maf_pay"`
  9184. PsnName string `json:"psn_name"`
  9185. InsuOptins interface{} `json:"insu_optins"`
  9186. PrefFundPay interface{} `json:"pref_fund_pay"`
  9187. ClrOptins string `json:"clr_optins"`
  9188. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  9189. DiseName string `json:"dise_name"`
  9190. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  9191. Age float64 `json:"age"`
  9192. DtrtCertType string `json:"dtrt_cert_type"`
  9193. HospLv string `json:"hosp_lv"`
  9194. PsnCashPay float64
  9195. } `json:"setlinfo"`
  9196. } `json:"output"`
  9197. RefmsgTime string `json:"refmsg_time"`
  9198. RespondTime string `json:"respond_time"`
  9199. Signtype interface{} `json:"signtype"`
  9200. WarnMsg interface{} `json:"warn_msg"`
  9201. }
  9202. type ResultTwelve struct {
  9203. Cainfo string `json:"cainfo"`
  9204. ErrMsg string `json:"err_msg"`
  9205. InfRefmsgid string `json:"inf_refmsgid"`
  9206. Infcode int64 `json:"infcode"`
  9207. Output struct {
  9208. MdtrtId string `json:"mdtrt_id"`
  9209. ChrgBchno string `json:"chrg_bchno"`
  9210. PsnNo string `json:"psn_no"`
  9211. } `json:"output"`
  9212. RefmsgTime string `json:"refmsg_time"`
  9213. RespondTime string `json:"respond_time"`
  9214. Signtype interface{} `json:"signtype"`
  9215. WarnMsg interface{} `json:"warn_msg"`
  9216. }
  9217. type ResultThirteen struct {
  9218. ErrMsg string `json:"err_msg"`
  9219. InfRefmsgid string `json:"inf_refmsgid"`
  9220. Infcode int64 `json:"infcode"`
  9221. Output struct {
  9222. Result struct {
  9223. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  9224. } `json:"result"`
  9225. } `json:"output"`
  9226. RefmsgTime string `json:"refmsg_time"`
  9227. RespondTime string `json:"respond_time"`
  9228. Signtype interface{} `json:"signtype"`
  9229. WarnInfo interface{} `json:"warn_info"`
  9230. }
  9231. type ResultThirteen10265 struct {
  9232. ErrMsg string `json:"err_msg"`
  9233. InfRefmsgid string `json:"inf_refmsgid"`
  9234. Infcode string `json:"infcode"`
  9235. Output struct {
  9236. Result struct {
  9237. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  9238. } `json:"result"`
  9239. } `json:"output"`
  9240. RefmsgTime string `json:"refmsg_time"`
  9241. RespondTime string `json:"respond_time"`
  9242. Signtype interface{} `json:"signtype"`
  9243. WarnInfo interface{} `json:"warn_info"`
  9244. }
  9245. type ResultFourteen struct {
  9246. ErrMsg string `json:"err_msg"`
  9247. InfRefmsgid string `json:"inf_refmsgid"`
  9248. Infcode int64 `json:"infcode"`
  9249. Output struct {
  9250. } `json:"output"`
  9251. RefmsgTime string `json:"refmsg_time"`
  9252. RespondTime string `json:"respond_time"`
  9253. Signtype interface{} `json:"signtype"`
  9254. WarnInfo interface{} `json:"warn_info"`
  9255. }
  9256. type ResultFourteen10265 struct {
  9257. ErrMsg string `json:"err_msg"`
  9258. InfRefmsgid string `json:"inf_refmsgid"`
  9259. Infcode string `json:"infcode"`
  9260. Output struct {
  9261. } `json:"output"`
  9262. RefmsgTime string `json:"refmsg_time"`
  9263. RespondTime string `json:"respond_time"`
  9264. Signtype interface{} `json:"signtype"`
  9265. WarnInfo interface{} `json:"warn_info"`
  9266. }
  9267. type ResultSixteen struct {
  9268. Cainfo string `json:"cainfo"`
  9269. ErrMsg string `json:"err_msg"`
  9270. InfRefmsgid string `json:"inf_refmsgid"`
  9271. Infcode int64 `json:"infcode"`
  9272. Output struct {
  9273. Setldetail []interface{} `json:"setldetail"`
  9274. Setlinfo struct {
  9275. MdtrtID string `json:"mdtrt_id"`
  9276. SetlID string `json:"setl_id"`
  9277. ClrOptins string `json:"clr_optins"`
  9278. SetlTime string `json:"setl_time"`
  9279. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9280. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9281. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9282. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9283. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9284. ActPayDedc float64 `json:"act_pay_dedc"`
  9285. HifpPay float64 `json:"hifp_pay"`
  9286. PoolPropSe float64 `json:"pool_prop_selfpay"`
  9287. Lfpay float64 `json:"selfpay"`
  9288. CvlservPay float64 `json:"cvlserv_pay"`
  9289. HifesPay float64 `json:"hifes_pay"`
  9290. HifmiPay float64 `json:"hifmi_pay"`
  9291. HifobPay float64 `json:"hifob_pay"`
  9292. MafPay float64 `json:"maf_pay"`
  9293. OthPay float64 `json:"oth_pay"`
  9294. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9295. PsnPartAmt float64 `json:"psn_part_amt"`
  9296. AcctPay float64 `json:"acct_pay"`
  9297. Balc float64 `json:"balc"`
  9298. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  9299. HospPartAmt float64 `json:"hosp_part_amt"`
  9300. MedinsSetlID string `json:"medins_setl_id"`
  9301. PdnCashPay string `json:"pdn_cash_pay"`
  9302. } `json:"setlinfo"`
  9303. } `json:"output"`
  9304. RefmsgTime string `json:"refmsg_time"`
  9305. RespondTime string `json:"respond_time"`
  9306. Signtype interface{} `json:"signtype"`
  9307. WarnMsg interface{} `json:"warn_msg"`
  9308. }
  9309. type ResultSixteen10265 struct {
  9310. Cainfo string `json:"cainfo"`
  9311. ErrMsg string `json:"err_msg"`
  9312. InfRefmsgid string `json:"inf_refmsgid"`
  9313. Infcode string `json:"infcode"`
  9314. Output struct {
  9315. Setldetail []interface{} `json:"setldetail"`
  9316. Setlinfo struct {
  9317. MdtrtID string `json:"mdtrt_id"`
  9318. SetlID string `json:"setl_id"`
  9319. ClrOptins string `json:"clr_optins"`
  9320. SetlTime string `json:"setl_time"`
  9321. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9322. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9323. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9324. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9325. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9326. ActPayDedc float64 `json:"act_pay_dedc"`
  9327. HifpPay float64 `json:"hifp_pay"`
  9328. PoolPropSe float64 `json:"pool_prop_selfpay"`
  9329. Lfpay float64 `json:"selfpay"`
  9330. CvlservPay float64 `json:"cvlserv_pay"`
  9331. HifesPay float64 `json:"hifes_pay"`
  9332. HifmiPay float64 `json:"hifmi_pay"`
  9333. HifobPay float64 `json:"hifob_pay"`
  9334. MafPay float64 `json:"maf_pay"`
  9335. OthPay float64 `json:"oth_pay"`
  9336. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9337. PsnPartAmt float64 `json:"psn_part_amt"`
  9338. AcctPay float64 `json:"acct_pay"`
  9339. Balc float64 `json:"balc"`
  9340. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  9341. HospPartAmt float64 `json:"hosp_part_amt"`
  9342. MedinsSetlID string `json:"medins_setl_id"`
  9343. PdnCashPay string `json:"pdn_cash_pay"`
  9344. } `json:"setlinfo"`
  9345. } `json:"output"`
  9346. RefmsgTime string `json:"refmsg_time"`
  9347. RespondTime string `json:"respond_time"`
  9348. Signtype interface{} `json:"signtype"`
  9349. WarnMsg interface{} `json:"warn_msg"`
  9350. }
  9351. type ResultSeventeen struct {
  9352. ErrMsg string `json:"err_msg"`
  9353. InfRefmsgid string `json:"inf_refmsgid"`
  9354. Infcode int64 `json:"infcode"`
  9355. Output struct {
  9356. SetlListId string `json:"setl_list_id"`
  9357. } `json:"output"`
  9358. RefmsgTime string `json:"refmsg_time"`
  9359. RespondTime string `json:"respond_time"`
  9360. Signtype string `json:"signtype"`
  9361. WarnInfo string `json:"warn_info"`
  9362. }
  9363. type ResultSeventeenOther struct {
  9364. ErrMsg string `json:"err_msg"`
  9365. InfRefmsgid string `json:"inf_refmsgid"`
  9366. Infcode string `json:"infcode"`
  9367. Output struct {
  9368. SetlListId string `json:"setl_list_id"`
  9369. } `json:"output"`
  9370. RefmsgTime string `json:"refmsg_time"`
  9371. RespondTime string `json:"respond_time"`
  9372. Signtype string `json:"signtype"`
  9373. WarnInfo string `json:"warn_info"`
  9374. }
  9375. type Result90991 struct {
  9376. ErrMsg string `json:"err_msg"`
  9377. InfRefmsgid string `json:"inf_refmsgid"`
  9378. Infcode int64 `json:"infcode"`
  9379. Output struct {
  9380. Result struct {
  9381. PsnNo string `json:"psn_no"`
  9382. CardStat string `json:"card_stat"`
  9383. Certno string `json:"certno"`
  9384. PsnName string `json:"psn_name"`
  9385. CheckStat string `json:"check_stat"`
  9386. SscnoCheckStat string `json:"sscno_check_stat"`
  9387. } `json:"result"`
  9388. } `json:"output"`
  9389. RefmsgTime string `json:"refmsg_time"`
  9390. RespondTime string `json:"respond_time"`
  9391. Signtype interface{} `json:"signtype"`
  9392. WarnInfo interface{} `json:"warn_info"`
  9393. }
  9394. type Result90100 struct {
  9395. ErrMsg string `json:"err_msg"`
  9396. InfRefmsgid string `json:"inf_refmsgid"`
  9397. Infcode int64 `json:"infcode"`
  9398. Output struct {
  9399. PoolareaNo string `json:"poolarea_no"`
  9400. PoolareaNoName string `json:"poolarea_no_name"`
  9401. Insutype string `json:"insutype"`
  9402. InsutypeName string `json:"insutype_name"`
  9403. ClctType string `json:"clct_type"`
  9404. ClctTypeName string `json:"clct_type_name"`
  9405. ClctFlag string `json:"clct_flag"`
  9406. ClctFlagName string `json:"clct_flag_name"`
  9407. AccrymBegn string `json:"accrym_begn"`
  9408. AccrymEnd string `json:"accrym_end"`
  9409. ClctTime string `json:"clct_time"`
  9410. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  9411. } `json:"output"`
  9412. RefmsgTime string `json:"refmsg_time"`
  9413. RespondTime string `json:"respond_time"`
  9414. Signtype interface{} `json:"signtype"`
  9415. WarnInfo interface{} `json:"warn_info"`
  9416. }
  9417. type Custom struct {
  9418. DetItemFeeSumamt string
  9419. Cut string
  9420. FeedetlSn string
  9421. Price string
  9422. MedListCodg string
  9423. Type int64
  9424. AdviceId int64
  9425. ProjectId int64
  9426. ItemId int64
  9427. }
  9428. type Result5301 struct {
  9429. ErrMsg string `json:"err_msg"`
  9430. InfRefmsgid string `json:"inf_refmsgid"`
  9431. Infcode int64 `json:"infcode"`
  9432. Output struct {
  9433. Result []struct {
  9434. OpspDiseCode string `json:"opsp_dise_code"`
  9435. OpspDiseName string `json:"opsp_dise_name"`
  9436. Begndate string `json:"begndate"`
  9437. Enddate string `json:"enddate"`
  9438. } `json:"feedetail"`
  9439. } `json:"output"`
  9440. RefmsgTime string `json:"refmsg_time"`
  9441. RespondTime string `json:"respond_time"`
  9442. Signtype interface{} `json:"signtype"`
  9443. WarnInfo interface{} `json:"warn_info"`
  9444. }
  9445. type Result5301For10265 struct {
  9446. ErrMsg string `json:"err_msg"`
  9447. InfRefmsgid string `json:"inf_refmsgid"`
  9448. Infcode string `json:"infcode"`
  9449. Output struct {
  9450. Result []struct {
  9451. OpspDiseCode string `json:"opsp_dise_code"`
  9452. OpspDiseName string `json:"opsp_dise_name"`
  9453. Begndate string `json:"begndate"`
  9454. Enddate string `json:"enddate"`
  9455. } `json:"feedetail"`
  9456. } `json:"output"`
  9457. RefmsgTime string `json:"refmsg_time"`
  9458. RespondTime string `json:"respond_time"`
  9459. Signtype interface{} `json:"signtype"`
  9460. WarnInfo interface{} `json:"warn_info"`
  9461. }
  9462. //获取个人信息----挂号-----上传就诊信息
  9463. func (c *HisApiController) GetRegisterInfo() {
  9464. id, _ := c.GetInt64("id")
  9465. record_time := c.GetString("record_time")
  9466. settlementValue, _ := c.GetInt64("settlement_value")
  9467. medical_insurance_card := c.GetString("medical_insurance_card")
  9468. name := c.GetString("name")
  9469. id_card_type, _ := c.GetInt64("id_card_type")
  9470. certificates, _ := c.GetInt64("certificates")
  9471. medical_care, _ := c.GetInt64("medical_care")
  9472. birthday := c.GetString("birthday")
  9473. id_card := c.GetString("id_card")
  9474. register_type, _ := c.GetInt64("register")
  9475. doctor, _ := c.GetInt64("doctor")
  9476. department, _ := c.GetInt64("department")
  9477. gender, _ := c.GetInt64("sex")
  9478. registration_fee, _ := c.GetFloat("registration_fee")
  9479. medical_expenses, _ := c.GetFloat("medical_expenses")
  9480. social_type, _ := c.GetInt64("social_type")
  9481. admin_user_id, _ := c.GetInt64("admin_user_id")
  9482. insuplc_admdvs := c.GetString("insuplc_admdvs")
  9483. mdtrt_type := c.GetString("mdtrt_type")
  9484. timeLayout := "2006-01-02"
  9485. loc, _ := time.LoadLocation("Local")
  9486. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  9487. birthUnix := birthdays.Unix()
  9488. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9489. if err != nil {
  9490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9491. return
  9492. }
  9493. recordDateTime := theTime.Unix()
  9494. adminInfo := c.GetAdminUserInfo()
  9495. var patient service.Patients
  9496. if id == 0 {
  9497. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  9498. } else {
  9499. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  9500. }
  9501. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9502. if patientPrescription.ID == 0 {
  9503. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9504. }
  9505. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9506. if patient.ID == 0 {
  9507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9508. return
  9509. }
  9510. if len(patient.IdCardNo) == 0 {
  9511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9512. return
  9513. }
  9514. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9515. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  9516. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  9517. //就诊结算未完成,不能进行二次挂号
  9518. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  9519. if len(his) >= 1 {
  9520. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  9521. if len(his) >= 1 && order.ID == 0 {
  9522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  9523. return
  9524. }
  9525. }
  9526. //var register_log string
  9527. if config.IsOpen == 1 {
  9528. var res ResultTwo
  9529. var res10265 ResultTwo10265
  9530. var PsnNo string
  9531. var PsnCertType string
  9532. var Certno string
  9533. var PsnName string
  9534. var Gend string
  9535. var Naty string
  9536. var Brdy string
  9537. var Age float64
  9538. var infoStr string
  9539. var idetinfoStr string
  9540. var infocode int64
  9541. var verify_number string
  9542. fmt.Println(verify_number)
  9543. if miConfig.MdtrtareaAdmvs == "421300" {
  9544. psn_info, _ := service.GetPsnByPatientId(id)
  9545. PsnNo = psn_info.PsnNo
  9546. PsnCertType = psn_info.PsnCertType
  9547. Certno = psn_info.Certno
  9548. PsnName = psn_info.PsnName
  9549. Gend = psn_info.Gend
  9550. Naty = psn_info.Naty
  9551. Brdy = psn_info.Brdy
  9552. Age = psn_info.Age
  9553. infoStr = psn_info.Insuinfo
  9554. idetinfoStr = psn_info.Idetinfo
  9555. infocode = 0
  9556. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9557. psn_info, _ := service.GetPsnByPatientId(id)
  9558. PsnNo = psn_info.PsnNo
  9559. PsnCertType = psn_info.PsnCertType
  9560. Certno = psn_info.Certno
  9561. PsnName = psn_info.PsnName
  9562. Gend = psn_info.Gend
  9563. Naty = psn_info.Naty
  9564. Brdy = psn_info.Brdy
  9565. Age = psn_info.Age
  9566. infoStr = psn_info.Insuinfo
  9567. idetinfoStr = psn_info.Idetinfo
  9568. infocode = 0
  9569. verify_number = psn_info.VerifyNumber
  9570. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9571. if id_card_type == 1 {
  9572. psn_info, _ := service.GetPsnByPatientId(id)
  9573. PsnNo = psn_info.PsnNo
  9574. PsnCertType = psn_info.PsnCertType
  9575. Certno = psn_info.Certno
  9576. PsnName = psn_info.PsnName
  9577. Gend = psn_info.Gend
  9578. Naty = psn_info.Naty
  9579. Brdy = psn_info.Brdy
  9580. Age = psn_info.Age
  9581. infoStr = psn_info.Insuinfo
  9582. idetinfoStr = psn_info.Idetinfo
  9583. infocode = 0
  9584. verify_number = psn_info.VerifyNumber
  9585. } else if id_card_type == 2 {
  9586. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, "", id_card)
  9587. fmt.Println(errMsgLog)
  9588. saveLog(result, requestLog, "1101", "人员基本信息获取")
  9589. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9590. utils.ErrorLog("解析失败:%v", err)
  9591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9592. return
  9593. }
  9594. PsnNo = res.Output.Baseinfo.PsnNo
  9595. PsnCertType = res.Output.Baseinfo.PsnCertType
  9596. Certno = res.Output.Baseinfo.Certno
  9597. PsnName = res.Output.Baseinfo.PsnName
  9598. Gend = res.Output.Baseinfo.Gend
  9599. Naty = res.Output.Baseinfo.Naty
  9600. Brdy = res.Output.Baseinfo.Brdy
  9601. Age = res.Output.Baseinfo.Age
  9602. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9603. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9604. infoStr = string(Iinfos)
  9605. idetinfoStr = string(Idetinfos)
  9606. infocode = res.Infcode
  9607. }
  9608. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9609. if id_card_type == 1 {
  9610. psn_info, _ := service.GetPsnByPatientId(id)
  9611. PsnNo = psn_info.PsnNo
  9612. PsnCertType = psn_info.PsnCertType
  9613. Certno = psn_info.Certno
  9614. PsnName = psn_info.PsnName
  9615. Gend = psn_info.Gend
  9616. Naty = psn_info.Naty
  9617. Brdy = psn_info.Brdy
  9618. Age = psn_info.Age
  9619. infoStr = psn_info.Insuinfo
  9620. idetinfoStr = psn_info.Idetinfo
  9621. infocode = 0
  9622. verify_number = psn_info.VerifyNumber
  9623. } else if id_card_type == 2 {
  9624. 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, "")
  9625. saveLog(result, requestLog, "1101", "人员基本信息获取")
  9626. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9627. utils.ErrorLog("解析失败:%v", err)
  9628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9629. return
  9630. }
  9631. PsnNo = res.Output.Baseinfo.PsnNo
  9632. PsnCertType = res.Output.Baseinfo.PsnCertType
  9633. Certno = res.Output.Baseinfo.Certno
  9634. PsnName = res.Output.Baseinfo.PsnName
  9635. Gend = res.Output.Baseinfo.Gend
  9636. Naty = res.Output.Baseinfo.Naty
  9637. Brdy = res.Output.Baseinfo.Brdy
  9638. Age = res.Output.Baseinfo.Age
  9639. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9640. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9641. infoStr = string(Iinfos)
  9642. idetinfoStr = string(Idetinfos)
  9643. infocode = res.Infcode
  9644. }
  9645. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9646. if id_card_type == 1 {
  9647. psn_info, _ := service.GetPsnByPatientId(id)
  9648. PsnNo = psn_info.PsnNo
  9649. PsnCertType = psn_info.PsnCertType
  9650. Certno = psn_info.Certno
  9651. PsnName = psn_info.PsnName
  9652. Gend = psn_info.Gend
  9653. Naty = psn_info.Naty
  9654. Brdy = psn_info.Brdy
  9655. Age = psn_info.Age
  9656. infoStr = psn_info.Insuinfo
  9657. idetinfoStr = psn_info.Idetinfo
  9658. infocode = 0
  9659. verify_number = psn_info.VerifyNumber
  9660. } else if id_card_type == 2 {
  9661. 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)
  9662. saveLog(result, requestLog, "1101", "人员基本信息获取")
  9663. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9664. utils.ErrorLog("解析失败:%v", err)
  9665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9666. return
  9667. }
  9668. PsnNo = res.Output.Baseinfo.PsnNo
  9669. PsnCertType = res.Output.Baseinfo.PsnCertType
  9670. Certno = res.Output.Baseinfo.Certno
  9671. PsnName = res.Output.Baseinfo.PsnName
  9672. Gend = res.Output.Baseinfo.Gend
  9673. Naty = res.Output.Baseinfo.Naty
  9674. Brdy = res.Output.Baseinfo.Brdy
  9675. Age = res.Output.Baseinfo.Age
  9676. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9677. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9678. infoStr = string(Iinfos)
  9679. idetinfoStr = string(Idetinfos)
  9680. infocode = res.Infcode
  9681. } else if id_card_type == 4 {
  9682. psn_info, _ := service.GetPsnByPatientId(id)
  9683. PsnNo = psn_info.PsnNo
  9684. PsnCertType = psn_info.PsnCertType
  9685. Certno = psn_info.Certno
  9686. PsnName = psn_info.PsnName
  9687. Gend = psn_info.Gend
  9688. Naty = psn_info.Naty
  9689. Brdy = psn_info.Brdy
  9690. Age = psn_info.Age
  9691. infoStr = psn_info.Insuinfo
  9692. idetinfoStr = psn_info.Idetinfo
  9693. infocode = 0
  9694. verify_number = psn_info.VerifyNumber
  9695. }
  9696. } else if miConfig.MdtrtareaAdmvs == "131023" {
  9697. var result string
  9698. var requestLog string
  9699. 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), "")
  9700. if id_card_type == 4 {
  9701. psn_info, _ := service.GetPsnByPatientId(id)
  9702. PsnNo = psn_info.PsnNo
  9703. PsnCertType = psn_info.PsnCertType
  9704. Certno = psn_info.Certno
  9705. PsnName = psn_info.PsnName
  9706. Gend = psn_info.Gend
  9707. Naty = psn_info.Naty
  9708. Brdy = psn_info.Brdy
  9709. Age = psn_info.Age
  9710. infoStr = psn_info.Insuinfo
  9711. idetinfoStr = psn_info.Idetinfo
  9712. infocode = 0
  9713. verify_number = psn_info.VerifyNumber
  9714. } else {
  9715. saveLog(result, requestLog, "1101", "人员基本信息获取")
  9716. if miConfig.Code == "H15049901371" {
  9717. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9718. utils.ErrorLog("解析失败:%v", err)
  9719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9720. return
  9721. }
  9722. res.ErrMsg = res10265.ErrMsg
  9723. res.Output = res10265.Output
  9724. res.InfRefmsgid = res10265.InfRefmsgid
  9725. } else {
  9726. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9727. utils.ErrorLog("解析失败:%v", err)
  9728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9729. return
  9730. }
  9731. }
  9732. PsnNo = res.Output.Baseinfo.PsnNo
  9733. PsnCertType = res.Output.Baseinfo.PsnCertType
  9734. Certno = res.Output.Baseinfo.Certno
  9735. PsnName = res.Output.Baseinfo.PsnName
  9736. Gend = res.Output.Baseinfo.Gend
  9737. Naty = res.Output.Baseinfo.Naty
  9738. Brdy = res.Output.Baseinfo.Brdy
  9739. Age = res.Output.Baseinfo.Age
  9740. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9741. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9742. infoStr = string(Iinfos)
  9743. idetinfoStr = string(Idetinfos)
  9744. if miConfig.Code == "H15049901371" {
  9745. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  9746. } else {
  9747. infocode = res.Infcode
  9748. }
  9749. }
  9750. } else {
  9751. var result string
  9752. var requestLog string
  9753. //if miConfig.UserOrgId == 10138 {
  9754. if id_card_type != 4 || id_card_type != 1 {
  9755. var insa string
  9756. if len(patient.InsuplcAdmdvs) > 0 {
  9757. insa = patient.InsuplcAdmdvs
  9758. } else {
  9759. insa = miConfig.InsuplcAdmdvs
  9760. }
  9761. //psn_info, _ := service.GetPsnByPatientId(id)
  9762. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  9763. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, insa, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  9764. }
  9765. //}
  9766. //else {
  9767. // var insa string
  9768. // if len(patient.InsuplcAdmdvs) > 0 {
  9769. // insa = patient.InsuplcAdmdvs
  9770. // } else {
  9771. // insa = miConfig.InsuplcAdmdvs
  9772. // }
  9773. // result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, insa, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  9774. //}
  9775. if id_card_type == 4 || id_card_type == 1 {
  9776. psn_info, _ := service.GetPsnByPatientId(id)
  9777. PsnNo = psn_info.PsnNo
  9778. PsnCertType = psn_info.PsnCertType
  9779. Certno = psn_info.Certno
  9780. PsnName = psn_info.PsnName
  9781. Gend = psn_info.Gend
  9782. Naty = psn_info.Naty
  9783. Brdy = psn_info.Brdy
  9784. Age = psn_info.Age
  9785. infoStr = psn_info.Insuinfo
  9786. idetinfoStr = psn_info.Idetinfo
  9787. infocode = 0
  9788. verify_number = psn_info.VerifyNumber
  9789. } else {
  9790. saveLog(result, requestLog, "1101", "人员基本信息获取")
  9791. if miConfig.Code == "H15049901371" {
  9792. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9793. utils.ErrorLog("解析失败:%v", err)
  9794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9795. return
  9796. }
  9797. res.ErrMsg = res10265.ErrMsg
  9798. res.Output = res10265.Output
  9799. res.InfRefmsgid = res10265.InfRefmsgid
  9800. } else {
  9801. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9802. utils.ErrorLog("解析失败:%v", err)
  9803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9804. return
  9805. }
  9806. }
  9807. PsnNo = res.Output.Baseinfo.PsnNo
  9808. PsnCertType = res.Output.Baseinfo.PsnCertType
  9809. Certno = res.Output.Baseinfo.Certno
  9810. PsnName = res.Output.Baseinfo.PsnName
  9811. Gend = res.Output.Baseinfo.Gend
  9812. Naty = res.Output.Baseinfo.Naty
  9813. Brdy = res.Output.Baseinfo.Brdy
  9814. Age = res.Output.Baseinfo.Age
  9815. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9816. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9817. infoStr = string(Iinfos)
  9818. idetinfoStr = string(Idetinfos)
  9819. if miConfig.Code == "H15049901371" {
  9820. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  9821. } else {
  9822. infocode = res.Infcode
  9823. }
  9824. }
  9825. }
  9826. if infocode == 0 {
  9827. his := models.VMHisPatient{
  9828. Name: name,
  9829. Gender: gender,
  9830. Birthday: birthUnix,
  9831. MedicalTreatmentType: medical_care,
  9832. IdType: certificates,
  9833. IdCardNo: id_card,
  9834. BalanceAccountsType: settlementValue,
  9835. SocialType: social_type,
  9836. MedicalInsuranceNumber: medical_insurance_card,
  9837. RegisterType: register_type,
  9838. RegisterCost: registration_fee,
  9839. TreatmentCost: medical_expenses,
  9840. Status: 1,
  9841. Ctime: time.Now().Unix(),
  9842. Mtime: time.Now().Unix(),
  9843. PsnNo: PsnNo,
  9844. PsnCertType: PsnCertType,
  9845. Certno: Certno,
  9846. PsnName: PsnName,
  9847. Gend: Gend,
  9848. Naty: Naty,
  9849. Brdy: Brdy,
  9850. Age: Age,
  9851. Iinfo: infoStr,
  9852. Idetinfo: idetinfoStr,
  9853. PatientId: patient.ID,
  9854. RecordDate: theTime.Unix(),
  9855. UserOrgId: adminInfo.CurrentOrgId,
  9856. AdminUserId: admin_user_id,
  9857. IsReturn: 1,
  9858. IdCardType: id_card_type,
  9859. Doctor: doctor,
  9860. Departments: department,
  9861. MdtrtGrpType: mdtrt_type,
  9862. }
  9863. timestamp := time.Now().Unix()
  9864. tempTime := time.Unix(timestamp, 0)
  9865. timeFormat := tempTime.Format("20060102150405")
  9866. chrgBchno := rand.Intn(100000) + 10000
  9867. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9868. his.Number = ipt_otp_no
  9869. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  9870. department, _ := service.GetDepartMentDetail(department)
  9871. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  9872. IdCardNo := ""
  9873. if id_card_type == 1 {
  9874. // IdCardNo = medical_insurance_card
  9875. IdCardNo = patient.IdCardNo
  9876. } else {
  9877. IdCardNo = patient.IdCardNo
  9878. }
  9879. var rf []*ResultFive
  9880. json.Unmarshal([]byte(his.Iinfo), &rf)
  9881. var insutypes []*ResultFive
  9882. var insutype string
  9883. var insuplc_admdvs_temp string
  9884. var is390 int = 0
  9885. var is310 int = 0
  9886. for _, item := range rf {
  9887. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9888. insutypes = append(insutypes, item)
  9889. }
  9890. }
  9891. if len(insutypes) == 1 {
  9892. insutype = insutypes[0].Insutype
  9893. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9894. } else {
  9895. for _, i := range insutypes {
  9896. if i.Insutype == "390" {
  9897. is390 = 1
  9898. }
  9899. if i.Insutype == "310" {
  9900. is310 = 1
  9901. }
  9902. }
  9903. }
  9904. if is390 == 1 {
  9905. insutype = "390"
  9906. }
  9907. if is310 == 1 {
  9908. insutype = "310"
  9909. }
  9910. fmt.Println(social_type)
  9911. if social_type > 0 {
  9912. insutype = strconv.FormatInt(social_type, 10)
  9913. }
  9914. var infocode int64
  9915. var resThree ResultThree
  9916. var resThree10265 ResultThree10265
  9917. if len(insuplc_admdvs) == 0 {
  9918. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  9919. } else {
  9920. insuplc_admdvs_temp = insuplc_admdvs
  9921. }
  9922. if miConfig.MdtrtareaAdmvs == "421300" {
  9923. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  9924. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  9925. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  9926. "&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
  9927. resp, requestErr := http.Get(api)
  9928. if requestErr != nil {
  9929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9930. return
  9931. }
  9932. body, ioErr := ioutil.ReadAll(resp.Body)
  9933. if ioErr != nil {
  9934. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9936. return
  9937. }
  9938. var respJSON map[string]interface{}
  9939. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9942. return
  9943. }
  9944. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9945. result, _ := json.Marshal(respJSON)
  9946. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  9947. utils.ErrorLog("解析失败:%v", err)
  9948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9949. return
  9950. }
  9951. infocode = resThree.Infcode
  9952. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9953. psn_info, _ := service.GetPsnByPatientId(id)
  9954. his.PsnNo = psn_info.PsnNo
  9955. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9956. var cert_no string
  9957. if id_card_type == 3 {
  9958. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  9959. cert_no = IdCardNo
  9960. } else if id_card_type == 4 {
  9961. cert_no = IdCardNo
  9962. psn_info.VerifyNumber = psn_info.VerifyNumber
  9963. } else {
  9964. bas := strings.Split(psn_info.CardInfo, "|")
  9965. cert_no = bas[2]
  9966. }
  9967. var hisPrescription []*models.HisPrescription
  9968. for _, item := range rf {
  9969. if item.Insutype == insutype {
  9970. //insuplc_admdvs = item.InsuplcAdmdvs
  9971. his.InsuplcAdmdvs = insuplc_admdvs
  9972. }
  9973. }
  9974. his.Insutype = insutype
  9975. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  9976. fmt.Println(res3101)
  9977. fmt.Println(res3101.Infcode)
  9978. if res3101.Infcode == "0" {
  9979. fmt.Println("33333333")
  9980. if len(res3101.Output.Result) > 0 {
  9981. fmt.Println("222222")
  9982. for _, item := range res3101.Output.Result {
  9983. if len(res3101.ErrMsg) == 0 {
  9984. res3101.ErrMsg = item.VolaCont
  9985. } else {
  9986. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  9987. }
  9988. }
  9989. c.ServeSuccessJSON(map[string]interface{}{
  9990. "failed_code": -10,
  9991. "msg": res3101.ErrMsg,
  9992. })
  9993. return
  9994. } else {
  9995. fmt.Println("11111")
  9996. var api string
  9997. if miConfig.MdtrtareaAdmvs == "320921" {
  9998. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  9999. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  10000. "&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
  10001. } else {
  10002. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  10003. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  10004. "&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
  10005. }
  10006. resp, requestErr := http.Get(api)
  10007. if requestErr != nil {
  10008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10009. return
  10010. }
  10011. body, ioErr := ioutil.ReadAll(resp.Body)
  10012. if ioErr != nil {
  10013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10015. return
  10016. }
  10017. var respJSON map[string]interface{}
  10018. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10021. return
  10022. }
  10023. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10024. result, _ := json.Marshal(respJSON)
  10025. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  10026. utils.ErrorLog("解析失败:%v", err)
  10027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10028. return
  10029. }
  10030. resThree.ErrMsg = resThree10265.ErrMsg
  10031. resThree.Output = resThree10265.Output
  10032. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  10033. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  10034. }
  10035. } else if res3101.Infcode != "0" {
  10036. c.ServeSuccessJSON(map[string]interface{}{
  10037. "failed_code": -10,
  10038. "msg": res3101.ErrMsg,
  10039. })
  10040. return
  10041. }
  10042. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10043. psn_info, _ := service.GetPsnByPatientId(id)
  10044. var cert_no string
  10045. if id_card_type == 1 {
  10046. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10047. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  10048. } else if id_card_type == 4 {
  10049. cert_no = psn_info.VerifyNumber
  10050. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  10051. } else {
  10052. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  10053. cert_no = psn_info.VerifyNumber
  10054. }
  10055. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no, record_time)
  10056. saveLog(result, requestLog, "2201", "挂号")
  10057. if miConfig.Code == "H15049901371" {
  10058. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  10059. utils.ErrorLog("解析失败:%v", err)
  10060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10061. return
  10062. }
  10063. resThree.ErrMsg = resThree10265.ErrMsg
  10064. resThree.Output = resThree10265.Output
  10065. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  10066. } else {
  10067. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10068. utils.ErrorLog("解析失败:%v", err)
  10069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10070. return
  10071. }
  10072. }
  10073. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  10074. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  10075. psn_info, _ := service.GetPsnByPatientId(id)
  10076. var result string
  10077. var requestLog string
  10078. if id_card_type == 1 {
  10079. bas := strings.Split(psn_info.CardInfo, "|")
  10080. basNumber := bas[2]
  10081. card_sn := bas[3]
  10082. 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)
  10083. saveLog(result, requestLog, "2201A", "挂号")
  10084. } else if id_card_type == 2 {
  10085. 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, "", "")
  10086. saveLog(result, requestLog, "2201A", "挂号")
  10087. } else {
  10088. 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, "", "")
  10089. saveLog(result, requestLog, "2201A", "挂号")
  10090. }
  10091. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10092. utils.ErrorLog("解析失败:%v", err)
  10093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10094. return
  10095. }
  10096. infocode = resThree.Infcode
  10097. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  10098. psn_info, _ := service.GetPsnByPatientId(id)
  10099. var result string
  10100. var requestLog string
  10101. if id_card_type == 1 {
  10102. bas := strings.Split(psn_info.CardInfo, "|")
  10103. basNumber := bas[2]
  10104. card_sn := bas[3]
  10105. 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)
  10106. saveLog(result, requestLog, "2201A", "挂号")
  10107. } else if id_card_type == 2 {
  10108. 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, "", "")
  10109. saveLog(result, requestLog, "2201A", "挂号")
  10110. } else {
  10111. 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, "", "")
  10112. saveLog(result, requestLog, "2201A", "挂号")
  10113. }
  10114. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10115. utils.ErrorLog("解析失败:%v", err)
  10116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10117. return
  10118. }
  10119. infocode = resThree.Infcode
  10120. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10121. psn_info, _ := service.GetPsnByPatientId(id)
  10122. 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)
  10123. saveLog(result, requestLog, "2201A", "挂号")
  10124. if miConfig.Code == "H15049901371" {
  10125. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  10126. utils.ErrorLog("解析失败:%v", err)
  10127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10128. return
  10129. }
  10130. resThree.ErrMsg = resThree10265.ErrMsg
  10131. resThree.Output = resThree10265.Output
  10132. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  10133. } else {
  10134. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10135. utils.ErrorLog("解析失败:%v", err)
  10136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10137. return
  10138. }
  10139. }
  10140. if miConfig.Code == "H15049901371" {
  10141. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  10142. } else {
  10143. infocode = resThree.Infcode
  10144. }
  10145. } else {
  10146. psn_info, _ := service.GetPsnByPatientId(id)
  10147. if id_card_type == 4 || id_card_type == 1 {
  10148. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  10149. }
  10150. var rf []*ResultFive
  10151. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  10152. var insutypes []*ResultFive
  10153. var insutype string
  10154. var is390 int = 0
  10155. var is310 int = 0
  10156. for _, item := range rf {
  10157. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10158. insutypes = append(insutypes, item)
  10159. }
  10160. }
  10161. if len(insutypes) == 1 {
  10162. insutype = insutypes[0].Insutype
  10163. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10164. } else {
  10165. for _, i := range insutypes {
  10166. if i.Insutype == "390" {
  10167. is390 = 1
  10168. }
  10169. if i.Insutype == "310" {
  10170. is310 = 1
  10171. }
  10172. }
  10173. }
  10174. if is390 == 1 {
  10175. insutype = "390"
  10176. }
  10177. if is310 == 1 {
  10178. insutype = "310"
  10179. }
  10180. fmt.Println(len(insutypes))
  10181. if len(insutypes) == 0 {
  10182. for index, item := range rf {
  10183. if index == 0 {
  10184. insutype = item.Insutype
  10185. insuplc_admdvs = item.InsuplcAdmdvs
  10186. }
  10187. }
  10188. fmt.Println(insutype)
  10189. fmt.Println(insuplc_admdvs)
  10190. }
  10191. if social_type > 0 {
  10192. insutype = strconv.FormatInt(social_type, 10)
  10193. }
  10194. 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)
  10195. saveLog(result, requestLog, "2201A", "挂号")
  10196. if miConfig.Code == "H15049901371" {
  10197. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  10198. utils.ErrorLog("解析失败:%v", err)
  10199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10200. return
  10201. }
  10202. resThree.ErrMsg = resThree10265.ErrMsg
  10203. resThree.Output = resThree10265.Output
  10204. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  10205. } else {
  10206. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10207. utils.ErrorLog("解析失败:%v", err)
  10208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10209. return
  10210. }
  10211. }
  10212. if miConfig.Code == "H15049901371" {
  10213. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  10214. } else {
  10215. infocode = resThree.Infcode
  10216. }
  10217. }
  10218. if infocode != 0 {
  10219. adminUser := c.GetAdminUserInfo()
  10220. errlog := &models.HisOrderError{
  10221. UserOrgId: adminUser.CurrentOrgId,
  10222. Ctime: time.Now().Unix(),
  10223. Mtime: time.Now().Unix(),
  10224. ErrMsg: resThree.ErrMsg,
  10225. Status: 1,
  10226. PatientId: id,
  10227. RecordTime: recordDateTime,
  10228. Stage: 2,
  10229. }
  10230. service.CreateErrMsgLog(errlog)
  10231. c.ServeSuccessJSON(map[string]interface{}{
  10232. "failed_code": -10,
  10233. "msg": resThree.ErrMsg,
  10234. })
  10235. return
  10236. }
  10237. his.Number = resThree.Output.Data.MdtrtID
  10238. his.PsnNo = resThree.Output.Data.PsnNo
  10239. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  10240. his.IdCardNo = patient.IdCardNo
  10241. his.PhoneNumber = patient.Phone
  10242. his.UserOrgId = adminInfo.CurrentOrgId
  10243. his.Insutype = insutype
  10244. his.Ctime = time.Now().Unix()
  10245. his.Mtime = time.Now().Unix()
  10246. his.InsuplcAdmdvs = insuplc_admdvs_temp
  10247. his.Status = 1
  10248. his.MdtrtGrpType = mdtrt_type
  10249. service.UpdateHisPatientStatus(&his)
  10250. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  10251. c.ServeSuccessJSON(map[string]interface{}{
  10252. "his_info": his,
  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: 1,
  10265. }
  10266. service.CreateErrMsgLog(errlog)
  10267. c.ServeSuccessJSON(map[string]interface{}{
  10268. "failed_code": -10,
  10269. "msg": res.ErrMsg,
  10270. })
  10271. return
  10272. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  10273. }
  10274. }
  10275. }
  10276. func (c *HisApiController) GetUploadInfo() {
  10277. id, _ := c.GetInt64("id")
  10278. record_time := c.GetString("record_time")
  10279. his_patient_id, _ := c.GetInt64("his_patient_id")
  10280. order_id, _ := c.GetInt64("order_id")
  10281. pay_way, _ := c.GetInt64("pay_way")
  10282. pay_ways := c.GetString("pay_ways")
  10283. oth_desc := c.GetString("oth_desc")
  10284. pay_price, _ := c.GetFloat("pay_price")
  10285. pay_card_no := c.GetString("pay_card_no")
  10286. discount_price, _ := c.GetFloat("discount_price")
  10287. preferential_price, _ := c.GetFloat("preferential_price")
  10288. reality_price, _ := c.GetFloat("reality_price")
  10289. found_price, _ := c.GetFloat("found_price")
  10290. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  10291. private_price, _ := c.GetFloat("private_price")
  10292. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  10293. admin_user_id, _ := c.GetInt64("admin_user_id")
  10294. fapiao_code := c.GetString("fapiao_code")
  10295. fapiao_number := c.GetString("fapiao_number")
  10296. diagnosis_id := c.GetString("diagnosis")
  10297. sick_type, _ := c.GetInt64("sick_type")
  10298. reg_type, _ := c.GetInt64("p_type")
  10299. begin_time := c.GetString("begin_time")
  10300. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  10301. cash_pay := c.GetString("cash_pay")
  10302. band_card_pay := c.GetString("band_card_pay")
  10303. wechat_pay := c.GetString("wechat_pay")
  10304. ali_pay := c.GetString("ali_pay")
  10305. jifen_pay := c.GetString("jifen_pay")
  10306. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  10307. fmt.Println(acct_used_flag)
  10308. id_str := c.GetString("ids")
  10309. ids_arr := strings.Split(id_str, ",")
  10310. timeLayout := "2006-01-02"
  10311. loc, _ := time.LoadLocation("Local")
  10312. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10313. if err != nil {
  10314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10315. return
  10316. }
  10317. recordDateTime := theTime.Unix()
  10318. adminUser := c.GetAdminUserInfo()
  10319. var tempOrder models.HisOrder
  10320. tempOrder, _ = service.GetHisOrderByID(order_id)
  10321. var prescriptions []*models.HisPrescription
  10322. var start_time int64
  10323. var end_time int64
  10324. //押金模块
  10325. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  10326. tmp_decimal := c.GetString("tmp_decimal")
  10327. var decimal float64 //本次使用的押金
  10328. var errmsg error
  10329. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  10330. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  10331. return
  10332. }
  10333. if len(tmp_decimal) > 0 {
  10334. if tmp_decimal[0] == 45 {
  10335. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  10336. return
  10337. }
  10338. }
  10339. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  10340. fmt.Println(errs)
  10341. decimal = tt
  10342. //if adminUser.CurrentOrgId == 10106{
  10343. // if len(fapiao_code) == 0{
  10344. // fapiao_code = "144072080589"
  10345. // }
  10346. // if len(fapiao_number) == 0{
  10347. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  10348. // if order.ID == 0{
  10349. // fapiao_number = "00001520"
  10350. // }else{
  10351. // //fapiao_code = "00001520"
  10352. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  10353. // var zero string
  10354. // if fpNumber >= 1000{
  10355. // zero = "0000" + strconv.Itoa(fpNumber)
  10356. // }else if fpNumber >= 10000{
  10357. // zero = "000" + strconv.Itoa(fpNumber)
  10358. // } else if fpNumber >= 100000{
  10359. // zero = "00" + strconv.Itoa(fpNumber)
  10360. // } else if fpNumber >= 1000000{
  10361. // zero = "0" + strconv.Itoa(fpNumber)
  10362. // }else {
  10363. // zero = strconv.Itoa(fpNumber)
  10364. // }
  10365. // fapiao_number = zero
  10366. // }
  10367. // }
  10368. //}
  10369. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10370. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10371. var patientPrescription models.HisPrescriptionInfo
  10372. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10373. if patientPrescription.ID == 0 {
  10374. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10375. }
  10376. //if patientPrescription.Do
  10377. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10378. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10379. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10380. diagnosis_ids := strings.Split(diagnosis_id, ",")
  10381. var config []*models.HisXtDiagnoseConfig
  10382. for _, item := range diagnosis_ids {
  10383. id, _ := strconv.ParseInt(item, 10, 64)
  10384. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10385. config = append(config, &diagnosisConfig)
  10386. }
  10387. sickConfig, _ := service.FindSickById(sick_type)
  10388. //if tempOrder.ID == 0 {
  10389. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  10390. //}
  10391. if tempOrder.ID == 0 {
  10392. var result string
  10393. var requestLog string
  10394. var res2 ResultSix
  10395. var ressix10265 ResultSix10265
  10396. if miConfig.MdtrtareaAdmvs == "421300" {
  10397. data := make(map[string]interface{})
  10398. client := &http.Client{}
  10399. data["psn_no"] = his.PsnNo
  10400. data["mdtrt_id"] = his.Number
  10401. data["opter"] = roles.UserName
  10402. data["org_name"] = miConfig.OrgName
  10403. data["med_type"] = strconv.FormatInt(reg_type, 10)
  10404. data["doctor_id"] = doctor_info.DoctorNumber
  10405. data["doctor_name"] = doctor_info.UserName
  10406. data["department"] = department.Name
  10407. data["fixmedins_code"] = miConfig.Code
  10408. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  10409. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10410. data["secret_key"] = miConfig.SecretKey
  10411. data["sick_code"] = sickConfig.CountryCode
  10412. data["sick_name"] = sickConfig.ClassName
  10413. data["dept"] = strconv.FormatInt(department.ID, 10)
  10414. data["config"] = config
  10415. data["begin_time"] = begin_time
  10416. bytesData, _ := json.Marshal(data)
  10417. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  10418. resp, _ := client.Do(req)
  10419. defer resp.Body.Close()
  10420. body, ioErr := ioutil.ReadAll(resp.Body)
  10421. if ioErr != nil {
  10422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10424. return
  10425. }
  10426. var respJSON map[string]interface{}
  10427. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10430. return
  10431. }
  10432. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10433. userJSONBytes, _ := json.Marshal(respJSON)
  10434. fmt.Println("log")
  10435. fmt.Println(string(userJSONBytes))
  10436. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10437. utils.ErrorLog("解析失败:%v", err)
  10438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10439. return
  10440. }
  10441. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10442. data := make(map[string]interface{})
  10443. client := &http.Client{}
  10444. data["psn_no"] = his.PsnNo
  10445. data["mdtrt_id"] = his.Number
  10446. data["doctor"] = roles.UserName
  10447. data["department"] = department.Name
  10448. data["org_name"] = miConfig.OrgName
  10449. data["med_type"] = strconv.FormatInt(reg_type, 10)
  10450. data["doctor_id"] = doctor_info.DoctorNumber
  10451. data["new_doctor_name"] = doctor_info.UserName
  10452. data["fixmedins_code"] = miConfig.Code
  10453. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  10454. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10455. data["secret_key"] = miConfig.SecretKey
  10456. data["sick_code"] = sickConfig.CountryCode
  10457. data["sick_name"] = sickConfig.ClassName
  10458. data["url"] = miConfig.Url
  10459. data["ak"] = miConfig.AccessKey
  10460. data["begin_time"] = begin_time
  10461. data["cainfo"] = miConfig.Cainfo
  10462. data["dept"] = strconv.FormatInt(department.ID, 10)
  10463. data["config"] = config
  10464. bytesData, _ := json.Marshal(data)
  10465. var req *http.Request
  10466. if miConfig.MdtrtareaAdmvs == "320921" {
  10467. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  10468. //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 +
  10469. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  10470. } else {
  10471. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  10472. }
  10473. resp, _ := client.Do(req)
  10474. defer resp.Body.Close()
  10475. body, ioErr := ioutil.ReadAll(resp.Body)
  10476. if ioErr != nil {
  10477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10479. return
  10480. }
  10481. var respJSON map[string]interface{}
  10482. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10485. return
  10486. }
  10487. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10488. userJSONBytes, _ := json.Marshal(respJSON)
  10489. fmt.Println("log")
  10490. fmt.Println(string(userJSONBytes))
  10491. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  10492. utils.ErrorLog("解析失败:%v", err)
  10493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10494. return
  10495. }
  10496. res2.InfRefmsgid = ressix10265.InfRefmsgid
  10497. res2.Output = ressix10265.Output
  10498. res2.ErrMsg = ressix10265.ErrMsg
  10499. res2.Cainfo = ressix10265.Cainfo
  10500. res2.WarnMsg = ressix10265.WarnMsg
  10501. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  10502. res2.Infcode = infocode
  10503. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10504. 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)
  10505. saveLog(result, requestLog, "2203", "上传就诊信息")
  10506. var respJSON2 map[string]interface{}
  10507. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10510. return
  10511. }
  10512. userJSONBytes2, _ := json.Marshal(respJSON2)
  10513. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10514. utils.ErrorLog("解析失败:%v", err)
  10515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10516. return
  10517. }
  10518. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, "0000", miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  10519. fmt.Println(result2)
  10520. fmt.Println(src_request)
  10521. } else {
  10522. if miConfig.MdtrtareaAdmvs == "440781" { //
  10523. 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)
  10524. } else {
  10525. if miConfig.Code == "H15049901371" {
  10526. //赤峰地区国家医保医疗类别
  10527. //职工透析:医疗类别选特殊情况门诊990502
  10528. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10529. var med_type string
  10530. if his.Insutype == "390" {
  10531. if reg_type == 14 {
  10532. med_type = "9933"
  10533. } else if reg_type == 11 {
  10534. med_type = "11"
  10535. }
  10536. } else if his.Insutype == "310" {
  10537. if reg_type == 14 {
  10538. med_type = "990502"
  10539. } else if reg_type == 11 {
  10540. med_type = "11"
  10541. }
  10542. }
  10543. 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)
  10544. } else {
  10545. 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)
  10546. }
  10547. }
  10548. saveLog(result, requestLog, "2203", "上传就诊信息")
  10549. var respJSON2 map[string]interface{}
  10550. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10553. return
  10554. }
  10555. userJSONBytes2, _ := json.Marshal(respJSON2)
  10556. if miConfig.Code == "H15049901371" {
  10557. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  10558. utils.ErrorLog("解析失败:%v", err)
  10559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10560. return
  10561. }
  10562. res2.InfRefmsgid = ressix10265.InfRefmsgid
  10563. res2.Output = ressix10265.Output
  10564. res2.ErrMsg = ressix10265.ErrMsg
  10565. res2.Cainfo = ressix10265.Cainfo
  10566. res2.WarnMsg = ressix10265.WarnMsg
  10567. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  10568. res2.Infcode = infocode
  10569. } else {
  10570. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10571. utils.ErrorLog("解析失败:%v", err)
  10572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10573. return
  10574. }
  10575. }
  10576. }
  10577. if res2.Infcode != 0 {
  10578. adminUser := c.GetAdminUserInfo()
  10579. errlog := &models.HisOrderError{
  10580. UserOrgId: adminUser.CurrentOrgId,
  10581. Ctime: time.Now().Unix(),
  10582. Mtime: time.Now().Unix(),
  10583. ErrMsg: res2.ErrMsg,
  10584. Status: 1,
  10585. PatientId: id,
  10586. RecordTime: recordDateTime,
  10587. Stage: 3,
  10588. }
  10589. service.CreateErrMsgLog(errlog)
  10590. c.ServeSuccessJSON(map[string]interface{}{
  10591. "failed_code": -10,
  10592. "msg": res2.ErrMsg,
  10593. })
  10594. return
  10595. } else {
  10596. his.Diagnosis = diagnosis_id
  10597. his.SickType = sickConfig.ID
  10598. //var p_type int64
  10599. //if reg_type == 1111 || reg_type == 1112 {
  10600. // p_type = 11
  10601. //
  10602. //}
  10603. his.PType = fmt.Sprintf("%d", reg_type)
  10604. service.UpdateHisPatientThree(&his)
  10605. data := make(map[string]interface{})
  10606. if settle_accounts_type == 1 { //日结
  10607. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  10608. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  10609. } else {
  10610. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  10611. }
  10612. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  10613. data["pre"] = prescriptions
  10614. } else { //月结
  10615. start_time_str := c.GetString("start_time")
  10616. end_time_str := c.GetString("end_time")
  10617. timeLayout := "2006-01-02"
  10618. loc, _ := time.LoadLocation("Local")
  10619. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  10620. if err != nil {
  10621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10622. return
  10623. }
  10624. recordStartTime := theStartTime.Unix()
  10625. start_time = recordStartTime
  10626. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  10627. if err != nil {
  10628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10629. return
  10630. }
  10631. recordEndTime := theEndTime.Unix()
  10632. end_time = recordEndTime
  10633. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  10634. data["pre"] = prescriptions
  10635. }
  10636. timestamp := time.Now().Unix()
  10637. tempTime := time.Unix(timestamp, 0)
  10638. timeFormat := tempTime.Format("20060102150405")
  10639. chrgBchno := rand.Intn(100000) + 10000
  10640. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  10641. strconv.FormatInt(his.PatientId, 10)
  10642. client := &http.Client{}
  10643. data["psn_no"] = his.PsnNo
  10644. data["mdtrt_id"] = his.Number
  10645. data["chrg_bchno"] = chrg_bchno
  10646. data["org_name"] = miConfig.OrgName
  10647. data["doctor"] = doctor_info.UserName
  10648. data["doctor_id"] = doctor_info.DoctorNumber
  10649. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  10650. data["fixmedins_code"] = miConfig.Code
  10651. data["opter"] = roles.UserName
  10652. data["dept_code"] = department.Number
  10653. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  10654. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10655. data["secret_key"] = miConfig.SecretKey
  10656. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  10657. data["url"] = miConfig.Url
  10658. data["ak"] = miConfig.AccessKey
  10659. data["new_doctor_name"] = patientPrescription.Doctor
  10660. data["diag_code"] = sickConfig.CountryCode
  10661. data["cainfo"] = miConfig.Cainfo
  10662. data["opter"] = roles.UserName
  10663. var ids []int64
  10664. for _, item := range prescriptions {
  10665. ids = append(ids, item.ID)
  10666. }
  10667. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10668. if config.IsOpen == 1 { //对接了医保,走医保流程
  10669. var res ResultFour
  10670. var resFour10265 ResultFour10265
  10671. if miConfig.MdtrtareaAdmvs == "421300" {
  10672. bytesData, _ := json.Marshal(data)
  10673. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  10674. resp, _ := client.Do(req)
  10675. defer resp.Body.Close()
  10676. body, ioErr := ioutil.ReadAll(resp.Body)
  10677. if ioErr != nil {
  10678. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10680. return
  10681. }
  10682. var respJSON map[string]interface{}
  10683. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10684. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10686. return
  10687. }
  10688. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10689. userJSONBytes, _ := json.Marshal(respJSON)
  10690. fmt.Println("log")
  10691. fmt.Println(string(userJSONBytes))
  10692. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10693. utils.ErrorLog("解析失败:%v", err)
  10694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10695. return
  10696. }
  10697. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10698. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  10699. if result3101.Infcode == "0" {
  10700. if len(result3101.Output.Result) > 0 {
  10701. var errMsgs []string
  10702. for _, item := range result3101.Output.Result {
  10703. errMsgs = append(errMsgs, item.VolaCont)
  10704. }
  10705. c.ServeSuccessJSON(map[string]interface{}{
  10706. "failed_code": -10,
  10707. "msg": errMsgs,
  10708. })
  10709. return
  10710. }
  10711. }
  10712. if miConfig.MdtrtareaAdmvs == "320921" {
  10713. data["doctor_id"] = "D320923012139"
  10714. } else {
  10715. data["doctor_id"] = "D371621008686"
  10716. }
  10717. bytesData, _ := json.Marshal(data)
  10718. var req *http.Request
  10719. if miConfig.MdtrtareaAdmvs == "320921" {
  10720. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10721. } else {
  10722. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10723. }
  10724. resp, _ := client.Do(req)
  10725. defer resp.Body.Close()
  10726. body, ioErr := ioutil.ReadAll(resp.Body)
  10727. if ioErr != nil {
  10728. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10730. return
  10731. }
  10732. var respJSON map[string]interface{}
  10733. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10736. return
  10737. }
  10738. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10739. userJSONBytes, _ := json.Marshal(respJSON)
  10740. fmt.Println("log")
  10741. fmt.Println(string(userJSONBytes))
  10742. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  10743. utils.ErrorLog("解析失败:%v", err)
  10744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10745. return
  10746. }
  10747. res.InfRefmsgid = resFour10265.InfRefmsgid
  10748. res.Output = resFour10265.Output
  10749. res.ErrMsg = resFour10265.ErrMsg
  10750. res.Cainfo = resFour10265.Cainfo
  10751. res.WarnMsg = resFour10265.WarnMsg
  10752. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  10753. res.Infcode = infocode
  10754. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10755. 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)
  10756. var dat map[string]interface{}
  10757. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10758. fmt.Println(dat)
  10759. } else {
  10760. fmt.Println(err)
  10761. }
  10762. saveLog(result, request_log, "2204", "上传费用明细")
  10763. userJSONBytes, _ := json.Marshal(dat)
  10764. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  10765. utils.ErrorLog("解析失败:%v", err)
  10766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10767. return
  10768. }
  10769. res.InfRefmsgid = resFour10265.InfRefmsgid
  10770. res.Output = resFour10265.Output
  10771. res.ErrMsg = resFour10265.ErrMsg
  10772. res.Cainfo = resFour10265.Cainfo
  10773. res.WarnMsg = resFour10265.WarnMsg
  10774. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  10775. res.Infcode = infocode
  10776. } else {
  10777. if miConfig.Code == "H15049901371" {
  10778. 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)
  10779. var dat map[string]interface{}
  10780. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10781. fmt.Println(dat)
  10782. } else {
  10783. fmt.Println(err)
  10784. }
  10785. saveLog(result, request_log, "2204", "上传费用明细")
  10786. userJSONBytes, _ := json.Marshal(dat)
  10787. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  10788. utils.ErrorLog("解析失败:%v", err)
  10789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10790. return
  10791. }
  10792. res.InfRefmsgid = resFour10265.InfRefmsgid
  10793. res.Output = resFour10265.Output
  10794. res.ErrMsg = resFour10265.ErrMsg
  10795. res.Cainfo = resFour10265.Cainfo
  10796. res.WarnMsg = resFour10265.WarnMsg
  10797. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  10798. res.Infcode = infocode
  10799. } else {
  10800. 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)
  10801. var dat map[string]interface{}
  10802. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10803. fmt.Println(dat)
  10804. } else {
  10805. fmt.Println(err)
  10806. }
  10807. saveLog(result, request_log, "2204", "上传费用明细")
  10808. userJSONBytes, _ := json.Marshal(dat)
  10809. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10810. utils.ErrorLog("解析失败:%v", err)
  10811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10812. return
  10813. }
  10814. }
  10815. }
  10816. if res.Infcode == 0 {
  10817. order := &models.HisOrder{
  10818. UserOrgId: adminUser.CurrentOrgId,
  10819. HisPatientId: his.ID,
  10820. PatientId: his.PatientId,
  10821. SettleAccountsDate: recordDateTime,
  10822. MdtrtId: his.Number,
  10823. PsnNo: his.PsnNo,
  10824. MedType: strconv.FormatInt(reg_type, 10),
  10825. Ctime: time.Now().Unix(),
  10826. Mtime: time.Now().Unix(),
  10827. Status: 1,
  10828. Number: chrg_bchno,
  10829. Infcode: res.Infcode,
  10830. WarnMsg: res.WarnMsg,
  10831. Cainfo: res.Cainfo,
  10832. ErrMsg: res.ErrMsg,
  10833. RespondTime: res.RefmsgTime,
  10834. InfRefmsgid: res.InfRefmsgid,
  10835. OrderStatus: 1,
  10836. PayWay: pay_way,
  10837. PayWays: pay_ways,
  10838. OthDesc: oth_desc,
  10839. PayPrice: pay_price,
  10840. PayCardNo: pay_card_no,
  10841. DiscountPrice: discount_price,
  10842. PreferentialPrice: preferential_price,
  10843. RealityPrice: reality_price,
  10844. FoundPrice: found_price,
  10845. MedicalInsurancePrice: medical_insurance_price,
  10846. PrivatePrice: private_price,
  10847. IsMedicineInsurance: 1,
  10848. SettleType: settle_accounts_type,
  10849. SettleStartTime: start_time,
  10850. SettleEndTime: end_time,
  10851. Creator: roles.AdminUserId,
  10852. Modify: roles.AdminUserId,
  10853. FaPiaoNumber: fapiao_number,
  10854. FaPiaoCode: fapiao_code,
  10855. PType: 2,
  10856. Diagnosis: diagnosis_id,
  10857. CashPay: cash_pay,
  10858. WechatPay: wechat_pay,
  10859. AliPay: ali_pay,
  10860. JifenPay: jifen_pay,
  10861. BandCardPay: band_card_pay,
  10862. }
  10863. err = service.CreateOrder(order)
  10864. if err != nil {
  10865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  10866. return
  10867. }
  10868. for _, item := range res.Output.Result {
  10869. temp := strings.Split(item.FeedetlSn, "-")
  10870. var advice_id int64 = 0
  10871. var project_id int64 = 0
  10872. var types int64 = 0
  10873. id, _ := strconv.ParseInt(temp[2], 10, 64)
  10874. types, _ = strconv.ParseInt(temp[1], 10, 64)
  10875. if temp[1] == "1" {
  10876. advice_id = id
  10877. project_id = 0
  10878. } else if temp[1] == "2" {
  10879. advice_id = 0
  10880. project_id = id
  10881. }
  10882. if item.MedChrgitmType == "9" {
  10883. item.MedChrgitmType = "09"
  10884. }
  10885. info := &models.HisOrderInfo{
  10886. OrderNumber: order.Number,
  10887. FeedetlSn: item.FeedetlSn,
  10888. UploadDate: time.Now().Unix(),
  10889. AdviceId: advice_id,
  10890. DetItemFeeSumamt: item.DetItemFeeSumamt,
  10891. Cnt: item.Cnt,
  10892. Pric: float64(item.Pric),
  10893. PatientId: his.PatientId,
  10894. PricUplmtAmt: item.PricUplmtAmt,
  10895. SelfpayProp: item.SelfpayProp,
  10896. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  10897. OverlmtAmt: item.OverlmtAmt,
  10898. PreselfpayAmt: item.PreselfpayAmt,
  10899. BasMednFlag: item.BasMednFlag,
  10900. MedChrgitmType: item.MedChrgitmType,
  10901. HiNegoDrugFlag: item.HiNegoDrugFlag,
  10902. Status: 1,
  10903. Memo: item.Memo,
  10904. Mtime: time.Now().Unix(),
  10905. InscpScpAmt: item.InscpScpAmt,
  10906. DrtReimFlag: item.DrtReimFlag,
  10907. Ctime: time.Now().Unix(),
  10908. ListSpItemFlag: item.ListSpItemFlag,
  10909. ChldMedcFlag: item.ChldMedcFlag,
  10910. LmtUsedFlag: item.LmtUsedFlag,
  10911. ChrgitmLv: item.ChrgitmLv,
  10912. UserOrgId: adminUser.CurrentOrgId,
  10913. HisPatientId: his.ID,
  10914. OrderId: order.ID,
  10915. ProjectId: project_id,
  10916. Type: types,
  10917. }
  10918. service.CreateOrderInfo(info)
  10919. }
  10920. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10921. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  10922. var total float64
  10923. for _, item := range prescriptions {
  10924. if item.Type == 1 { //药品
  10925. for _, subItem := range item.HisDoctorAdviceInfo {
  10926. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  10927. total_one := price * subItem.PrescribingNumber
  10928. total = total + total_one
  10929. }
  10930. }
  10931. if item.Type == 2 { //项目
  10932. for _, subItem := range item.HisPrescriptionProject {
  10933. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10934. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  10935. total_one := price * cnt
  10936. total = total + total_one
  10937. }
  10938. }
  10939. }
  10940. allTotal := fmt.Sprintf("%f", total)
  10941. //if adminUser.CurrentOrgId == 9919 {
  10942. //
  10943. // allTotal = fmt.Sprintf("%.2f", total)
  10944. //
  10945. //} else {
  10946. //
  10947. // allTotal = fmt.Sprintf("%.2f", total)
  10948. //
  10949. //}
  10950. if res.Infcode == 0 {
  10951. var rf []*ResultFive
  10952. json.Unmarshal([]byte(his.Iinfo), &rf)
  10953. chrg_bchno := chrg_bchno
  10954. cert_no := his.Certno
  10955. var insutypes []string
  10956. var insutype string
  10957. var is390 int = 0
  10958. var is310 int = 0
  10959. for _, item := range rf {
  10960. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10961. insutypes = append(insutypes, item.Insutype)
  10962. }
  10963. }
  10964. if len(insutypes) == 1 {
  10965. insutype = insutypes[0]
  10966. } else {
  10967. for _, i := range insutypes {
  10968. if i == "390" {
  10969. is390 = 1
  10970. }
  10971. if i == "310" {
  10972. is310 = 1
  10973. }
  10974. }
  10975. }
  10976. if is390 == 1 {
  10977. insutype = "390"
  10978. }
  10979. if is310 == 1 {
  10980. insutype = "310"
  10981. }
  10982. if len(insutypes) == 0 {
  10983. insutype = "310"
  10984. }
  10985. if len(insutypes) == 2 {
  10986. insutype = strconv.FormatInt(his.SocialType, 10)
  10987. }
  10988. insutype = strconv.FormatInt(his.SocialType, 10)
  10989. //insutype = "390"
  10990. if his.IdCardType == 1 {
  10991. // cert_no = his.MedicalInsuranceNumber
  10992. cert_no = his.Certno
  10993. } else {
  10994. cert_no = his.Certno
  10995. }
  10996. var res ResultSeven
  10997. var resSeven10265 ResultSeven10265
  10998. var src_resquest string
  10999. var result2 string
  11000. if miConfig.MdtrtareaAdmvs == "421300" {
  11001. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11002. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11003. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11004. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11005. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11006. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11007. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  11008. resp, requestErr := http.Get(api)
  11009. if requestErr != nil {
  11010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11011. return
  11012. }
  11013. body, ioErr := ioutil.ReadAll(resp.Body)
  11014. if ioErr != nil {
  11015. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11017. return
  11018. }
  11019. var respJSON map[string]interface{}
  11020. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11023. return
  11024. }
  11025. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11026. result, _ := json.Marshal(respJSON)
  11027. if miConfig.Code == "H15049901371" {
  11028. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  11029. utils.ErrorLog("解析失败:%v", err)
  11030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11031. return
  11032. }
  11033. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11034. res.Output = resSeven10265.Output
  11035. res.ErrMsg = resSeven10265.ErrMsg
  11036. res.Cainfo = resSeven10265.Cainfo
  11037. res.WarnMsg = resSeven10265.WarnMsg
  11038. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11039. res.Infcode = infocode
  11040. } else {
  11041. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11042. utils.ErrorLog("解析失败:%v", err)
  11043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11044. return
  11045. }
  11046. }
  11047. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11048. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  11049. if result3101.Infcode == "0" {
  11050. if len(result3101.Output.Result) > 0 {
  11051. var errMsgs []string
  11052. for _, item := range result3101.Output.Result {
  11053. errMsgs = append(errMsgs, item.VolaCont)
  11054. }
  11055. c.ServeSuccessJSON(map[string]interface{}{
  11056. "failed_code": -10,
  11057. "msg": errMsgs,
  11058. })
  11059. return
  11060. } else {
  11061. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11062. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  11063. bas := strings.Split(psn_info.CardInfo, "|")
  11064. if his.IdCardType == 1 {
  11065. cert_no = bas[2]
  11066. } else if his.IdCardType == 3 {
  11067. cert_no = his.Certno
  11068. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  11069. } else if his.IdCardType == 4 {
  11070. cert_no = his.Certno
  11071. psn_info.VerifyNumber = psn_info.VerifyNumber
  11072. }
  11073. var api string
  11074. if miConfig.MdtrtareaAdmvs == "320921" {
  11075. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11076. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11077. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11078. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11079. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11080. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11081. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  11082. } else {
  11083. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11084. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11085. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11086. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11087. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11088. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11089. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  11090. }
  11091. resp, requestErr := http.Get(api)
  11092. if requestErr != nil {
  11093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11094. return
  11095. }
  11096. body, ioErr := ioutil.ReadAll(resp.Body)
  11097. if ioErr != nil {
  11098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11100. return
  11101. }
  11102. var respJSON map[string]interface{}
  11103. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11106. return
  11107. }
  11108. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11109. result, _ := json.Marshal(respJSON)
  11110. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  11111. utils.ErrorLog("解析失败:%v", err)
  11112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11113. return
  11114. }
  11115. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11116. res.Output = resSeven10265.Output
  11117. res.ErrMsg = resSeven10265.ErrMsg
  11118. res.Cainfo = resSeven10265.Cainfo
  11119. res.WarnMsg = resSeven10265.WarnMsg
  11120. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11121. res.Infcode = infocode
  11122. }
  11123. }
  11124. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11125. var cert_no string
  11126. if his.IdCardType == 4 {
  11127. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11128. cert_no = psn_info.VerifyNumber
  11129. 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)
  11130. } else if his.IdCardType == 1 {
  11131. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11132. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  11133. 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)
  11134. }
  11135. //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)
  11136. var dat map[string]interface{}
  11137. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11138. fmt.Println(dat)
  11139. } else {
  11140. fmt.Println(err)
  11141. }
  11142. saveLog(result2, src_resquest, "2207", "结算")
  11143. userJSONBytes, _ := json.Marshal(dat)
  11144. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  11145. utils.ErrorLog("解析失败:%v", err)
  11146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11147. return
  11148. }
  11149. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11150. res.Output = resSeven10265.Output
  11151. res.ErrMsg = resSeven10265.ErrMsg
  11152. res.Cainfo = resSeven10265.Cainfo
  11153. res.WarnMsg = resSeven10265.WarnMsg
  11154. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11155. res.Infcode = infocode
  11156. } else {
  11157. if miConfig.Code == "H15049901371" {
  11158. //赤峰地区国家医保医疗类别
  11159. //职工透析:医疗类别选特殊情况门诊990502
  11160. //居民定额血透门慢: 医疗类别选门诊慢病140104
  11161. var med_type string
  11162. if his.Insutype == "390" {
  11163. if reg_type == 14 {
  11164. med_type = "9933"
  11165. } else if reg_type == 11 {
  11166. med_type = "11"
  11167. }
  11168. } else if his.Insutype == "310" {
  11169. if reg_type == 14 {
  11170. med_type = "990502"
  11171. } else if reg_type == 11 {
  11172. med_type = "11"
  11173. }
  11174. }
  11175. 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, "")
  11176. } else {
  11177. if his.IdCardType == 4 {
  11178. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11179. var token string
  11180. token = psn_info.VerifyNumber
  11181. 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)
  11182. } else {
  11183. 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, "")
  11184. }
  11185. }
  11186. //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)
  11187. var dat map[string]interface{}
  11188. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11189. fmt.Println(dat)
  11190. } else {
  11191. fmt.Println(err)
  11192. }
  11193. saveLog(result2, src_resquest, "2207", "结算")
  11194. userJSONBytes, _ := json.Marshal(dat)
  11195. if miConfig.Code == "H15049901371" {
  11196. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  11197. utils.ErrorLog("解析失败:%v", err)
  11198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11199. return
  11200. }
  11201. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11202. res.Output = resSeven10265.Output
  11203. res.ErrMsg = resSeven10265.ErrMsg
  11204. res.Cainfo = resSeven10265.Cainfo
  11205. res.WarnMsg = resSeven10265.WarnMsg
  11206. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11207. res.Infcode = infocode
  11208. } else {
  11209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11210. utils.ErrorLog("解析失败:%v", err)
  11211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11212. return
  11213. }
  11214. }
  11215. }
  11216. if res.Infcode != 0 {
  11217. errlog := &models.HisOrderError{
  11218. UserOrgId: adminUser.CurrentOrgId,
  11219. Ctime: time.Now().Unix(),
  11220. Mtime: time.Now().Unix(),
  11221. Number: chrg_bchno,
  11222. ErrMsg: res.ErrMsg,
  11223. Status: 1,
  11224. PatientId: id,
  11225. RecordTime: recordDateTime,
  11226. Stage: 6,
  11227. }
  11228. service.CreateErrMsgLog(errlog)
  11229. c.ServeSuccessJSON(map[string]interface{}{
  11230. "failed_code": -10,
  11231. "msg": res.ErrMsg,
  11232. })
  11233. return
  11234. } else {
  11235. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  11236. order.OrderStatus = 2
  11237. order.Status = 1
  11238. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  11239. order.SetlId = res.Output.Setlinfo.SetlID
  11240. order.PsnNo = res.Output.Setlinfo.PsnNo
  11241. order.PsnName = res.Output.Setlinfo.PsnName
  11242. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  11243. order.Certno = res.Output.Setlinfo.Certno
  11244. order.Gend = res.Output.Setlinfo.Gend
  11245. order.Naty = res.Output.Setlinfo.Naty
  11246. order.Age = res.Output.Setlinfo.Age
  11247. order.Insutype = res.Output.Setlinfo.Insutype
  11248. order.PsnType = res.Output.Setlinfo.PsnType
  11249. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  11250. order.SetlTime = res.Output.Setlinfo.SetlTime
  11251. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  11252. if res.Output.Setlinfo.MedType == "140101" {
  11253. order.MedType = "14"
  11254. } else {
  11255. order.MedType = res.Output.Setlinfo.MedType
  11256. }
  11257. if reg_type == 1112 {
  11258. order.MedType = "1112"
  11259. }
  11260. if reg_type == 1111 {
  11261. order.MedType = "1111"
  11262. }
  11263. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  11264. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  11265. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  11266. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  11267. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  11268. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  11269. order.HifpPay = res.Output.Setlinfo.HifpPay
  11270. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  11271. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  11272. order.HifesPay = res.Output.Setlinfo.HifesPay
  11273. order.HifobPay = res.Output.Setlinfo.HifobPay
  11274. order.MafPay = res.Output.Setlinfo.MafPay
  11275. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  11276. order.OthPay = res.Output.Setlinfo.OthPay
  11277. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  11278. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  11279. order.AcctPay = res.Output.Setlinfo.AcctPay
  11280. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  11281. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  11282. order.Balc = res.Output.Setlinfo.Balc
  11283. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  11284. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  11285. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  11286. order.ClrType = res.Output.Setlinfo.ClrType
  11287. order.ClrWay = res.Output.Setlinfo.ClrWay
  11288. order.Creator = order.Creator
  11289. order.Modify = roles.AdminUserId
  11290. order.RequestLog = src_resquest
  11291. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  11292. detailStr := string(setlDetail)
  11293. order.SetlDetail = detailStr
  11294. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  11295. err = service.UpDateOrder(order)
  11296. if err == nil {
  11297. //判断是否使用了押金
  11298. if dec_way == "true" {
  11299. tmpstring := strconv.FormatInt(order.ID, 10)
  11300. order.Decimal = decimal
  11301. service.UpDateOrder(order)
  11302. //扣押金
  11303. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  11304. if errmsg != nil {
  11305. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  11306. return
  11307. }
  11308. }
  11309. c.ServeSuccessJSON(map[string]interface{}{
  11310. "msg": "结算成功",
  11311. })
  11312. } else {
  11313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  11314. return
  11315. }
  11316. }
  11317. } else {
  11318. adminUser := c.GetAdminUserInfo()
  11319. errlog := &models.HisOrderError{
  11320. UserOrgId: adminUser.CurrentOrgId,
  11321. Ctime: time.Now().Unix(),
  11322. Mtime: time.Now().Unix(),
  11323. ErrMsg: res.ErrMsg,
  11324. Status: 1,
  11325. PatientId: id,
  11326. RecordTime: recordDateTime,
  11327. Stage: 4,
  11328. }
  11329. service.CreateErrMsgLog(errlog)
  11330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  11331. return
  11332. }
  11333. } else {
  11334. adminUser := c.GetAdminUserInfo()
  11335. errlog := &models.HisOrderError{
  11336. UserOrgId: adminUser.CurrentOrgId,
  11337. Ctime: time.Now().Unix(),
  11338. Mtime: time.Now().Unix(),
  11339. ErrMsg: res.ErrMsg,
  11340. Status: 1,
  11341. PatientId: id,
  11342. RecordTime: recordDateTime,
  11343. Stage: 4,
  11344. }
  11345. service.CreateErrMsgLog(errlog)
  11346. c.ServeSuccessJSON(map[string]interface{}{
  11347. "failed_code": -10,
  11348. "msg": res.ErrMsg,
  11349. })
  11350. return
  11351. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  11352. //return
  11353. }
  11354. }
  11355. }
  11356. } else if tempOrder.ID > 0 {
  11357. if tempOrder.IsPre == 1 {
  11358. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  11359. var rf []*ResultFive
  11360. json.Unmarshal([]byte(his.Iinfo), &rf)
  11361. chrg_bchno := tempOrder.Number
  11362. cert_no := his.Certno
  11363. var insutypes []string
  11364. var insutype string
  11365. var is390 int = 0
  11366. var is310 int = 0
  11367. for _, item := range rf {
  11368. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11369. insutypes = append(insutypes, item.Insutype)
  11370. }
  11371. }
  11372. if len(insutypes) == 1 {
  11373. insutype = insutypes[0]
  11374. } else {
  11375. for _, i := range insutypes {
  11376. if i == "390" {
  11377. is390 = 1
  11378. }
  11379. if i == "310" {
  11380. is310 = 1
  11381. }
  11382. }
  11383. }
  11384. if is390 == 1 {
  11385. insutype = "390"
  11386. }
  11387. if is310 == 1 {
  11388. insutype = "310"
  11389. }
  11390. if len(insutypes) == 0 {
  11391. insutype = "310"
  11392. }
  11393. if len(insutypes) == 2 {
  11394. insutype = strconv.FormatInt(his.SocialType, 10)
  11395. }
  11396. //insutype = "390"
  11397. if his.IdCardType == 1 {
  11398. // cert_no = his.MedicalInsuranceNumber
  11399. cert_no = his.Certno
  11400. } else {
  11401. cert_no = his.Certno
  11402. }
  11403. var res ResultSeven
  11404. var resSeven10265 ResultSeven10265
  11405. var src_resquest string
  11406. var result2 string
  11407. if miConfig.MdtrtareaAdmvs == "421300" {
  11408. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11409. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11410. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11411. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11412. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11413. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11414. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  11415. resp, requestErr := http.Get(api)
  11416. if requestErr != nil {
  11417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11418. return
  11419. }
  11420. body, ioErr := ioutil.ReadAll(resp.Body)
  11421. if ioErr != nil {
  11422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11424. return
  11425. }
  11426. var respJSON map[string]interface{}
  11427. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11430. return
  11431. }
  11432. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11433. result, _ := json.Marshal(respJSON)
  11434. fmt.Println("log")
  11435. fmt.Println(string(result))
  11436. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11437. utils.ErrorLog("解析失败:%v", err)
  11438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11439. return
  11440. }
  11441. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11442. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  11443. if result3101.Infcode == "0" {
  11444. if len(result3101.Output.Result) > 0 {
  11445. var errMsgs []string
  11446. for _, item := range result3101.Output.Result {
  11447. errMsgs = append(errMsgs, item.VolaCont)
  11448. }
  11449. c.ServeSuccessJSON(map[string]interface{}{
  11450. "failed_code": -10,
  11451. "msg": errMsgs,
  11452. })
  11453. return
  11454. } else {
  11455. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11456. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  11457. bas := strings.Split(psn_info.CardInfo, "|")
  11458. if his.IdCardType == 1 {
  11459. cert_no = bas[2]
  11460. } else if his.IdCardType == 3 {
  11461. cert_no = his.Certno
  11462. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  11463. } else if his.IdCardType == 4 {
  11464. cert_no = his.Certno
  11465. psn_info.VerifyNumber = psn_info.VerifyNumber
  11466. }
  11467. //江苏地区国家医保医疗类别
  11468. //职工透析:医疗类别选特殊情况门诊9933
  11469. //居民血透门慢: 医疗类别选门诊慢病1402
  11470. //var med_type string
  11471. //if his.Insutype == "310" {
  11472. // if reg_type == 14 {
  11473. // med_type = "9933"
  11474. // } else if reg_type == 11 {
  11475. // med_type = "11"
  11476. //
  11477. // }
  11478. //} else if his.Insutype == "390" {
  11479. // if reg_type == 14 {
  11480. // med_type = "1402"
  11481. // } else if reg_type == 11 {
  11482. // med_type = "11"
  11483. // }
  11484. //}
  11485. var api string
  11486. if miConfig.MdtrtareaAdmvs == "320921" {
  11487. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11488. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11489. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11490. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11491. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11492. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11493. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  11494. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11495. } else {
  11496. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11497. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11498. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11499. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11500. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11501. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11502. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11503. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  11504. }
  11505. resp, requestErr := http.Get(api)
  11506. if requestErr != nil {
  11507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11508. return
  11509. }
  11510. body, ioErr := ioutil.ReadAll(resp.Body)
  11511. if ioErr != nil {
  11512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11514. return
  11515. }
  11516. var respJSON map[string]interface{}
  11517. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11520. return
  11521. }
  11522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11523. result, _ := json.Marshal(respJSON)
  11524. fmt.Println("log")
  11525. fmt.Println(string(result))
  11526. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  11527. utils.ErrorLog("解析失败:%v", err)
  11528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11529. return
  11530. }
  11531. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11532. res.Output = resSeven10265.Output
  11533. res.ErrMsg = resSeven10265.ErrMsg
  11534. res.Cainfo = resSeven10265.Cainfo
  11535. res.WarnMsg = resSeven10265.WarnMsg
  11536. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11537. res.Infcode = infocode
  11538. }
  11539. }
  11540. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11541. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11542. var cert_no string
  11543. if his.IdCardType == 1 {
  11544. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  11545. } else {
  11546. cert_no = psn_info.VerifyNumber
  11547. }
  11548. 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)
  11549. var dat map[string]interface{}
  11550. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11551. fmt.Println(dat)
  11552. } else {
  11553. fmt.Println(err)
  11554. }
  11555. saveLog(result2, src_resquest, "2207", "结算")
  11556. userJSONBytes, _ := json.Marshal(dat)
  11557. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11558. utils.ErrorLog("解析失败:%v", err)
  11559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11560. return
  11561. }
  11562. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11563. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11564. var cert_no string
  11565. if his.IdCardType == 1 {
  11566. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  11567. } else if his.IdCardType == 2 {
  11568. cert_no = his.IdCardNo
  11569. } else {
  11570. cert_no = psn_info.VerifyNumber
  11571. }
  11572. 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, "")
  11573. var dat map[string]interface{}
  11574. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11575. fmt.Println(dat)
  11576. } else {
  11577. fmt.Println(err)
  11578. }
  11579. saveLog(result2, src_resquest, "2207", "结算")
  11580. userJSONBytes, _ := json.Marshal(dat)
  11581. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11582. utils.ErrorLog("解析失败:%v", err)
  11583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11584. return
  11585. }
  11586. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11587. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11588. var cert_no string
  11589. if his.IdCardType == 1 {
  11590. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  11591. } else if his.IdCardType == 2 {
  11592. cert_no = his.IdCardNo
  11593. } else {
  11594. cert_no = psn_info.VerifyNumber
  11595. }
  11596. 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, "")
  11597. var dat map[string]interface{}
  11598. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11599. fmt.Println(dat)
  11600. } else {
  11601. fmt.Println(err)
  11602. }
  11603. saveLog(result2, src_resquest, "2207", "结算")
  11604. userJSONBytes, _ := json.Marshal(dat)
  11605. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11606. utils.ErrorLog("解析失败:%v", err)
  11607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11608. return
  11609. }
  11610. } else {
  11611. var src_resquest string
  11612. if miConfig.Code == "H15049901371" {
  11613. //赤峰地区国家医保医疗类别
  11614. //职工透析:医疗类别选特殊情况门诊990502
  11615. //居民定额血透门慢: 医疗类别选门诊慢病140104
  11616. var med_type string
  11617. if his.Insutype == "390" {
  11618. if reg_type == 14 {
  11619. med_type = "9933"
  11620. } else if reg_type == 11 {
  11621. med_type = "11"
  11622. }
  11623. } else if his.Insutype == "310" {
  11624. if reg_type == 14 {
  11625. med_type = "990502"
  11626. } else if reg_type == 11 {
  11627. med_type = "11"
  11628. }
  11629. }
  11630. 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, "")
  11631. } else {
  11632. if his.IdCardType == 4 {
  11633. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11634. token := psn_info.VerifyNumber
  11635. 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)
  11636. } else {
  11637. 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, "")
  11638. }
  11639. }
  11640. var dat map[string]interface{}
  11641. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11642. fmt.Println(dat)
  11643. } else {
  11644. fmt.Println(err)
  11645. }
  11646. saveLog(result2, src_resquest, "2207", "结算")
  11647. userJSONBytes, _ := json.Marshal(dat)
  11648. if miConfig.Code == "H15049901371" {
  11649. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  11650. utils.ErrorLog("解析失败:%v", err)
  11651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11652. return
  11653. }
  11654. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11655. res.Output = resSeven10265.Output
  11656. res.ErrMsg = resSeven10265.ErrMsg
  11657. res.Cainfo = resSeven10265.Cainfo
  11658. res.WarnMsg = resSeven10265.WarnMsg
  11659. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11660. res.Infcode = infocode
  11661. } else {
  11662. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11663. utils.ErrorLog("解析失败:%v", err)
  11664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11665. return
  11666. }
  11667. }
  11668. }
  11669. if res.Infcode != 0 {
  11670. errlog := &models.HisOrderError{
  11671. UserOrgId: adminUser.CurrentOrgId,
  11672. Ctime: time.Now().Unix(),
  11673. Mtime: time.Now().Unix(),
  11674. Number: chrg_bchno,
  11675. ErrMsg: res.ErrMsg,
  11676. Status: 1,
  11677. PatientId: id,
  11678. RecordTime: recordDateTime,
  11679. Stage: 6,
  11680. }
  11681. service.CreateErrMsgLog(errlog)
  11682. c.ServeSuccessJSON(map[string]interface{}{
  11683. "failed_code": -10,
  11684. "msg": res.ErrMsg,
  11685. })
  11686. return
  11687. } else {
  11688. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  11689. order.OrderStatus = 2
  11690. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  11691. order.SetlId = res.Output.Setlinfo.SetlID
  11692. order.PsnNo = res.Output.Setlinfo.PsnNo
  11693. order.PsnName = res.Output.Setlinfo.PsnName
  11694. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  11695. order.Certno = res.Output.Setlinfo.Certno
  11696. order.Gend = res.Output.Setlinfo.Gend
  11697. order.Naty = res.Output.Setlinfo.Naty
  11698. order.Age = res.Output.Setlinfo.Age
  11699. order.Insutype = res.Output.Setlinfo.Insutype
  11700. order.PsnType = res.Output.Setlinfo.PsnType
  11701. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  11702. order.SetlTime = res.Output.Setlinfo.SetlTime
  11703. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  11704. order.PayWays = pay_ways
  11705. order.AcctUsedFlag = acct_used_flag
  11706. order.WechatPay = wechat_pay
  11707. order.AliPay = ali_pay
  11708. order.JifenPay = jifen_pay
  11709. order.BandCardPay = band_card_pay
  11710. order.CashPay = cash_pay
  11711. order.OthDesc = oth_desc
  11712. //order.MedType = res.Output.Setlinfo.MedType
  11713. if reg_type == 1112 {
  11714. order.MedType = "1112"
  11715. }
  11716. if reg_type == 1111 {
  11717. order.MedType = "1111"
  11718. }
  11719. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  11720. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  11721. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  11722. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  11723. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  11724. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  11725. order.HifpPay = res.Output.Setlinfo.HifpPay
  11726. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  11727. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  11728. order.HifesPay = res.Output.Setlinfo.HifesPay
  11729. order.HifobPay = res.Output.Setlinfo.HifobPay
  11730. order.MafPay = res.Output.Setlinfo.MafPay
  11731. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  11732. order.OthPay = res.Output.Setlinfo.OthPay
  11733. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  11734. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  11735. order.AcctPay = res.Output.Setlinfo.AcctPay
  11736. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  11737. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  11738. order.Balc = res.Output.Setlinfo.Balc
  11739. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  11740. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  11741. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  11742. order.ClrWay = res.Output.Setlinfo.ClrWay
  11743. order.Creator = order.Creator
  11744. order.Modify = roles.AdminUserId
  11745. order.RequestLog = src_resquest
  11746. order.Diagnosis = diagnosis_id
  11747. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  11748. detailStr := string(setlDetail)
  11749. order.SetlDetail = detailStr
  11750. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  11751. err = service.UpDateOrder(order)
  11752. if err == nil {
  11753. //判断是否使用了押金
  11754. if dec_way == "true" {
  11755. tmpstring := strconv.FormatInt(order.ID, 10)
  11756. //扣押金
  11757. order.Decimal = decimal
  11758. service.UpDateOrder(order)
  11759. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  11760. if errmsg != nil {
  11761. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  11762. return
  11763. }
  11764. }
  11765. c.ServeSuccessJSON(map[string]interface{}{
  11766. "msg": "结算成功",
  11767. })
  11768. } else {
  11769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  11770. return
  11771. }
  11772. }
  11773. }
  11774. }
  11775. }
  11776. //func (c *HisApiController) GetPreUploadInfo() {
  11777. // id, _ := c.GetInt64("id")
  11778. // record_time := c.GetString("record_time")
  11779. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  11780. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11781. //
  11782. // timeLayout := "2006-01-02"
  11783. // loc, _ := time.LoadLocation("Local")
  11784. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11785. // if err != nil {
  11786. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11787. // return
  11788. // }
  11789. // recordDateTime := theTime.Unix()
  11790. // adminUser := c.GetAdminUserInfo()
  11791. //
  11792. // var prescriptions []*models.HisPrescription
  11793. //
  11794. // var start_time int64
  11795. // var end_time int64
  11796. //
  11797. // data := make(map[string]interface{})
  11798. // if settle_accounts_type == 1 { //日结
  11799. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  11800. // data["pre"] = prescriptions
  11801. //
  11802. // } else { //月结
  11803. // start_time_str := c.GetString("start_time")
  11804. // end_time_str := c.GetString("end_time")
  11805. // timeLayout := "2006-01-02"
  11806. // loc, _ := time.LoadLocation("Local")
  11807. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  11808. // if err != nil {
  11809. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11810. // return
  11811. // }
  11812. // recordStartTime := theStartTime.Unix()
  11813. // start_time = recordStartTime
  11814. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  11815. // if err != nil {
  11816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11817. // return
  11818. // }
  11819. // recordEndTime := theEndTime.Unix()
  11820. // end_time = recordEndTime
  11821. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  11822. // data["pre"] = prescriptions
  11823. //
  11824. // }
  11825. //
  11826. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11827. //
  11828. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  11829. // timestamp := time.Now().Unix()
  11830. // tempTime := time.Unix(timestamp, 0)
  11831. // timeFormat := tempTime.Format("20060102150405")
  11832. // chrgBchno := rand.Intn(100000) + 10000
  11833. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  11834. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11835. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  11836. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11837. // strconv.FormatInt(his.PatientId, 10)
  11838. // client := &http.Client{}
  11839. // data["psn_no"] = his.PsnNo
  11840. // data["mdtrt_id"] = his.Number
  11841. // data["chrg_bchno"] = chrg_bchno
  11842. // data["org_name"] = miConfig.OrgName
  11843. // data["doctor"] = roles.UserName
  11844. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  11845. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  11846. // data["fixmedins_code"] = miConfig.Code
  11847. // data["dept_code"] = department.Number
  11848. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  11849. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11850. // data["secret_key"] = miConfig.SecretKey
  11851. // var ids []int64
  11852. //
  11853. // for _, item := range prescriptions {
  11854. // ids = append(ids, item.ID)
  11855. // }
  11856. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11857. // if config.IsOpen == 1 { //对接了医保,走医保流程
  11858. // bytesData, _ := json.Marshal(data)
  11859. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  11860. // resp, _ := client.Do(req)
  11861. // defer resp.Body.Close()
  11862. // body, ioErr := ioutil.ReadAll(resp.Body)
  11863. // if ioErr != nil {
  11864. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11866. // return
  11867. // }
  11868. // var respJSON map[string]interface{}
  11869. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11870. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11871. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11872. // return
  11873. // }
  11874. //
  11875. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11876. // userJSONBytes, _ := json.Marshal(respJSON)
  11877. // var res ResultFour
  11878. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11879. // utils.ErrorLog("解析失败:%v", err)
  11880. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11881. // return
  11882. // }
  11883. //
  11884. // if res.Infcode == 0 {
  11885. // order := &models.HisOrder{
  11886. // UserOrgId: adminUser.CurrentOrgId,
  11887. // HisPatientId: his.ID,
  11888. // PatientId: his.PatientId,
  11889. // SettleAccountsDate: recordDateTime,
  11890. // Ctime: time.Now().Unix(),
  11891. // Mtime: time.Now().Unix(),
  11892. // Status: 1,
  11893. // Number: chrg_bchno,
  11894. // Infcode: res.Infcode,
  11895. // WarnMsg: res.WarnMsg,
  11896. // Cainfo: res.Cainfo,
  11897. // ErrMsg: res.ErrMsg,
  11898. // RespondTime: res.RefmsgTime,
  11899. // InfRefmsgid: res.InfRefmsgid,
  11900. // OrderStatus: 1,
  11901. // IsMedicineInsurance: 1,
  11902. // SettleType: settle_accounts_type,
  11903. // SettleStartTime: start_time,
  11904. // SettleEndTime: end_time,
  11905. // Creator: roles.ID,
  11906. // Modify: roles.ID,
  11907. // PType: 2,
  11908. // }
  11909. // err = service.CreateOrder(order)
  11910. // if err != nil {
  11911. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  11912. // return
  11913. // }
  11914. //
  11915. // for _, item := range res.Output.Result {
  11916. // temp := strings.Split(item.FeedetlSn, "-")
  11917. // var advice_id int64 = 0
  11918. // var project_id int64 = 0
  11919. // var types int64 = 0
  11920. //
  11921. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  11922. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  11923. //
  11924. // if temp[1] == "1" {
  11925. // advice_id = id
  11926. // project_id = 0
  11927. // } else if temp[1] == "2" {
  11928. // advice_id = 0
  11929. // project_id = id
  11930. // }
  11931. //
  11932. // info := &models.HisOrderInfo{
  11933. // OrderNumber: order.Number,
  11934. // FeedetlSn: item.FeedetlSn,
  11935. // UploadDate: time.Now().Unix(),
  11936. // AdviceId: advice_id,
  11937. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  11938. // Cnt: item.Cnt,
  11939. // Pric: float64(item.Pric),
  11940. // PatientId: his.PatientId,
  11941. // PricUplmtAmt: item.PricUplmtAmt,
  11942. // SelfpayProp: item.SelfpayProp,
  11943. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  11944. // OverlmtAmt: item.OverlmtAmt,
  11945. // PreselfpayAmt: item.PreselfpayAmt,
  11946. // BasMednFlag: item.BasMednFlag,
  11947. // MedChrgitmType: item.MedChrgitmType,
  11948. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  11949. // Status: 1,
  11950. // Memo: item.Memo,
  11951. // Mtime: time.Now().Unix(),
  11952. // InscpScpAmt: item.InscpScpAmt,
  11953. // DrtReimFlag: item.DrtReimFlag,
  11954. // Ctime: time.Now().Unix(),
  11955. // ListSpItemFlag: item.ListSpItemFlag,
  11956. // ChldMedcFlag: item.ChldMedcFlag,
  11957. // LmtUsedFlag: item.LmtUsedFlag,
  11958. // ChrgitmLv: item.ChrgitmLv,
  11959. // UserOrgId: adminUser.CurrentOrgId,
  11960. // HisPatientId: his.ID,
  11961. // OrderId: order.ID,
  11962. // ProjectId: project_id,
  11963. // Type: types,
  11964. // }
  11965. // service.CreateOrderInfo(info)
  11966. //
  11967. // }
  11968. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11969. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  11970. //
  11971. // var total float64
  11972. // for _, item := range prescriptions {
  11973. // if item.Type == 1 { //药品
  11974. // for _, subItem := range item.HisDoctorAdviceInfo {
  11975. // total = total + (subItem.Price * subItem.PrescribingNumber)
  11976. // }
  11977. // }
  11978. // if item.Type == 2 { //项目
  11979. // for _, subItem := range item.HisPrescriptionProject {
  11980. // total = total + (subItem.Price * float64(subItem.Count))
  11981. // }
  11982. // }
  11983. // }
  11984. //
  11985. // for _, item := range prescriptions {
  11986. // for _, subItem := range item.HisAdditionalCharge {
  11987. // total = total + (subItem.Price * float64(subItem.Count))
  11988. // }
  11989. // }
  11990. //
  11991. // allTotal := fmt.Sprintf("%.2f", total)
  11992. // if res.Infcode == 0 {
  11993. // var rf []*ResultFive
  11994. // json.Unmarshal([]byte(his.Iinfo), &rf)
  11995. // psn_no := his.PsnNo
  11996. // mdtrt_id := his.Number
  11997. // chrg_bchno := chrg_bchno
  11998. // cert_no := his.Certno
  11999. // insutype := rf[0].Insutype
  12000. //
  12001. // if his.IdCardType == 1 {
  12002. // cert_no = his.MedicalInsuranceNumber
  12003. //
  12004. // } else {
  12005. //
  12006. // cert_no = his.Certno
  12007. //
  12008. // }
  12009. //
  12010. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  12011. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  12012. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  12013. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  12014. // resp, requestErr := http.Get(api)
  12015. // if requestErr != nil {
  12016. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12017. // return
  12018. // }
  12019. // defer resp.Body.Close()
  12020. // body, ioErr := ioutil.ReadAll(resp.Body)
  12021. // if ioErr != nil {
  12022. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12023. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12024. // return
  12025. // }
  12026. // var respJSON map[string]interface{}
  12027. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12028. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12030. // return
  12031. // }
  12032. // fmt.Println(respJSON)
  12033. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12034. // userJSONBytes, _ := json.Marshal(respJSON)
  12035. // var res ResultSeven
  12036. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12037. // utils.ErrorLog("解析失败:%v", err)
  12038. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12039. // return
  12040. // }
  12041. // if res.Infcode != 0 {
  12042. // errlog := &models.HisOrderError{
  12043. // UserOrgId: adminUser.CurrentOrgId,
  12044. // Ctime: time.Now().Unix(),
  12045. // Mtime: time.Now().Unix(),
  12046. // Number: chrg_bchno,
  12047. // ErrMsg: res.ErrMsg,
  12048. // Status: 1,
  12049. // PatientId: id,
  12050. // RecordTime: recordDateTime,
  12051. // Stage: 7,
  12052. // }
  12053. // service.CreateErrMsgLog(errlog)
  12054. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  12055. // return
  12056. // } else {
  12057. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  12058. // order.OrderStatus = 1
  12059. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  12060. // order.SetlId = res.Output.Setlinfo.SetlID
  12061. // order.PsnNo = res.Output.Setlinfo.PsnNo
  12062. // order.PsnName = res.Output.Setlinfo.PsnName
  12063. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  12064. // order.Certno = res.Output.Setlinfo.Certno
  12065. // order.Gend = res.Output.Setlinfo.Gend
  12066. // order.Naty = res.Output.Setlinfo.Naty
  12067. // order.Age = res.Output.Setlinfo.Age
  12068. // order.Insutype = res.Output.Setlinfo.Insutype
  12069. // order.PsnType = res.Output.Setlinfo.PsnType
  12070. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  12071. // order.SetlTime = res.Output.Setlinfo.SetlTime
  12072. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  12073. // order.MedType = res.Output.Setlinfo.MedType
  12074. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  12075. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  12076. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  12077. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  12078. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  12079. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  12080. // order.HifpPay = res.Output.Setlinfo.HifpPay
  12081. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  12082. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  12083. // order.HifesPay = res.Output.Setlinfo.HifesPay
  12084. // order.HifobPay = res.Output.Setlinfo.HifobPay
  12085. // order.MafPay = res.Output.Setlinfo.MafPay
  12086. // order.OthPay = res.Output.Setlinfo.OthPay
  12087. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  12088. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  12089. // order.AcctPay = res.Output.Setlinfo.AcctPay
  12090. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  12091. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  12092. // order.Balc = res.Output.Setlinfo.Balc
  12093. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  12094. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  12095. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  12096. // order.ClrWay = res.Output.Setlinfo.ClrWay
  12097. // order.Creator = order.Creator
  12098. // order.Modify = roles.ID
  12099. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  12100. // detailStr := string(setlDetail)
  12101. // order.SetlDetail = detailStr
  12102. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  12103. // err = service.UpDateOrder(order)
  12104. // if err == nil {
  12105. // c.ServeSuccessJSON(map[string]interface{}{
  12106. // "msg": "预结算成功",
  12107. // })
  12108. // } else {
  12109. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  12110. // return
  12111. // }
  12112. // }
  12113. // } else {
  12114. // adminUser := c.GetAdminUserInfo()
  12115. // errlog := &models.HisOrderError{
  12116. // UserOrgId: adminUser.CurrentOrgId,
  12117. // Ctime: time.Now().Unix(),
  12118. // Mtime: time.Now().Unix(),
  12119. // ErrMsg: res.ErrMsg,
  12120. // Status: 1,
  12121. // PatientId: id,
  12122. // RecordTime: recordDateTime,
  12123. // Stage: 4,
  12124. // }
  12125. // service.CreateErrMsgLog(errlog)
  12126. //
  12127. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  12128. // return
  12129. // }
  12130. // } else {
  12131. // adminUser := c.GetAdminUserInfo()
  12132. // errlog := &models.HisOrderError{
  12133. // UserOrgId: adminUser.CurrentOrgId,
  12134. // Ctime: time.Now().Unix(),
  12135. // Mtime: time.Now().Unix(),
  12136. // ErrMsg: res.ErrMsg,
  12137. // Status: 1,
  12138. // PatientId: id,
  12139. // RecordTime: recordDateTime,
  12140. // Stage: 4,
  12141. // }
  12142. // service.CreateErrMsgLog(errlog)
  12143. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  12144. // return
  12145. // }
  12146. //
  12147. // } else {
  12148. // var total float64
  12149. // for _, item := range prescriptions {
  12150. // if item.Type == 1 { //药品
  12151. // for _, subItem := range item.HisDoctorAdviceInfo {
  12152. // total = total + (subItem.Price * subItem.PrescribingNumber)
  12153. // }
  12154. // }
  12155. // if item.Type == 2 { //项目
  12156. // for _, subItem := range item.HisPrescriptionProject {
  12157. // total = total + (subItem.Price * float64(subItem.Count))
  12158. // }
  12159. // }
  12160. //
  12161. // for _, subItem := range item.HisAdditionalCharge {
  12162. // total = total + (subItem.Price * float64(subItem.Count))
  12163. // }
  12164. // }
  12165. //
  12166. // allTotal := fmt.Sprintf("%.2f", total)
  12167. // totals, _ := strconv.ParseFloat(allTotal, 64)
  12168. // order := &models.HisOrder{
  12169. // UserOrgId: adminUser.CurrentOrgId,
  12170. // HisPatientId: his.ID,
  12171. // PatientId: id,
  12172. // SettleAccountsDate: recordDateTime,
  12173. // Ctime: time.Now().Unix(),
  12174. // Mtime: time.Now().Unix(),
  12175. // Status: 1,
  12176. // OrderStatus: 2,
  12177. // Number: chrg_bchno,
  12178. // MedfeeSumamt: totals,
  12179. // }
  12180. // err = service.CreateOrder(order)
  12181. // if err != nil {
  12182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  12183. // return
  12184. // }
  12185. //
  12186. // var customs []*Custom
  12187. // for _, item := range prescriptions {
  12188. //
  12189. // if item.Type == 1 { //药品
  12190. // for _, subItem := range item.HisDoctorAdviceInfo {
  12191. // cus := &Custom{
  12192. // AdviceId: subItem.ID,
  12193. // ProjectId: 0,
  12194. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  12195. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  12196. // FeedetlSn: subItem.FeedetlSn,
  12197. // Price: fmt.Sprintf("%.2f", subItem.Price),
  12198. // MedListCodg: subItem.MedListCodg,
  12199. // Type: 1,
  12200. // }
  12201. // customs = append(customs, cus)
  12202. // }
  12203. // }
  12204. //
  12205. // if item.Type == 2 { //项目
  12206. // for _, subItem := range item.HisPrescriptionProject {
  12207. //
  12208. // cus := &Custom{
  12209. // AdviceId: 0,
  12210. // ProjectId: subItem.ID,
  12211. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  12212. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  12213. // FeedetlSn: subItem.FeedetlSn,
  12214. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  12215. // MedListCodg: subItem.MedListCodg,
  12216. // Type: 2,
  12217. // }
  12218. //
  12219. // customs = append(customs, cus)
  12220. // }
  12221. // }
  12222. //
  12223. // for _, item := range item.HisAdditionalCharge {
  12224. // cus := &Custom{
  12225. // ItemId: item.ID,
  12226. // AdviceId: 0,
  12227. // ProjectId: 0,
  12228. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  12229. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  12230. // FeedetlSn: item.FeedetlSn,
  12231. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  12232. // MedListCodg: item.XtHisAddtionConfig.Code,
  12233. // Type: 3,
  12234. // }
  12235. //
  12236. // customs = append(customs, cus)
  12237. // }
  12238. //
  12239. // }
  12240. //
  12241. // for _, item := range customs {
  12242. // var advice_id int64 = 0
  12243. // var project_id int64 = 0
  12244. // var item_id int64 = 0
  12245. //
  12246. // var types int64 = 0
  12247. //
  12248. // if item.Type == 1 {
  12249. // advice_id = item.AdviceId
  12250. // project_id = 0
  12251. // item_id = 0
  12252. // } else if item.Type == 2 {
  12253. // advice_id = 0
  12254. // item_id = 0
  12255. //
  12256. // project_id = item.ProjectId
  12257. // } else if item.Type == 3 {
  12258. // advice_id = 0
  12259. // item_id = item.ItemId
  12260. // project_id = 0
  12261. // }
  12262. //
  12263. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  12264. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  12265. // pric, _ := strconv.ParseFloat(item.Price, 32)
  12266. //
  12267. // info := &models.HisOrderInfo{
  12268. // OrderNumber: order.Number,
  12269. // UploadDate: time.Now().Unix(),
  12270. // AdviceId: advice_id,
  12271. // DetItemFeeSumamt: detItemFeeSumamt,
  12272. // Cnt: cut,
  12273. // Pric: pric,
  12274. // PatientId: id,
  12275. // Status: 1,
  12276. // Mtime: time.Now().Unix(),
  12277. // Ctime: time.Now().Unix(),
  12278. // UserOrgId: adminUser.CurrentOrgId,
  12279. // HisPatientId: his.ID,
  12280. // OrderId: order.ID,
  12281. // ProjectId: project_id,
  12282. // Type: types,
  12283. // ItemId: item_id,
  12284. // }
  12285. // service.CreateOrderInfo(info)
  12286. // }
  12287. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  12288. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  12289. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  12290. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  12291. // if err == nil {
  12292. // c.ServeSuccessJSON(map[string]interface{}{
  12293. // "msg": "结算成功",
  12294. // })
  12295. // } else {
  12296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  12297. // return
  12298. // }
  12299. // }
  12300. //}
  12301. // 上传明细-预结算-
  12302. func (c *HisApiController) GetPreUploadInfo() {
  12303. id, _ := c.GetInt64("id")
  12304. record_time := c.GetString("record_time")
  12305. his_patient_id, _ := c.GetInt64("his_patient_id")
  12306. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  12307. admin_user_id, _ := c.GetInt64("admin_user_id")
  12308. diagnosis_id := c.GetString("diagnosis")
  12309. sick_type, _ := c.GetInt64("sick_type")
  12310. reg_type, _ := c.GetInt64("p_type")
  12311. begin_time := c.GetString("begin_time")
  12312. acct_used_flag := c.GetString("acct_used_flag")
  12313. id_str := c.GetString("ids")
  12314. ids_arr := strings.Split(id_str, ",")
  12315. timeLayout := "2006-01-02"
  12316. loc, _ := time.LoadLocation("Local")
  12317. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12318. if err != nil {
  12319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12320. return
  12321. }
  12322. recordDateTime := theTime.Unix()
  12323. adminUser := c.GetAdminUserInfo()
  12324. diagnosis_ids := strings.Split(diagnosis_id, ",")
  12325. var config []*models.HisXtDiagnoseConfig
  12326. for _, item := range diagnosis_ids {
  12327. id, _ := strconv.ParseInt(item, 10, 64)
  12328. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12329. config = append(config, &diagnosisConfig)
  12330. }
  12331. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  12332. sickConfig, _ := service.FindSickById(sick_type)
  12333. var prescriptions []*models.HisPrescription
  12334. var start_time int64
  12335. var end_time int64
  12336. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12337. fmt.Println(his_patient_id)
  12338. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12339. timestamp := time.Now().Unix()
  12340. tempTime := time.Unix(timestamp, 0)
  12341. timeFormat := tempTime.Format("20060102150405")
  12342. chrgBchno := rand.Intn(100000) + 10000
  12343. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  12344. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12345. var patientPrescription models.HisPrescriptionInfo
  12346. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12347. if patientPrescription.ID == 0 {
  12348. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  12349. }
  12350. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12351. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12352. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12353. strconv.FormatInt(his.PatientId, 10)
  12354. var res2 ResultSix
  12355. var resSix10265 ResultSix10265
  12356. //var time_stamp string
  12357. if miConfig.MdtrtareaAdmvs == "421300" {
  12358. data := make(map[string]interface{})
  12359. client := &http.Client{}
  12360. data["psn_no"] = his.PsnNo
  12361. data["mdtrt_id"] = his.Number
  12362. data["department"] = department.Name
  12363. data["org_name"] = miConfig.OrgName
  12364. data["med_type"] = strconv.FormatInt(reg_type, 10)
  12365. data["doctor_id"] = doctor_info.DoctorNumber
  12366. data["doctor_name"] = roles.UserName
  12367. data["fixmedins_code"] = miConfig.Code
  12368. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  12369. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  12370. data["secret_key"] = miConfig.SecretKey
  12371. data["sick_code"] = sickConfig.CountryCode
  12372. data["sick_name"] = sickConfig.ClassName
  12373. data["begin_time"] = begin_time
  12374. data["dept"] = strconv.FormatInt(department.ID, 10)
  12375. data["config"] = config
  12376. data["opter"] = roles.UserName
  12377. fmt.Println(data)
  12378. bytesData, _ := json.Marshal(data)
  12379. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  12380. resp, _ := client.Do(req)
  12381. defer resp.Body.Close()
  12382. body, ioErr := ioutil.ReadAll(resp.Body)
  12383. if ioErr != nil {
  12384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12386. return
  12387. }
  12388. var respJSON map[string]interface{}
  12389. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12392. return
  12393. }
  12394. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12395. userJSONBytes, _ := json.Marshal(respJSON)
  12396. fmt.Println("log")
  12397. fmt.Println(string(userJSONBytes))
  12398. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12399. utils.ErrorLog("解析失败:%v", err)
  12400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12401. return
  12402. }
  12403. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12404. data := make(map[string]interface{})
  12405. client := &http.Client{}
  12406. data["psn_no"] = his.PsnNo
  12407. data["mdtrt_id"] = his.Number
  12408. data["doctor"] = roles.UserName
  12409. data["department"] = department.Name
  12410. data["org_name"] = miConfig.OrgName
  12411. data["med_type"] = strconv.FormatInt(reg_type, 10)
  12412. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  12413. data["fixmedins_code"] = miConfig.Code
  12414. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  12415. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  12416. data["secret_key"] = miConfig.SecretKey
  12417. data["sick_code"] = sickConfig.CountryCode
  12418. data["sick_name"] = sickConfig.ClassName
  12419. data["begin_time"] = begin_time
  12420. data["dept"] = strconv.FormatInt(department.ID, 10)
  12421. data["config"] = config
  12422. data["url"] = miConfig.Url
  12423. data["ak"] = miConfig.AccessKey
  12424. data["cainfo"] = miConfig.Cainfo
  12425. bytesData, _ := json.Marshal(data)
  12426. var req *http.Request
  12427. if miConfig.MdtrtareaAdmvs == "320921" {
  12428. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  12429. } else {
  12430. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  12431. }
  12432. resp, _ := client.Do(req)
  12433. defer resp.Body.Close()
  12434. body, ioErr := ioutil.ReadAll(resp.Body)
  12435. if ioErr != nil {
  12436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12438. return
  12439. }
  12440. var respJSON map[string]interface{}
  12441. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12444. return
  12445. }
  12446. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  12447. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  12448. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  12449. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12450. userJSONBytes, _ := json.Marshal(respJSON)
  12451. fmt.Println("log")
  12452. fmt.Println(string(userJSONBytes))
  12453. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  12454. utils.ErrorLog("解析失败:%v", err)
  12455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12456. return
  12457. }
  12458. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12459. res2.Output = resSix10265.Output
  12460. res2.ErrMsg = resSix10265.ErrMsg
  12461. res2.Cainfo = resSix10265.Cainfo
  12462. res2.WarnMsg = resSix10265.WarnMsg
  12463. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12464. res2.Infcode = infocode
  12465. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12466. 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)
  12467. saveLog(result, requestLog, "2203", "上传就诊信息")
  12468. var respJSON2 map[string]interface{}
  12469. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  12470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12472. return
  12473. }
  12474. userJSONBytes2, _ := json.Marshal(respJSON2)
  12475. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12476. utils.ErrorLog("解析失败:%v", err)
  12477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12478. return
  12479. }
  12480. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12481. var result string
  12482. var requestLog string
  12483. 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, "")
  12484. saveLog(result, requestLog, "2203", "上传就诊信息")
  12485. var respJSON2 map[string]interface{}
  12486. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  12487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12489. return
  12490. }
  12491. userJSONBytes2, _ := json.Marshal(respJSON2)
  12492. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12493. utils.ErrorLog("解析失败:%v", err)
  12494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12495. return
  12496. }
  12497. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12498. var result string
  12499. var requestLog string
  12500. 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, "")
  12501. saveLog(result, requestLog, "2203", "上传就诊信息")
  12502. var respJSON2 map[string]interface{}
  12503. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  12504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12506. return
  12507. }
  12508. userJSONBytes2, _ := json.Marshal(respJSON2)
  12509. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12510. utils.ErrorLog("解析失败:%v", err)
  12511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12512. return
  12513. }
  12514. } else {
  12515. var result string
  12516. var requestLog string
  12517. if miConfig.MdtrtareaAdmvs == "440781" { //
  12518. 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)
  12519. } else {
  12520. if miConfig.Code == "H15049901371" {
  12521. //赤峰地区国家医保医疗类别
  12522. //职工透析:医疗类别选特殊情况门诊990502
  12523. //居民定额血透门慢: 医疗类别选门诊慢病140104
  12524. var med_type string
  12525. if his.Insutype == "390" {
  12526. if reg_type == 14 {
  12527. med_type = "9933"
  12528. } else if reg_type == 11 {
  12529. med_type = "11"
  12530. }
  12531. } else if his.Insutype == "310" {
  12532. if reg_type == 14 {
  12533. med_type = "990502"
  12534. } else if reg_type == 11 {
  12535. med_type = "11"
  12536. }
  12537. }
  12538. 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)
  12539. } else {
  12540. 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)
  12541. }
  12542. saveLog(result, requestLog, "2203", "上传就诊信息")
  12543. var respJSON2 map[string]interface{}
  12544. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  12545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12547. return
  12548. }
  12549. userJSONBytes2, _ := json.Marshal(respJSON2)
  12550. if miConfig.Code == "H15049901371" {
  12551. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  12552. utils.ErrorLog("解析失败:%v", err)
  12553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12554. return
  12555. }
  12556. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12557. res2.Output = resSix10265.Output
  12558. res2.ErrMsg = resSix10265.ErrMsg
  12559. res2.Cainfo = resSix10265.Cainfo
  12560. res2.WarnMsg = resSix10265.WarnMsg
  12561. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12562. res2.Infcode = infocode
  12563. } else {
  12564. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12565. utils.ErrorLog("解析失败:%v", err)
  12566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12567. return
  12568. }
  12569. }
  12570. }
  12571. }
  12572. if res2.Infcode != 0 {
  12573. adminUser := c.GetAdminUserInfo()
  12574. errlog := &models.HisOrderError{
  12575. UserOrgId: adminUser.CurrentOrgId,
  12576. Ctime: time.Now().Unix(),
  12577. Mtime: time.Now().Unix(),
  12578. ErrMsg: res2.ErrMsg,
  12579. Status: 1,
  12580. PatientId: id,
  12581. RecordTime: recordDateTime,
  12582. Stage: 3,
  12583. }
  12584. service.CreateErrMsgLog(errlog)
  12585. c.ServeSuccessJSON(map[string]interface{}{
  12586. "failed_code": -10,
  12587. "msg": res2.ErrMsg,
  12588. })
  12589. return
  12590. } else {
  12591. his.Diagnosis = diagnosis_id
  12592. his.SickType = sickConfig.ID
  12593. his.PType = fmt.Sprintf("%d", reg_type)
  12594. service.UpdateHisPatientThree(&his)
  12595. data := make(map[string]interface{})
  12596. if settle_accounts_type == 1 { //日结
  12597. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  12598. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  12599. } else {
  12600. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  12601. }
  12602. data["pre"] = prescriptions
  12603. } else { //月结
  12604. start_time_str := c.GetString("start_time")
  12605. end_time_str := c.GetString("end_time")
  12606. timeLayout := "2006-01-02"
  12607. loc, _ := time.LoadLocation("Local")
  12608. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  12609. if err != nil {
  12610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12611. return
  12612. }
  12613. recordStartTime := theStartTime.Unix()
  12614. start_time = recordStartTime
  12615. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  12616. if err != nil {
  12617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12618. return
  12619. }
  12620. recordEndTime := theEndTime.Unix()
  12621. end_time = recordEndTime
  12622. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  12623. data["pre"] = prescriptions
  12624. }
  12625. client := &http.Client{}
  12626. data["psn_no"] = his.PsnNo
  12627. data["mdtrt_id"] = his.Number
  12628. data["chrg_bchno"] = chrg_bchno
  12629. data["org_name"] = miConfig.OrgName
  12630. data["doctor"] = doctor_info.UserName
  12631. data["doctor_id"] = doctor_info.DoctorNumber
  12632. data["dept"] = department.Name
  12633. data["fixmedins_code"] = miConfig.Code
  12634. data["opter"] = roles.UserName
  12635. data["dept_code"] = department.Number
  12636. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  12637. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  12638. data["secret_key"] = miConfig.SecretKey
  12639. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  12640. data["url"] = miConfig.Url
  12641. data["ak"] = miConfig.AccessKey
  12642. data["new_doctor_name"] = patientPrescription.Doctor
  12643. data["diag_code"] = sickConfig.CountryCode
  12644. data["cainfo"] = miConfig.Cainfo
  12645. data["opter"] = roles.UserName
  12646. var ids []int64
  12647. for _, item := range prescriptions {
  12648. ids = append(ids, item.ID)
  12649. }
  12650. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12651. if config.IsOpen == 1 { //对接了医保,走医保流程
  12652. var res ResultFour
  12653. var resFour10265 ResultFour10265
  12654. if miConfig.MdtrtareaAdmvs == "421300" {
  12655. bytesData, _ := json.Marshal(data)
  12656. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  12657. resp, _ := client.Do(req)
  12658. defer resp.Body.Close()
  12659. body, ioErr := ioutil.ReadAll(resp.Body)
  12660. if ioErr != nil {
  12661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12663. return
  12664. }
  12665. var respJSON map[string]interface{}
  12666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12669. return
  12670. }
  12671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12672. userJSONBytes, _ := json.Marshal(respJSON)
  12673. fmt.Println("log")
  12674. fmt.Println(string(userJSONBytes))
  12675. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12676. utils.ErrorLog("解析失败:%v", err)
  12677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12678. return
  12679. }
  12680. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12681. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  12682. if result3101.Infcode == "0" {
  12683. if len(result3101.Output.Result) > 0 {
  12684. var errMsgs []string
  12685. for _, item := range result3101.Output.Result {
  12686. errMsgs = append(errMsgs, item.VolaCont)
  12687. }
  12688. c.ServeSuccessJSON(map[string]interface{}{
  12689. "failed_code": -10,
  12690. "msg": errMsgs,
  12691. })
  12692. return
  12693. } else {
  12694. if miConfig.MdtrtareaAdmvs == "320921" {
  12695. data["doctor_id"] = "D320923012139"
  12696. } else {
  12697. data["doctor_id"] = "D371621008686"
  12698. }
  12699. bytesData, _ := json.Marshal(data)
  12700. var req *http.Request
  12701. if miConfig.MdtrtareaAdmvs == "320921" {
  12702. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12703. } else {
  12704. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12705. }
  12706. resp, _ := client.Do(req)
  12707. defer resp.Body.Close()
  12708. body, ioErr := ioutil.ReadAll(resp.Body)
  12709. if ioErr != nil {
  12710. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12712. return
  12713. }
  12714. var respJSON map[string]interface{}
  12715. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12718. return
  12719. }
  12720. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12721. userJSONBytes, _ := json.Marshal(respJSON)
  12722. fmt.Println("log")
  12723. fmt.Println(string(userJSONBytes))
  12724. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  12725. utils.ErrorLog("解析失败:%v", err)
  12726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12727. return
  12728. }
  12729. res.InfRefmsgid = resFour10265.InfRefmsgid
  12730. res.Output = resFour10265.Output
  12731. res.ErrMsg = resFour10265.ErrMsg
  12732. res.Cainfo = resFour10265.Cainfo
  12733. res.WarnMsg = resFour10265.WarnMsg
  12734. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  12735. res.Infcode = infocode
  12736. }
  12737. }
  12738. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12739. 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)
  12740. var dat map[string]interface{}
  12741. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12742. fmt.Println(dat)
  12743. } else {
  12744. fmt.Println(err)
  12745. }
  12746. saveLog(result, request_log, "2204", "上传费用明细")
  12747. userJSONBytes, _ := json.Marshal(dat)
  12748. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12749. utils.ErrorLog("解析失败:%v", err)
  12750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12751. return
  12752. }
  12753. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12754. 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, "", "")
  12755. var dat map[string]interface{}
  12756. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12757. fmt.Println(dat)
  12758. } else {
  12759. fmt.Println(err)
  12760. }
  12761. saveLog(result, request_log, "2204", "上传费用明细")
  12762. userJSONBytes, _ := json.Marshal(dat)
  12763. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12764. utils.ErrorLog("解析失败:%v", err)
  12765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12766. return
  12767. }
  12768. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12769. 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, "", "")
  12770. var dat map[string]interface{}
  12771. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12772. fmt.Println(dat)
  12773. } else {
  12774. fmt.Println(err)
  12775. }
  12776. saveLog(result, request_log, "2204", "上传费用明细")
  12777. userJSONBytes, _ := json.Marshal(dat)
  12778. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12779. utils.ErrorLog("解析失败:%v", err)
  12780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12781. return
  12782. }
  12783. } else {
  12784. if miConfig.Code == "H15049901371" {
  12785. 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)
  12786. var dat map[string]interface{}
  12787. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12788. fmt.Println(dat)
  12789. } else {
  12790. fmt.Println(err)
  12791. }
  12792. saveLog(result, request_log, "2204", "上传费用明细")
  12793. userJSONBytes, _ := json.Marshal(dat)
  12794. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  12795. utils.ErrorLog("解析失败:%v", err)
  12796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12797. return
  12798. }
  12799. res.InfRefmsgid = resFour10265.InfRefmsgid
  12800. res.Output = resFour10265.Output
  12801. res.ErrMsg = resFour10265.ErrMsg
  12802. res.Cainfo = resFour10265.Cainfo
  12803. res.WarnMsg = resFour10265.WarnMsg
  12804. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  12805. res.Infcode = infocode
  12806. } else {
  12807. 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)
  12808. var dat map[string]interface{}
  12809. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12810. fmt.Println(dat)
  12811. } else {
  12812. fmt.Println(err)
  12813. }
  12814. saveLog(result, request_log, "2204", "上传费用明细")
  12815. userJSONBytes, _ := json.Marshal(dat)
  12816. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12817. utils.ErrorLog("解析失败:%v", err)
  12818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12819. return
  12820. }
  12821. }
  12822. }
  12823. var total_two float64
  12824. if res.Infcode == 0 {
  12825. order := &models.HisOrder{
  12826. UserOrgId: adminUser.CurrentOrgId,
  12827. HisPatientId: his.ID,
  12828. PatientId: his.PatientId,
  12829. SettleAccountsDate: recordDateTime,
  12830. Ctime: time.Now().Unix(),
  12831. Mtime: time.Now().Unix(),
  12832. MdtrtId: his.Number,
  12833. PsnNo: his.PsnNo,
  12834. MedType: strconv.FormatInt(reg_type, 10),
  12835. Status: 1,
  12836. Number: chrg_bchno,
  12837. Infcode: res.Infcode,
  12838. WarnMsg: res.WarnMsg,
  12839. Cainfo: res.Cainfo,
  12840. ErrMsg: res.ErrMsg,
  12841. RespondTime: res.RefmsgTime,
  12842. InfRefmsgid: res.InfRefmsgid,
  12843. OrderStatus: 1,
  12844. IsMedicineInsurance: 1,
  12845. SettleType: settle_accounts_type,
  12846. SettleStartTime: start_time,
  12847. SettleEndTime: end_time,
  12848. Creator: roles.AdminUserId,
  12849. Modify: roles.AdminUserId,
  12850. PType: 2,
  12851. Diagnosis: diagnosis_id,
  12852. }
  12853. err = service.CreateOrder(order)
  12854. if err != nil {
  12855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  12856. return
  12857. }
  12858. for _, item := range res.Output.Result {
  12859. temp := strings.Split(item.FeedetlSn, "-")
  12860. var advice_id int64 = 0
  12861. var project_id int64 = 0
  12862. var types int64 = 0
  12863. id, _ := strconv.ParseInt(temp[2], 10, 64)
  12864. types, _ = strconv.ParseInt(temp[1], 10, 64)
  12865. if temp[1] == "1" {
  12866. advice_id = id
  12867. project_id = 0
  12868. } else if temp[1] == "2" {
  12869. advice_id = 0
  12870. project_id = id
  12871. }
  12872. total_two = total_two + item.DetItemFeeSumamt
  12873. info := &models.HisOrderInfo{
  12874. OrderNumber: order.Number,
  12875. FeedetlSn: item.FeedetlSn,
  12876. UploadDate: time.Now().Unix(),
  12877. AdviceId: advice_id,
  12878. DetItemFeeSumamt: item.DetItemFeeSumamt,
  12879. Cnt: item.Cnt,
  12880. Pric: float64(item.Pric),
  12881. PatientId: his.PatientId,
  12882. PricUplmtAmt: item.PricUplmtAmt,
  12883. SelfpayProp: item.SelfpayProp,
  12884. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  12885. OverlmtAmt: item.OverlmtAmt,
  12886. PreselfpayAmt: item.PreselfpayAmt,
  12887. BasMednFlag: item.BasMednFlag,
  12888. MedChrgitmType: item.MedChrgitmType,
  12889. HiNegoDrugFlag: item.HiNegoDrugFlag,
  12890. Status: 1,
  12891. Memo: item.Memo,
  12892. Mtime: time.Now().Unix(),
  12893. InscpScpAmt: item.InscpScpAmt,
  12894. DrtReimFlag: item.DrtReimFlag,
  12895. Ctime: time.Now().Unix(),
  12896. ListSpItemFlag: item.ListSpItemFlag,
  12897. ChldMedcFlag: item.ChldMedcFlag,
  12898. LmtUsedFlag: item.LmtUsedFlag,
  12899. ChrgitmLv: item.ChrgitmLv,
  12900. UserOrgId: adminUser.CurrentOrgId,
  12901. HisPatientId: his.ID,
  12902. OrderId: order.ID,
  12903. ProjectId: project_id,
  12904. Type: types,
  12905. }
  12906. service.CreateOrderInfo(info)
  12907. }
  12908. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  12909. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  12910. var total float64
  12911. for _, item := range prescriptions {
  12912. if item.Type == 1 { //药品
  12913. for _, subItem := range item.HisDoctorAdviceInfo {
  12914. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  12915. total_one := price * subItem.PrescribingNumber
  12916. fmt.Println("subItem")
  12917. fmt.Println(subItem.Price)
  12918. fmt.Println("price")
  12919. fmt.Println(price)
  12920. fmt.Println("total_one")
  12921. fmt.Println(total_one)
  12922. total = total + total_one
  12923. fmt.Println(total)
  12924. }
  12925. }
  12926. if item.Type == 2 { //项目
  12927. for _, subItem := range item.HisPrescriptionProject {
  12928. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12929. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  12930. total_one := price * cnt
  12931. total = total + total_one
  12932. }
  12933. }
  12934. }
  12935. allTotal := fmt.Sprintf("%2f", total)
  12936. if res.Infcode == 0 {
  12937. var rf []*ResultFive
  12938. json.Unmarshal([]byte(his.Iinfo), &rf)
  12939. chrg_bchno := chrg_bchno
  12940. cert_no := his.Certno
  12941. var insutypes []string
  12942. var insutype string
  12943. var is390 int = 0
  12944. var is310 int = 0
  12945. for _, item := range rf {
  12946. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12947. insutypes = append(insutypes, item.Insutype)
  12948. }
  12949. }
  12950. if len(insutypes) == 1 {
  12951. insutype = insutypes[0]
  12952. } else {
  12953. for _, i := range insutypes {
  12954. if i == "390" {
  12955. is390 = 1
  12956. }
  12957. if i == "310" {
  12958. is310 = 1
  12959. }
  12960. }
  12961. }
  12962. if is390 == 1 {
  12963. insutype = "390"
  12964. }
  12965. if is310 == 1 {
  12966. insutype = "310"
  12967. }
  12968. if len(insutypes) == 0 {
  12969. insutype = "390"
  12970. }
  12971. if len(insutypes) == 2 {
  12972. insutype = strconv.FormatInt(his.SocialType, 10)
  12973. }
  12974. //insutype = "390"
  12975. if his.IdCardType == 1 {
  12976. cert_no = his.MedicalInsuranceNumber
  12977. } else {
  12978. cert_no = his.Certno
  12979. }
  12980. var res ResultSeven
  12981. var resSeven10265 ResultSeven10265
  12982. if miConfig.MdtrtareaAdmvs == "421300" {
  12983. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12984. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12985. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12986. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12987. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12988. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12989. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  12990. resp, requestErr := http.Get(api)
  12991. if requestErr != nil {
  12992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12993. return
  12994. }
  12995. body, ioErr := ioutil.ReadAll(resp.Body)
  12996. if ioErr != nil {
  12997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12999. return
  13000. }
  13001. var respJSON map[string]interface{}
  13002. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13005. return
  13006. }
  13007. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13008. result, _ := json.Marshal(respJSON)
  13009. fmt.Println("log")
  13010. fmt.Println(string(result))
  13011. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13012. utils.ErrorLog("解析失败:%v", err)
  13013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13014. return
  13015. }
  13016. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13017. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  13018. if result3101.Infcode == "0" {
  13019. if len(result3101.Output.Result) > 0 {
  13020. var errMsgs []string
  13021. for _, item := range result3101.Output.Result {
  13022. errMsgs = append(errMsgs, item.VolaCont)
  13023. }
  13024. c.ServeSuccessJSON(map[string]interface{}{
  13025. "failed_code": -10,
  13026. "msg": errMsgs,
  13027. })
  13028. return
  13029. } else {
  13030. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  13031. if his.IdCardType != 4 {
  13032. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  13033. bas := strings.Split(psn_info.CardInfo, "|")
  13034. if his.IdCardType == 1 {
  13035. cert_no = bas[2]
  13036. } else {
  13037. cert_no = bas[1]
  13038. }
  13039. } else {
  13040. cert_no = his.Certno
  13041. }
  13042. //江苏地区国家医保医疗类别
  13043. //职工透析:医疗类别选特殊情况门诊9933
  13044. //居民血透门慢: 医疗类别选门诊慢病1402
  13045. //var med_type string
  13046. //if his.Insutype == "310" {
  13047. // if reg_type == 14 {
  13048. // med_type = "9933"
  13049. // } else if reg_type == 11 {
  13050. // med_type = "11"
  13051. //
  13052. // }
  13053. //} else if his.Insutype == "390" {
  13054. // if reg_type == 14 {
  13055. // med_type = "1402"
  13056. // } else if reg_type == 11 {
  13057. // med_type = "11"
  13058. // }
  13059. //}
  13060. var api string
  13061. if miConfig.MdtrtareaAdmvs == "320921" {
  13062. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  13063. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  13064. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13065. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13066. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  13067. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  13068. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  13069. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13070. } else {
  13071. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13072. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  13073. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  13074. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13075. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13076. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  13077. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  13078. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  13079. }
  13080. resp, requestErr := http.Get(api)
  13081. if requestErr != nil {
  13082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13083. return
  13084. }
  13085. body, ioErr := ioutil.ReadAll(resp.Body)
  13086. if ioErr != nil {
  13087. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13089. return
  13090. }
  13091. var respJSON map[string]interface{}
  13092. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13095. return
  13096. }
  13097. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13098. result, _ := json.Marshal(respJSON)
  13099. fmt.Println("log")
  13100. fmt.Println(string(result))
  13101. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  13102. utils.ErrorLog("解析失败:%v", err)
  13103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13104. return
  13105. }
  13106. res.InfRefmsgid = resSeven10265.InfRefmsgid
  13107. res.Output = resSeven10265.Output
  13108. res.ErrMsg = resSeven10265.ErrMsg
  13109. res.Cainfo = resSeven10265.Cainfo
  13110. res.WarnMsg = resSeven10265.WarnMsg
  13111. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  13112. res.Infcode = infocode
  13113. }
  13114. }
  13115. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13116. acct_used_flag := "1"
  13117. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  13118. var result string
  13119. var request_log string
  13120. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  13121. result, request_log, _ = service.FJyb2206ForToken(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, acct_used_flag)
  13122. } else {
  13123. result, request_log, _ = service.FJyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, acct_used_flag)
  13124. }
  13125. var dat map[string]interface{}
  13126. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13127. fmt.Println(dat)
  13128. } else {
  13129. fmt.Println(err)
  13130. }
  13131. saveLog(result, request_log, "2206", "预结算")
  13132. userJSONBytes, _ := json.Marshal(dat)
  13133. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13134. utils.ErrorLog("解析失败:%v", err)
  13135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13136. return
  13137. }
  13138. } else if miConfig.MdtrtareaAdmvs == "360399" {
  13139. var result string
  13140. var request_log string
  13141. if his.IdCardType == 2 {
  13142. 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, "")
  13143. } else if his.IdCardType == 1 {
  13144. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  13145. bas := strings.Split(psn_info.CardInfo, "|")
  13146. basNumber := bas[2]
  13147. card_sn := bas[3]
  13148. 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)
  13149. } else {
  13150. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  13151. 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, "")
  13152. }
  13153. var dat map[string]interface{}
  13154. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13155. fmt.Println(dat)
  13156. } else {
  13157. fmt.Println(err)
  13158. }
  13159. saveLog(result, request_log, "2206", "预结算")
  13160. userJSONBytes, _ := json.Marshal(dat)
  13161. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13162. utils.ErrorLog("解析失败:%v", err)
  13163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13164. return
  13165. }
  13166. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13167. var result string
  13168. var request_log string
  13169. if his.IdCardType == 2 {
  13170. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, his.IdCardNo, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, his.IdCardNo, "", "1")
  13171. } else if his.IdCardType == 1 {
  13172. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  13173. bas := strings.Split(psn_info.CardInfo, "|")
  13174. basNumber := bas[2]
  13175. card_sn := bas[3]
  13176. result, request_log = service.Hnyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn, "1")
  13177. } else {
  13178. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  13179. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "1")
  13180. }
  13181. var dat map[string]interface{}
  13182. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13183. fmt.Println(dat)
  13184. } else {
  13185. fmt.Println(err)
  13186. }
  13187. saveLog(result, request_log, "2206", "预结算")
  13188. userJSONBytes, _ := json.Marshal(dat)
  13189. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13190. utils.ErrorLog("解析失败:%v", err)
  13191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13192. return
  13193. }
  13194. } else {
  13195. var result string
  13196. var request_log string
  13197. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  13198. allTotal = fmt.Sprintf("%2f", total_two)
  13199. if his.IdCardType == 4 {
  13200. 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)
  13201. } else {
  13202. 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)
  13203. }
  13204. var dat map[string]interface{}
  13205. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13206. fmt.Println(dat)
  13207. } else {
  13208. fmt.Println(err)
  13209. }
  13210. saveLog(result, request_log, "2206", "预结算")
  13211. //userJSONBytes, _ := json.Marshal(dat)
  13212. //
  13213. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13214. // utils.ErrorLog("解析失败:%v", err)
  13215. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13216. // return
  13217. //}
  13218. userJSONBytes, _ := json.Marshal(dat)
  13219. if miConfig.Code == "H15049901371" {
  13220. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  13221. utils.ErrorLog("解析失败:%v", err)
  13222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13223. return
  13224. }
  13225. res.InfRefmsgid = resSeven10265.InfRefmsgid
  13226. res.Output = resSeven10265.Output
  13227. res.ErrMsg = resSeven10265.ErrMsg
  13228. res.Cainfo = resSeven10265.Cainfo
  13229. res.WarnMsg = resSeven10265.WarnMsg
  13230. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  13231. res.Infcode = infocode
  13232. } else {
  13233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13234. utils.ErrorLog("解析失败:%v", err)
  13235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13236. return
  13237. }
  13238. }
  13239. }
  13240. if res.Infcode != 0 {
  13241. errlog := &models.HisOrderError{
  13242. UserOrgId: adminUser.CurrentOrgId,
  13243. Ctime: time.Now().Unix(),
  13244. Mtime: time.Now().Unix(),
  13245. Number: chrg_bchno,
  13246. ErrMsg: res.ErrMsg,
  13247. Status: 1,
  13248. PatientId: id,
  13249. RecordTime: recordDateTime,
  13250. Stage: 20,
  13251. }
  13252. service.CreateErrMsgLog(errlog)
  13253. c.ServeSuccessJSON(map[string]interface{}{
  13254. "failed_code": -10,
  13255. "msg": res.ErrMsg,
  13256. })
  13257. return
  13258. } else {
  13259. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  13260. order.OrderStatus = 1
  13261. order.IsPre = 1
  13262. order.Status = 1
  13263. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  13264. order.SetlId = res.Output.Setlinfo.SetlID
  13265. order.PsnNo = res.Output.Setlinfo.PsnNo
  13266. order.PsnName = res.Output.Setlinfo.PsnName
  13267. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  13268. order.Certno = res.Output.Setlinfo.Certno
  13269. order.Gend = res.Output.Setlinfo.Gend
  13270. order.Naty = res.Output.Setlinfo.Naty
  13271. order.Age = res.Output.Setlinfo.Age
  13272. order.Insutype = res.Output.Setlinfo.Insutype
  13273. order.PsnType = res.Output.Setlinfo.PsnType
  13274. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  13275. order.SetlTime = res.Output.Setlinfo.SetlTime
  13276. order.AcctUsedFlag = acct_used_flag
  13277. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  13278. if res.Output.Setlinfo.MedType == "140101" {
  13279. order.MedType = "14"
  13280. } else {
  13281. order.MedType = res.Output.Setlinfo.MedType
  13282. }
  13283. if reg_type == 1112 {
  13284. order.MedType = "1112"
  13285. }
  13286. if reg_type == 1111 {
  13287. order.MedType = "1111"
  13288. }
  13289. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  13290. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  13291. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  13292. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  13293. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  13294. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  13295. order.HifpPay = res.Output.Setlinfo.HifpPay
  13296. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  13297. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  13298. order.HifesPay = res.Output.Setlinfo.HifesPay
  13299. order.HifobPay = res.Output.Setlinfo.HifobPay
  13300. order.MafPay = res.Output.Setlinfo.MafPay
  13301. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  13302. order.OthPay = res.Output.Setlinfo.OthPay
  13303. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  13304. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  13305. order.AcctPay = res.Output.Setlinfo.AcctPay
  13306. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  13307. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  13308. order.Balc = res.Output.Setlinfo.Balc
  13309. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  13310. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  13311. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  13312. order.ClrWay = res.Output.Setlinfo.ClrWay
  13313. order.Creator = order.Creator
  13314. order.Modify = roles.AdminUserId
  13315. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  13316. detailStr := string(setlDetail)
  13317. order.SetlDetail = detailStr
  13318. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  13319. err = service.UpDateOrder(order)
  13320. if err == nil {
  13321. c.ServeSuccessJSON(map[string]interface{}{
  13322. "msg": "预结算成功",
  13323. })
  13324. } else {
  13325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  13326. return
  13327. }
  13328. }
  13329. } else {
  13330. adminUser := c.GetAdminUserInfo()
  13331. errlog := &models.HisOrderError{
  13332. UserOrgId: adminUser.CurrentOrgId,
  13333. Ctime: time.Now().Unix(),
  13334. Mtime: time.Now().Unix(),
  13335. ErrMsg: res.ErrMsg,
  13336. Status: 1,
  13337. PatientId: id,
  13338. RecordTime: recordDateTime,
  13339. Stage: 4,
  13340. }
  13341. service.CreateErrMsgLog(errlog)
  13342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  13343. return
  13344. }
  13345. } else {
  13346. adminUser := c.GetAdminUserInfo()
  13347. errlog := &models.HisOrderError{
  13348. UserOrgId: adminUser.CurrentOrgId,
  13349. Ctime: time.Now().Unix(),
  13350. Mtime: time.Now().Unix(),
  13351. ErrMsg: res.ErrMsg,
  13352. Status: 1,
  13353. PatientId: id,
  13354. RecordTime: recordDateTime,
  13355. Stage: 4,
  13356. }
  13357. service.CreateErrMsgLog(errlog)
  13358. c.ServeSuccessJSON(map[string]interface{}{
  13359. "failed_code": -10,
  13360. "msg": res.ErrMsg,
  13361. })
  13362. return
  13363. }
  13364. }
  13365. }
  13366. }
  13367. // 退款
  13368. func (c *HisApiController) Refund() {
  13369. order_id, _ := c.GetInt64("order_id")
  13370. admin_user_id, _ := c.GetInt64("admin_user_id")
  13371. adminUser := c.GetAdminUserInfo()
  13372. var order models.HisOrder
  13373. order, _ = service.GetHisOrderByID(order_id)
  13374. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13375. if order.ID == 0 {
  13376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13377. return
  13378. }
  13379. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13380. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13381. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13382. if config.IsOpen == 1 { //对接了医保,走医保流程
  13383. var res ResultSixteen
  13384. var resSixteen10265 ResultSixteen10265
  13385. var src_resquest string
  13386. var result string
  13387. if miConfig.MdtrtareaAdmvs == "421300" {
  13388. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  13389. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13390. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13391. resp3, requestErr3 := http.Get(api3)
  13392. if requestErr3 != nil {
  13393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13394. return
  13395. }
  13396. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13397. if ioErr3 != nil {
  13398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13400. return
  13401. }
  13402. var respJSON3 map[string]interface{}
  13403. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13406. return
  13407. }
  13408. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13409. userJSONBytes3, _ := json.Marshal(respJSON3)
  13410. fmt.Println("log")
  13411. fmt.Println(string(userJSONBytes3))
  13412. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  13413. utils.ErrorLog("解析失败:%v", err)
  13414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13415. return
  13416. }
  13417. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13418. var api3 string
  13419. if miConfig.MdtrtareaAdmvs == "320921" {
  13420. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  13421. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13422. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13423. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13424. } else {
  13425. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13426. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  13427. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13428. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13429. }
  13430. resp3, requestErr3 := http.Get(api3)
  13431. if requestErr3 != nil {
  13432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13433. return
  13434. }
  13435. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13436. if ioErr3 != nil {
  13437. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13439. return
  13440. }
  13441. var respJSON3 map[string]interface{}
  13442. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13445. return
  13446. }
  13447. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13448. userJSONBytes3, _ := json.Marshal(respJSON3)
  13449. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  13450. utils.ErrorLog("解析失败:%v", err)
  13451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13452. return
  13453. }
  13454. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  13455. res.Output = resSixteen10265.Output
  13456. res.ErrMsg = resSixteen10265.ErrMsg
  13457. res.Cainfo = resSixteen10265.Cainfo
  13458. res.WarnMsg = resSixteen10265.WarnMsg
  13459. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  13460. res.Infcode = infocode
  13461. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13462. 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)
  13463. var dat map[string]interface{}
  13464. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13465. fmt.Println(dat)
  13466. } else {
  13467. fmt.Println(err)
  13468. }
  13469. saveLog(result, src_resquest, "2208", "退费")
  13470. userJSONBytes, _ := json.Marshal(dat)
  13471. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13472. utils.ErrorLog("解析失败:%v", err)
  13473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13474. return
  13475. }
  13476. } else if miConfig.MdtrtareaAdmvs == "360399" {
  13477. 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, "")
  13478. var dat map[string]interface{}
  13479. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13480. fmt.Println(dat)
  13481. } else {
  13482. fmt.Println(err)
  13483. }
  13484. saveLog(result, src_resquest, "2208", "退费")
  13485. userJSONBytes, _ := json.Marshal(dat)
  13486. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13487. utils.ErrorLog("解析失败:%v", err)
  13488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13489. return
  13490. }
  13491. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13492. 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, "")
  13493. var dat map[string]interface{}
  13494. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13495. fmt.Println(dat)
  13496. } else {
  13497. fmt.Println(err)
  13498. }
  13499. saveLog(result, src_resquest, "2208", "退费")
  13500. userJSONBytes, _ := json.Marshal(dat)
  13501. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13502. utils.ErrorLog("解析失败:%v", err)
  13503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13504. return
  13505. }
  13506. } else {
  13507. if miConfig.Code == "H15049901371" {
  13508. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  13509. var dat map[string]interface{}
  13510. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13511. fmt.Println(dat)
  13512. } else {
  13513. fmt.Println(err)
  13514. }
  13515. saveLog(result, src_resquest, "2208", "退费")
  13516. userJSONBytes, _ := json.Marshal(dat)
  13517. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  13518. utils.ErrorLog("解析失败:%v", err)
  13519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13520. return
  13521. }
  13522. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  13523. res.Output = resSixteen10265.Output
  13524. res.ErrMsg = resSixteen10265.ErrMsg
  13525. res.Cainfo = resSixteen10265.Cainfo
  13526. res.WarnMsg = resSixteen10265.WarnMsg
  13527. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  13528. res.Infcode = infocode
  13529. } else {
  13530. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  13531. var dat map[string]interface{}
  13532. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13533. fmt.Println(dat)
  13534. } else {
  13535. fmt.Println(err)
  13536. }
  13537. saveLog(result, src_resquest, "2208", "退费")
  13538. userJSONBytes, _ := json.Marshal(dat)
  13539. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13540. utils.ErrorLog("解析失败:%v", err)
  13541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13542. return
  13543. }
  13544. }
  13545. }
  13546. if res.Infcode == 0 {
  13547. var res2 ResultSix
  13548. var resSix10265 ResultSix10265
  13549. if miConfig.MdtrtareaAdmvs == "421300" {
  13550. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  13551. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13552. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13553. resp3, requestErr3 := http.Get(api3)
  13554. if requestErr3 != nil {
  13555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13556. return
  13557. }
  13558. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13559. if ioErr3 != nil {
  13560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13562. return
  13563. }
  13564. var respJSON3 map[string]interface{}
  13565. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13568. return
  13569. }
  13570. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13571. userJSONBytes3, _ := json.Marshal(respJSON3)
  13572. fmt.Println("log")
  13573. fmt.Println(string(userJSONBytes3))
  13574. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  13575. utils.ErrorLog("解析失败:%v", err)
  13576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13577. return
  13578. }
  13579. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13580. var api3 string
  13581. if miConfig.MdtrtareaAdmvs == "320921" {
  13582. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  13583. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13584. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13585. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13586. } else {
  13587. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13588. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  13589. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13590. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13591. }
  13592. resp3, requestErr3 := http.Get(api3)
  13593. if requestErr3 != nil {
  13594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13595. return
  13596. }
  13597. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13598. if ioErr3 != nil {
  13599. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13601. return
  13602. }
  13603. var respJSON3 map[string]interface{}
  13604. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13605. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13607. return
  13608. }
  13609. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13610. userJSONBytes3, _ := json.Marshal(respJSON3)
  13611. fmt.Println("log")
  13612. fmt.Println(string(userJSONBytes3))
  13613. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  13614. utils.ErrorLog("解析失败:%v", err)
  13615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13616. return
  13617. }
  13618. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13619. res2.Output = resSix10265.Output
  13620. res2.ErrMsg = resSix10265.ErrMsg
  13621. res2.Cainfo = resSix10265.Cainfo
  13622. res2.WarnMsg = resSix10265.WarnMsg
  13623. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13624. res2.Infcode = infocode
  13625. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13626. 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)
  13627. var dat map[string]interface{}
  13628. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  13629. fmt.Println(dat)
  13630. } else {
  13631. fmt.Println(err)
  13632. }
  13633. saveLog(result2, src_request, "2205", "撤销明细")
  13634. userJSONBytes, _ := json.Marshal(dat)
  13635. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13636. utils.ErrorLog("解析失败:%v", err)
  13637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13638. return
  13639. }
  13640. } else if miConfig.MdtrtareaAdmvs == "360399" {
  13641. 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, "")
  13642. var dat map[string]interface{}
  13643. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  13644. fmt.Println(dat)
  13645. } else {
  13646. fmt.Println(err)
  13647. }
  13648. saveLog(result2, src_request, "2205", "撤销明细")
  13649. userJSONBytes, _ := json.Marshal(dat)
  13650. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13651. utils.ErrorLog("解析失败:%v", err)
  13652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13653. return
  13654. }
  13655. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13656. 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, "")
  13657. var dat map[string]interface{}
  13658. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  13659. fmt.Println(dat)
  13660. } else {
  13661. fmt.Println(err)
  13662. }
  13663. saveLog(result2, src_request, "2205", "撤销明细")
  13664. userJSONBytes, _ := json.Marshal(dat)
  13665. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13666. utils.ErrorLog("解析失败:%v", err)
  13667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13668. return
  13669. }
  13670. } else {
  13671. if miConfig.Code == "H15049901371" {
  13672. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  13673. var dat map[string]interface{}
  13674. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  13675. fmt.Println(dat)
  13676. } else {
  13677. fmt.Println(err)
  13678. }
  13679. saveLog(result2, src_request, "2205", "撤销明细")
  13680. userJSONBytes, _ := json.Marshal(dat)
  13681. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  13682. utils.ErrorLog("解析失败:%v", err)
  13683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13684. return
  13685. }
  13686. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13687. res2.Output = resSix10265.Output
  13688. res2.ErrMsg = resSix10265.ErrMsg
  13689. res2.Cainfo = resSix10265.Cainfo
  13690. res2.WarnMsg = resSix10265.WarnMsg
  13691. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13692. res2.Infcode = infocode
  13693. } else {
  13694. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  13695. var dat map[string]interface{}
  13696. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  13697. fmt.Println(dat)
  13698. } else {
  13699. fmt.Println(err)
  13700. }
  13701. saveLog(result2, src_request, "2205", "撤销明细")
  13702. userJSONBytes, _ := json.Marshal(dat)
  13703. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13704. utils.ErrorLog("解析失败:%v", err)
  13705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13706. return
  13707. }
  13708. }
  13709. }
  13710. if res2.Infcode == 0 {
  13711. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  13712. if err == nil {
  13713. //当押金不为零时产生退费记录
  13714. if order.Decimal != 0 {
  13715. tmp := strconv.FormatInt(order.ID, 10)
  13716. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  13717. if err != nil {
  13718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13719. return
  13720. }
  13721. }
  13722. c.ServeSuccessJSON(map[string]interface{}{
  13723. "msg": "退费成功",
  13724. })
  13725. } else {
  13726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13727. return
  13728. }
  13729. } else {
  13730. c.ServeSuccessJSON(map[string]interface{}{
  13731. "code": -10,
  13732. "msg": res2.ErrMsg,
  13733. })
  13734. }
  13735. } else {
  13736. c.ServeSuccessJSON(map[string]interface{}{
  13737. "code": -10,
  13738. "msg": res.ErrMsg,
  13739. })
  13740. }
  13741. }
  13742. }
  13743. func (c *HisApiController) RefundNumber() {
  13744. record_time := c.GetString("record_time")
  13745. //patient_id, _ := c.GetInt64("patient_id")
  13746. admin_user_id, _ := c.GetInt64("admin_user_id")
  13747. his_patient_id, _ := c.GetInt64("id")
  13748. timeLayout := "2006-01-02"
  13749. loc, _ := time.LoadLocation("Local")
  13750. adminUser := c.GetAdminUserInfo()
  13751. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13752. fmt.Println(err)
  13753. if err != nil {
  13754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13755. return
  13756. }
  13757. recordDateTime := theTime.Unix()
  13758. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  13759. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  13760. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  13761. //order, _ := service.GetHisOrderByID(order_id)
  13762. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13763. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13764. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13765. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  13766. if count > 0 {
  13767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  13768. return
  13769. }
  13770. if config.IsOpen == 1 { //对接了医保,走医保流程
  13771. var res2 ResultSix
  13772. var resSix10265 ResultSix10265
  13773. if miConfig.MdtrtareaAdmvs == "421300" {
  13774. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  13775. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13776. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13777. resp3, requestErr3 := http.Get(api3)
  13778. if requestErr3 != nil {
  13779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13780. return
  13781. }
  13782. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13783. if ioErr3 != nil {
  13784. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13786. return
  13787. }
  13788. var respJSON3 map[string]interface{}
  13789. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13792. return
  13793. }
  13794. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13795. userJSONBytes3, _ := json.Marshal(respJSON3)
  13796. fmt.Println("log")
  13797. fmt.Println(string(userJSONBytes3))
  13798. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  13799. utils.ErrorLog("解析失败:%v", err)
  13800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13801. return
  13802. }
  13803. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13804. var api3 string
  13805. if miConfig.MdtrtareaAdmvs == "320921" {
  13806. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  13807. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13808. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13809. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13810. } else {
  13811. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13812. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  13813. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13814. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13815. }
  13816. resp3, requestErr3 := http.Get(api3)
  13817. if requestErr3 != nil {
  13818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13819. return
  13820. }
  13821. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13822. if ioErr3 != nil {
  13823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13825. return
  13826. }
  13827. var respJSON3 map[string]interface{}
  13828. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13831. return
  13832. }
  13833. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13834. userJSONBytes3, _ := json.Marshal(respJSON3)
  13835. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  13836. utils.ErrorLog("解析失败:%v", err)
  13837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13838. return
  13839. }
  13840. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13841. res2.Output = resSix10265.Output
  13842. res2.ErrMsg = resSix10265.ErrMsg
  13843. res2.Cainfo = resSix10265.Cainfo
  13844. res2.WarnMsg = resSix10265.WarnMsg
  13845. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13846. res2.Infcode = infocode
  13847. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13848. 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)
  13849. var dat map[string]interface{}
  13850. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13851. fmt.Println(dat)
  13852. } else {
  13853. fmt.Println(err)
  13854. }
  13855. saveLog(result, request, "2202", "退号")
  13856. userJSONBytes, _ := json.Marshal(dat)
  13857. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13858. utils.ErrorLog("解析失败:%v", err)
  13859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13860. return
  13861. }
  13862. } else if miConfig.MdtrtareaAdmvs == "360399" {
  13863. 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, "")
  13864. var dat map[string]interface{}
  13865. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13866. fmt.Println(dat)
  13867. } else {
  13868. fmt.Println(err)
  13869. }
  13870. saveLog(result, request, "2202", "退号")
  13871. userJSONBytes, _ := json.Marshal(dat)
  13872. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13873. utils.ErrorLog("解析失败:%v", err)
  13874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13875. return
  13876. }
  13877. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13878. 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, "")
  13879. var dat map[string]interface{}
  13880. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13881. fmt.Println(dat)
  13882. } else {
  13883. fmt.Println(err)
  13884. }
  13885. saveLog(result, request, "2202", "退号")
  13886. userJSONBytes, _ := json.Marshal(dat)
  13887. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13888. utils.ErrorLog("解析失败:%v", err)
  13889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13890. return
  13891. }
  13892. } else {
  13893. var api3 string
  13894. if miConfig.Code == "H15049901371" {
  13895. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  13896. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13897. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13898. } else {
  13899. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  13900. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13901. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13902. }
  13903. resp3, requestErr3 := http.Get(api3)
  13904. if requestErr3 != nil {
  13905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13906. return
  13907. }
  13908. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13909. if ioErr3 != nil {
  13910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13912. return
  13913. }
  13914. var respJSON3 map[string]interface{}
  13915. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13918. return
  13919. }
  13920. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13921. userJSONBytes3, _ := json.Marshal(respJSON3)
  13922. if miConfig.Code == "H15049901371" {
  13923. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  13924. utils.ErrorLog("解析失败:%v", err)
  13925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13926. return
  13927. }
  13928. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13929. res2.Output = resSix10265.Output
  13930. res2.ErrMsg = resSix10265.ErrMsg
  13931. res2.Cainfo = resSix10265.Cainfo
  13932. res2.WarnMsg = resSix10265.WarnMsg
  13933. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13934. res2.Infcode = infocode
  13935. } else {
  13936. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  13937. utils.ErrorLog("解析失败:%v", err)
  13938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13939. return
  13940. }
  13941. }
  13942. }
  13943. if res2.Infcode == 0 {
  13944. if err == nil {
  13945. c.ServeSuccessJSON(map[string]interface{}{
  13946. "msg": "退号成功",
  13947. })
  13948. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  13949. } else {
  13950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13951. return
  13952. }
  13953. } else {
  13954. c.ServeSuccessJSON(map[string]interface{}{
  13955. "code": -10,
  13956. "msg": res2.ErrMsg,
  13957. })
  13958. }
  13959. } else {
  13960. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  13961. //if err == nil {
  13962. // c.ServeSuccessJSON(map[string]interface{}{
  13963. // "msg": "退费成功",
  13964. // })
  13965. //} else {
  13966. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13967. // return
  13968. //}
  13969. }
  13970. }
  13971. func (c *HisApiController) RefundDetail() {
  13972. order_id, _ := c.GetInt64("order_id")
  13973. admin_user_id, _ := c.GetInt64("admin_user_id")
  13974. //his_patient_id, _ := c.GetInt64("his_patient_id")
  13975. number := c.GetString("number")
  13976. record_time := c.GetString("record_time")
  13977. patient_id, _ := c.GetInt64("patient_id")
  13978. //med_type, _ := c.GetInt64("med_type")
  13979. timeLayout := "2006-01-02"
  13980. loc, _ := time.LoadLocation("Local")
  13981. adminUser := c.GetAdminUserInfo()
  13982. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13983. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13984. fmt.Println(err)
  13985. if err != nil {
  13986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13987. return
  13988. }
  13989. recordDateTime := theTime.Unix()
  13990. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  13991. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  13992. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13993. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13994. var order models.HisOrder
  13995. order, _ = service.GetHisOrderByID(order_id)
  13996. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13997. if config.IsOpen == 1 { //对接了医保,走医保流程
  13998. var res2 ResultSix
  13999. if miConfig.MdtrtareaAdmvs == "421300" {
  14000. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  14001. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14002. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14003. resp3, requestErr3 := http.Get(api3)
  14004. if requestErr3 != nil {
  14005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14006. return
  14007. }
  14008. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  14009. if ioErr3 != nil {
  14010. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  14011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14012. return
  14013. }
  14014. var respJSON3 map[string]interface{}
  14015. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  14016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14018. return
  14019. }
  14020. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14021. userJSONBytes3, _ := json.Marshal(respJSON3)
  14022. fmt.Println("log")
  14023. fmt.Println(string(userJSONBytes3))
  14024. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  14025. utils.ErrorLog("解析失败:%v", err)
  14026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14027. return
  14028. }
  14029. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  14030. if err == nil {
  14031. c.ServeSuccessJSON(map[string]interface{}{
  14032. "msg": "撤销明细成功",
  14033. })
  14034. return
  14035. } else {
  14036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14037. return
  14038. }
  14039. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14040. var resSix10265 ResultSix10265
  14041. var api3 string
  14042. if miConfig.MdtrtareaAdmvs == "320921" {
  14043. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  14044. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14045. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14046. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14047. } else {
  14048. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14049. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  14050. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14051. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14052. }
  14053. resp3, requestErr3 := http.Get(api3)
  14054. if requestErr3 != nil {
  14055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14056. return
  14057. }
  14058. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  14059. if ioErr3 != nil {
  14060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  14061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14062. return
  14063. }
  14064. var respJSON3 map[string]interface{}
  14065. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  14066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14068. return
  14069. }
  14070. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14071. userJSONBytes3, _ := json.Marshal(respJSON3)
  14072. fmt.Println("log")
  14073. fmt.Println(string(userJSONBytes3))
  14074. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  14075. utils.ErrorLog("解析失败:%v", err)
  14076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14077. return
  14078. }
  14079. res2.InfRefmsgid = resSix10265.InfRefmsgid
  14080. res2.Output = resSix10265.Output
  14081. res2.ErrMsg = resSix10265.ErrMsg
  14082. res2.Cainfo = resSix10265.Cainfo
  14083. res2.WarnMsg = resSix10265.WarnMsg
  14084. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14085. res2.Infcode = infocode
  14086. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  14087. if err == nil {
  14088. c.ServeSuccessJSON(map[string]interface{}{
  14089. "msg": "撤销明细成功",
  14090. })
  14091. return
  14092. } else {
  14093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14094. return
  14095. }
  14096. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14097. 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)
  14098. var dat map[string]interface{}
  14099. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14100. fmt.Println(dat)
  14101. } else {
  14102. fmt.Println(err)
  14103. }
  14104. saveLog(result2, src_request, "2205", "撤销明细")
  14105. userJSONBytes, _ := json.Marshal(dat)
  14106. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14107. utils.ErrorLog("解析失败:%v", err)
  14108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14109. return
  14110. }
  14111. if res2.Infcode == 0 {
  14112. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  14113. if err == nil {
  14114. c.ServeSuccessJSON(map[string]interface{}{
  14115. "msg": "撤销明细成功",
  14116. })
  14117. return
  14118. } else {
  14119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14120. return
  14121. }
  14122. } else {
  14123. c.ServeSuccessJSON(map[string]interface{}{
  14124. "code": -10,
  14125. "msg": res2.ErrMsg,
  14126. })
  14127. }
  14128. } else if miConfig.MdtrtareaAdmvs == "360399" {
  14129. 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, "")
  14130. var dat map[string]interface{}
  14131. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14132. fmt.Println(dat)
  14133. } else {
  14134. fmt.Println(err)
  14135. }
  14136. saveLog(result2, src_request, "2205", "撤销明细")
  14137. userJSONBytes, _ := json.Marshal(dat)
  14138. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14139. utils.ErrorLog("解析失败:%v", err)
  14140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14141. return
  14142. }
  14143. if res2.Infcode == 0 {
  14144. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  14145. if err == nil {
  14146. c.ServeSuccessJSON(map[string]interface{}{
  14147. "msg": "撤销明细成功",
  14148. })
  14149. return
  14150. } else {
  14151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14152. return
  14153. }
  14154. } else {
  14155. c.ServeSuccessJSON(map[string]interface{}{
  14156. "code": -10,
  14157. "msg": res2.ErrMsg,
  14158. })
  14159. }
  14160. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14161. 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, "")
  14162. var dat map[string]interface{}
  14163. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14164. fmt.Println(dat)
  14165. } else {
  14166. fmt.Println(err)
  14167. }
  14168. saveLog(result2, src_request, "2205", "撤销明细")
  14169. userJSONBytes, _ := json.Marshal(dat)
  14170. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14171. utils.ErrorLog("解析失败:%v", err)
  14172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14173. return
  14174. }
  14175. if res2.Infcode == 0 {
  14176. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  14177. if err == nil {
  14178. c.ServeSuccessJSON(map[string]interface{}{
  14179. "msg": "撤销明细成功",
  14180. })
  14181. return
  14182. } else {
  14183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14184. return
  14185. }
  14186. } else {
  14187. c.ServeSuccessJSON(map[string]interface{}{
  14188. "code": -10,
  14189. "msg": res2.ErrMsg,
  14190. })
  14191. }
  14192. } else {
  14193. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  14194. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14195. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14196. resp2, requestErr2 := http.Get(api2)
  14197. if requestErr2 != nil {
  14198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14199. return
  14200. }
  14201. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  14202. if ioErr2 != nil {
  14203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  14204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14205. return
  14206. }
  14207. var respJSON2 map[string]interface{}
  14208. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  14209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14211. return
  14212. }
  14213. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  14214. if err == nil {
  14215. c.ServeSuccessJSON(map[string]interface{}{
  14216. "msg": "撤销明细成功",
  14217. })
  14218. return
  14219. } else {
  14220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14221. return
  14222. }
  14223. }
  14224. } else {
  14225. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  14226. if err == nil {
  14227. c.ServeSuccessJSON(map[string]interface{}{
  14228. "msg": "退费成功",
  14229. })
  14230. } else {
  14231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14232. return
  14233. }
  14234. }
  14235. }
  14236. // 对账
  14237. func (c *HisApiController) GetCheckAccount() {
  14238. start_time := c.GetString("start_time")
  14239. end_time := c.GetString("end_time")
  14240. insutype := c.GetString("insutype")
  14241. clr_type := c.GetString("clr_type")
  14242. clr_org := c.GetString("clr_optins")
  14243. admin_user_id, _ := c.GetInt64("admin_user_id")
  14244. adminUser := c.GetAdminUserInfo()
  14245. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14246. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14247. if len(clr_org) == 0 {
  14248. clr_org = miConfig.MdtrtareaAdmvs
  14249. }
  14250. timeLayout := "2006-01-02"
  14251. loc, _ := time.LoadLocation("Local")
  14252. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  14253. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  14254. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  14255. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  14256. fixmedins_setl_cnt := int64(len(orders))
  14257. var medfee_sumamt float64
  14258. var acct_pay float64
  14259. var fund_pay_sumamt float64
  14260. for _, item := range orders {
  14261. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  14262. acct_pay = acct_pay + item.AcctPay
  14263. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  14264. }
  14265. var user_name string
  14266. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14267. if role.ID == 0 {
  14268. user_name = "xxx"
  14269. } else {
  14270. user_name = role.UserName
  14271. }
  14272. var res ResultEight
  14273. var res10188 ResultEightFor10188
  14274. if config.IsOpen == 1 {
  14275. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14276. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  14277. "insutype=" + insutype +
  14278. "&clr_type=" + clr_type +
  14279. "&setl_optins=" + clr_org +
  14280. "&stmt_begndate=" + start_time +
  14281. "&stm_enddate=" + end_time +
  14282. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  14283. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  14284. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  14285. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  14286. "&fixmedins_code=" + miConfig.Code +
  14287. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  14288. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14289. "&secret_key=" + miConfig.SecretKey +
  14290. "&org_name=" + miConfig.OrgName +
  14291. "&doctor=" + user_name +
  14292. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14293. fmt.Println(api)
  14294. resp, requestErr := http.Get(api)
  14295. if requestErr != nil {
  14296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14297. return
  14298. }
  14299. body, ioErr := ioutil.ReadAll(resp.Body)
  14300. fmt.Println(body)
  14301. if ioErr != nil {
  14302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14304. return
  14305. }
  14306. var respJSON map[string]interface{}
  14307. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14310. return
  14311. }
  14312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14313. userJSONBytes, _ := json.Marshal(respJSON)
  14314. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14315. utils.ErrorLog("解析失败:%v", err)
  14316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14317. return
  14318. }
  14319. res.InfRefmsgid = res10188.InfRefmsgid
  14320. res.Output = res10188.Output
  14321. res.ErrMsg = res10188.ErrMsg
  14322. res.Cainfo = res10188.Cainfo
  14323. res.WarnMsg = res10188.WarnMsg
  14324. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  14325. res.Infcode = infocode
  14326. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14327. if clr_type == "11" {
  14328. fixmedins_setl_cnt = 0
  14329. }
  14330. //if clr_type == "21" {
  14331. // clr_type = "22"
  14332. //}
  14333. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  14334. "insutype=" + insutype +
  14335. "&clr_type=" + clr_type +
  14336. "&setl_optins=" + clr_org +
  14337. "&stmt_begndate=" + start_time +
  14338. "&stm_enddate=" + end_time +
  14339. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  14340. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  14341. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  14342. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  14343. "&fixmedins_code=" + miConfig.Code +
  14344. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  14345. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14346. "&secret_key=" + miConfig.SecretKey +
  14347. "&org_name=" + miConfig.OrgName +
  14348. "&doctor=" + user_name
  14349. resp, requestErr := http.Get(api)
  14350. if requestErr != nil {
  14351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14352. return
  14353. }
  14354. body, ioErr := ioutil.ReadAll(resp.Body)
  14355. if ioErr != nil {
  14356. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14358. return
  14359. }
  14360. var respJSON map[string]interface{}
  14361. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14362. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14364. return
  14365. }
  14366. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14367. result, _ := json.Marshal(respJSON)
  14368. fmt.Println("log")
  14369. fmt.Println(string(result))
  14370. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  14371. utils.ErrorLog("解析失败:%v", err)
  14372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14373. return
  14374. }
  14375. res.InfRefmsgid = res10188.InfRefmsgid
  14376. res.Output = res10188.Output
  14377. res.ErrMsg = res10188.ErrMsg
  14378. res.Cainfo = res10188.Cainfo
  14379. res.WarnMsg = res10188.WarnMsg
  14380. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  14381. res.Infcode = infocode
  14382. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14383. var baseParams models.BaseParams
  14384. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14385. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14386. baseParams.SecretKey = miConfig.SecretKey
  14387. baseParams.OrgName = miConfig.OrgName
  14388. baseParams.FixmedinsCode = miConfig.Code
  14389. baseParams.EncKey = miConfig.EncKey
  14390. baseParams.AppSecret = miConfig.AppSecret
  14391. baseParams.SignKey = miConfig.SignKey
  14392. baseParams.AppID = miConfig.Code
  14393. baseParams.Doctor = role.UserName
  14394. baseParams.RequestUrl = miConfig.Url
  14395. businessParams := models.BusinessParams{
  14396. Insutype: insutype,
  14397. ClrType: clr_type,
  14398. SetlOptins: clr_org,
  14399. StmtBegndate: start_time,
  14400. StmtEnddate: end_time,
  14401. MedfeeSumamt: medfee_sumamt,
  14402. FundPaySumamt: fund_pay_sumamt,
  14403. AcctPay: acct_pay,
  14404. FixmedinsSetlCnt: fixmedins_setl_cnt,
  14405. }
  14406. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  14407. fmt.Println(requestLog)
  14408. fmt.Println(result)
  14409. fmt.Println(err_msg)
  14410. var dat map[string]interface{}
  14411. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14412. fmt.Println(dat)
  14413. } else {
  14414. fmt.Println(err)
  14415. }
  14416. userJSONBytes, _ := json.Marshal(dat)
  14417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14418. utils.ErrorLog("解析失败:%v", err)
  14419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14420. return
  14421. }
  14422. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14423. var baseParams models.BaseParams
  14424. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14425. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14426. baseParams.SecretKey = miConfig.SecretKey
  14427. baseParams.OrgName = miConfig.OrgName
  14428. baseParams.FixmedinsCode = miConfig.Code
  14429. baseParams.EncKey = miConfig.EncKey
  14430. baseParams.AppSecret = miConfig.AppSecret
  14431. baseParams.SignKey = miConfig.SignKey
  14432. baseParams.AppID = miConfig.Code
  14433. baseParams.Doctor = role.UserName
  14434. baseParams.RequestUrl = miConfig.Url
  14435. baseParams.AccessKey = miConfig.AccessKey
  14436. businessParams := models.BusinessParams{
  14437. Insutype: insutype,
  14438. ClrType: clr_type,
  14439. SetlOptins: "430822",
  14440. StmtBegndate: start_time,
  14441. StmtEnddate: end_time,
  14442. MedfeeSumamt: medfee_sumamt,
  14443. FundPaySumamt: fund_pay_sumamt,
  14444. AcctPay: acct_pay,
  14445. FixmedinsSetlCnt: fixmedins_setl_cnt,
  14446. }
  14447. 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)
  14448. fmt.Println(requestLog)
  14449. fmt.Println(result)
  14450. var dat map[string]interface{}
  14451. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14452. fmt.Println(dat)
  14453. } else {
  14454. fmt.Println(err)
  14455. }
  14456. userJSONBytes, _ := json.Marshal(dat)
  14457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14458. utils.ErrorLog("解析失败:%v", err)
  14459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14460. return
  14461. }
  14462. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14463. var baseParams models.BaseParams
  14464. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14465. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14466. baseParams.SecretKey = miConfig.SecretKey
  14467. baseParams.OrgName = miConfig.OrgName
  14468. baseParams.FixmedinsCode = miConfig.Code
  14469. baseParams.EncKey = miConfig.EncKey
  14470. baseParams.AppSecret = miConfig.AppSecret
  14471. baseParams.SignKey = miConfig.SignKey
  14472. baseParams.AppID = miConfig.Code
  14473. baseParams.Doctor = role.UserName
  14474. baseParams.RequestUrl = miConfig.Url
  14475. businessParams := models.BusinessParams{
  14476. Insutype: insutype,
  14477. ClrType: clr_type,
  14478. SetlOptins: clr_org,
  14479. StmtBegndate: start_time,
  14480. StmtEnddate: end_time,
  14481. MedfeeSumamt: medfee_sumamt,
  14482. FundPaySumamt: fund_pay_sumamt,
  14483. AcctPay: acct_pay,
  14484. FixmedinsSetlCnt: fixmedins_setl_cnt,
  14485. }
  14486. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  14487. fmt.Println(requestLog)
  14488. fmt.Println(result)
  14489. fmt.Println(err_msg)
  14490. var dat map[string]interface{}
  14491. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14492. fmt.Println(dat)
  14493. } else {
  14494. fmt.Println(err)
  14495. }
  14496. userJSONBytes, _ := json.Marshal(dat)
  14497. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14498. utils.ErrorLog("解析失败:%v", err)
  14499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14500. return
  14501. }
  14502. } else {
  14503. if len(clr_type) == 0 {
  14504. clr_type = "11"
  14505. }
  14506. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  14507. "insutype=" + insutype +
  14508. "&clr_type=" + clr_type +
  14509. "&setl_optins=" + clr_org +
  14510. "&stmt_begndate=" + start_time +
  14511. "&stm_enddate=" + end_time +
  14512. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  14513. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  14514. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  14515. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  14516. "&fixmedins_code=" + miConfig.Code +
  14517. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  14518. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14519. "&secret_key=" + miConfig.SecretKey +
  14520. "&org_name=" + miConfig.OrgName +
  14521. "&doctor=" + user_name
  14522. fmt.Println(api)
  14523. resp, requestErr := http.Get(api)
  14524. if requestErr != nil {
  14525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14526. return
  14527. }
  14528. body, ioErr := ioutil.ReadAll(resp.Body)
  14529. fmt.Println(body)
  14530. if ioErr != nil {
  14531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14533. return
  14534. }
  14535. var respJSON map[string]interface{}
  14536. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14539. return
  14540. }
  14541. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14542. userJSONBytes, _ := json.Marshal(respJSON)
  14543. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14544. utils.ErrorLog("解析失败:%v", err)
  14545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14546. return
  14547. }
  14548. }
  14549. if res.Infcode == 0 {
  14550. if res.Output.Stmtinfo.StmtRslt == "0" {
  14551. micc := &models.MedicalInsuranceCostCompare{
  14552. StartTime: startime.Unix(),
  14553. EndTime: endtime.Unix(),
  14554. Insutype: insutype,
  14555. CheckType: 1,
  14556. Num: fixmedins_setl_cnt,
  14557. Mtime: time.Now().Unix(),
  14558. Status: 1,
  14559. UserOrgId: adminUser.CurrentOrgId,
  14560. CostTotal: medfee_sumamt,
  14561. FuncTotal: fund_pay_sumamt,
  14562. PsnPay: acct_pay,
  14563. Creator: admin_user_id,
  14564. Ctime: time.Now().Unix(),
  14565. ClrType: clr_type,
  14566. }
  14567. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  14568. if err == nil {
  14569. c.ServeSuccessJSON(map[string]interface{}{
  14570. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  14571. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  14572. })
  14573. } else {
  14574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14575. }
  14576. } else {
  14577. c.ServeSuccessJSON(map[string]interface{}{
  14578. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  14579. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  14580. })
  14581. }
  14582. } else {
  14583. c.ServeSuccessJSON(map[string]interface{}{
  14584. "code": -10,
  14585. "msg": res.ErrMsg,
  14586. })
  14587. }
  14588. }
  14589. }
  14590. func (c *HisApiController) Check310() {
  14591. adminUser := c.GetAdminUserInfo()
  14592. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14593. var user_name string
  14594. user_name = "高慧裕"
  14595. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  14596. "insutype=" + "310" +
  14597. "&clr_type=" + "" +
  14598. "&setl_optins=" + "441202" +
  14599. "&stmt_begndate=" + "2022-03-01" +
  14600. "&stm_enddate=" + "2022-03-31" +
  14601. "&medfee_sumamt=" + "194930.12" +
  14602. "&fund_pay_sumamt=" + "188741.46" +
  14603. "&acct_pay=" + "0" +
  14604. "&fixmedins_setl_cnt=" + "452" +
  14605. "&fixmedins_code=" + miConfig.Code +
  14606. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  14607. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14608. "&secret_key=" + miConfig.SecretKey +
  14609. "&org_name=" + miConfig.OrgName +
  14610. "&doctor=" + user_name
  14611. fmt.Println(api)
  14612. resp, requestErr := http.Get(api)
  14613. if requestErr != nil {
  14614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14615. return
  14616. }
  14617. body, ioErr := ioutil.ReadAll(resp.Body)
  14618. fmt.Println(body)
  14619. if ioErr != nil {
  14620. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14622. return
  14623. }
  14624. var respJSON map[string]interface{}
  14625. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14628. return
  14629. }
  14630. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14631. userJSONBytes, _ := json.Marshal(respJSON)
  14632. var res ResultEight
  14633. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14634. utils.ErrorLog("解析失败:%v", err)
  14635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14636. return
  14637. }
  14638. }
  14639. func (c *HisApiController) Check390() {
  14640. adminUser := c.GetAdminUserInfo()
  14641. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14642. var user_name string
  14643. user_name = "高慧裕"
  14644. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  14645. "insutype=" + "390" +
  14646. "&clr_type=" + "" +
  14647. "&setl_optins=" + "441202" +
  14648. "&stmt_begndate=" + "2022-03-01" +
  14649. "&stm_enddate=" + "2022-03-31" +
  14650. "&medfee_sumamt=" + "1068448.89" +
  14651. "&fund_pay_sumamt=" + "1014677.62" +
  14652. "&acct_pay=" + "0" +
  14653. "&fixmedins_setl_cnt=" + "1950" +
  14654. "&fixmedins_code=" + miConfig.Code +
  14655. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  14656. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14657. "&secret_key=" + miConfig.SecretKey +
  14658. "&org_name=" + miConfig.OrgName +
  14659. "&doctor=" + user_name
  14660. fmt.Println(api)
  14661. resp, requestErr := http.Get(api)
  14662. if requestErr != nil {
  14663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14664. return
  14665. }
  14666. body, ioErr := ioutil.ReadAll(resp.Body)
  14667. fmt.Println(body)
  14668. if ioErr != nil {
  14669. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14671. return
  14672. }
  14673. var respJSON map[string]interface{}
  14674. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14677. return
  14678. }
  14679. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14680. userJSONBytes, _ := json.Marshal(respJSON)
  14681. var res ResultEight
  14682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14683. utils.ErrorLog("解析失败:%v", err)
  14684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14685. return
  14686. }
  14687. }
  14688. // 对账明细
  14689. func (c *HisApiController) GetCheckDetailAccount() {
  14690. start_time := c.GetString("start_time")
  14691. end_time := c.GetString("end_time")
  14692. admin_user_id, _ := c.GetInt64("admin_user_id")
  14693. adminUser := c.GetAdminUserInfo()
  14694. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14695. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14696. timeLayout := "2006-01-02"
  14697. loc, _ := time.LoadLocation("Local")
  14698. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  14699. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  14700. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  14701. rand.Seed(time.Now().UnixNano())
  14702. num := rand.Intn(30000)
  14703. Mkdir(miConfig.OrgName)
  14704. file := strconv.FormatInt(int64(num), 10)
  14705. file_name := file + ".txt"
  14706. zip_name := file + ".zip"
  14707. zip_path := miConfig.OrgName + "/" + zip_name
  14708. file_path := miConfig.OrgName + "/" + file_name
  14709. decimal.DivisionPrecision = 2
  14710. var medfee_sumamt float64
  14711. var psn_cash_pay float64
  14712. var fund_pay_sumamt float64
  14713. fixmedins_setl_cnt := int64(len(orders))
  14714. for _, item := range orders {
  14715. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  14716. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  14717. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  14718. }
  14719. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  14720. defer f.Close()
  14721. if err != nil {
  14722. fmt.Println(err.Error())
  14723. } else {
  14724. for _, item := range orders {
  14725. var refd_setl_flag string
  14726. if item.OrderStatus == 2 {
  14727. refd_setl_flag = "0"
  14728. var str string
  14729. str = item.SetlId + " " +
  14730. item.MdtrtId + " " +
  14731. item.PsnNo + " " +
  14732. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  14733. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  14734. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  14735. _, err = f.Write([]byte(str))
  14736. }
  14737. if item.OrderStatus == 3 {
  14738. var str string
  14739. str = item.SetlId + " " +
  14740. item.MdtrtId + " " +
  14741. item.PsnNo + " " +
  14742. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  14743. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  14744. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  14745. _, err = f.Write([]byte(str))
  14746. var str2 string
  14747. str2 = item.SetlId + " " +
  14748. item.MdtrtId + " " +
  14749. item.PsnNo + " " +
  14750. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  14751. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  14752. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  14753. _, err = f.Write([]byte(str2))
  14754. }
  14755. }
  14756. }
  14757. Zip(file_path, zip_path)
  14758. fmt.Println(ReadFile(zip_path))
  14759. fmt.Println(string(ReadFile(zip_path)))
  14760. if config.IsOpen == 1 {
  14761. var user_name string
  14762. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14763. if role.ID == 0 {
  14764. user_name = "管理员"
  14765. } else {
  14766. user_name = role.UserName
  14767. }
  14768. baseParams := models.BaseParams{
  14769. SecretKey: miConfig.SecretKey,
  14770. FixmedinsCode: miConfig.Code,
  14771. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14772. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14773. OrgName: miConfig.OrgName,
  14774. Doctor: user_name,
  14775. }
  14776. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  14777. var dat map[string]interface{}
  14778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14779. fmt.Println(dat)
  14780. } else {
  14781. fmt.Println(err)
  14782. }
  14783. userJSONBytes, _ := json.Marshal(dat)
  14784. var res ResultNine
  14785. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14786. utils.ErrorLog("解析失败:%v", err)
  14787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14788. return
  14789. }
  14790. if res.Infcode == 0 {
  14791. fileNo := res.Output.FileQuryNo
  14792. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  14793. "file_qury_no=" + fileNo +
  14794. "&setl_optins=" + "定点医保中心" +
  14795. "&stmt_begndate=" + start_time +
  14796. "&stm_enddate=" + end_time +
  14797. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  14798. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  14799. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  14800. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  14801. "&fixmedins_code=" + miConfig.Code +
  14802. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  14803. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14804. "&secret_key=" + miConfig.SecretKey +
  14805. "&org_name=" + miConfig.OrgName +
  14806. "&doctor=" + user_name
  14807. resp, requestErr := http.Get(api)
  14808. if requestErr != nil {
  14809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14810. return
  14811. }
  14812. body, ioErr := ioutil.ReadAll(resp.Body)
  14813. if ioErr != nil {
  14814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14816. return
  14817. }
  14818. var respJSON map[string]interface{}
  14819. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14822. return
  14823. }
  14824. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14825. userJSONBytes, _ := json.Marshal(respJSON)
  14826. var res ResultTen
  14827. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14828. utils.ErrorLog("解析失败:%v", err)
  14829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14830. return
  14831. }
  14832. if res.Infcode == 0 {
  14833. service.Gdyb9102(baseParams, zip_name, fileNo)
  14834. micc := &models.MedicalInsuranceCostCompare{
  14835. StartTime: startime.Unix(),
  14836. EndTime: endtime.Unix(),
  14837. Insutype: "0",
  14838. CheckType: 2,
  14839. Num: fixmedins_setl_cnt,
  14840. Mtime: time.Now().Unix(),
  14841. Status: 1,
  14842. UserOrgId: adminUser.CurrentOrgId,
  14843. CostTotal: medfee_sumamt,
  14844. FuncTotal: fund_pay_sumamt,
  14845. PsnPay: psn_cash_pay,
  14846. Creator: admin_user_id,
  14847. Ctime: time.Now().Unix(),
  14848. }
  14849. service.CreateMedicalInsuranceCostCompareRecord(micc)
  14850. c.ServeSuccessJSON(map[string]interface{}{
  14851. "msg": "明细对账成功",
  14852. })
  14853. }
  14854. } else {
  14855. }
  14856. }
  14857. }
  14858. type CustomOrderInfo struct {
  14859. Name string
  14860. Spec string
  14861. Unit string
  14862. Count float64
  14863. Price float64
  14864. Total float64
  14865. }
  14866. func (c *HisApiController) GetBatchSettleAccounts() {
  14867. admin_user_id, _ := c.GetInt64("admin_user_id")
  14868. order_ids := c.GetString("order_ids")
  14869. order_ids_arr := strings.Split(order_ids, ",")
  14870. data3 := []map[string]interface{}{}
  14871. for _, item := range order_ids_arr {
  14872. id, _ := strconv.ParseInt(item, 10, 64)
  14873. order_id := id
  14874. adminUser := c.GetAdminUserInfo()
  14875. order, _ := service.GetHisOrderByID(order_id)
  14876. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  14877. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  14878. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  14879. orderInfos = append(orderInfos, orderInfos_two...)
  14880. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  14881. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  14882. var diagnosis_ids []string
  14883. if his.ID > 0 {
  14884. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  14885. } else {
  14886. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  14887. }
  14888. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  14889. var dia_config []*models.HisXtDiagnoseConfig
  14890. var name string
  14891. for _, item := range diagnosis_ids {
  14892. id, _ := strconv.ParseInt(item, 10, 64)
  14893. diagnosisConfig, _ := service.FindDiagnoseById(id)
  14894. dia_config = append(dia_config, &diagnosisConfig)
  14895. if len(name) == 0 {
  14896. name = diagnosisConfig.ClassName
  14897. } else {
  14898. name = name + "," + diagnosisConfig.ClassName
  14899. }
  14900. }
  14901. var bedCostTotal float64 = 0 //床位总费
  14902. var bedCostSelfTotal float64 = 0 //床位自费
  14903. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14904. var bedSelfTotal float64 = 0 //床位部分项目自费
  14905. var bedInscpTotal float64 = 0 //床位部分项目自费
  14906. var operationCostTotal float64 = 0 //手术费
  14907. var operationCostSelfTotal float64 = 0 //手术费
  14908. var operationCostPartSelfTotal float64 = 0 //手术费
  14909. var operationSelfTotal float64 = 0 //床位部分项目自费
  14910. var operationInscpTotal float64 = 0 //床位部分项目自费
  14911. var otherCostTotal float64 = 0 //其他费用
  14912. var otherCostSelfTotal float64 = 0 //其他费用
  14913. var otherCostPartSelfTotal float64 = 0 //其他费用
  14914. var otherSelfTotal float64 = 0 //床位部分项目自费
  14915. var otherInscpTotal float64 = 0 //床位部分项目自费
  14916. var materialCostTotal float64 = 0 //材料费
  14917. var materialCostSelfTotal float64 = 0 //材料费
  14918. var materialCostPartSelfTotal float64 = 0 //材料费
  14919. var materialSelfTotal float64 = 0 //床位部分项目自费
  14920. var materialInscpTotal float64 = 0 //床位部分项目自费
  14921. var westernMedicineCostTotal float64 = 0 //西药费
  14922. var westernMedicineCostSelfTotal float64 = 0 //西药费
  14923. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14924. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  14925. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  14926. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14927. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14928. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14929. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  14930. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  14931. var checkCostTotal float64 = 0 //检查费
  14932. var checkCostSelfTotal float64 = 0 //检查费
  14933. var checkCostPartSelfTotal float64 = 0 //检查费
  14934. var checkSelfTotal float64 = 0 //床位部分项目自费
  14935. var checkInscpTotal float64 = 0 //床位部分项目自费
  14936. var laboratoryCostTotal float64 = 0 //化验费
  14937. var laboratoryCostSelfTotal float64 = 0 //化验费
  14938. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14939. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  14940. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  14941. var treatCostTotal float64 = 0 //治疗费用
  14942. var treatCostSelfTotal float64 = 0 //治疗费用
  14943. var treatCostPartSelfTotal float64 = 0 //治疗费用
  14944. var treatSelfTotal float64 = 0 //床位部分项目自费
  14945. var treatInscpTotal float64 = 0 //床位部分项目自费
  14946. decimal.DivisionPrecision = 2
  14947. for _, item := range orderInfos {
  14948. if item.MedChrgitmType == "01" { //床位费
  14949. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14950. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14951. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14952. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14953. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14954. }
  14955. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  14956. if item.MedChrgitmType == "03" { //检查费
  14957. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14958. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14959. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14960. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14961. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14962. }
  14963. } else {
  14964. if item.MedChrgitmType == "03" { //检查费
  14965. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14966. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14967. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14968. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14969. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14970. }
  14971. }
  14972. if item.MedChrgitmType == "04" { //化验费
  14973. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14974. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14975. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14976. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14977. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14978. }
  14979. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  14980. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14981. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14982. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14983. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14984. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14985. }
  14986. if item.MedChrgitmType == "06" { //手术费
  14987. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14988. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14989. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14990. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14991. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14992. }
  14993. if item.MedChrgitmType == "08" { //材料费
  14994. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14995. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14996. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14997. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14998. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14999. }
  15000. if item.MedChrgitmType == "09" { //西药费
  15001. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15002. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15003. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15004. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15005. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15006. }
  15007. if item.MedChrgitmType == "11" { //中成费
  15008. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15009. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15010. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15011. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15012. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15013. }
  15014. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  15015. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15016. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15017. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15018. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15019. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15020. }
  15021. }
  15022. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15023. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15024. var user_name string
  15025. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15026. if role.ID == 0 {
  15027. user_name = "管理员"
  15028. } else {
  15029. user_name = role.UserName
  15030. }
  15031. baseParams := models.BaseParams{
  15032. SecretKey: miConfig.SecretKey,
  15033. FixmedinsCode: miConfig.Code,
  15034. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  15035. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  15036. OrgName: miConfig.OrgName,
  15037. Doctor: user_name,
  15038. RequestUrl: miConfig.Url,
  15039. AccessKey: miConfig.AccessKey,
  15040. }
  15041. businessParams := models.BusinessParams{
  15042. PsnNo: order.PsnNo,
  15043. MdtrtId: order.MdtrtId,
  15044. SetlId: order.SetlId,
  15045. }
  15046. var res ResultEleven
  15047. var resEleven10265 ResultEleven10265
  15048. if config.IsOpen == 1 {
  15049. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  15050. result := service.Gdyb5203(baseParams, businessParams)
  15051. //service.Gdyb5204(baseParams, businessParams)
  15052. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  15053. var dat map[string]interface{}
  15054. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15055. fmt.Println(dat)
  15056. } else {
  15057. fmt.Println(err)
  15058. }
  15059. userJSONBytes, _ := json.Marshal(dat)
  15060. if miConfig.Code == "H15049901371" {
  15061. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  15062. utils.ErrorLog("解析失败:%v", err)
  15063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15064. return
  15065. }
  15066. res.InfRefmsgid = resEleven10265.InfRefmsgid
  15067. res.Output = resEleven10265.Output
  15068. res.ErrMsg = resEleven10265.ErrMsg
  15069. res.Cainfo = resEleven10265.Cainfo
  15070. res.WarnMsg = resEleven10265.WarnMsg
  15071. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  15072. res.Infcode = infocode
  15073. } else {
  15074. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15075. utils.ErrorLog("解析失败:%v", err)
  15076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15077. return
  15078. }
  15079. }
  15080. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15081. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  15082. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  15083. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  15084. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  15085. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15086. var doctor_name string
  15087. if roles.ID == 0 {
  15088. doctor_name = "管理员"
  15089. } else {
  15090. doctor_name = roles.UserName
  15091. }
  15092. yiliao_leibie := ""
  15093. switch order.MedType {
  15094. case "11":
  15095. yiliao_leibie = "普通门诊"
  15096. break
  15097. case "12":
  15098. yiliao_leibie = "门诊挂号"
  15099. break
  15100. case "13":
  15101. yiliao_leibie = "急诊"
  15102. break
  15103. case "14":
  15104. yiliao_leibie = "门诊特殊病"
  15105. break
  15106. case "15":
  15107. yiliao_leibie = "门诊统筹"
  15108. break
  15109. case "16":
  15110. yiliao_leibie = "门诊慢性病"
  15111. break
  15112. case "21":
  15113. yiliao_leibie = "普通住院"
  15114. break
  15115. }
  15116. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  15117. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  15118. if res.Infcode == 0 {
  15119. data2 := map[string]interface{}{
  15120. "diagnosis": name,
  15121. "order_infos": orderInfos,
  15122. "number": order.MdtrtId,
  15123. "date": order.SettleAccountsDate,
  15124. "charge_admin": charge_admin,
  15125. "printor_admin": printor_admin,
  15126. "info": res.Output.Setlinfo,
  15127. "order": order,
  15128. "bedCostTotal": bedCostTotal,
  15129. "bedCostSelfTotal": bedCostSelfTotal,
  15130. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  15131. "bedSelfTotal": bedSelfTotal,
  15132. "bedInscpTotal": bedInscpTotal,
  15133. "operationCostTotal": operationCostTotal,
  15134. "operationCostSelfTotal": operationCostSelfTotal,
  15135. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  15136. "operationSelfTotal": operationSelfTotal,
  15137. "operationInscpTotal": operationInscpTotal,
  15138. "otherCostTotal": otherCostTotal,
  15139. "otherCostSelfTotal": otherCostSelfTotal,
  15140. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  15141. "otherSelfTotal": otherSelfTotal,
  15142. "otherInscpTotal": otherInscpTotal,
  15143. "materialCostTotal": materialCostTotal,
  15144. "materialCostSelfTotal": materialCostSelfTotal,
  15145. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  15146. "materialSelfTotal": materialSelfTotal,
  15147. "materialInscpTotal": materialInscpTotal,
  15148. "westernMedicineCostTotal": westernMedicineCostTotal,
  15149. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  15150. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  15151. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  15152. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  15153. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  15154. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  15155. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  15156. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  15157. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  15158. "checkCostTotal": checkCostTotal,
  15159. "checkCostSelfTotal": checkCostSelfTotal,
  15160. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  15161. "checkSelfTotal": checkSelfTotal,
  15162. "checkInscpTotal": checkInscpTotal,
  15163. "laboratoryCostTotal": laboratoryCostTotal,
  15164. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  15165. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  15166. "laboratorySelfTotal": laboratorySelfTotal,
  15167. "laboratoryInscpTotal": laboratoryInscpTotal,
  15168. "treatCostTotal": treatCostTotal,
  15169. "treatCostSelfTotal": treatCostSelfTotal,
  15170. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  15171. "treatSelfTotal": treatSelfTotal,
  15172. "treatInscpTotal": treatInscpTotal,
  15173. "doctor_info": doctor_info,
  15174. "doctor_code": adminRole_two.DoctorCode,
  15175. "doctor_name": doctor_name,
  15176. "health_card_no": order.PsnNo,
  15177. "department": departments.Name,
  15178. "yiliao_leibie": yiliao_leibie,
  15179. "after_money": order.AccountPrice,
  15180. "patient": patient,
  15181. "org_name": miConfig.OrgName,
  15182. "org_code": miConfig.Code,
  15183. "order_number": order.Number,
  15184. "his_hospital": his_hospital,
  15185. "his": his,
  15186. "dia_config": dia_config,
  15187. "psn_cash_pay": order.PsnCashPay,
  15188. //"check_order_info": cus_slice,
  15189. }
  15190. data3 = append(data3, data2)
  15191. }
  15192. }
  15193. }
  15194. c.ServeSuccessJSON(map[string]interface{}{
  15195. "infos": data3,
  15196. })
  15197. }
  15198. func (c *HisApiController) GetSettleAccounts() {
  15199. //id, _ := c.GetInt64("id")
  15200. //record_time := c.GetString("record_time")
  15201. order_id, _ := c.GetInt64("order_id")
  15202. admin_user_id, _ := c.GetInt64("admin_user_id")
  15203. //timeLayout := "2006-01-02"
  15204. //loc, _ := time.LoadLocation("Local")
  15205. //
  15206. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  15207. //if err != nil {
  15208. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  15209. // return
  15210. //}
  15211. //recordDateTime := theTime.Unix()
  15212. adminUser := c.GetAdminUserInfo()
  15213. order, _ := service.GetHisOrderByID(order_id)
  15214. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  15215. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  15216. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  15217. orderInfos = append(orderInfos, orderInfos_two...)
  15218. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  15219. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  15220. var diagnosis_ids []string
  15221. if his.ID > 0 {
  15222. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  15223. } else {
  15224. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  15225. }
  15226. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  15227. var dia_config []*models.HisXtDiagnoseConfig
  15228. var name string
  15229. for _, item := range diagnosis_ids {
  15230. id, _ := strconv.ParseInt(item, 10, 64)
  15231. diagnosisConfig, _ := service.FindDiagnoseById(id)
  15232. dia_config = append(dia_config, &diagnosisConfig)
  15233. if len(name) == 0 {
  15234. name = diagnosisConfig.ClassName
  15235. } else {
  15236. name = name + "," + diagnosisConfig.ClassName
  15237. }
  15238. }
  15239. var bedCostTotal float64 = 0 //床位总费
  15240. var bedCostSelfTotal float64 = 0 //床位自费
  15241. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  15242. var bedSelfTotal float64 = 0 //床位部分项目自费
  15243. var bedInscpTotal float64 = 0 //床位部分项目自费
  15244. var operationCostTotal float64 = 0 //手术费
  15245. var operationCostSelfTotal float64 = 0 //手术费
  15246. var operationCostPartSelfTotal float64 = 0 //手术费
  15247. var operationSelfTotal float64 = 0 //床位部分项目自费
  15248. var operationInscpTotal float64 = 0 //床位部分项目自费
  15249. var otherCostTotal float64 = 0 //其他费用
  15250. var otherCostSelfTotal float64 = 0 //其他费用
  15251. var otherCostPartSelfTotal float64 = 0 //其他费用
  15252. var otherSelfTotal float64 = 0 //床位部分项目自费
  15253. var otherInscpTotal float64 = 0 //床位部分项目自费
  15254. var materialCostTotal float64 = 0 //材料费
  15255. var materialCostSelfTotal float64 = 0 //材料费
  15256. var materialCostPartSelfTotal float64 = 0 //材料费
  15257. var materialSelfTotal float64 = 0 //床位部分项目自费
  15258. var materialInscpTotal float64 = 0 //床位部分项目自费
  15259. var westernMedicineCostTotal float64 = 0 //西药费
  15260. var westernMedicineCostSelfTotal float64 = 0 //西药费
  15261. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  15262. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  15263. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  15264. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  15265. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  15266. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  15267. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  15268. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  15269. var checkCostTotal float64 = 0 //检查费
  15270. var checkCostSelfTotal float64 = 0 //检查费
  15271. var checkCostPartSelfTotal float64 = 0 //检查费
  15272. var checkSelfTotal float64 = 0 //床位部分项目自费
  15273. var checkInscpTotal float64 = 0 //床位部分项目自费
  15274. var laboratoryCostTotal float64 = 0 //化验费
  15275. var laboratoryCostSelfTotal float64 = 0 //化验费
  15276. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  15277. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  15278. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  15279. var treatCostTotal float64 = 0 //治疗费用
  15280. var treatCostSelfTotal float64 = 0 //治疗费用
  15281. var treatCostPartSelfTotal float64 = 0 //治疗费用
  15282. var treatSelfTotal float64 = 0 //床位部分项目自费
  15283. var treatInscpTotal float64 = 0 //床位部分项目自费
  15284. decimal.DivisionPrecision = 2
  15285. for _, item := range orderInfos {
  15286. if item.MedChrgitmType == "01" { //床位费
  15287. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15288. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15289. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15290. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15291. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15292. }
  15293. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  15294. if item.MedChrgitmType == "03" { //检查费
  15295. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15296. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15297. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15298. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15299. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15300. }
  15301. } else {
  15302. if item.MedChrgitmType == "03" { //检查费
  15303. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15304. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15305. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15306. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15307. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15308. }
  15309. }
  15310. if item.MedChrgitmType == "04" { //化验费
  15311. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15312. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15313. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15314. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15315. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15316. }
  15317. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  15318. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15319. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15320. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15321. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15322. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15323. }
  15324. if item.MedChrgitmType == "06" { //手术费
  15325. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15326. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15327. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15328. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15329. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15330. }
  15331. if item.MedChrgitmType == "08" { //材料费
  15332. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15333. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15334. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15335. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15336. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15337. }
  15338. if item.MedChrgitmType == "09" { //西药费
  15339. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15340. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15341. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15342. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15343. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15344. }
  15345. if item.MedChrgitmType == "11" { //中成费
  15346. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15347. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15348. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15349. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15350. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15351. }
  15352. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  15353. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15354. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15355. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15356. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15357. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  15358. }
  15359. }
  15360. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15361. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15362. var user_name string
  15363. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15364. if role.ID == 0 {
  15365. user_name = "管理员"
  15366. } else {
  15367. user_name = role.UserName
  15368. }
  15369. baseParams := models.BaseParams{
  15370. SecretKey: miConfig.SecretKey,
  15371. FixmedinsCode: miConfig.Code,
  15372. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  15373. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  15374. OrgName: miConfig.OrgName,
  15375. Doctor: user_name,
  15376. RequestUrl: miConfig.Url,
  15377. AccessKey: miConfig.AccessKey,
  15378. }
  15379. businessParams := models.BusinessParams{
  15380. PsnNo: order.PsnNo,
  15381. MdtrtId: order.MdtrtId,
  15382. SetlId: order.SetlId,
  15383. }
  15384. var res ResultEleven
  15385. var resEleven10265 ResultEleven10265
  15386. if config.IsOpen == 1 {
  15387. if miConfig.MdtrtareaAdmvs == "421300" {
  15388. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  15389. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  15390. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  15391. resp, requestErr := http.Get(api)
  15392. if requestErr != nil {
  15393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15394. return
  15395. }
  15396. body, ioErr := ioutil.ReadAll(resp.Body)
  15397. if ioErr != nil {
  15398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15400. return
  15401. }
  15402. var respJSON map[string]interface{}
  15403. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15406. return
  15407. }
  15408. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15409. result, _ := json.Marshal(respJSON)
  15410. fmt.Println("log")
  15411. fmt.Println(string(result))
  15412. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15413. utils.ErrorLog("解析失败:%v", err)
  15414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15415. return
  15416. }
  15417. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15418. var api string
  15419. if miConfig.MdtrtareaAdmvs == "320921" {
  15420. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  15421. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  15422. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15423. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  15424. } else {
  15425. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  15426. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  15427. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  15428. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15429. }
  15430. resp, requestErr := http.Get(api)
  15431. if requestErr != nil {
  15432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15433. return
  15434. }
  15435. body, ioErr := ioutil.ReadAll(resp.Body)
  15436. if ioErr != nil {
  15437. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15439. return
  15440. }
  15441. var respJSON map[string]interface{}
  15442. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15445. return
  15446. }
  15447. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15448. result, _ := json.Marshal(respJSON)
  15449. fmt.Println("log")
  15450. fmt.Println(string(result))
  15451. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  15452. utils.ErrorLog("解析失败:%v", err)
  15453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15454. return
  15455. }
  15456. res.InfRefmsgid = resEleven10265.InfRefmsgid
  15457. res.Output = resEleven10265.Output
  15458. res.ErrMsg = resEleven10265.ErrMsg
  15459. res.Cainfo = resEleven10265.Cainfo
  15460. res.WarnMsg = resEleven10265.WarnMsg
  15461. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  15462. res.Infcode = infocode
  15463. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15464. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  15465. saveLog(result, requestLog, "5203", "结算单")
  15466. var dat map[string]interface{}
  15467. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15468. fmt.Println(dat)
  15469. } else {
  15470. fmt.Println(err)
  15471. }
  15472. userJSONBytes, _ := json.Marshal(dat)
  15473. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15474. utils.ErrorLog("解析失败:%v", err)
  15475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15476. return
  15477. }
  15478. } else if miConfig.MdtrtareaAdmvs == "360399" {
  15479. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  15480. saveLog(result, requestLog, "5203", "结算单")
  15481. var dat map[string]interface{}
  15482. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15483. fmt.Println(dat)
  15484. } else {
  15485. fmt.Println(err)
  15486. }
  15487. userJSONBytes, _ := json.Marshal(dat)
  15488. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15489. utils.ErrorLog("解析失败:%v", err)
  15490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15491. return
  15492. }
  15493. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15494. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  15495. saveLog(result, requestLog, "5203", "结算单")
  15496. var dat map[string]interface{}
  15497. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15498. fmt.Println(dat)
  15499. } else {
  15500. fmt.Println(err)
  15501. }
  15502. userJSONBytes, _ := json.Marshal(dat)
  15503. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15504. utils.ErrorLog("解析失败:%v", err)
  15505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15506. return
  15507. }
  15508. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15509. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  15510. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  15511. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  15512. resp, requestErr := http.Get(api)
  15513. if requestErr != nil {
  15514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15515. return
  15516. }
  15517. body, ioErr := ioutil.ReadAll(resp.Body)
  15518. if ioErr != nil {
  15519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15521. return
  15522. }
  15523. var respJSON map[string]interface{}
  15524. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15527. return
  15528. }
  15529. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15530. result, _ := json.Marshal(respJSON)
  15531. fmt.Println("log")
  15532. fmt.Println(string(result))
  15533. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  15534. utils.ErrorLog("解析失败:%v", err)
  15535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15536. return
  15537. }
  15538. res.InfRefmsgid = resEleven10265.InfRefmsgid
  15539. res.Output = resEleven10265.Output
  15540. res.ErrMsg = resEleven10265.ErrMsg
  15541. res.Cainfo = resEleven10265.Cainfo
  15542. res.WarnMsg = resEleven10265.WarnMsg
  15543. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  15544. res.Infcode = infocode
  15545. } else {
  15546. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  15547. result := service.Gdyb5203(baseParams, businessParams)
  15548. //service.Gdyb5204(baseParams, businessParams)
  15549. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  15550. var dat map[string]interface{}
  15551. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15552. fmt.Println(dat)
  15553. } else {
  15554. fmt.Println(err)
  15555. }
  15556. userJSONBytes, _ := json.Marshal(dat)
  15557. if miConfig.Code == "H15049901371" {
  15558. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  15559. utils.ErrorLog("解析失败:%v", err)
  15560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15561. return
  15562. }
  15563. res.InfRefmsgid = resEleven10265.InfRefmsgid
  15564. res.Output = resEleven10265.Output
  15565. res.ErrMsg = resEleven10265.ErrMsg
  15566. res.Cainfo = resEleven10265.Cainfo
  15567. res.WarnMsg = resEleven10265.WarnMsg
  15568. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  15569. res.Infcode = infocode
  15570. } else {
  15571. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15572. utils.ErrorLog("解析失败:%v", err)
  15573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15574. return
  15575. }
  15576. }
  15577. }
  15578. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15579. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  15580. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  15581. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  15582. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  15583. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15584. var doctor_name string
  15585. if roles.ID == 0 {
  15586. doctor_name = "管理员"
  15587. } else {
  15588. doctor_name = roles.UserName
  15589. }
  15590. yiliao_leibie := ""
  15591. switch order.MedType {
  15592. case "11":
  15593. yiliao_leibie = "普通门诊"
  15594. break
  15595. case "12":
  15596. yiliao_leibie = "门诊挂号"
  15597. break
  15598. case "13":
  15599. yiliao_leibie = "急诊"
  15600. break
  15601. case "14":
  15602. yiliao_leibie = "门诊特殊病"
  15603. break
  15604. case "15":
  15605. yiliao_leibie = "门诊统筹"
  15606. break
  15607. case "16":
  15608. yiliao_leibie = "门诊慢性病"
  15609. break
  15610. case "21":
  15611. yiliao_leibie = "普通住院"
  15612. break
  15613. }
  15614. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  15615. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  15616. if res.Infcode == 0 {
  15617. c.ServeSuccessJSON(map[string]interface{}{
  15618. "diagnosis": name,
  15619. "order_infos": orderInfos,
  15620. "number": order.MdtrtId,
  15621. "date": order.SettleAccountsDate,
  15622. "charge_admin": charge_admin,
  15623. "printor_admin": printor_admin,
  15624. "info": res.Output.Setlinfo,
  15625. "order": order,
  15626. "bedCostTotal": bedCostTotal,
  15627. "bedCostSelfTotal": bedCostSelfTotal,
  15628. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  15629. "bedSelfTotal": bedSelfTotal,
  15630. "bedInscpTotal": bedInscpTotal,
  15631. "operationCostTotal": operationCostTotal,
  15632. "operationCostSelfTotal": operationCostSelfTotal,
  15633. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  15634. "operationSelfTotal": operationSelfTotal,
  15635. "operationInscpTotal": operationInscpTotal,
  15636. "otherCostTotal": otherCostTotal,
  15637. "otherCostSelfTotal": otherCostSelfTotal,
  15638. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  15639. "otherSelfTotal": otherSelfTotal,
  15640. "otherInscpTotal": otherInscpTotal,
  15641. "materialCostTotal": materialCostTotal,
  15642. "materialCostSelfTotal": materialCostSelfTotal,
  15643. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  15644. "materialSelfTotal": materialSelfTotal,
  15645. "materialInscpTotal": materialInscpTotal,
  15646. "westernMedicineCostTotal": westernMedicineCostTotal,
  15647. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  15648. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  15649. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  15650. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  15651. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  15652. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  15653. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  15654. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  15655. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  15656. "checkCostTotal": checkCostTotal,
  15657. "checkCostSelfTotal": checkCostSelfTotal,
  15658. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  15659. "checkSelfTotal": checkSelfTotal,
  15660. "checkInscpTotal": checkInscpTotal,
  15661. "laboratoryCostTotal": laboratoryCostTotal,
  15662. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  15663. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  15664. "laboratorySelfTotal": laboratorySelfTotal,
  15665. "laboratoryInscpTotal": laboratoryInscpTotal,
  15666. "treatCostTotal": treatCostTotal,
  15667. "treatCostSelfTotal": treatCostSelfTotal,
  15668. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  15669. "treatSelfTotal": treatSelfTotal,
  15670. "treatInscpTotal": treatInscpTotal,
  15671. "doctor_info": doctor_info,
  15672. "doctor_code": adminRole_two.DoctorCode,
  15673. "doctor_name": doctor_name,
  15674. "health_card_no": order.PsnNo,
  15675. "department": departments.Name,
  15676. "yiliao_leibie": yiliao_leibie,
  15677. "after_money": order.AccountPrice,
  15678. "patient": patient,
  15679. "org_name": miConfig.OrgName,
  15680. "org_code": miConfig.Code,
  15681. "order_number": order.Number,
  15682. "his_hospital": his_hospital,
  15683. "his": his,
  15684. "dia_config": dia_config,
  15685. "psn_cash_pay": order.PsnCashPay,
  15686. //"check_order_info": cus_slice,
  15687. })
  15688. }
  15689. }
  15690. }
  15691. func (c *HisApiController) CheckTreatment() {
  15692. patient_id, _ := c.GetInt64("patient_id")
  15693. id_card_no := c.GetString("id_card_no")
  15694. insutype := c.GetString("insutype")
  15695. med_type := c.GetString("med_type")
  15696. admin_user_id, _ := c.GetInt64("admin_user_id")
  15697. adminUser := c.GetAdminUserInfo()
  15698. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  15699. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15700. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15701. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15702. if miConfig.MdtrtareaAdmvs == "421300" {
  15703. var res ResultTwo
  15704. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  15705. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15706. "&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)
  15707. resp, requestErr := http.Get(api)
  15708. if requestErr != nil {
  15709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15710. return
  15711. }
  15712. body, ioErr := ioutil.ReadAll(resp.Body)
  15713. if ioErr != nil {
  15714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15716. return
  15717. }
  15718. var respJSON map[string]interface{}
  15719. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15722. return
  15723. }
  15724. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15725. result, _ := json.Marshal(respJSON)
  15726. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15727. utils.ErrorLog("解析失败:%v", err)
  15728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15729. return
  15730. }
  15731. if res.Infcode == 0 {
  15732. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  15733. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15734. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  15735. resp, requestErr := http.Get(api)
  15736. if requestErr != nil {
  15737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15738. return
  15739. }
  15740. body, ioErr := ioutil.ReadAll(resp.Body)
  15741. if ioErr != nil {
  15742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15744. return
  15745. }
  15746. var respJSON map[string]interface{}
  15747. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15750. return
  15751. }
  15752. var res Result2001
  15753. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15754. result2, _ := json.Marshal(respJSON)
  15755. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15756. utils.ErrorLog("解析失败:%v", err)
  15757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15758. return
  15759. }
  15760. if res.Infcode == 0 {
  15761. c.ServeSuccessJSON(map[string]interface{}{
  15762. "msg": res.Output.Trtinfo,
  15763. })
  15764. }
  15765. } else {
  15766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15767. return
  15768. }
  15769. } else {
  15770. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  15771. var dat map[string]interface{}
  15772. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15773. fmt.Println(dat)
  15774. } else {
  15775. fmt.Println(err)
  15776. }
  15777. userJSONBytes, _ := json.Marshal(dat)
  15778. var res ResultTwo
  15779. var res10265 ResultTwo10265
  15780. if miConfig.Code == "H15049901371" {
  15781. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  15782. utils.ErrorLog("解析失败:%v", err)
  15783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15784. return
  15785. }
  15786. res.ErrMsg = res10265.ErrMsg
  15787. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15788. res.Infcode = infocode
  15789. res.Output = res10265.Output
  15790. res.InfRefmsgid = res10265.InfRefmsgid
  15791. } else {
  15792. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15793. utils.ErrorLog("解析失败:%v", err)
  15794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15795. return
  15796. }
  15797. }
  15798. var user_name string
  15799. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  15800. if role.ID == 0 {
  15801. user_name = "xxx"
  15802. } else {
  15803. user_name = role.UserName
  15804. }
  15805. baseParams := models.BaseParams{
  15806. SecretKey: miConfig.SecretKey,
  15807. FixmedinsCode: miConfig.Code,
  15808. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  15809. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  15810. OrgName: miConfig.OrgName,
  15811. Doctor: user_name,
  15812. }
  15813. if config.IsOpen == 1 {
  15814. if miConfig.Code == "H15049901371" {
  15815. if med_type == "14" {
  15816. if insutype == "390" {
  15817. med_type = "9933"
  15818. } else if insutype == "310" {
  15819. med_type = "990502"
  15820. }
  15821. } else if med_type == "11" {
  15822. med_type = "11"
  15823. }
  15824. }
  15825. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  15826. var dat map[string]interface{}
  15827. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15828. fmt.Println(dat)
  15829. } else {
  15830. fmt.Println(err)
  15831. }
  15832. var res Result2001
  15833. var res10265 Result2001Org10265
  15834. if miConfig.Code == "H15049901371" {
  15835. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15836. utils.ErrorLog("解析失败:%v", err)
  15837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15838. return
  15839. }
  15840. res.ErrMsg = res10265.ErrMsg
  15841. res.Output = res10265.Output
  15842. res.InfRefmsgid = res10265.InfRefmsgid
  15843. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15844. res.Infcode = infocode
  15845. } else {
  15846. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15847. utils.ErrorLog("解析失败:%v", err)
  15848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15849. return
  15850. }
  15851. }
  15852. if res.Infcode == 0 {
  15853. c.ServeSuccessJSON(map[string]interface{}{
  15854. "msg": res.Output.Trtinfo,
  15855. })
  15856. }
  15857. }
  15858. }
  15859. }
  15860. //func (c *HisApiController) PutRecord() {
  15861. // id, _ := c.GetInt64("id")
  15862. // record_time := c.GetString("record_time")
  15863. // timeLayout := "2006-01-02"
  15864. // loc, _ := time.LoadLocation("Local")
  15865. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  15866. // if err != nil {
  15867. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  15868. // return
  15869. // }
  15870. // recordDateTime := theTime.Unix()
  15871. //
  15872. // adminInfo := c.GetAdminUserInfo()
  15873. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  15874. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  15875. //
  15876. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  15877. //
  15878. // fmt.Println(miConfig.SecretKey)
  15879. //
  15880. // if patient == nil {
  15881. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  15882. // return
  15883. // }
  15884. // if len(patient.IdCardNo) == 0 {
  15885. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  15886. // return
  15887. // }
  15888. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  15889. // if config.IsOpen == 1 {
  15890. // 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
  15891. // resp, requestErr := http.Get(api)
  15892. // if requestErr != nil {
  15893. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15894. // return
  15895. // }
  15896. // defer resp.Body.Close()
  15897. // body, ioErr := ioutil.ReadAll(resp.Body)
  15898. // if ioErr != nil {
  15899. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15900. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15901. // return
  15902. // }
  15903. // var respJSON map[string]interface{}
  15904. //
  15905. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15906. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15907. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15908. // return
  15909. // }
  15910. //
  15911. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15912. // userJSONBytes, _ := json.Marshal(userJSON)
  15913. // var res ResultTwo
  15914. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15915. // utils.ErrorLog("解析失败:%v", err)
  15916. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15917. // return
  15918. // }
  15919. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15920. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15921. // infoStr := string(Iinfos)
  15922. // idetinfoStr := string(Idetinfos)
  15923. //
  15924. // if res.Infcode == 0 {
  15925. // his := models.VMHisPatient{
  15926. // Status: 1,
  15927. // Ctime: time.Now().Unix(),
  15928. // Mtime: time.Now().Unix(),
  15929. // PsnNo: res.Output.Baseinfo.PsnNo,
  15930. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  15931. // Certno: res.Output.Baseinfo.Certno,
  15932. // PsnName: res.Output.Baseinfo.PsnName,
  15933. // Gend: res.Output.Baseinfo.Gend,
  15934. // Naty: res.Output.Baseinfo.Naty,
  15935. // Brdy: res.Output.Baseinfo.Brdy,
  15936. // Age: res.Output.Baseinfo.Age,
  15937. // Iinfo: infoStr,
  15938. // Idetinfo: idetinfoStr,
  15939. // PatientId: patient.ID,
  15940. // RecordDate: theTime.Unix(),
  15941. // UserOrgId: adminInfo.CurrentOrgId,
  15942. // AdminUserId: adminInfo.AdminUser.Id,
  15943. // IsReturn: 1,
  15944. // }
  15945. //
  15946. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  15947. // //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")
  15948. // //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")
  15949. //
  15950. // //var dat map[string]interface{}
  15951. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15952. // // fmt.Println(dat)
  15953. // //} else {
  15954. // // fmt.Println(err)
  15955. // //}
  15956. //
  15957. // var dat2 map[string]interface{}
  15958. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  15959. // fmt.Println(dat2)
  15960. // } else {
  15961. // fmt.Println(err)
  15962. // }
  15963. //
  15964. // } else {
  15965. // adminUser := c.GetAdminUserInfo()
  15966. // errlog := &models.HisOrderError{
  15967. // UserOrgId: adminUser.CurrentOrgId,
  15968. // Ctime: time.Now().Unix(),
  15969. // Mtime: time.Now().Unix(),
  15970. // ErrMsg: res.ErrMsg,
  15971. // Status: 1,
  15972. // PatientId: id,
  15973. // RecordTime: recordDateTime,
  15974. // Stage: 1,
  15975. // }
  15976. // service.CreateErrMsgLog(errlog)
  15977. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  15978. // return
  15979. // }
  15980. // }
  15981. //
  15982. //}
  15983. //func (c *HisApiController) GetUploadDiag() {
  15984. // id, _ := c.GetInt64("id")
  15985. // record_time := c.GetString("record_time")
  15986. //
  15987. // diagnosis_id, _ := c.GetInt64("diagnosis")
  15988. // sick_type, _ := c.GetInt64("sick_type")
  15989. // reg_type, _ := c.GetInt64("reg_type")
  15990. //
  15991. // timeLayout := "2006-01-02"
  15992. // loc, _ := time.LoadLocation("Local")
  15993. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  15994. // if err != nil {
  15995. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  15996. // return
  15997. // }
  15998. //
  15999. // var patientPrescription models.HisPrescriptionInfo
  16000. // recordDateTime := theTime.Unix()
  16001. // adminInfo := c.GetAdminUserInfo()
  16002. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16003. //
  16004. // if patientPrescription.ID == 0 {
  16005. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16006. // }
  16007. //
  16008. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  16009. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  16010. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16011. // sickConfig, _ := service.FindSickById(sick_type)
  16012. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  16013. //
  16014. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  16015. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  16016. // "&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 +
  16017. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  16018. // resp2, requestErr2 := http.Get(api2)
  16019. // if requestErr2 != nil {
  16020. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16021. // return
  16022. // }
  16023. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  16024. // if ioErr2 != nil {
  16025. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  16026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16027. // return
  16028. // }
  16029. // var respJSON2 map[string]interface{}
  16030. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  16031. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16032. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16033. // return
  16034. // }
  16035. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16036. // userJSONBytes2, _ := json.Marshal(respJSON2)
  16037. //
  16038. // var res2 ResultSix
  16039. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  16040. // utils.ErrorLog("解析失败:%v", err)
  16041. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16042. // return
  16043. // }
  16044. // if res2.Infcode != 0 {
  16045. // adminUser := c.GetAdminUserInfo()
  16046. // errlog := &models.HisOrderError{
  16047. // UserOrgId: adminUser.CurrentOrgId,
  16048. // Ctime: time.Now().Unix(),
  16049. // Mtime: time.Now().Unix(),
  16050. // ErrMsg: res2.ErrMsg,
  16051. // Status: 1,
  16052. // PatientId: id,
  16053. // RecordTime: recordDateTime,
  16054. // Stage: 3,
  16055. // }
  16056. // service.CreateErrMsgLog(errlog)
  16057. //
  16058. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  16059. // return
  16060. // }
  16061. //
  16062. // c.ServeSuccessJSON(map[string]interface{}{
  16063. // "msg": "上传成功",
  16064. // })
  16065. //
  16066. //}
  16067. type QueryResult struct {
  16068. ID int64
  16069. Name string
  16070. Code string
  16071. List_type_code string
  16072. }
  16073. func (c *HisApiController) GetCheckCode() {
  16074. ids_str := c.GetString("ids")
  16075. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  16076. ids_arr := strings.Split(ids_str, ",")
  16077. var queryResult []QueryResult
  16078. ids := make([]int64, 0)
  16079. for _, item := range ids_arr {
  16080. id, _ := strconv.ParseInt(item, 10, 64)
  16081. ids = append(ids, id)
  16082. }
  16083. if record_type == 1 {
  16084. drugs, _ := service.GetBatchDrugList(ids)
  16085. for _, item := range drugs {
  16086. result := QueryResult{
  16087. ID: item.ID,
  16088. Name: item.DrugName,
  16089. Code: item.MedicalInsuranceNumber,
  16090. List_type_code: "101",
  16091. }
  16092. queryResult = append(queryResult, result)
  16093. }
  16094. } else if record_type == 2 {
  16095. goods, _ := service.GetBatchGoodInformationList(ids)
  16096. for _, item := range goods {
  16097. result := QueryResult{
  16098. ID: item.ID,
  16099. Name: item.GoodName,
  16100. Code: item.MedicalInsuranceNumber,
  16101. List_type_code: "301",
  16102. }
  16103. queryResult = append(queryResult, result)
  16104. }
  16105. } else if record_type == 3 {
  16106. projects, _ := service.GetBathchMyPorjecgList(ids)
  16107. for _, item := range projects {
  16108. result := QueryResult{
  16109. ID: item.ID,
  16110. Name: item.ProjectName,
  16111. Code: item.MedicalCode,
  16112. List_type_code: "201",
  16113. }
  16114. queryResult = append(queryResult, result)
  16115. }
  16116. }
  16117. admin_user_id, _ := c.GetInt64("admin_user_id")
  16118. adminUser := c.GetAdminUserInfo()
  16119. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16120. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16121. var user_name string
  16122. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16123. if role.ID == 0 {
  16124. user_name = "xxx"
  16125. } else {
  16126. user_name = role.UserName
  16127. }
  16128. baseParams := &models.BaseParams{
  16129. SecretKey: miConfig.SecretKey,
  16130. FixmedinsCode: miConfig.Code,
  16131. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  16132. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  16133. OrgName: miConfig.OrgName,
  16134. Doctor: user_name,
  16135. }
  16136. if config.IsOpen == 1 {
  16137. for _, item := range queryResult {
  16138. var result string
  16139. if record_type == 1 {
  16140. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  16141. } else if record_type == 2 {
  16142. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  16143. } else if record_type == 3 {
  16144. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  16145. }
  16146. var dat map[string]interface{}
  16147. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16148. fmt.Println(dat)
  16149. } else {
  16150. fmt.Println(err)
  16151. }
  16152. userJSONBytes, _ := json.Marshal(dat)
  16153. var res ResultSix
  16154. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16155. utils.ErrorLog("解析失败:%v", err)
  16156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16157. return
  16158. }
  16159. if res.Infcode == 0 {
  16160. if record_type == 1 {
  16161. service.UpdateBaseDrugById(item.ID)
  16162. } else if record_type == 2 {
  16163. service.UpdateGoodInformaitonByDetail(item.ID)
  16164. } else if record_type == 3 {
  16165. service.UpdateProjectById(item.ID)
  16166. }
  16167. c.ServeSuccessJSON(map[string]interface{}{
  16168. "failed_code": 0,
  16169. "msg": "目录对照成功",
  16170. })
  16171. } else {
  16172. c.ServeSuccessJSON(map[string]interface{}{
  16173. "failed_code": -10,
  16174. "msg": res.ErrMsg,
  16175. })
  16176. }
  16177. }
  16178. }
  16179. }
  16180. func (c *HisApiController) UnCheckCode() {
  16181. ids_str := c.GetString("ids")
  16182. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  16183. admin_user_id, _ := c.GetInt64("admin_user_id")
  16184. ids_arr := strings.Split(ids_str, ",")
  16185. var queryResult []QueryResult
  16186. ids := make([]int64, 0)
  16187. for _, item := range ids_arr {
  16188. id, _ := strconv.ParseInt(item, 10, 64)
  16189. ids = append(ids, id)
  16190. }
  16191. if record_type == 1 {
  16192. drugs, _ := service.GetBatchDrugList(ids)
  16193. for _, item := range drugs {
  16194. result := QueryResult{
  16195. ID: item.ID,
  16196. Name: item.DrugName,
  16197. Code: item.MedicalInsuranceNumber,
  16198. List_type_code: "101",
  16199. }
  16200. queryResult = append(queryResult, result)
  16201. }
  16202. } else if record_type == 2 {
  16203. goods, _ := service.GetBatchGoodInformationList(ids)
  16204. for _, item := range goods {
  16205. result := QueryResult{
  16206. ID: item.ID,
  16207. Name: item.GoodName,
  16208. Code: item.MedicalInsuranceNumber,
  16209. List_type_code: "301",
  16210. }
  16211. queryResult = append(queryResult, result)
  16212. }
  16213. } else if record_type == 3 {
  16214. projects, _ := service.GetBathchMyPorjecgList(ids)
  16215. for _, item := range projects {
  16216. result := QueryResult{
  16217. ID: item.ID,
  16218. Name: item.ProjectName,
  16219. Code: item.MedicalCode,
  16220. List_type_code: "201",
  16221. }
  16222. queryResult = append(queryResult, result)
  16223. }
  16224. }
  16225. adminUser := c.GetAdminUserInfo()
  16226. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16227. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16228. var user_name string
  16229. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16230. if role.ID == 0 {
  16231. user_name = "xxx"
  16232. } else {
  16233. user_name = role.UserName
  16234. }
  16235. baseParams := &models.BaseParams{
  16236. SecretKey: miConfig.SecretKey,
  16237. FixmedinsCode: miConfig.Code,
  16238. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  16239. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  16240. OrgName: miConfig.OrgName,
  16241. Doctor: user_name,
  16242. }
  16243. if config.IsOpen == 1 {
  16244. for _, item := range queryResult {
  16245. var result string
  16246. if record_type == 1 {
  16247. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  16248. } else if record_type == 2 {
  16249. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  16250. } else if record_type == 3 {
  16251. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  16252. }
  16253. var dat2 map[string]interface{}
  16254. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  16255. fmt.Println(dat2)
  16256. } else {
  16257. fmt.Println(err)
  16258. }
  16259. userJSONBytes, _ := json.Marshal(dat2)
  16260. var res ResultSix
  16261. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16262. utils.ErrorLog("解析失败:%v", err)
  16263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16264. return
  16265. }
  16266. if res.Infcode == 0 {
  16267. if record_type == 1 {
  16268. service.UpdateDrugByIdDetail(item.ID)
  16269. } else if record_type == 2 {
  16270. service.UpdateGoodInfoById(item.ID)
  16271. } else if record_type == 3 {
  16272. service.UpdateMyProjectById(item.ID)
  16273. }
  16274. c.ServeSuccessJSON(map[string]interface{}{
  16275. "failed_code": 0,
  16276. "msg": "撤销目录对照成功",
  16277. })
  16278. } else {
  16279. c.ServeSuccessJSON(map[string]interface{}{
  16280. "failed_code": -10,
  16281. "msg": res.ErrMsg,
  16282. })
  16283. }
  16284. }
  16285. }
  16286. }
  16287. func (c *HisApiController) GetPatientInfo() {
  16288. id_card_no := c.GetString("id_card_no")
  16289. admin_user_id, _ := c.GetInt64("admin_user_id")
  16290. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  16291. if patient.ID == 0 {
  16292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  16293. return
  16294. }
  16295. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16296. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16297. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  16298. if config.IsOpen == 1 {
  16299. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  16300. var dat map[string]interface{}
  16301. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16302. fmt.Println(dat)
  16303. } else {
  16304. fmt.Println(err)
  16305. }
  16306. userJSONBytes, _ := json.Marshal(dat)
  16307. var res ResultTwo
  16308. var res10265 ResultTwo10265
  16309. if miConfig.Code == "H15049901371" {
  16310. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  16311. utils.ErrorLog("解析失败:%v", err)
  16312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16313. return
  16314. }
  16315. res.ErrMsg = res10265.ErrMsg
  16316. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16317. res.Infcode = infocode
  16318. res.Output = res10265.Output
  16319. res.InfRefmsgid = res10265.InfRefmsgid
  16320. } else {
  16321. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16322. utils.ErrorLog("解析失败:%v", err)
  16323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16324. return
  16325. }
  16326. }
  16327. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16328. // utils.ErrorLog("解析失败:%v", err)
  16329. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16330. // return
  16331. //}
  16332. for index, item := range res.Output.Iinfo {
  16333. if item.PsnInsuStas == "2" {
  16334. fmt.Println("--------")
  16335. res.Output.Iinfo[index].Insutype = "300"
  16336. res.Output.Iinfo[index].PsnInsuStas = "1"
  16337. }
  16338. }
  16339. fmt.Println(res.Output.Iinfo)
  16340. if res.Infcode != 0 {
  16341. c.ServeSuccessJSON(map[string]interface{}{
  16342. "failed_code": -10,
  16343. "msg": res.ErrMsg,
  16344. })
  16345. } else {
  16346. c.ServeSuccessJSON(map[string]interface{}{
  16347. "failed_code": 0,
  16348. "info": res,
  16349. })
  16350. }
  16351. }
  16352. }
  16353. func (c *HisApiController) PsnPutOnRecord() {
  16354. record_type, _ := c.GetInt64("type")
  16355. patient_id, _ := c.GetInt64("patient_id")
  16356. admin_user_id, _ := c.GetInt64("admin_user_id")
  16357. start_time := c.GetString("start_time")
  16358. end_time := c.GetString("end_time")
  16359. adminUser := c.GetAdminUserInfo()
  16360. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16361. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16362. var patients []*models.Patients
  16363. if record_type == 1 { //全部备案
  16364. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  16365. patients = append(patients, patient...)
  16366. } else { //单个备案
  16367. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  16368. patients = append(patients, patient)
  16369. }
  16370. var user_name string
  16371. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16372. if role.ID == 0 {
  16373. user_name = "xxx"
  16374. } else {
  16375. user_name = role.UserName
  16376. }
  16377. if config.IsOpen == 1 {
  16378. for _, item := range patients {
  16379. 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
  16380. resp, requestErr := http.Get(api)
  16381. if requestErr != nil {
  16382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16383. return
  16384. }
  16385. defer resp.Body.Close()
  16386. body, ioErr := ioutil.ReadAll(resp.Body)
  16387. if ioErr != nil {
  16388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16390. return
  16391. }
  16392. var respJSON map[string]interface{}
  16393. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16396. return
  16397. }
  16398. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16399. userJSONBytes, _ := json.Marshal(userJSON)
  16400. var res ResultTwo
  16401. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16402. utils.ErrorLog("解析失败:%v", err)
  16403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16404. return
  16405. }
  16406. if res.Infcode == 0 {
  16407. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  16408. var dat map[string]interface{}
  16409. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16410. fmt.Println(dat)
  16411. } else {
  16412. fmt.Println(err)
  16413. }
  16414. userJSONBytes, _ := json.Marshal(dat)
  16415. var res2 ResultThirteen
  16416. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16417. utils.ErrorLog("解析失败:%v", err)
  16418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16419. return
  16420. }
  16421. if res2.Infcode == 0 {
  16422. psnResult := &models.GdybPsnRecord{
  16423. UserOrgId: adminUser.CurrentOrgId,
  16424. PatientId: item.ID,
  16425. PsnNo: res.Output.Baseinfo.PsnNo,
  16426. Ctime: time.Now().Unix(),
  16427. Mtime: time.Now().Unix(),
  16428. Status: 1,
  16429. IsCancel: 1,
  16430. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  16431. }
  16432. service.CreatePsnRecord(psnResult)
  16433. } else {
  16434. c.ServeSuccessJSON(map[string]interface{}{
  16435. "failed_code": -10,
  16436. "msg": res2.ErrMsg,
  16437. })
  16438. return
  16439. }
  16440. }
  16441. }
  16442. }
  16443. }
  16444. func (c *HisApiController) PsnUnPutOnRecord() {
  16445. id, _ := c.GetInt64("id")
  16446. //record_type, _ := c.GetInt64("type")
  16447. admin_user_id, _ := c.GetInt64("admin_user_id")
  16448. adminUser := c.GetAdminUserInfo()
  16449. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16450. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16451. var user_name string
  16452. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16453. if role.ID == 0 {
  16454. user_name = "xxx"
  16455. } else {
  16456. user_name = role.UserName
  16457. }
  16458. psn_record, _ := service.GetPsnRecordById(id)
  16459. if psn_record.ID == 0 {
  16460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  16461. return
  16462. }
  16463. if config.IsOpen == 1 {
  16464. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  16465. var dat map[string]interface{}
  16466. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16467. fmt.Println(dat)
  16468. } else {
  16469. fmt.Println(err)
  16470. }
  16471. userJSONBytes, _ := json.Marshal(dat)
  16472. var res ResultFourteen
  16473. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16474. utils.ErrorLog("解析失败:%v", err)
  16475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16476. return
  16477. }
  16478. if res.Infcode == 0 {
  16479. psn_record.IsCancel = 2
  16480. service.CreatePsnRecord(&psn_record)
  16481. } else {
  16482. c.ServeSuccessJSON(map[string]interface{}{
  16483. "failed_code": -10,
  16484. "msg": res.ErrMsg,
  16485. })
  16486. return
  16487. }
  16488. }
  16489. }
  16490. func (c *HisApiController) PsnPutNCDSOnRecord() {
  16491. patient_id, _ := c.GetInt64("patient_id")
  16492. insutype_two := c.GetString("insutype")
  16493. psn_no := c.GetString("psn_no")
  16494. doctor_id, _ := c.GetInt64("doctor_id")
  16495. sick_id, _ := c.GetInt64("sick_id")
  16496. department_id, _ := c.GetInt64("department_id")
  16497. start_time := c.GetString("start_time")
  16498. end_time := c.GetString("end_time")
  16499. check_time := c.GetString("check_time")
  16500. hospital_code := c.GetString("hospital_code")
  16501. hospital_name := c.GetString("hospital_name")
  16502. adminUser := c.GetAdminUserInfo()
  16503. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  16504. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16505. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16506. sick, _ := service.FindSickById(sick_id)
  16507. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  16508. if len(hospital_code) == 0 {
  16509. hospital_code = miConfig.Code
  16510. }
  16511. if len(hospital_name) == 0 {
  16512. hospital_name = miConfig.OrgName
  16513. }
  16514. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  16515. var res ResultTwo
  16516. var res10265 ResultTwo10265
  16517. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16518. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  16519. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  16520. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  16521. "&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
  16522. resp, requestErr := http.Get(api)
  16523. if requestErr != nil {
  16524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16525. return
  16526. }
  16527. body, ioErr := ioutil.ReadAll(resp.Body)
  16528. if ioErr != nil {
  16529. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16531. return
  16532. }
  16533. var respJSON map[string]interface{}
  16534. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16535. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16537. return
  16538. }
  16539. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16540. result, _ := json.Marshal(respJSON)
  16541. fmt.Println("log")
  16542. fmt.Println(string(result))
  16543. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16544. utils.ErrorLog("解析失败:%v", err)
  16545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16546. return
  16547. }
  16548. res.ErrMsg = res10265.ErrMsg
  16549. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16550. res.Infcode = infocode
  16551. res.Output = res10265.Output
  16552. res.InfRefmsgid = res10265.InfRefmsgid
  16553. } else {
  16554. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  16555. if miConfig.Code == "H15049901371" {
  16556. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16557. utils.ErrorLog("解析失败:%v", err)
  16558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16559. return
  16560. }
  16561. res.ErrMsg = res10265.ErrMsg
  16562. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16563. res.Infcode = infocode
  16564. res.Output = res10265.Output
  16565. res.InfRefmsgid = res10265.InfRefmsgid
  16566. } else {
  16567. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16568. utils.ErrorLog("解析失败:%v", err)
  16569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16570. return
  16571. }
  16572. }
  16573. }
  16574. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16575. infoStr := string(Iinfos)
  16576. var rf []*ResultFive
  16577. json.Unmarshal([]byte(infoStr), &rf)
  16578. var insuplc_admdvs string
  16579. var insutype string
  16580. var is390 int = 0
  16581. var is310 int = 0
  16582. var insutypes []*ResultFive
  16583. for _, item := range rf {
  16584. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16585. insutypes = append(insutypes, item)
  16586. }
  16587. }
  16588. if len(insutypes) == 1 {
  16589. insutype = insutypes[0].Insutype
  16590. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16591. } else {
  16592. for _, i := range insutypes {
  16593. if i.Insutype == "390" {
  16594. is390 = 1
  16595. }
  16596. if i.Insutype == "310" {
  16597. is310 = 1
  16598. }
  16599. }
  16600. }
  16601. if is390 == 1 {
  16602. insutype = "390"
  16603. }
  16604. if is310 == 1 {
  16605. insutype = "310"
  16606. }
  16607. if len(insutypes) == 2 {
  16608. insutype = insutype_two
  16609. }
  16610. if len(insutypes) == 0 {
  16611. insutype = "310"
  16612. }
  16613. insutype = insutype_two
  16614. fmt.Println(insutype)
  16615. for _, item := range rf {
  16616. fmt.Println(item.Insutype)
  16617. fmt.Println(insutype)
  16618. if item.Insutype == insutype {
  16619. fmt.Println(item.Insutype)
  16620. fmt.Println(insutype)
  16621. insuplc_admdvs = item.InsuplcAdmdvs
  16622. }
  16623. }
  16624. fmt.Println(insuplc_admdvs)
  16625. var res2 ResultThirteen
  16626. var res10265_2 ResultThirteen10265
  16627. if config.IsOpen == 1 {
  16628. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16629. } else {
  16630. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time, hospital_code, hospital_name)
  16631. var dat map[string]interface{}
  16632. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16633. fmt.Println(dat)
  16634. } else {
  16635. fmt.Println(err)
  16636. }
  16637. userJSONBytes, _ := json.Marshal(dat)
  16638. if miConfig.Code == "H15049901371" {
  16639. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  16640. utils.ErrorLog("解析失败:%v", err)
  16641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16642. return
  16643. }
  16644. res2.ErrMsg = res10265_2.ErrMsg
  16645. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  16646. res2.Infcode = infocode
  16647. res2.Output = res10265_2.Output
  16648. res2.InfRefmsgid = res10265_2.InfRefmsgid
  16649. } else {
  16650. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16651. utils.ErrorLog("解析失败:%v", err)
  16652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16653. return
  16654. }
  16655. }
  16656. }
  16657. if res2.Infcode == 0 {
  16658. psnResult := &models.GdybPsnNcdsRecord{
  16659. UserOrgId: adminUser.CurrentOrgId,
  16660. PatientId: patient.ID,
  16661. PsnNo: psn_no,
  16662. DoctorId: doctor.AdminUserId,
  16663. DepartmentId: department_id,
  16664. SickType: sick_id,
  16665. Insutype: insutype,
  16666. Ctime: time.Now().Unix(),
  16667. Mtime: time.Now().Unix(),
  16668. Status: 1,
  16669. IsCancel: 1,
  16670. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  16671. }
  16672. service.CreatePsnNCDSRecord(psnResult)
  16673. c.ServeSuccessJSON(map[string]interface{}{
  16674. "failed_code": 0,
  16675. "msg": "备案成功",
  16676. "result": psnResult,
  16677. })
  16678. } else {
  16679. c.ServeSuccessJSON(map[string]interface{}{
  16680. "failed_code": -10,
  16681. "msg": res2.ErrMsg,
  16682. })
  16683. return
  16684. }
  16685. }
  16686. }
  16687. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  16688. id, _ := c.GetInt64("id")
  16689. admin_user_id, _ := c.GetInt64("admin_user_id")
  16690. adminUser := c.GetAdminUserInfo()
  16691. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16692. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16693. //config, _ := service.Ge(adminUser.CurrentOrgId)
  16694. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  16695. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16696. //var user_name string
  16697. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16698. //if role.ID == 0 {
  16699. // user_name = "xxx"
  16700. //} else {
  16701. // user_name = role.UserName
  16702. //}
  16703. psn_record, _ := service.GetPsnNCDSRecordById(id)
  16704. if psn_record.ID == 0 {
  16705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  16706. return
  16707. }
  16708. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  16709. var res ResultTwo
  16710. var res10265 ResultTwo10265
  16711. if miConfig.Code == "H15049901371" {
  16712. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16713. utils.ErrorLog("解析失败:%v", err)
  16714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16715. return
  16716. }
  16717. res.ErrMsg = res10265.ErrMsg
  16718. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16719. res.Infcode = infocode
  16720. res.Output = res10265.Output
  16721. res.InfRefmsgid = res10265.InfRefmsgid
  16722. } else {
  16723. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16724. utils.ErrorLog("解析失败:%v", err)
  16725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16726. return
  16727. }
  16728. }
  16729. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16730. infoStr := string(Iinfos)
  16731. var rf []*ResultFive
  16732. json.Unmarshal([]byte(infoStr), &rf)
  16733. var insuplc_admdvs string
  16734. var insutype string
  16735. var is390 int = 0
  16736. var is310 int = 0
  16737. var insutypes []*ResultFive
  16738. for _, item := range rf {
  16739. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16740. insutypes = append(insutypes, item)
  16741. }
  16742. }
  16743. if len(insutypes) == 1 {
  16744. insutype = insutypes[0].Insutype
  16745. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16746. } else {
  16747. for _, i := range insutypes {
  16748. if i.Insutype == "390" {
  16749. is390 = 1
  16750. }
  16751. if i.Insutype == "310" {
  16752. is310 = 1
  16753. }
  16754. }
  16755. }
  16756. if is390 == 1 {
  16757. insutype = "390"
  16758. }
  16759. if is310 == 1 {
  16760. insutype = "310"
  16761. }
  16762. if len(insutypes) == 0 {
  16763. insutype = "310"
  16764. }
  16765. insutype = psn_record.Insutype
  16766. for _, item := range rf {
  16767. if item.Insutype == insutype {
  16768. insuplc_admdvs = item.InsuplcAdmdvs
  16769. }
  16770. }
  16771. if config.IsOpen == 1 {
  16772. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  16773. var dat map[string]interface{}
  16774. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16775. fmt.Println(dat)
  16776. } else {
  16777. fmt.Println(err)
  16778. }
  16779. userJSONBytes, _ := json.Marshal(dat)
  16780. var res ResultFourteen
  16781. var res10265 ResultFourteen10265
  16782. if miConfig.Code == "H15049901371" {
  16783. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  16784. utils.ErrorLog("解析失败:%v", err)
  16785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16786. return
  16787. }
  16788. res.ErrMsg = res10265.ErrMsg
  16789. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16790. res.Infcode = infocode
  16791. res.Output = res10265.Output
  16792. res.InfRefmsgid = res10265.InfRefmsgid
  16793. } else {
  16794. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16795. utils.ErrorLog("解析失败:%v", err)
  16796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16797. return
  16798. }
  16799. }
  16800. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16801. // utils.ErrorLog("解析失败:%v", err)
  16802. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16803. // return
  16804. //}
  16805. if res.Infcode == 0 {
  16806. psn_record.IsCancel = 2
  16807. service.CreatePsnNCDSRecord(&psn_record)
  16808. c.ServeSuccessJSON(map[string]interface{}{
  16809. "failed_code": 0,
  16810. "msg": "撤销备案成功",
  16811. })
  16812. } else {
  16813. c.ServeSuccessJSON(map[string]interface{}{
  16814. "failed_code": -10,
  16815. "msg": res.ErrMsg,
  16816. })
  16817. return
  16818. }
  16819. }
  16820. }
  16821. func (c *HisApiController) TestTest() {
  16822. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  16823. fmt.Println(patient.Iinfo)
  16824. }
  16825. type CustomData struct {
  16826. MsgId string
  16827. PsnNo string
  16828. Info string
  16829. }
  16830. func (c *HisApiController) ReversalData() {
  16831. var customData []*CustomData
  16832. custom := &CustomData{
  16833. MsgId: "H44022900158202103301714472004",
  16834. PsnNo: "44020000001101329945",
  16835. Info: "2207",
  16836. }
  16837. customData = append(customData, custom)
  16838. custom1 := &CustomData{
  16839. MsgId: "H4402290015820210330172057803",
  16840. PsnNo: "44020000001101161813",
  16841. Info: "2207",
  16842. }
  16843. customData = append(customData, custom1)
  16844. custom2 := &CustomData{
  16845. MsgId: "H44022900158202103301705198813",
  16846. PsnNo: "44190000133097375417",
  16847. Info: "2207",
  16848. }
  16849. customData = append(customData, custom2)
  16850. custom3 := &CustomData{
  16851. MsgId: "H44022900158202103301715524756",
  16852. PsnNo: "44020000001100187221",
  16853. Info: "2207",
  16854. }
  16855. customData = append(customData, custom3)
  16856. custom4 := &CustomData{
  16857. MsgId: "H44022900158202103301730376224",
  16858. PsnNo: "44020000001101959155",
  16859. Info: "2207",
  16860. }
  16861. customData = append(customData, custom4)
  16862. custom5 := &CustomData{
  16863. MsgId: "H44022900158202103301748008725",
  16864. PsnNo: "44020000001104246641",
  16865. Info: "2207",
  16866. }
  16867. customData = append(customData, custom5)
  16868. custom6 := &CustomData{
  16869. MsgId: "H44022900158202103301718096755",
  16870. PsnNo: "44020000001102211860",
  16871. Info: "2207",
  16872. }
  16873. customData = append(customData, custom6)
  16874. custom7 := &CustomData{
  16875. MsgId: "H44022900158202103301736551640",
  16876. PsnNo: "44020000001102687718",
  16877. Info: "2207",
  16878. }
  16879. customData = append(customData, custom7)
  16880. custom8 := &CustomData{
  16881. MsgId: "H44022900158202103301743097676",
  16882. PsnNo: "44020000001102127785",
  16883. Info: "2207",
  16884. }
  16885. customData = append(customData, custom8)
  16886. custom9 := &CustomData{
  16887. MsgId: "H44022900158202103301712304203",
  16888. PsnNo: "44020000001101518097",
  16889. Info: "2207",
  16890. }
  16891. customData = append(customData, custom9)
  16892. custom10 := &CustomData{
  16893. MsgId: "H44022900158202103301738448785",
  16894. PsnNo: "44020000001100500813",
  16895. Info: "2207",
  16896. }
  16897. customData = append(customData, custom10)
  16898. custom11 := &CustomData{
  16899. MsgId: "H44022900158202103301732455843",
  16900. PsnNo: "44020000001102690557",
  16901. Info: "2207",
  16902. }
  16903. customData = append(customData, custom11)
  16904. custom12 := &CustomData{
  16905. MsgId: "H44022900158202103301745421708",
  16906. PsnNo: "44020000001102211928",
  16907. Info: "2207",
  16908. }
  16909. customData = append(customData, custom12)
  16910. custom1212 := &CustomData{
  16911. MsgId: "H440229001582021033017351627",
  16912. PsnNo: "44020000001102481733",
  16913. Info: "2207",
  16914. }
  16915. customData = append(customData, custom1212)
  16916. custom13 := &CustomData{
  16917. MsgId: "H44022900158202103301740327951",
  16918. PsnNo: "44020000001103174866",
  16919. Info: "2207",
  16920. }
  16921. customData = append(customData, custom13)
  16922. custom14 := &CustomData{
  16923. MsgId: "H4402290015820210330174922668",
  16924. PsnNo: "44020000001102927272",
  16925. Info: "2207",
  16926. }
  16927. customData = append(customData, custom14)
  16928. custom15 := &CustomData{
  16929. MsgId: "H44022900158202103301752362273",
  16930. PsnNo: "44020000001102942890",
  16931. Info: "2207",
  16932. }
  16933. customData = append(customData, custom15)
  16934. custom16 := &CustomData{
  16935. MsgId: "H44022900158202103301751082917",
  16936. PsnNo: "44020000001101662162",
  16937. Info: "2207",
  16938. }
  16939. customData = append(customData, custom16)
  16940. custom17 := &CustomData{
  16941. MsgId: "H44022900158202103301754147728",
  16942. PsnNo: "44020000000229014511",
  16943. Info: "2207",
  16944. }
  16945. customData = append(customData, custom17)
  16946. adminUser := c.GetAdminUserInfo()
  16947. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16948. for _, item := range customData {
  16949. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  16950. fmt.Println(result)
  16951. }
  16952. }
  16953. func (c *HisApiController) GetAllopatry() {
  16954. year := c.GetString("year")
  16955. month := c.GetString("month")
  16956. admin_user_id, _ := c.GetInt64("admin_user_id")
  16957. adminUser := c.GetAdminUserInfo()
  16958. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16959. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16960. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  16961. var dat map[string]interface{}
  16962. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16963. fmt.Println(dat)
  16964. } else {
  16965. fmt.Println(err)
  16966. }
  16967. userJSONBytes, _ := json.Marshal(dat)
  16968. var res models.Result9001
  16969. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16970. utils.ErrorLog("解析失败:%v", err)
  16971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16972. return
  16973. }
  16974. fmt.Println(res.Output.Signinoutb)
  16975. fmt.Println(res.Output.Signinoutb.SignNo)
  16976. fmt.Println(string(userJSONBytes))
  16977. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  16978. var dat3 map[string]interface{}
  16979. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  16980. fmt.Println(dat3)
  16981. } else {
  16982. fmt.Println(err)
  16983. }
  16984. userJSONBytes3, _ := json.Marshal(dat3)
  16985. var res3 models.Result3260
  16986. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  16987. utils.ErrorLog("解析失败:%v", err)
  16988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16989. return
  16990. }
  16991. var curpage int
  16992. var pagesize int = 100
  16993. var start int = 1
  16994. //var stop int
  16995. //pagecount := 10
  16996. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  16997. for curpage = 1; curpage <= pagecount; curpage++ {
  16998. if curpage == 1 {
  16999. start = 0
  17000. } else {
  17001. start = (curpage-1)*pagesize + 1
  17002. }
  17003. //stop = curpage * pagesize
  17004. //if stop > int(res3.Output.Totalrow) {
  17005. // stop =int(res3.Output.Totalrow)
  17006. //}
  17007. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  17008. var dat2 map[string]interface{}
  17009. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  17010. fmt.Println(dat)
  17011. } else {
  17012. fmt.Println(err)
  17013. }
  17014. userJSONBytes2, _ := json.Marshal(dat2)
  17015. var res2 models.Result3260
  17016. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  17017. utils.ErrorLog("解析失败:%v", err)
  17018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17019. return
  17020. }
  17021. //if res2.Infcode == 0 {
  17022. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  17023. // //var dat2 map[string]interface{}
  17024. // //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  17025. // // fmt.Println(dat)
  17026. // //} else {
  17027. // // fmt.Println(err)
  17028. // //}
  17029. // //c.ServeSuccessJSON(map[string]interface{}{
  17030. // // "list": res2.Output.Data,
  17031. // //})
  17032. // //return
  17033. //}
  17034. }
  17035. }
  17036. func (c *HisApiController) ComfirmAllopatry() {
  17037. year := c.GetString("year")
  17038. month := c.GetString("month")
  17039. admin_user_id, _ := c.GetInt64("admin_user_id")
  17040. adminUser := c.GetAdminUserInfo()
  17041. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17042. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17043. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  17044. var dat map[string]interface{}
  17045. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17046. fmt.Println(dat)
  17047. } else {
  17048. fmt.Println(err)
  17049. }
  17050. userJSONBytes, _ := json.Marshal(dat)
  17051. var res models.Result9001
  17052. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17053. utils.ErrorLog("解析失败:%v", err)
  17054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17055. return
  17056. }
  17057. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  17058. var dat2 map[string]interface{}
  17059. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  17060. fmt.Println(dat)
  17061. } else {
  17062. fmt.Println(err)
  17063. }
  17064. userJSONBytes2, _ := json.Marshal(dat2)
  17065. var res2 models.Result3260
  17066. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  17067. utils.ErrorLog("解析失败:%v", err)
  17068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17069. return
  17070. }
  17071. //if res2.Infcode == 0 {
  17072. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  17073. // var dat map[string]interface{}
  17074. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17075. // fmt.Println(dat)
  17076. // } else {
  17077. // fmt.Println(err)
  17078. // }
  17079. // userJSONBytes, _ := json.Marshal(dat)
  17080. // var res3 models.Result3261
  17081. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  17082. // utils.ErrorLog("解析失败:%v", err)
  17083. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17084. // return
  17085. // }
  17086. //
  17087. // if res3.Infcode == 0 {
  17088. // record := &models.HisYidiClearRecord{
  17089. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17090. // Ctime: time.Now().Unix(),
  17091. // Mtime: time.Now().Unix(),
  17092. // Status: 1,
  17093. // MsgId: msgId,
  17094. // }
  17095. // service.SaveClearRecord(record)
  17096. // c.ServeSuccessJSON(map[string]interface{}{
  17097. // "msg": "提取成功",
  17098. // })
  17099. // }
  17100. //}
  17101. }
  17102. func (c *HisApiController) RefundAllopatry() {
  17103. year := c.GetString("year")
  17104. month := c.GetString("month")
  17105. //id, _ := c.GetInt64("id")
  17106. admin_user_id, _ := c.GetInt64("admin_user_id")
  17107. adminUser := c.GetAdminUserInfo()
  17108. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17109. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17110. //record, _ := service.GetClearRecordById(id)
  17111. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  17112. var dat map[string]interface{}
  17113. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  17114. fmt.Println(dat)
  17115. } else {
  17116. fmt.Println(err)
  17117. }
  17118. userJSONBytes, _ := json.Marshal(dat)
  17119. var res models.Result9001
  17120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17121. utils.ErrorLog("解析失败:%v", err)
  17122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17123. return
  17124. }
  17125. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  17126. var dat2 map[string]interface{}
  17127. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  17128. fmt.Println(dat)
  17129. } else {
  17130. fmt.Println(err)
  17131. }
  17132. userJSONBytes2, _ := json.Marshal(dat2)
  17133. var empty ResultFourteen
  17134. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  17135. utils.ErrorLog("解析失败:%v", err)
  17136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17137. return
  17138. }
  17139. if empty.Infcode == 0 {
  17140. c.ServeSuccessJSON(map[string]interface{}{
  17141. "msg": "撤销成功",
  17142. })
  17143. return
  17144. }
  17145. }
  17146. func (c *HisApiController) ReversalOtherData() {
  17147. var customData []*CustomData
  17148. custom := &CustomData{
  17149. MsgId: "H44022900158202103301714472004",
  17150. PsnNo: "44020000001101329945",
  17151. Info: "2208",
  17152. }
  17153. customData = append(customData, custom)
  17154. custom1 := &CustomData{
  17155. MsgId: "H4402290015820210330172057803",
  17156. PsnNo: "44020000001101161813",
  17157. Info: "2208",
  17158. }
  17159. customData = append(customData, custom1)
  17160. custom2 := &CustomData{
  17161. MsgId: "H44022900158202103301705198813",
  17162. PsnNo: "44190000133097375417",
  17163. Info: "2208",
  17164. }
  17165. customData = append(customData, custom2)
  17166. custom3 := &CustomData{
  17167. MsgId: "H44022900158202103301715524756",
  17168. PsnNo: "44020000001100187221",
  17169. Info: "2208",
  17170. }
  17171. customData = append(customData, custom3)
  17172. custom4 := &CustomData{
  17173. MsgId: "H44022900158202103301730376224",
  17174. PsnNo: "44020000001101959155",
  17175. Info: "2208",
  17176. }
  17177. customData = append(customData, custom4)
  17178. custom5 := &CustomData{
  17179. MsgId: "H44022900158202103301748008725",
  17180. PsnNo: "44020000001104246641",
  17181. Info: "2208",
  17182. }
  17183. customData = append(customData, custom5)
  17184. custom6 := &CustomData{
  17185. MsgId: "H44022900158202103301718096755",
  17186. PsnNo: "44020000001102211860",
  17187. Info: "2208",
  17188. }
  17189. customData = append(customData, custom6)
  17190. custom7 := &CustomData{
  17191. MsgId: "H44022900158202103301736551640",
  17192. PsnNo: "44020000001102687718",
  17193. Info: "2208",
  17194. }
  17195. customData = append(customData, custom7)
  17196. custom8 := &CustomData{
  17197. MsgId: "H44022900158202103301743097676",
  17198. PsnNo: "44020000001102127785",
  17199. Info: "2208",
  17200. }
  17201. customData = append(customData, custom8)
  17202. custom9 := &CustomData{
  17203. MsgId: "H44022900158202103301712304203",
  17204. PsnNo: "44020000001101518097",
  17205. Info: "2208",
  17206. }
  17207. customData = append(customData, custom9)
  17208. custom10 := &CustomData{
  17209. MsgId: "H44022900158202103301738448785",
  17210. PsnNo: "44020000001100500813",
  17211. Info: "2208",
  17212. }
  17213. customData = append(customData, custom10)
  17214. custom11 := &CustomData{
  17215. MsgId: "H44022900158202103301732455843",
  17216. PsnNo: "44020000001102690557",
  17217. Info: "2208",
  17218. }
  17219. customData = append(customData, custom11)
  17220. custom12 := &CustomData{
  17221. MsgId: "H44022900158202103301745421708",
  17222. PsnNo: "44020000001102211928",
  17223. Info: "2208",
  17224. }
  17225. customData = append(customData, custom12)
  17226. custom1212 := &CustomData{
  17227. MsgId: "H440229001582021033017351627",
  17228. PsnNo: "44020000001102481733",
  17229. Info: "2208",
  17230. }
  17231. customData = append(customData, custom1212)
  17232. custom13 := &CustomData{
  17233. MsgId: "H44022900158202103301740327951",
  17234. PsnNo: "44020000001103174866",
  17235. Info: "2208",
  17236. }
  17237. customData = append(customData, custom13)
  17238. custom14 := &CustomData{
  17239. MsgId: "H4402290015820210330174922668",
  17240. PsnNo: "44020000001102927272",
  17241. Info: "2208",
  17242. }
  17243. customData = append(customData, custom14)
  17244. custom15 := &CustomData{
  17245. MsgId: "H44022900158202103301752362273",
  17246. PsnNo: "44020000001102942890",
  17247. Info: "2208",
  17248. }
  17249. customData = append(customData, custom15)
  17250. custom16 := &CustomData{
  17251. MsgId: "H44022900158202103301751082917",
  17252. PsnNo: "44020000001101662162",
  17253. Info: "2208",
  17254. }
  17255. customData = append(customData, custom16)
  17256. custom17 := &CustomData{
  17257. MsgId: "H44022900158202103301754147728",
  17258. PsnNo: "44020000000229014511",
  17259. Info: "2208",
  17260. }
  17261. customData = append(customData, custom17)
  17262. adminUser := c.GetAdminUserInfo()
  17263. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17264. for _, item := range customData {
  17265. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  17266. fmt.Println(result)
  17267. }
  17268. }
  17269. func PathExists(path string) (bool, error) {
  17270. _, err := os.Stat(path)
  17271. if err == nil {
  17272. return true, nil
  17273. }
  17274. if os.IsNotExist(err) {
  17275. return false, nil
  17276. }
  17277. return false, err
  17278. }
  17279. // 创建文件夹
  17280. func Mkdir(dir string) {
  17281. // 创建文件夹
  17282. exist, err := PathExists(dir)
  17283. if err != nil {
  17284. fmt.Println(err.Error())
  17285. } else {
  17286. if exist {
  17287. fmt.Println(dir + "文件夹已存在!")
  17288. } else {
  17289. // 文件夹名称,权限
  17290. err := os.Mkdir(dir, os.ModePerm)
  17291. if err != nil {
  17292. fmt.Println(dir+"文件夹创建失败:", err.Error())
  17293. } else {
  17294. fmt.Println(dir + "文件夹创建成功!")
  17295. }
  17296. }
  17297. }
  17298. }
  17299. // 压缩文件
  17300. func Zip(srcFile string, destZip string) error {
  17301. zipfile, err := os.Create(destZip)
  17302. if err != nil {
  17303. return err
  17304. }
  17305. defer zipfile.Close()
  17306. archive := zip.NewWriter(zipfile)
  17307. defer archive.Close()
  17308. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  17309. if err != nil {
  17310. return err
  17311. }
  17312. header, err := zip.FileInfoHeader(info)
  17313. if err != nil {
  17314. return err
  17315. }
  17316. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  17317. // header.Name = path
  17318. if info.IsDir() {
  17319. header.Name += "/"
  17320. } else {
  17321. header.Method = zip.Deflate
  17322. }
  17323. writer, err := archive.CreateHeader(header)
  17324. if err != nil {
  17325. return err
  17326. }
  17327. if !info.IsDir() {
  17328. file, err := os.Open(path)
  17329. if err != nil {
  17330. return err
  17331. }
  17332. defer file.Close()
  17333. _, err = io.Copy(writer, file)
  17334. }
  17335. return err
  17336. })
  17337. return err
  17338. }
  17339. func ReadFile(filePath string) []byte {
  17340. f, err := os.Open(filePath)
  17341. if err != nil {
  17342. fmt.Println("read file fail", err)
  17343. return nil
  17344. }
  17345. defer f.Close()
  17346. fd, err := ioutil.ReadAll(f)
  17347. if err != nil {
  17348. fmt.Println("read to fd fail", err)
  17349. return nil
  17350. }
  17351. return fd
  17352. }
  17353. func saveLog(result string, request string, infno string, desc string) {
  17354. org_id, _ := beego.AppConfig.Int64("org_id")
  17355. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17356. dir := miConfig.OrgName + "日志"
  17357. utils.Mkdir(dir)
  17358. month := time.Unix(1557042972, 0).Format("1")
  17359. year := time.Now().Format("2006")
  17360. month = time.Now().Format("01")
  17361. day := time.Now().Format("02")
  17362. hour := time.Now().Format("15")
  17363. min := time.Now().Format("04")
  17364. sec := time.Now().Format("05")
  17365. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  17366. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  17367. file_name := file + ".txt"
  17368. file_path := miConfig.OrgName + "日志" + "/" + file_name
  17369. exist, _ := utils.PathExists(file_path)
  17370. if exist { //存在
  17371. fmt.Println("存在")
  17372. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  17373. if err != nil {
  17374. fmt.Println("read fail")
  17375. }
  17376. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  17377. n, _ := f.Seek(0, 2)
  17378. _, err = f.WriteAt([]byte(content), n)
  17379. } else { //不存在
  17380. fmt.Println("文件不存在,创建文件")
  17381. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  17382. defer f.Close()
  17383. if err != nil {
  17384. } else {
  17385. _, err = f.Write([]byte("记录日志"))
  17386. }
  17387. }
  17388. }
  17389. type Charset string
  17390. const (
  17391. UTF8 = Charset("UTF-8")
  17392. GB18030 = Charset("GB18030")
  17393. )
  17394. func ConvertToString(src string, srcCode string, tagCode string) string {
  17395. srcCoder := mahonia.NewDecoder(srcCode)
  17396. srcResult := srcCoder.ConvertString(src)
  17397. tagCoder := mahonia.NewDecoder(tagCode)
  17398. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  17399. result := string(cdata)
  17400. return result
  17401. }
  17402. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  17403. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  17404. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17405. var token string
  17406. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17407. var api string
  17408. if miConfig.MdtrtareaAdmvs == "320921" {
  17409. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  17410. "&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
  17411. fmt.Println(api)
  17412. } else {
  17413. 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 +
  17414. "&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
  17415. }
  17416. resp, requestErr := http.Get(api)
  17417. if requestErr != nil {
  17418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17419. return ""
  17420. }
  17421. body, ioErr := ioutil.ReadAll(resp.Body)
  17422. if ioErr != nil {
  17423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17425. return ""
  17426. }
  17427. var respJSON map[string]interface{}
  17428. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17431. return ""
  17432. }
  17433. var status string
  17434. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17435. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17436. var res ResultTwo //1101结果
  17437. var res10265 ResultTwo10265 //1101结果
  17438. if status == "0" { //读卡成功
  17439. var card_info string //卡信息
  17440. var busi_card_info string
  17441. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17442. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17443. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17444. fmt.Println(card_info)
  17445. fmt.Println(busi_card_info)
  17446. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17447. result, _ := json.Marshal(respJSON)
  17448. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17449. utils.ErrorLog("解析失败:%v", err)
  17450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17451. return ""
  17452. }
  17453. res.ErrMsg = res10265.ErrMsg
  17454. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17455. res.Infcode = infocode
  17456. res.Output = res10265.Output
  17457. res.InfRefmsgid = res10265.InfRefmsgid
  17458. if res.Infcode == 0 {
  17459. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17460. if err == gorm.ErrRecordNotFound {
  17461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17462. return ""
  17463. } else if err != nil {
  17464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17465. return ""
  17466. } else {
  17467. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17468. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17469. infoStr := string(Iinfos)
  17470. idetinfoStr := string(Idetinfos)
  17471. psn := &models.HisPsn{
  17472. PsnNo: res.Output.Baseinfo.PsnNo,
  17473. Age: res.Output.Baseinfo.Age,
  17474. PatientId: patient.ID,
  17475. Certno: res.Output.Baseinfo.Certno,
  17476. Brdy: res.Output.Baseinfo.Brdy,
  17477. Gend: res.Output.Baseinfo.Gend,
  17478. Naty: res.Output.Baseinfo.Naty,
  17479. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17480. PsnName: res.Output.Baseinfo.PsnName,
  17481. Idetinfo: idetinfoStr,
  17482. Insuinfo: infoStr,
  17483. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17484. CardInfo: card_info,
  17485. VerifyNumber: token,
  17486. }
  17487. service.CreateHisPsn(psn)
  17488. return token
  17489. }
  17490. }
  17491. } else {
  17492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17493. return ""
  17494. }
  17495. } else { //读卡失败
  17496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17497. return ""
  17498. }
  17499. return token
  17500. }
  17501. func DeleteExtraSpaceTwo(s string) string {
  17502. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  17503. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  17504. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  17505. reg, _ := regexp.Compile(regstr) //编译正则表达式
  17506. s2 := make([]byte, len(s1)) //定义字符数组切片
  17507. copy(s2, s1) //将字符串复制到切片
  17508. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  17509. for len(spc_index) > 0 { //找到适配项
  17510. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  17511. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  17512. }
  17513. return string(s2)
  17514. }
  17515. func Remove0000(s string) string {
  17516. str := make([]rune, 0, len(s))
  17517. for _, v := range []rune(s) {
  17518. if v == 0 {
  17519. continue
  17520. }
  17521. str = append(str, v)
  17522. }
  17523. return string(str)
  17524. }
  17525. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  17526. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  17527. readCard := DllDef.MustFindProc("EcQuery")
  17528. pCardInfo := make([]byte, 8192)
  17529. pBusiCardInfo := make([]byte, 8192)
  17530. data := make(map[string]interface{})
  17531. //pData := make(map[string]interface{})
  17532. inputData := make(map[string]interface{})
  17533. inputData["orgId"] = code
  17534. inputData["businessType"] = "01101"
  17535. inputData["operatorId"] = operator_id
  17536. inputData["operatorName"] = operator_name
  17537. inputData["officeId"] = "001"
  17538. inputData["officeName"] = "血透室"
  17539. //
  17540. data["data"] = inputData
  17541. data["transType"] = "ec.query"
  17542. data["orgId"] = code
  17543. bytesData, _ := json.Marshal(data)
  17544. pCardInfo = bytesData
  17545. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17546. fmt.Println(ret2)
  17547. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  17548. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17549. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  17550. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17551. if ret2 != 0 {
  17552. return "", ""
  17553. }
  17554. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  17555. }
  17556. func DeleteExtraSpace(s string) string {
  17557. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  17558. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  17559. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  17560. reg, _ := regexp.Compile(regstr) //编译正则表达式
  17561. s2 := make([]byte, len(s1)) //定义字符数组切片
  17562. copy(s2, s1) //将字符串复制到切片
  17563. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  17564. for len(spc_index) > 0 { //找到适配项
  17565. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  17566. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  17567. }
  17568. return string(s2)
  17569. }
  17570. // 对账
  17571. func (c *HisApiController) Post3202() {
  17572. start_time := c.GetString("start_time")
  17573. end_time := c.GetString("end_time")
  17574. //insutype := c.GetString("insutype")
  17575. clr_type := c.GetString("clr_type")
  17576. clr_org := c.GetString("clr_optins")
  17577. admin_user_id, _ := c.GetInt64("admin_user_id")
  17578. adminUser := c.GetAdminUserInfo()
  17579. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17580. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17581. if len(clr_org) == 0 {
  17582. clr_org = miConfig.MdtrtareaAdmvs
  17583. }
  17584. timeLayout := "2006-01-02"
  17585. loc, _ := time.LoadLocation("Local")
  17586. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  17587. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  17588. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  17589. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  17590. //fixmedins_setl_cnt := int64(len(orders))
  17591. var medfee_sumamt float64
  17592. var acct_pay float64
  17593. var fund_pay_sumamt float64
  17594. for _, item := range orders {
  17595. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  17596. acct_pay = acct_pay + item.AcctPay
  17597. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  17598. }
  17599. //var medfee_sumamt_two float64
  17600. //var acct_pay_two float64
  17601. //var fund_pay_sumamt_two float64
  17602. //for _, item := range orders_two {
  17603. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  17604. // acct_pay_two = acct_pay_two + item.AcctPay
  17605. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  17606. //}
  17607. //var user_name string
  17608. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17609. //if role.ID == 0 {
  17610. // user_name = "xxx"
  17611. //} else {
  17612. // user_name = role.UserName
  17613. //}
  17614. var res ResultSix
  17615. if config.IsOpen == 1 {
  17616. var bps []*models.BusinessParamsTwo
  17617. var bp models.BusinessParamsTwo
  17618. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  17619. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  17620. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  17621. bp.MedfeeSumamt = medfee_sumamt_str
  17622. bp.AcctPay = acct_pay_str
  17623. bp.FundPaySumamt = fund_pay_sumamt_str
  17624. bp.Insutype = "390"
  17625. bp.StmtBegndate = start_time
  17626. bp.ClrType = clr_type
  17627. bp.SetlOptins = clr_org
  17628. bp.StmtEnddate = end_time
  17629. bps = append(bps, &bp)
  17630. data := make(map[string]interface{})
  17631. data["bps"] = bps
  17632. data["org_name"] = miConfig.OrgName
  17633. data["doctor"] = role.UserName
  17634. data["fixmedins_code"] = miConfig.Code
  17635. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  17636. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17637. if miConfig.MdtrtareaAdmvs == "421300" {
  17638. client := &http.Client{}
  17639. bytesData, _ := json.Marshal(data)
  17640. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  17641. resp, _ := client.Do(req)
  17642. defer resp.Body.Close()
  17643. body, ioErr := ioutil.ReadAll(resp.Body)
  17644. if ioErr != nil {
  17645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17647. return
  17648. }
  17649. var respJSON map[string]interface{}
  17650. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17653. return
  17654. }
  17655. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17656. userJSONBytes, _ := json.Marshal(respJSON)
  17657. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17658. utils.ErrorLog("解析失败:%v", err)
  17659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17660. return
  17661. }
  17662. }
  17663. if res.Infcode == 0 {
  17664. c.ServeSuccessJSON(map[string]interface{}{
  17665. "msg": "发起成功",
  17666. })
  17667. } else {
  17668. c.ServeSuccessJSON(map[string]interface{}{
  17669. "code": -10,
  17670. "msg": res.ErrMsg,
  17671. })
  17672. }
  17673. }
  17674. }
  17675. func (c *HisApiController) Post3501() {
  17676. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17677. data := make(map[string]interface{})
  17678. var struct3501s []models.Struct3501
  17679. var struct3501 models.Struct3501
  17680. struct3501.OrgName = miConfig.OrgName
  17681. struct3501.AccessKey = miConfig.AccessKey
  17682. struct3501.RequestUrl = miConfig.Url
  17683. struct3501.SecretKey = miConfig.SecretKey
  17684. struct3501.ManuDate = "2022-08-17"
  17685. struct3501.FixmedinsBchno = ""
  17686. struct3501.ManuLotnum = ""
  17687. struct3501.RxFlag = "0"
  17688. struct3501.ExpyEnd = "2022-08-17"
  17689. struct3501.Invdate = "2022-08-17"
  17690. struct3501.InvCnt = "20.25"
  17691. struct3501.Memo = ""
  17692. struct3501.MedListCodg = "XB01ABD056B002020200517"
  17693. struct3501.FixmedinsHilistId = miConfig.Code
  17694. struct3501.FixmedinsHilistName = miConfig.OrgName
  17695. struct3501s = append(struct3501s, struct3501)
  17696. data["struct_3501s"] = struct3501s
  17697. client := &http.Client{}
  17698. bytesData, _ := json.Marshal(data)
  17699. var req *http.Request
  17700. if miConfig.MdtrtareaAdmvs == "320921" {
  17701. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17702. } else {
  17703. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17704. }
  17705. resp, _ := client.Do(req)
  17706. defer resp.Body.Close()
  17707. body, ioErr := ioutil.ReadAll(resp.Body)
  17708. if ioErr != nil {
  17709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17711. return
  17712. }
  17713. var respJSON map[string]interface{}
  17714. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17717. return
  17718. }
  17719. var res ResultSix
  17720. var resSix10265 ResultSix10265 //1101结果
  17721. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17722. result, _ := json.Marshal(respJSON)
  17723. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17724. utils.ErrorLog("解析失败:%v", err)
  17725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17726. return
  17727. }
  17728. res.InfRefmsgid = resSix10265.InfRefmsgid
  17729. res.Output = resSix10265.Output
  17730. res.ErrMsg = resSix10265.ErrMsg
  17731. res.Cainfo = resSix10265.Cainfo
  17732. res.WarnMsg = resSix10265.WarnMsg
  17733. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17734. res.Infcode = infocode
  17735. if infocode == 0 {
  17736. c.ServeSuccessJSON(map[string]interface{}{
  17737. "msg": "上传成功",
  17738. })
  17739. return
  17740. } else {
  17741. c.ServeSuccessJSON(map[string]interface{}{
  17742. "failed_code": -10,
  17743. "msg": res.ErrMsg,
  17744. })
  17745. return
  17746. }
  17747. }
  17748. func (c *HisApiController) Post3502() {
  17749. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17750. data := make(map[string]interface{})
  17751. var struct3502s []models.Struct3502
  17752. var struct3502 models.Struct3502
  17753. struct3502.OrgName = miConfig.OrgName
  17754. struct3502.AccessKey = miConfig.AccessKey
  17755. struct3502.RequestUrl = miConfig.Url
  17756. struct3502.SecretKey = miConfig.SecretKey
  17757. struct3502.ManuDate = "2022-08-15"
  17758. struct3502.FixmedinsBchno = ""
  17759. struct3502.ManuLotnum = ""
  17760. struct3502.RxFlag = "0"
  17761. struct3502.ExpyEnd = "2022-08-15"
  17762. struct3502.Invdate = "2022-08-15"
  17763. struct3502.InvCnt = "20.25"
  17764. struct3502.Memo = ""
  17765. struct3502.MedListCodg = "XB01ABD056B002020200517"
  17766. struct3502.FixmedinsHilistId = miConfig.Code
  17767. struct3502.FixmedinsHilistName = miConfig.OrgName
  17768. struct3502s = append(struct3502s, struct3502)
  17769. data["struct_3502s"] = struct3502s
  17770. client := &http.Client{}
  17771. bytesData, _ := json.Marshal(data)
  17772. var req *http.Request
  17773. if miConfig.MdtrtareaAdmvs == "320921" {
  17774. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17775. } else {
  17776. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17777. }
  17778. resp, _ := client.Do(req)
  17779. defer resp.Body.Close()
  17780. body, ioErr := ioutil.ReadAll(resp.Body)
  17781. if ioErr != nil {
  17782. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17784. return
  17785. }
  17786. var respJSON map[string]interface{}
  17787. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17790. return
  17791. }
  17792. var res ResultSix
  17793. var resSix10265 ResultSix10265 //1101结果
  17794. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17795. result, _ := json.Marshal(respJSON)
  17796. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17797. utils.ErrorLog("解析失败:%v", err)
  17798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17799. return
  17800. }
  17801. res.InfRefmsgid = resSix10265.InfRefmsgid
  17802. res.Output = resSix10265.Output
  17803. res.ErrMsg = resSix10265.ErrMsg
  17804. res.Cainfo = resSix10265.Cainfo
  17805. res.WarnMsg = resSix10265.WarnMsg
  17806. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17807. res.Infcode = infocode
  17808. if infocode == 0 {
  17809. c.ServeSuccessJSON(map[string]interface{}{
  17810. "msg": "上传成功",
  17811. })
  17812. return
  17813. } else {
  17814. c.ServeSuccessJSON(map[string]interface{}{
  17815. "failed_code": -10,
  17816. "msg": res.ErrMsg,
  17817. })
  17818. return
  17819. }
  17820. }
  17821. func (c *HisApiController) Post3503() {
  17822. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17823. data := make(map[string]interface{})
  17824. var struct3501s []models.Struct3501
  17825. var struct3501 models.Struct3501
  17826. struct3501.OrgName = miConfig.OrgName
  17827. struct3501.AccessKey = miConfig.AccessKey
  17828. struct3501.RequestUrl = miConfig.Url
  17829. struct3501.SecretKey = miConfig.SecretKey
  17830. struct3501.ManuDate = "2022-08-15"
  17831. struct3501.FixmedinsBchno = ""
  17832. struct3501.ManuLotnum = ""
  17833. struct3501.RxFlag = "0"
  17834. struct3501.ExpyEnd = "2022-08-15"
  17835. struct3501.Invdate = "2022-08-15"
  17836. struct3501.InvCnt = "20.25"
  17837. struct3501.Memo = ""
  17838. struct3501.MedListCodg = "XB01ABD056B002020200517"
  17839. struct3501.FixmedinsHilistId = miConfig.Code
  17840. struct3501.FixmedinsHilistName = miConfig.OrgName
  17841. struct3501s = append(struct3501s, struct3501)
  17842. data["struct_3501s"] = struct3501s
  17843. client := &http.Client{}
  17844. bytesData, _ := json.Marshal(data)
  17845. var req *http.Request
  17846. if miConfig.MdtrtareaAdmvs == "320921" {
  17847. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17848. } else {
  17849. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17850. }
  17851. resp, _ := client.Do(req)
  17852. defer resp.Body.Close()
  17853. body, ioErr := ioutil.ReadAll(resp.Body)
  17854. if ioErr != nil {
  17855. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17857. return
  17858. }
  17859. var respJSON map[string]interface{}
  17860. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17863. return
  17864. }
  17865. var res ResultSix
  17866. var resSix10265 ResultSix10265 //1101结果
  17867. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17868. result, _ := json.Marshal(respJSON)
  17869. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17870. utils.ErrorLog("解析失败:%v", err)
  17871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17872. return
  17873. }
  17874. res.InfRefmsgid = resSix10265.InfRefmsgid
  17875. res.Output = resSix10265.Output
  17876. res.ErrMsg = resSix10265.ErrMsg
  17877. res.Cainfo = resSix10265.Cainfo
  17878. res.WarnMsg = resSix10265.WarnMsg
  17879. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17880. res.Infcode = infocode
  17881. if infocode == 0 {
  17882. c.ServeSuccessJSON(map[string]interface{}{
  17883. "msg": "上传成功",
  17884. })
  17885. return
  17886. } else {
  17887. c.ServeSuccessJSON(map[string]interface{}{
  17888. "failed_code": -10,
  17889. "msg": res.ErrMsg,
  17890. })
  17891. return
  17892. }
  17893. }
  17894. func (c *HisApiController) Post3504() {
  17895. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17896. data := make(map[string]interface{})
  17897. var struct3501s []models.Struct3501
  17898. var struct3501 models.Struct3501
  17899. struct3501.OrgName = miConfig.OrgName
  17900. struct3501.AccessKey = miConfig.AccessKey
  17901. struct3501.RequestUrl = miConfig.Url
  17902. struct3501.SecretKey = miConfig.SecretKey
  17903. struct3501.ManuDate = "2022-08-15"
  17904. struct3501.FixmedinsBchno = ""
  17905. struct3501.ManuLotnum = ""
  17906. struct3501.RxFlag = "0"
  17907. struct3501.ExpyEnd = "2022-08-15"
  17908. struct3501.Invdate = "2022-08-15"
  17909. struct3501.InvCnt = "20.25"
  17910. struct3501.Memo = ""
  17911. struct3501.MedListCodg = "XB01ABD056B002020200517"
  17912. struct3501.FixmedinsHilistId = miConfig.Code
  17913. struct3501.FixmedinsHilistName = miConfig.OrgName
  17914. struct3501s = append(struct3501s, struct3501)
  17915. data["struct_3501s"] = struct3501s
  17916. client := &http.Client{}
  17917. bytesData, _ := json.Marshal(data)
  17918. var req *http.Request
  17919. if miConfig.MdtrtareaAdmvs == "320921" {
  17920. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17921. } else {
  17922. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17923. }
  17924. resp, _ := client.Do(req)
  17925. defer resp.Body.Close()
  17926. body, ioErr := ioutil.ReadAll(resp.Body)
  17927. if ioErr != nil {
  17928. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17930. return
  17931. }
  17932. var respJSON map[string]interface{}
  17933. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17936. return
  17937. }
  17938. var res ResultSix
  17939. var resSix10265 ResultSix10265 //1101结果
  17940. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17941. result, _ := json.Marshal(respJSON)
  17942. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17943. utils.ErrorLog("解析失败:%v", err)
  17944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17945. return
  17946. }
  17947. res.InfRefmsgid = resSix10265.InfRefmsgid
  17948. res.Output = resSix10265.Output
  17949. res.ErrMsg = resSix10265.ErrMsg
  17950. res.Cainfo = resSix10265.Cainfo
  17951. res.WarnMsg = resSix10265.WarnMsg
  17952. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17953. res.Infcode = infocode
  17954. if infocode == 0 {
  17955. c.ServeSuccessJSON(map[string]interface{}{
  17956. "msg": "上传成功",
  17957. })
  17958. return
  17959. } else {
  17960. c.ServeSuccessJSON(map[string]interface{}{
  17961. "failed_code": -10,
  17962. "msg": res.ErrMsg,
  17963. })
  17964. return
  17965. }
  17966. }
  17967. func (c *HisApiController) Post3505() {
  17968. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17969. data := make(map[string]interface{})
  17970. var struct3501s []models.Struct3501
  17971. var struct3501 models.Struct3501
  17972. struct3501.OrgName = miConfig.OrgName
  17973. struct3501.AccessKey = miConfig.AccessKey
  17974. struct3501.RequestUrl = miConfig.Url
  17975. struct3501.SecretKey = miConfig.SecretKey
  17976. struct3501.ManuDate = "2022-08-15"
  17977. struct3501.FixmedinsBchno = ""
  17978. struct3501.ManuLotnum = ""
  17979. struct3501.RxFlag = "0"
  17980. struct3501.ExpyEnd = "2022-08-15"
  17981. struct3501.Invdate = "2022-08-15"
  17982. struct3501.InvCnt = "20.25"
  17983. struct3501.Memo = ""
  17984. struct3501.MedListCodg = "XB01ABD056B002020200517"
  17985. struct3501.FixmedinsHilistId = miConfig.Code
  17986. struct3501.FixmedinsHilistName = miConfig.OrgName
  17987. struct3501s = append(struct3501s, struct3501)
  17988. data["struct_3501s"] = struct3501s
  17989. client := &http.Client{}
  17990. bytesData, _ := json.Marshal(data)
  17991. var req *http.Request
  17992. if miConfig.MdtrtareaAdmvs == "320921" {
  17993. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17994. } else {
  17995. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17996. }
  17997. resp, _ := client.Do(req)
  17998. defer resp.Body.Close()
  17999. body, ioErr := ioutil.ReadAll(resp.Body)
  18000. if ioErr != nil {
  18001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18003. return
  18004. }
  18005. var respJSON map[string]interface{}
  18006. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18009. return
  18010. }
  18011. var res ResultSix
  18012. var resSix10265 ResultSix10265 //1101结果
  18013. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18014. result, _ := json.Marshal(respJSON)
  18015. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  18016. utils.ErrorLog("解析失败:%v", err)
  18017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18018. return
  18019. }
  18020. res.InfRefmsgid = resSix10265.InfRefmsgid
  18021. res.Output = resSix10265.Output
  18022. res.ErrMsg = resSix10265.ErrMsg
  18023. res.Cainfo = resSix10265.Cainfo
  18024. res.WarnMsg = resSix10265.WarnMsg
  18025. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  18026. res.Infcode = infocode
  18027. if infocode == 0 {
  18028. c.ServeSuccessJSON(map[string]interface{}{
  18029. "msg": "上传成功",
  18030. })
  18031. return
  18032. } else {
  18033. c.ServeSuccessJSON(map[string]interface{}{
  18034. "failed_code": -10,
  18035. "msg": res.ErrMsg,
  18036. })
  18037. return
  18038. }
  18039. }
  18040. func (c *HisApiController) Post3506() {
  18041. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18042. data := make(map[string]interface{})
  18043. var struct3501s []models.Struct3501
  18044. var struct3501 models.Struct3501
  18045. struct3501.OrgName = miConfig.OrgName
  18046. struct3501.AccessKey = miConfig.AccessKey
  18047. struct3501.RequestUrl = miConfig.Url
  18048. struct3501.SecretKey = miConfig.SecretKey
  18049. struct3501.ManuDate = "2022-08-15"
  18050. struct3501.FixmedinsBchno = ""
  18051. struct3501.ManuLotnum = ""
  18052. struct3501.RxFlag = "0"
  18053. struct3501.ExpyEnd = "2022-08-15"
  18054. struct3501.Invdate = "2022-08-15"
  18055. struct3501.InvCnt = "20.25"
  18056. struct3501.Memo = ""
  18057. struct3501.MedListCodg = "XB01ABD056B002020200517"
  18058. struct3501.FixmedinsHilistId = miConfig.Code
  18059. struct3501.FixmedinsHilistName = miConfig.OrgName
  18060. struct3501s = append(struct3501s, struct3501)
  18061. data["struct_3501s"] = struct3501s
  18062. client := &http.Client{}
  18063. bytesData, _ := json.Marshal(data)
  18064. var req *http.Request
  18065. if miConfig.MdtrtareaAdmvs == "320921" {
  18066. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  18067. } else {
  18068. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  18069. }
  18070. resp, _ := client.Do(req)
  18071. defer resp.Body.Close()
  18072. body, ioErr := ioutil.ReadAll(resp.Body)
  18073. if ioErr != nil {
  18074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18076. return
  18077. }
  18078. var respJSON map[string]interface{}
  18079. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18082. return
  18083. }
  18084. var res ResultSix
  18085. var resSix10265 ResultSix10265 //1101结果
  18086. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18087. result, _ := json.Marshal(respJSON)
  18088. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  18089. utils.ErrorLog("解析失败:%v", err)
  18090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18091. return
  18092. }
  18093. res.InfRefmsgid = resSix10265.InfRefmsgid
  18094. res.Output = resSix10265.Output
  18095. res.ErrMsg = resSix10265.ErrMsg
  18096. res.Cainfo = resSix10265.Cainfo
  18097. res.WarnMsg = resSix10265.WarnMsg
  18098. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  18099. res.Infcode = infocode
  18100. if infocode == 0 {
  18101. c.ServeSuccessJSON(map[string]interface{}{
  18102. "msg": "上传成功",
  18103. })
  18104. return
  18105. } else {
  18106. c.ServeSuccessJSON(map[string]interface{}{
  18107. "failed_code": -10,
  18108. "msg": res.ErrMsg,
  18109. })
  18110. return
  18111. }
  18112. }
  18113. func (c *HisApiController) Post3507() {
  18114. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18115. data := make(map[string]interface{})
  18116. var struct3501s []models.Struct3501
  18117. var struct3501 models.Struct3501
  18118. struct3501.OrgName = miConfig.OrgName
  18119. struct3501.AccessKey = miConfig.AccessKey
  18120. struct3501.RequestUrl = miConfig.Url
  18121. struct3501.SecretKey = miConfig.SecretKey
  18122. struct3501.ManuDate = "2022-08-15"
  18123. struct3501.FixmedinsBchno = ""
  18124. struct3501.ManuLotnum = ""
  18125. struct3501.RxFlag = "0"
  18126. struct3501.ExpyEnd = "2022-08-15"
  18127. struct3501.Invdate = "2022-08-15"
  18128. struct3501.InvCnt = "20.25"
  18129. struct3501.Memo = ""
  18130. struct3501.MedListCodg = "XB01ABD056B002020200517"
  18131. struct3501.FixmedinsHilistId = miConfig.Code
  18132. struct3501.FixmedinsHilistName = miConfig.OrgName
  18133. struct3501s = append(struct3501s, struct3501)
  18134. data["struct_3501s"] = struct3501s
  18135. client := &http.Client{}
  18136. bytesData, _ := json.Marshal(data)
  18137. var req *http.Request
  18138. if miConfig.MdtrtareaAdmvs == "320921" {
  18139. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  18140. } else {
  18141. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  18142. }
  18143. resp, _ := client.Do(req)
  18144. defer resp.Body.Close()
  18145. body, ioErr := ioutil.ReadAll(resp.Body)
  18146. if ioErr != nil {
  18147. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18149. return
  18150. }
  18151. var respJSON map[string]interface{}
  18152. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18153. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18155. return
  18156. }
  18157. var res ResultSix
  18158. var resSix10265 ResultSix10265 //1101结果
  18159. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18160. result, _ := json.Marshal(respJSON)
  18161. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  18162. utils.ErrorLog("解析失败:%v", err)
  18163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18164. return
  18165. }
  18166. res.InfRefmsgid = resSix10265.InfRefmsgid
  18167. res.Output = resSix10265.Output
  18168. res.ErrMsg = resSix10265.ErrMsg
  18169. res.Cainfo = resSix10265.Cainfo
  18170. res.WarnMsg = resSix10265.WarnMsg
  18171. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  18172. res.Infcode = infocode
  18173. if infocode == 0 {
  18174. c.ServeSuccessJSON(map[string]interface{}{
  18175. "msg": "上传成功",
  18176. })
  18177. return
  18178. } else {
  18179. c.ServeSuccessJSON(map[string]interface{}{
  18180. "failed_code": -10,
  18181. "msg": res.ErrMsg,
  18182. })
  18183. return
  18184. }
  18185. }
  18186. func GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  18187. // WebSocket服务器地址
  18188. serverURL := "ws://127.0.0.1:8899"
  18189. // 解析WebSocket服务器地址
  18190. u, err := url.Parse(serverURL)
  18191. if err != nil {
  18192. }
  18193. // 建立WebSocket连接
  18194. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  18195. if err != nil {
  18196. }
  18197. defer conn.Close()
  18198. input2 := make(map[string]interface{})
  18199. input := make(map[string]interface{})
  18200. inputData := make(map[string]interface{})
  18201. inputData["orgId"] = code
  18202. inputData["businessType"] = "01101"
  18203. inputData["operatorId"] = operator_id
  18204. inputData["operatorName"] = operator_name
  18205. inputData["officeId"] = "001"
  18206. inputData["officeName"] = "血透室"
  18207. inputData["deviceType"] = ""
  18208. input["data"] = inputData
  18209. input["orgId"] = code
  18210. input["transType"] = "ec.query"
  18211. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  18212. input2["indata"] = input
  18213. bytesData, _ := json.Marshal(input2)
  18214. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  18215. if err != nil {
  18216. fmt.Println(err)
  18217. }
  18218. // 接收消息
  18219. _, receivedMessage, err := conn.ReadMessage()
  18220. if err != nil {
  18221. fmt.Println(err)
  18222. }
  18223. return "", string(receivedMessage)
  18224. }
  18225. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  18226. // WebSocket服务器地址
  18227. serverURL := "ws://127.0.0.1:8899"
  18228. // 解析WebSocket服务器地址
  18229. u, err := url.Parse(serverURL)
  18230. if err != nil {
  18231. }
  18232. // 建立WebSocket连接
  18233. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  18234. if err != nil {
  18235. }
  18236. defer conn.Close()
  18237. input2 := make(map[string]interface{})
  18238. input := make(map[string]interface{})
  18239. inputData := make(map[string]interface{})
  18240. inputData["orgId"] = code
  18241. inputData["businessType"] = "01301"
  18242. inputData["operatorId"] = operator_id
  18243. inputData["operatorName"] = operator_name
  18244. inputData["officeId"] = "001"
  18245. inputData["officeName"] = "血透室"
  18246. inputData["deviceType"] = ""
  18247. input["data"] = inputData
  18248. input["orgId"] = code
  18249. input["transType"] = "ec.query"
  18250. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  18251. input2["indata"] = input
  18252. bytesData, _ := json.Marshal(input2)
  18253. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  18254. if err != nil {
  18255. fmt.Println(err)
  18256. }
  18257. // 接收消息
  18258. _, receivedMessage, err := conn.ReadMessage()
  18259. if err != nil {
  18260. fmt.Println(err)
  18261. }
  18262. return "", string(receivedMessage)
  18263. }